[PATCH] D39913: [ObjC] warn about availability attributes missing from a method's declaration when they're specified for a method's definition

2017-11-25 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak accepted this revision.
ahatanak added a comment.

LGTM




Comment at: lib/Sema/SemaDeclAttr.cpp:2295
+  MissingIntroduced =
+  MissingIntroduced ? Decl->getIntroduced().empty() : false;
+  MissingDeprecated =

I feel like using "if" is easier to understand than a conditional operator, but 
it's up to you:

```
if (MissingIntroduced)
  MissingIntroduced = Decl->getIntroduced().empty();
```


Repository:
  rL LLVM

https://reviews.llvm.org/D39913



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


[clang-tools-extra] r318971 - [clang-tidy] Actually fix header guard handling in scripts

2017-11-25 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Sat Nov 25 00:49:04 2017
New Revision: 318971

URL: http://llvm.org/viewvc/llvm-project?rev=318971&view=rev
Log:
[clang-tidy] Actually fix header guard handling in scripts

Modified:
clang-tools-extra/trunk/clang-tidy/add_new_check.py
clang-tools-extra/trunk/clang-tidy/rename_check.py

Modified: clang-tools-extra/trunk/clang-tidy/add_new_check.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/add_new_check.py?rev=318971&r1=318970&r2=318971&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/add_new_check.py (original)
+++ clang-tools-extra/trunk/clang-tidy/add_new_check.py Sat Nov 25 00:49:04 2017
@@ -51,7 +51,7 @@ def write_header(module_path, module, ch
   print('Creating %s...' % filename)
   with open(filename, 'wb') as f:
 header_guard = ('LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_' + module.upper() + '_'
-+ check_name.upper().replace('-', '_') + '_H')
++ check_name_camel.upper() + '_H')
 f.write('//===--- ')
 f.write(os.path.basename(filename))
 f.write(' - clang-tidy')

Modified: clang-tools-extra/trunk/clang-tidy/rename_check.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/rename_check.py?rev=318971&r1=318970&r2=318971&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/rename_check.py (original)
+++ clang-tools-extra/trunk/clang-tidy/rename_check.py Sat Nov 25 00:49:04 2017
@@ -196,7 +196,9 @@ def main():
 
   clang_tidy_path = os.path.dirname(__file__)
 
-  header_guard_old = (old_module + '_' + check_name_camel).upper()
+  header_guard_variants = [
+  (old_module + '_' + new_check_name_camel).upper(),
+  args.old_check_name.replace('-', '_').upper()]
   header_guard_new = (new_module + '_' + new_check_name_camel).upper()
 
   old_module_path = os.path.join(clang_tidy_path, old_module)
@@ -225,7 +227,8 @@ def main():
   generateCommentLineHeader(filename))
 replaceInFile(filename, generateCommentLineSource(originalName),
   generateCommentLineSource(filename))
-replaceInFile(filename, header_guard_old, header_guard_new)
+for header_guard in header_guard_variants:
+  replaceInFile(filename, header_guard, header_guard_new)
 
 if args.new_check_name + '.rst' in filename:
   replaceInFile(


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


[clang-tools-extra] r318972 - [clang-tidy] Fix link error (http://llvm.org/PR35417).

2017-11-25 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Sat Nov 25 00:52:42 2017
New Revision: 318972

URL: http://llvm.org/viewvc/llvm-project?rev=318972&view=rev
Log:
[clang-tidy] Fix link error (http://llvm.org/PR35417).

Modified:
clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt

Modified: clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt?rev=318972&r1=318971&r2=318972&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt Sat Nov 25 00:52:42 
2017
@@ -12,6 +12,7 @@ add_clang_library(clangTidyHICPPModule
   clangBasic
   clangLex
   clangTidy
+  clangTidyBugproneModule
   clangTidyCppCoreGuidelinesModule
   clangTidyGoogleModule
   clangTidyMiscModule


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


[PATCH] D40415: [libcxx] Define istream_iterator equality comparison operators out-of-line

2017-11-25 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


https://reviews.llvm.org/D40415



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


r318973 - clang-format: [JS] disable ASI on decorators.

2017-11-25 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Sat Nov 25 01:19:42 2017
New Revision: 318973

URL: http://llvm.org/viewvc/llvm-project?rev=318973&view=rev
Log:
clang-format: [JS] disable ASI on decorators.

Summary:
Automatic Semicolon Insertion in clang-format tries to guess if a line
wrap should insert an implicit semicolong. The previous heuristic would
not trigger ASI if a token was immediately preceded by an `@` sign:

function foo(@Bar  // <-- does not trigger due to preceding @
baz) {}

However decorators can have arbitrary parameters:

function foo(@Bar(param, param, param)  // <-- precending @ missed
baz) {}

While it would be possible to precisely find the matching `@`, just
conversatively disabling ASI for the entire line is simpler, while also
not regressing ASI substatially.

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=318973&r1=318972&r2=318973&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Sat Nov 25 01:19:42 2017
@@ -18,6 +18,8 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
 
+#include 
+
 #define DEBUG_TYPE "format-parser"
 
 namespace clang {
@@ -891,11 +893,14 @@ void UnwrappedLineParser::readTokenWithJ
   bool PreviousMustBeValue = mustBeJSIdentOrValue(Keywords, Previous);
   bool PreviousStartsTemplateExpr =
   Previous->is(TT_TemplateString) && Previous->TokenText.endswith("${");
-  if (PreviousMustBeValue && Line && Line->Tokens.size() > 1) {
-// If the token before the previous one is an '@', the previous token is an
-// annotation and can precede another identifier/value.
-const FormatToken *PrePrevious = std::prev(Line->Tokens.end(), 2)->Tok;
-if (PrePrevious->is(tok::at))
+  if (PreviousMustBeValue || Previous->is(tok::r_paren)) {
+// If the line contains an '@' sign, the previous token might be an
+// annotation, which can precede another identifier/value.
+bool HasAt = std::find_if(Line->Tokens.begin(), Line->Tokens.end(),
+  [](UnwrappedLineNode &LineNode) {
+return LineNode.Tok->is(tok::at);
+  }) != Line->Tokens.end();
+if (HasAt)
   return;
   }
   if (Next->is(tok::exclaim) && PreviousMustBeValue)

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=318973&r1=318972&r2=318973&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Sat Nov 25 01:19:42 2017
@@ -1197,6 +1197,8 @@ TEST_F(FormatTestJS, AutomaticSemicolonI
   "String");
   verifyFormat("function f(@Foo bar) {}", "function f(@Foo\n"
   "  bar) {}");
+  verifyFormat("function f(@Foo(Param) bar) {}", "function f(@Foo(Param)\n"
+ "  bar) {}");
   verifyFormat("a = true\n"
"return 1",
"a = true\n"
@@ -1564,7 +1566,7 @@ TEST_F(FormatTestJS, EnumDeclarations) {
"}");
 }
 
-TEST_F(FormatTestJS, MetadataAnnotations) {
+TEST_F(FormatTestJS, Decorators) {
   verifyFormat("@A\nclass C {\n}");
   verifyFormat("@A({arg: 'value'})\nclass C {\n}");
   verifyFormat("@A\n@B\nclass C {\n}");


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


[PATCH] D40410: clang-format: [JS] disable ASI on decorators.

2017-11-25 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318973: clang-format: [JS] disable ASI on decorators. 
(authored by mprobst).

Repository:
  rL LLVM

https://reviews.llvm.org/D40410

Files:
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -18,6 +18,8 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
 
+#include 
+
 #define DEBUG_TYPE "format-parser"
 
 namespace clang {
@@ -891,11 +893,14 @@
   bool PreviousMustBeValue = mustBeJSIdentOrValue(Keywords, Previous);
   bool PreviousStartsTemplateExpr =
   Previous->is(TT_TemplateString) && Previous->TokenText.endswith("${");
-  if (PreviousMustBeValue && Line && Line->Tokens.size() > 1) {
-// If the token before the previous one is an '@', the previous token is an
-// annotation and can precede another identifier/value.
-const FormatToken *PrePrevious = std::prev(Line->Tokens.end(), 2)->Tok;
-if (PrePrevious->is(tok::at))
+  if (PreviousMustBeValue || Previous->is(tok::r_paren)) {
+// If the line contains an '@' sign, the previous token might be an
+// annotation, which can precede another identifier/value.
+bool HasAt = std::find_if(Line->Tokens.begin(), Line->Tokens.end(),
+  [](UnwrappedLineNode &LineNode) {
+return LineNode.Tok->is(tok::at);
+  }) != Line->Tokens.end();
+if (HasAt)
   return;
   }
   if (Next->is(tok::exclaim) && PreviousMustBeValue)
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1197,6 +1197,8 @@
   "String");
   verifyFormat("function f(@Foo bar) {}", "function f(@Foo\n"
   "  bar) {}");
+  verifyFormat("function f(@Foo(Param) bar) {}", "function f(@Foo(Param)\n"
+ "  bar) {}");
   verifyFormat("a = true\n"
"return 1",
"a = true\n"
@@ -1564,7 +1566,7 @@
"}");
 }
 
-TEST_F(FormatTestJS, MetadataAnnotations) {
+TEST_F(FormatTestJS, Decorators) {
   verifyFormat("@A\nclass C {\n}");
   verifyFormat("@A({arg: 'value'})\nclass C {\n}");
   verifyFormat("@A\n@B\nclass C {\n}");


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -18,6 +18,8 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
 
+#include 
+
 #define DEBUG_TYPE "format-parser"
 
 namespace clang {
@@ -891,11 +893,14 @@
   bool PreviousMustBeValue = mustBeJSIdentOrValue(Keywords, Previous);
   bool PreviousStartsTemplateExpr =
   Previous->is(TT_TemplateString) && Previous->TokenText.endswith("${");
-  if (PreviousMustBeValue && Line && Line->Tokens.size() > 1) {
-// If the token before the previous one is an '@', the previous token is an
-// annotation and can precede another identifier/value.
-const FormatToken *PrePrevious = std::prev(Line->Tokens.end(), 2)->Tok;
-if (PrePrevious->is(tok::at))
+  if (PreviousMustBeValue || Previous->is(tok::r_paren)) {
+// If the line contains an '@' sign, the previous token might be an
+// annotation, which can precede another identifier/value.
+bool HasAt = std::find_if(Line->Tokens.begin(), Line->Tokens.end(),
+  [](UnwrappedLineNode &LineNode) {
+return LineNode.Tok->is(tok::at);
+  }) != Line->Tokens.end();
+if (HasAt)
   return;
   }
   if (Next->is(tok::exclaim) && PreviousMustBeValue)
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1197,6 +1197,8 @@
   "String");
   verifyFormat("function f(@Foo bar) {}", "function f(@Foo\n"
   "  bar) {}");
+  verifyFormat("function f(@Foo(Param) bar) {}", "function f(@Foo(Param)\n"
+ "  bar) {}");
   verifyFormat("a = true\n"
"return 1",
"a = true\n"
@@ -1564,7 +1566,7 @@
"}");
 }
 
-TEST_F(FormatTestJS, MetadataAnnotations) {
+TEST_F(FormatTestJS, Decorators) {
   verifyFormat("@A\nclass C {\n}");
   verifyFormat("@A({arg: 'value'})\nclass C {\n}");
   v

[PATCH] D37187: [Analyzer] Fix Bug 25609 - Assertion UNREACHABLE: 'Unexpected ProgramPoint' with widen-loops=true

2017-11-25 Thread Henry Wong via Phabricator via cfe-commits
MTC updated this revision to Diff 124248.
MTC marked an inline comment as done.
MTC added a comment.

1.Use the `getAs<>` in the `if` condition.
2.Add an "Unexpected ProgramPoint" assertion to make this patch more complete.


https://reviews.llvm.org/D37187

Files:
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  test/Analysis/loop-widening-notes.cpp


Index: test/Analysis/loop-widening-notes.cpp
===
--- /dev/null
+++ test/Analysis/loop-widening-notes.cpp
@@ -0,0 +1,72 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha -analyzer-max-loop 2 
-analyzer-config widen-loops=true -analyzer-output=text -verify %s
+
+int *p_a;
+int bar();
+int flag_a;
+int test_for_bug_25609() {
+  if (p_a == 0) // expected-note {{Assuming 'p_a' is equal to null}} 
+// expected-note@-1 {{Taking true branch}}
+bar();
+  for (int i = 0;  // expected-note {{Loop condition is true.  Entering loop 
body}}
+   // expected-note@-1 {{Loop condition is false. Execution 
continues on line 16}}
+   ++i,// expected-note {{Value assigned to 'p_a'}} 
+   i < flag_a;
+   ++i) {}
+  
+  *p_a = 25609; // no-crash expected-warning {{Dereference of null pointer 
(loaded from variable 'p_a')}}
+// expected-note@-1 {{Dereference of null pointer (loaded from 
variable 'p_a')}}
+  return *p_a;
+}
+
+int flag_b;
+int while_analyzer_output() {
+  flag_b = 100;
+  int num = 10;
+  while (flag_b-- > 0) { // expected-note {{Loop condition is true.  Entering 
loop body}} 
+ // expected-note@-1 {{Value assigned to 'num'}} 
+ // expected-note@-2 {{Loop condition is false. 
Execution continues on line 30}}
+num = flag_b;
+  }
+  if (num < 0) // expected-note {{Assuming 'num' is >= 0}} 
+   // expected-note@-1 {{Taking false branch}}
+flag_b = 0;
+  else if (num >= 1) // expected-note {{Assuming 'num' is < 1}} 
+ // expected-note@-1 {{Taking false branch}}
+flag_b = 50;
+  else
+flag_b = 100;
+  return flag_b / num; // no-crash expected-warning {{Division by zero}} 
+   // expected-note@-1 {{Division by zero}}
+}
+
+int flag_c;
+int do_while_analyzer_output() {
+  int num = 10;
+  do {   // expected-note {{Loop condition is true. Execution continues on 
line 47}} 
+ // expected-note@-1 {{Loop condition is false.  Exiting loop}}
+num--;
+  } while (flag_c-- > 0); //expected-note {{Value assigned to 'num'}}
+  int local = 0;
+  if (num == 0)   // expected-note {{Assuming 'num' is equal to 0}} 
+  // expected-note@-1 {{Taking true branch}}
+local = 10 / num; // no-crash expected-warning {{Division by zero}}
+  // expected-note@-1 {{Division by zero}}
+  return local;
+}
+
+int flag_d;
+int test_for_loop() {
+  int num = 10;
+  for (int i = 0;// expected-note {{Loop condition is true.  Entering loop 
body}} 
+ // expected-note@-1 {{Loop condition is false. Execution 
continues on line 67}}
+   new int(10),  // expected-note {{Value assigned to 'num'}}
+   i < flag_d;
+   ++i) {
+++num;
+  }
+  if (num == 0) // expected-note {{Assuming 'num' is equal to 0}} 
+// expected-note@-1 {{Taking true branch}}
+flag_d += 10;
+  return flag_d / num; // no-crash expected-warning {{Division by zero}} 
+   // expected-note@-1 {{Division by zero}}
+}
Index: lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -690,6 +690,15 @@
 return getLocationForCaller(CEE->getCalleeContext(),
 CEE->getLocationContext(),
 SMng);
+  } else if (Optional BE = P.getAs()) {
+CFGElement BlockFront = BE->getBlock()->front();
+if (auto StmtElt = BlockFront.getAs()) {
+  return PathDiagnosticLocation(StmtElt->getStmt()->getLocStart(), SMng);
+} else if (auto NewAllocElt = BlockFront.getAs()) {
+  return PathDiagnosticLocation(
+  NewAllocElt->getAllocatorExpr()->getLocStart(), SMng);
+}
+llvm_unreachable("Unexpected ProgramPoint");
   } else {
 llvm_unreachable("Unexpected ProgramPoint");
   }


Index: test/Analysis/loop-widening-notes.cpp
===
--- /dev/null
+++ test/Analysis/loop-widening-notes.cpp
@@ -0,0 +1,72 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha -analyzer-max-loop 2 -analyzer-config widen-loops=true -analyzer-output=text -verify %s
+
+int *p_a;
+int bar();
+int flag_a;
+int test_for_bug_25609() {
+  if (p_a == 0) // expected-note {{Assuming 'p_a' is equal to null}} 
+// expected-note@-1 {{Taking 

r318974 - clang-format: [JS] handle `for` as object label.

2017-11-25 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Sat Nov 25 01:24:33 2017
New Revision: 318974

URL: http://llvm.org/viewvc/llvm-project?rev=318974&view=rev
Log:
clang-format: [JS] handle `for` as object label.

Summary: Previously, clang-format would fail formatting `{for: 1}`.

Reviewers: djasper

Subscribers: klimek

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

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=318974&r1=318973&r2=318974&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Sat Nov 25 01:24:33 2017
@@ -617,7 +617,9 @@ private:
   break;
 case tok::kw_for:
   if (Style.Language == FormatStyle::LK_JavaScript) {
-if (Tok->Previous && Tok->Previous->is(tok::period))
+// x.for and {for: ...}
+if ((Tok->Previous && Tok->Previous->is(tok::period)) ||
+(Tok->Next && Tok->Next->is(tok::colon)))
   break;
 // JS' for await ( ...
 if (CurrentToken && CurrentToken->is(Keywords.kw_await))

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=318974&r1=318973&r2=318974&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Sat Nov 25 01:24:33 2017
@@ -323,6 +323,11 @@ TEST_F(FormatTestJS, ReservedWords) {
"  case: string;\n"
"  default: string;\n"
"}\n");
+  verifyFormat("const Axis = {\n"
+   "  for: 'for',\n"
+   "  x: 'x'\n"
+   "};",
+   "const Axis = {for: 'for', x:   'x'};");
 }
 
 TEST_F(FormatTestJS, ReservedWordsMethods) {


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


[PATCH] D40453: Add the nvidia-cuda-toolkit Debian package path to search path

2017-11-25 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru created this revision.

Reported here:
http://bugs.debian.org/882505

Patch by Andreas Beckmann


https://reviews.llvm.org/D40453

Files:
  lib/Driver/ToolChains/Cuda.cpp


Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -75,6 +75,7 @@
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda");
 for (const char *Ver : Versions)
   CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-" + Ver);
+CudaPathCandidates.push_back(D.SysRoot + "/usr/lib/cuda");
   }
 
   for (const auto &CudaPath : CudaPathCandidates) {


Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -75,6 +75,7 @@
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda");
 for (const char *Ver : Versions)
   CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-" + Ver);
+CudaPathCandidates.push_back(D.SysRoot + "/usr/lib/cuda");
   }
 
   for (const auto &CudaPath : CudaPathCandidates) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40424: clang-format: [JS] handle semis in generic types.

2017-11-25 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318975: clang-format: [JS] handle semis in generic types. 
(authored by mprobst).

Repository:
  rL LLVM

https://reviews.llvm.org/D40424

Files:
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -379,13 +379,16 @@
 switch (Tok->Tok.getKind()) {
 case tok::l_brace:
   if (Style.Language == FormatStyle::LK_JavaScript && PrevTok) {
-if (PrevTok->is(tok::colon))
-  // A colon indicates this code is in a type, or a braced list
-  // following a label in an object literal ({a: {b: 1}}). The code
-  // below could be confused by semicolons between the individual
-  // members in a type member list, which would normally trigger
-  // BK_Block. In both cases, this must be parsed as an inline braced
-  // init.
+if (PrevTok->isOneOf(tok::colon, tok::less))
+  // A ':' indicates this code is in a type, or a braced list
+  // following a label in an object literal ({a: {b: 1}}).
+  // A '<' could be an object used in a comparison, but that is 
nonsense
+  // code (can never return true), so more likely it is a generic type
+  // argument (`X<{a: string; b: number}>`).
+  // The code below could be confused by semicolons between the
+  // individual members in a type member list, which would normally
+  // trigger BK_Block. In both cases, this must be parsed as an inline
+  // braced init.
   Tok->BlockKind = BK_BracedInit;
 else if (PrevTok->is(tok::r_paren))
   // `) { }` can only occur in function or method declarations in JS.
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1414,6 +1414,7 @@
   verifyFormat("function x(y: {a?: number;} = {}): number {\n"
"  return 12;\n"
"}");
+  verifyFormat("const x: Array<{a: number; b: string;}> = [];");
   verifyFormat("((a: string, b: number): string => a + b);");
   verifyFormat("var x: (y: number) => string;");
   verifyFormat("var x: P string>;");


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -379,13 +379,16 @@
 switch (Tok->Tok.getKind()) {
 case tok::l_brace:
   if (Style.Language == FormatStyle::LK_JavaScript && PrevTok) {
-if (PrevTok->is(tok::colon))
-  // A colon indicates this code is in a type, or a braced list
-  // following a label in an object literal ({a: {b: 1}}). The code
-  // below could be confused by semicolons between the individual
-  // members in a type member list, which would normally trigger
-  // BK_Block. In both cases, this must be parsed as an inline braced
-  // init.
+if (PrevTok->isOneOf(tok::colon, tok::less))
+  // A ':' indicates this code is in a type, or a braced list
+  // following a label in an object literal ({a: {b: 1}}).
+  // A '<' could be an object used in a comparison, but that is nonsense
+  // code (can never return true), so more likely it is a generic type
+  // argument (`X<{a: string; b: number}>`).
+  // The code below could be confused by semicolons between the
+  // individual members in a type member list, which would normally
+  // trigger BK_Block. In both cases, this must be parsed as an inline
+  // braced init.
   Tok->BlockKind = BK_BracedInit;
 else if (PrevTok->is(tok::r_paren))
   // `) { }` can only occur in function or method declarations in JS.
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1414,6 +1414,7 @@
   verifyFormat("function x(y: {a?: number;} = {}): number {\n"
"  return 12;\n"
"}");
+  verifyFormat("const x: Array<{a: number; b: string;}> = [];");
   verifyFormat("((a: string, b: number): string => a + b);");
   verifyFormat("var x: (y: number) => string;");
   verifyFormat("var x: P string>;");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r318975 - clang-format: [JS] handle semis in generic types.

2017-11-25 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Sat Nov 25 01:33:47 2017
New Revision: 318975

URL: http://llvm.org/viewvc/llvm-project?rev=318975&view=rev
Log:
clang-format: [JS] handle semis in generic types.

Summary:
TypeScript generic type arguments can contain object (literal) types,
which in turn can contain semicolons:

const x: Array<{a: number; b: string;} = [];

Previously, clang-format would incorrectly categorize the braced list as
a block and terminate the line at the openening `{`, and then format the
entire expression badly.

With this change, clang-format recognizes `<` preceding a `{` as
introducing a type expression. In JS, `<` comparison with an object
literal can never be true, so the chance of introducing false positives
here is very low.

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=318975&r1=318974&r2=318975&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Sat Nov 25 01:33:47 2017
@@ -379,13 +379,16 @@ void UnwrappedLineParser::calculateBrace
 switch (Tok->Tok.getKind()) {
 case tok::l_brace:
   if (Style.Language == FormatStyle::LK_JavaScript && PrevTok) {
-if (PrevTok->is(tok::colon))
-  // A colon indicates this code is in a type, or a braced list
-  // following a label in an object literal ({a: {b: 1}}). The code
-  // below could be confused by semicolons between the individual
-  // members in a type member list, which would normally trigger
-  // BK_Block. In both cases, this must be parsed as an inline braced
-  // init.
+if (PrevTok->isOneOf(tok::colon, tok::less))
+  // A ':' indicates this code is in a type, or a braced list
+  // following a label in an object literal ({a: {b: 1}}).
+  // A '<' could be an object used in a comparison, but that is 
nonsense
+  // code (can never return true), so more likely it is a generic type
+  // argument (`X<{a: string; b: number}>`).
+  // The code below could be confused by semicolons between the
+  // individual members in a type member list, which would normally
+  // trigger BK_Block. In both cases, this must be parsed as an inline
+  // braced init.
   Tok->BlockKind = BK_BracedInit;
 else if (PrevTok->is(tok::r_paren))
   // `) { }` can only occur in function or method declarations in JS.

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=318975&r1=318974&r2=318975&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Sat Nov 25 01:33:47 2017
@@ -1414,6 +1414,7 @@ TEST_F(FormatTestJS, TypeAnnotations) {
   verifyFormat("function x(y: {a?: number;} = {}): number {\n"
"  return 12;\n"
"}");
+  verifyFormat("const x: Array<{a: number; b: string;}> = [];");
   verifyFormat("((a: string, b: number): string => a + b);");
   verifyFormat("var x: (y: number) => string;");
   verifyFormat("var x: P string>;");


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


r318976 - clang-format: [JS] do not collapse short classes.

2017-11-25 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Sat Nov 25 01:35:33 2017
New Revision: 318976

URL: http://llvm.org/viewvc/llvm-project?rev=318976&view=rev
Log:
clang-format: [JS] do not collapse short classes.

Summary:
clang-format does not collapse short records, interfaces, unions, etc.,
but fails to do so if the record is preceded by certain modifiers
(export, default, abstract, declare). This change skips over all
modifiers, and thus handles all record definitions uniformly.

Before:
export class Foo { bar: string; }
class Baz {
  bam: string;
}

After:
export class Foo {
  bar: string;
}
class Baz {
  bam: string;
}

Reviewers: djasper

Subscribers: klimek

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

Modified:
cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp?rev=318976&r1=318975&r2=318976&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp Sat Nov 25 01:35:33 2017
@@ -517,8 +517,13 @@ private:
   } else if (Limit != 0 && !Line.startsWith(tok::kw_namespace) &&
  !startsExternCBlock(Line)) {
 // We don't merge short records.
-FormatToken *RecordTok =
-Line.First->is(tok::kw_typedef) ? Line.First->Next : Line.First;
+FormatToken *RecordTok = Line.First;
+// Skip record modifiers.
+while (RecordTok->Next &&
+   RecordTok->isOneOf(tok::kw_typedef, tok::kw_export,
+  Keywords.kw_declare, Keywords.kw_abstract,
+  tok::kw_default))
+  RecordTok = RecordTok->Next;
 if (RecordTok &&
 RecordTok->isOneOf(tok::kw_class, tok::kw_union, tok::kw_struct,
Keywords.kw_interface))

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=318976&r1=318975&r2=318976&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Sat Nov 25 01:35:33 2017
@@ -1674,9 +1674,15 @@ TEST_F(FormatTestJS, Modules) {
"  x: number;\n"
"  y: string;\n"
"}");
-  verifyFormat("export class X { y: number; }");
-  verifyFormat("export abstract class X { y: number; }");
-  verifyFormat("export default class X { y: number }");
+  verifyFormat("export class X {\n"
+   "  y: number;\n"
+   "}");
+  verifyFormat("export abstract class X {\n"
+   "  y: number;\n"
+   "}");
+  verifyFormat("export default class X {\n"
+   "  y: number\n"
+   "}");
   verifyFormat("export default function() {\n  return 1;\n}");
   verifyFormat("export var x = 12;");
   verifyFormat("class C {}\n"
@@ -1698,7 +1704,9 @@ TEST_F(FormatTestJS, Modules) {
"];");
   verifyFormat("export default [];");
   verifyFormat("export default () => {};");
-  verifyFormat("export interface Foo { foo: number; }\n"
+  verifyFormat("export interface Foo {\n"
+   "  foo: number;\n"
+   "}\n"
"export class Bar {\n"
"  blah(): string {\n"
"return this.blah;\n"


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


[PATCH] D39913: [ObjC] warn about availability attributes missing from a method's declaration when they're specified for a method's definition

2017-11-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added inline comments.
This revision now requires changes to proceed.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2921
+def warn_availability_on_implementation_not_interface : Warning<
+  "method declaration is missing an availability attribute for "
+  "%0 that is specified in the definition">,

Please quote 'availability' in the diagnostic wording. Same for the note.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2925
+def warn_deprecated_on_implementation_not_interface : Warning<
+  "method declaration is missing a deprecated attribute that is specified in "
+  "the definition">,

Please quote 'deprecated' in the diagnostic wording. Same for the note.

One concern I have about this diagnostic is that it suggests this will happen 
for *all* deprecated attributes when it does not.



Comment at: include/clang/Sema/Sema.h:2406-2407
+  /// This will warn on any missing clauses in the declaration.
+  void checkMissingAvailabilityClausesInDeclaration(NamedDecl *Original,
+NamedDecl *Implementation);
+

These should be `const` pointers.

Does this *only* warn on missing clauses, or does it also warn on  conflicting 
clauses as the first sentence suggests?



Comment at: lib/Sema/SemaDecl.cpp:3581-3582
+if (Imp->getClassInterface() == DC ||
+(isa(DC) &&
+ cast(DC)->IsClassExtension() &&
+ Imp->getClassInterface() ==

Please do not use `isa<>` followed by `cast<>` (same below). Rather than use 
this complex if statement, it might be better to split things out into local 
variables.



Comment at: lib/Sema/SemaDeclAttr.cpp:2286
+  llvm::SmallPtrSet MissingPlatformAttributes;
+  for (auto *Def : Implementation->specific_attrs()) {
+bool MissingIntroduced = !Def->getIntroduced().empty();

`const auto *`



Comment at: lib/Sema/SemaDeclAttr.cpp:2291
+bool MissingUnavailable = Def->getUnavailable();
+for (auto *Decl : Original->specific_attrs()) {
+  if (Def->getPlatform() != Decl->getPlatform())

`const auto *`



Comment at: lib/Sema/SemaDeclAttr.cpp:2295
+  MissingIntroduced =
+  MissingIntroduced ? Decl->getIntroduced().empty() : false;
+  MissingDeprecated =

ahatanak wrote:
> I feel like using "if" is easier to understand than a conditional operator, 
> but it's up to you:
> 
> ```
> if (MissingIntroduced)
>   MissingIntroduced = Decl->getIntroduced().empty();
> ```
The pattern we usually see is: `MissingIntroduced = MissingIntroduced && 
Decl->getIntroduced().empty();`


Repository:
  rL LLVM

https://reviews.llvm.org/D39913



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


r318979 - [analyzer] Teach RetainCountChecker about CoreMedia APIs

2017-11-25 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Sat Nov 25 06:57:42 2017
New Revision: 318979

URL: http://llvm.org/viewvc/llvm-project?rev=318979&view=rev
Log:
[analyzer] Teach RetainCountChecker about CoreMedia APIs

Teach the retain-count checker that CoreMedia reference types use
CoreFoundation-style reference counting. This enables the checker
to catch leaks and over releases of those types.

rdar://problem/33599757

Modified:
cfe/trunk/lib/Analysis/CocoaConventions.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
cfe/trunk/test/Analysis/retain-release.m

Modified: cfe/trunk/lib/Analysis/CocoaConventions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CocoaConventions.cpp?rev=318979&r1=318978&r2=318979&view=diff
==
--- cfe/trunk/lib/Analysis/CocoaConventions.cpp (original)
+++ cfe/trunk/lib/Analysis/CocoaConventions.cpp Sat Nov 25 06:57:42 2017
@@ -47,12 +47,19 @@ bool cocoa::isRefType(QualType RetTy, St
   return Name.startswith(Prefix);
 }
 
+/// Returns true when the passed-in type is a CF-style reference-counted
+/// type from the DiskArbitration framework.
+static bool isDiskArbitrationAPIRefType(QualType T) {
+  return cocoa::isRefType(T, "DADisk") ||
+  cocoa::isRefType(T, "DADissenter") ||
+  cocoa::isRefType(T, "DASessionRef");
+}
+
 bool coreFoundation::isCFObjectRef(QualType T) {
   return cocoa::isRefType(T, "CF") || // Core Foundation.
  cocoa::isRefType(T, "CG") || // Core Graphics.
- cocoa::isRefType(T, "DADisk") || // Disk Arbitration API.
- cocoa::isRefType(T, "DADissenter") ||
- cocoa::isRefType(T, "DASessionRef");
+ cocoa::isRefType(T, "CM") || // Core Media.
+ isDiskArbitrationAPIRefType(T);
 }
 
 

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp?rev=318979&r1=318978&r2=318979&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp Sat Nov 25 
06:57:42 2017
@@ -1201,10 +1201,10 @@ RetainSummaryManager::getFunctionSummary
 break;
   }
 
-  // For the Disk Arbitration API (DiskArbitration/DADisk.h)
-  if (cocoa::isRefType(RetTy, "DADisk") ||
-  cocoa::isRefType(RetTy, "DADissenter") ||
-  cocoa::isRefType(RetTy, "DASessionRef")) {
+  // For all other CF-style types, use the Create/Get
+  // rule for summaries but don't support Retain functions
+  // with framework-specific prefixes.
+  if (coreFoundation::isCFObjectRef(RetTy)) {
 S = getCFCreateGetRuleSummary(FD);
 break;
   }

Modified: cfe/trunk/test/Analysis/retain-release.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release.m?rev=318979&r1=318978&r2=318979&view=diff
==
--- cfe/trunk/test/Analysis/retain-release.m (original)
+++ cfe/trunk/test/Analysis/retain-release.m Sat Nov 25 06:57:42 2017
@@ -450,6 +450,51 @@ void f10(io_service_t media, DADiskRef d
   if (session) NSLog(@"ok");
 }
 
+
+// Handle CoreMedia API
+
+struct CMFoo;
+typedef struct CMFoo *CMFooRef;
+
+CMFooRef CMCreateFooRef();
+CMFooRef CMGetFooRef();
+
+typedef signed long SInt32;
+typedef SInt32  OSStatus;
+OSStatus CMCreateFooAndReturnViaOutParameter(CMFooRef * CF_RETURNS_RETAINED 
fooOut);
+
+void testLeakCoreMediaReferenceType() {
+  CMFooRef f = CMCreateFooRef(); // expected-warning{{leak}}
+}
+
+void testOverReleaseMediaReferenceType() {
+  CMFooRef f = CMGetFooRef();
+  CFRelease(f); // expected-warning{{Incorrect decrement of the reference 
count}}
+}
+
+void testOkToReleaseReturnsRetainedOutParameter() {
+  CMFooRef foo = 0;
+  OSStatus status = CMCreateFooAndReturnViaOutParameter(&foo);
+
+  if (status != 0)
+return;
+
+  CFRelease(foo); // no-warning
+}
+
+void testLeakWithReturnsRetainedOutParameter() {
+  CMFooRef foo = 0;
+  OSStatus status = CMCreateFooAndReturnViaOutParameter(&foo);
+
+  if (status != 0)
+return;
+
+  // FIXME: Ideally we would report a leak here since it is the caller's
+  // responsibility to release 'foo'. However, we don't currently have
+  // a mechanism in this checker to only require a release when a successful
+  // status is returned.
+}
+
 // Test retain/release checker with CFString and CFMutableArray.
 void f11() {
   // Create the array.


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


Re: [clang-tools-extra] r318840 - [FindAllSymbols] Cache regexes, creating them is expensive

2017-11-25 Thread Dimitry Andric via cfe-commits
Yeah, in the past libc++ broke its own ABI with 
http://llvm.org/viewvc/llvm-project?view=revision&revision=194536, which is why 
we had to add the _LIBCPP_TRIVIAL_PAIR_COPY_CTOR hack to our own libc++ 
__config, in https://svnweb.freebsd.org/base?view=revision&revision=261801.

(Afterwards, in 
http://llvm.org/viewvc/llvm-project?view=revision&revision=275749, that define 
was renamed to _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR, but its 
functionality stayed the same.)

More recently, Eric Fiselier made the hack unnecessary with 
http://llvm.org/viewvc/llvm-project?view=revision&revision=283944, which I 
merged into FreeBSD 11-STABLE in 
https://svnweb.freebsd.org/base?view=revision&revision=315702.

After this, hacks for std::pair having trivial constructors should no longer be 
nessary, but the fix only made it into FreeBSD 11.1-RELEASE, so users with 
11.0-RELEASE are still SOL.

-Dimitry

> On 24 Nov 2017, at 00:01, Krzysztof Parzyszek  wrote:
> 
> +Dimitry.
> 
> 
> On 11/23/2017 12:50 PM, Benjamin Kramer wrote:
>> I'm afraid I can't really help you here. You can try twiddling the
>> code a bit by creating the pair explicitly and moving it into the
>> vector, just to avoid the brokenness in the standard library. Not sure
>> if that will help though.
>> On Thu, Nov 23, 2017 at 7:05 PM, Krzysztof Parzyszek
>>  wrote:
>>> There has been some problem with std::pair on FreeBSD (due to some ABI
>>> compatibility issue), but I don't know much about what it was.
>>> 
>>> Commenting the reserve doesn't help, unfortunately. The same problem is now
>>> flagged in emplace_back.
>>> 
>>> -Krzysztof
>>> 
>>> 
>>> 
>>> On 11/23/2017 11:47 AM, Benjamin Kramer wrote:
 
 That looks like a bug in the standard library. Does removing the call
 to reserve fix it? It's not really necessary, that code isn't
 performance sensitive at all.
 
 On Thu, Nov 23, 2017 at 6:36 PM, Krzysztof Parzyszek
  wrote:
> 
> Hi,
> This broke build on FreeBSD 11:
> 
> [100%] Building CXX object
> 
> tools/clang/tools/extra/include-fixer/find-all-symbols/CMakeFiles/findAllSymbols.dir/HeaderMapCollector.cpp.o
> cd /w/bld/org/tools/clang/tools/extra/include-fixer/find-all-symbols &&
> /w/c/clang+llvm-5.0.0-x86_64-unknown-freebsd11/bin/clang++
> -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
> -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
> -I/w/bld/org/tools/clang/tools/extra/include-fixer/find-all-symbols
> -I/w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols
> -I/w/src/llvm.org/tools/clang/include -I/w/bld/org/tools/clang/include
> -I/w/bld/org/include -I/w/src/llvm.org/include -isystem
> /usr/local/include
> -stdlib=libc++ -fPIC -fvisibility-inlines-hidden -Werror=date-time
> -Werror=unguarded-availability-new -std=c++11 -Wall -W
> -Wno-unused-parameter
> -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic
> -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor
> -Wdelete-non-virtual-dtor -Wno-comment -Wstring-conversion
> -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual
> -Wno-nested-anon-types -O3-UNDEBUG -fno-exceptions -fno-rtti -o
> CMakeFiles/findAllSymbols.dir/HeaderMapCollector.cpp.o -c
> 
> /w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols/HeaderMapCollector.cpp
> In file included from
> 
> /w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols/HeaderMapCollector.cpp:10:
> In file included from
> 
> /w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols/HeaderMapCollector.h:13:
> In file included from /w/src/llvm.org/include/llvm/ADT/StringMap.h:17:
> In file included from /w/src/llvm.org/include/llvm/ADT/StringRef.h:13:
> In file included from /w/src/llvm.org/include/llvm/ADT/STLExtras.h:20:
> In file included from /w/src/llvm.org/include/llvm/ADT/Optional.h:22:
> In file included from
> /w/src/llvm.org/include/llvm/Support/type_traits.h:19:
> /usr/include/c++/v1/utility:315:11: error: call to deleted constructor of
> 'llvm::Regex'
>  : first(__p.first),
>^ ~
> /usr/include/c++/v1/memory:1747:31: note: in instantiation of member
> function 'std::__1::pair::pair' requested here
>  ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
>^
> /usr/include/c++/v1/memory:1658:18: note: in instantiation of function
> template specialization 'std::__1::allocator const char *> >::construct,
> const
> std::__1::pair &>' requested here
>  {__a.construct(__p, _VSTD::forward<_Args>(__args)...);}
>   ^
> /usr/include/c++/v1/memory:1504:14: note: in instantiation of function
> template specialization
> 
> 'std::__1::allocator_traits const c

r318985 - [X86] Use separate builtins for fma4 scalar intrinsics. Use negations to remove some of the scalar fma3 builtins.

2017-11-25 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sat Nov 25 11:32:12 2017
New Revision: 318985

URL: http://llvm.org/viewvc/llvm-project?rev=318985&view=rev
Log:
[X86] Use separate builtins for fma4 scalar intrinsics. Use negations to remove 
some of the scalar fma3 builtins.

fma4 instructions zero the upper bits of the xmm register. fma3 instructions 
leave the bits unmodified. This requires separate builtins for the different 
semantics.

While we're cleaning up the scalar builtins this also removes the fma3 
fmsub/fnmadd/fnmsub builtins by using negates in the header file.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/fma4intrin.h
cfe/trunk/lib/Headers/fmaintrin.h
cfe/trunk/test/CodeGen/fma-builtins.c
cfe/trunk/test/CodeGen/fma4-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=318985&r1=318984&r2=318985&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Sat Nov 25 11:32:12 2017
@@ -682,14 +682,10 @@ TARGET_BUILTIN(__builtin_ia32_sha256msg2
 // FMA
 TARGET_BUILTIN(__builtin_ia32_vfmaddps, "V4fV4fV4fV4f", "", "fma|fma4")
 TARGET_BUILTIN(__builtin_ia32_vfmaddpd, "V2dV2dV2dV2d", "", "fma|fma4")
-TARGET_BUILTIN(__builtin_ia32_vfmaddss3, "V4fV4fV4fV4f", "", "fma|fma4")
-TARGET_BUILTIN(__builtin_ia32_vfmaddsd3, "V2dV2dV2dV2d", "", "fma|fma4")
-TARGET_BUILTIN(__builtin_ia32_vfmsubss3, "V4fV4fV4fV4f", "", "fma|fma4")
-TARGET_BUILTIN(__builtin_ia32_vfmsubsd3, "V2dV2dV2dV2d", "", "fma|fma4")
-TARGET_BUILTIN(__builtin_ia32_vfnmaddss3, "V4fV4fV4fV4f", "", "fma|fma4")
-TARGET_BUILTIN(__builtin_ia32_vfnmaddsd3, "V2dV2dV2dV2d", "", "fma|fma4")
-TARGET_BUILTIN(__builtin_ia32_vfnmsubss3, "V4fV4fV4fV4f", "", "fma|fma4")
-TARGET_BUILTIN(__builtin_ia32_vfnmsubsd3, "V2dV2dV2dV2d", "", "fma|fma4")
+TARGET_BUILTIN(__builtin_ia32_vfmaddss3, "V4fV4fV4fV4f", "", "fma")
+TARGET_BUILTIN(__builtin_ia32_vfmaddsd3, "V2dV2dV2dV2d", "", "fma")
+TARGET_BUILTIN(__builtin_ia32_vfmaddss, "V4fV4fV4fV4f", "", "fma4")
+TARGET_BUILTIN(__builtin_ia32_vfmaddsd, "V2dV2dV2dV2d", "", "fma4")
 TARGET_BUILTIN(__builtin_ia32_vfmaddsubps, "V4fV4fV4fV4f", "", "fma|fma4")
 TARGET_BUILTIN(__builtin_ia32_vfmaddsubpd, "V2dV2dV2dV2d", "", "fma|fma4")
 TARGET_BUILTIN(__builtin_ia32_vfmaddps256, "V8fV8fV8fV8f", "", "fma|fma4")

Modified: cfe/trunk/lib/Headers/fma4intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/fma4intrin.h?rev=318985&r1=318984&r2=318985&view=diff
==
--- cfe/trunk/lib/Headers/fma4intrin.h (original)
+++ cfe/trunk/lib/Headers/fma4intrin.h Sat Nov 25 11:32:12 2017
@@ -48,13 +48,13 @@ _mm_macc_pd(__m128d __A, __m128d __B, __
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_macc_ss(__m128 __A, __m128 __B, __m128 __C)
 {
-  return (__m128)__builtin_ia32_vfmaddss3((__v4sf)__A, (__v4sf)__B, 
(__v4sf)__C);
+  return (__m128)__builtin_ia32_vfmaddss((__v4sf)__A, (__v4sf)__B, 
(__v4sf)__C);
 }
 
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_macc_sd(__m128d __A, __m128d __B, __m128d __C)
 {
-  return (__m128d)__builtin_ia32_vfmaddsd3((__v2df)__A, (__v2df)__B, 
(__v2df)__C);
+  return (__m128d)__builtin_ia32_vfmaddsd((__v2df)__A, (__v2df)__B, 
(__v2df)__C);
 }
 
 static __inline__ __m128 __DEFAULT_FN_ATTRS
@@ -72,13 +72,13 @@ _mm_msub_pd(__m128d __A, __m128d __B, __
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_msub_ss(__m128 __A, __m128 __B, __m128 __C)
 {
-  return (__m128)__builtin_ia32_vfmsubss3((__v4sf)__A, (__v4sf)__B, 
(__v4sf)__C);
+  return (__m128)__builtin_ia32_vfmaddss((__v4sf)__A, (__v4sf)__B, 
-(__v4sf)__C);
 }
 
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_msub_sd(__m128d __A, __m128d __B, __m128d __C)
 {
-  return (__m128d)__builtin_ia32_vfmsubsd3((__v2df)__A, (__v2df)__B, 
(__v2df)__C);
+  return (__m128d)__builtin_ia32_vfmaddsd((__v2df)__A, (__v2df)__B, 
-(__v2df)__C);
 }
 
 static __inline__ __m128 __DEFAULT_FN_ATTRS
@@ -96,13 +96,13 @@ _mm_nmacc_pd(__m128d __A, __m128d __B, _
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_nmacc_ss(__m128 __A, __m128 __B, __m128 __C)
 {
-  return (__m128)__builtin_ia32_vfnmaddss3((__v4sf)__A, (__v4sf)__B, 
(__v4sf)__C);
+  return (__m128)__builtin_ia32_vfmaddss(-(__v4sf)__A, (__v4sf)__B, 
(__v4sf)__C);
 }
 
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_nmacc_sd(__m128d __A, __m128d __B, __m128d __C)
 {
-  return (__m128d)__builtin_ia32_vfnmaddsd3((__v2df)__A, (__v2df)__B, 
(__v2df)__C);
+  return (__m128d)__builtin_ia32_vfmaddsd(-(__v2df)__A, (__v2df)__B, 
(__v2df)__C);
 }
 
 static __inline__ __m128 __DEFAULT_FN_ATTRS
@@ -120,13 +120,13 @@ _mm_nmsub_pd(__m128d __A, __m128d __B, _
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_nmsub_ss(__m128 __A, __m128 __B, __m128 __C)
 {
-  return (__m128)__built

[libcxx] r318989 - Fix installation of cxxabi.h through libc++.

2017-11-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sat Nov 25 15:39:17 2017
New Revision: 318989

URL: http://llvm.org/viewvc/llvm-project?rev=318989&view=rev
Log:
Fix installation of cxxabi.h through libc++.

Previously, the install command for the cxxabi headers specified
the wrong component, and therefore they were not being included
in the install-cxx command.

This patch corrects the component name.

Modified:
libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake

Modified: libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake?rev=318989&r1=318988&r2=318989&view=diff
==
--- libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake (original)
+++ libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake Sat Nov 25 15:39:17 2017
@@ -56,7 +56,7 @@ macro(setup_abi_lib abidefines abilib ab
 if (LIBCXX_INSTALL_HEADERS)
   install(FILES "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}"
 DESTINATION ${LIBCXX_INSTALL_PREFIX}include/c++/v1/${dstdir}
-COMPONENT libcxx
+COMPONENT cxx-headers
 PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
 )
 endif()


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


Re: [clang-tools-extra] r318840 - [FindAllSymbols] Cache regexes, creating them is expensive

2017-11-25 Thread Krzysztof Parzyszek via cfe-commits

After upgrading my FreeBSD to the latest -STABLE this no longer fails.

-Krzysztof

PS. And system clang was upgraded to 5.0.0.  Nice!

On 11/25/2017 11:20 AM, Dimitry Andric wrote:

Yeah, in the past libc++ broke its own ABI with 
http://llvm.org/viewvc/llvm-project?view=revision&revision=194536, which is why we 
had to add the _LIBCPP_TRIVIAL_PAIR_COPY_CTOR hack to our own libc++ __config, in 
https://svnweb.freebsd.org/base?view=revision&revision=261801.

(Afterwards, in 
http://llvm.org/viewvc/llvm-project?view=revision&revision=275749, that define 
was renamed to _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR, but its 
functionality stayed the same.)

More recently, Eric Fiselier made the hack unnecessary with 
http://llvm.org/viewvc/llvm-project?view=revision&revision=283944, which I merged 
into FreeBSD 11-STABLE in 
https://svnweb.freebsd.org/base?view=revision&revision=315702.

After this, hacks for std::pair having trivial constructors should no longer be 
nessary, but the fix only made it into FreeBSD 11.1-RELEASE, so users with 
11.0-RELEASE are still SOL.

-Dimitry


On 24 Nov 2017, at 00:01, Krzysztof Parzyszek  wrote:

+Dimitry.


On 11/23/2017 12:50 PM, Benjamin Kramer wrote:

I'm afraid I can't really help you here. You can try twiddling the
code a bit by creating the pair explicitly and moving it into the
vector, just to avoid the brokenness in the standard library. Not sure
if that will help though.
On Thu, Nov 23, 2017 at 7:05 PM, Krzysztof Parzyszek
 wrote:

There has been some problem with std::pair on FreeBSD (due to some ABI
compatibility issue), but I don't know much about what it was.

Commenting the reserve doesn't help, unfortunately. The same problem is now
flagged in emplace_back.

-Krzysztof



On 11/23/2017 11:47 AM, Benjamin Kramer wrote:


That looks like a bug in the standard library. Does removing the call
to reserve fix it? It's not really necessary, that code isn't
performance sensitive at all.

On Thu, Nov 23, 2017 at 6:36 PM, Krzysztof Parzyszek
 wrote:


Hi,
This broke build on FreeBSD 11:

[100%] Building CXX object

tools/clang/tools/extra/include-fixer/find-all-symbols/CMakeFiles/findAllSymbols.dir/HeaderMapCollector.cpp.o
cd /w/bld/org/tools/clang/tools/extra/include-fixer/find-all-symbols &&
/w/c/clang+llvm-5.0.0-x86_64-unknown-freebsd11/bin/clang++
-DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-I/w/bld/org/tools/clang/tools/extra/include-fixer/find-all-symbols
-I/w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols
-I/w/src/llvm.org/tools/clang/include -I/w/bld/org/tools/clang/include
-I/w/bld/org/include -I/w/src/llvm.org/include -isystem
/usr/local/include
-stdlib=libc++ -fPIC -fvisibility-inlines-hidden -Werror=date-time
-Werror=unguarded-availability-new -std=c++11 -Wall -W
-Wno-unused-parameter
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic
-Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor
-Wdelete-non-virtual-dtor -Wno-comment -Wstring-conversion
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual
-Wno-nested-anon-types -O3-UNDEBUG -fno-exceptions -fno-rtti -o
CMakeFiles/findAllSymbols.dir/HeaderMapCollector.cpp.o -c

/w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols/HeaderMapCollector.cpp
In file included from

/w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols/HeaderMapCollector.cpp:10:
In file included from

/w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols/HeaderMapCollector.h:13:
In file included from /w/src/llvm.org/include/llvm/ADT/StringMap.h:17:
In file included from /w/src/llvm.org/include/llvm/ADT/StringRef.h:13:
In file included from /w/src/llvm.org/include/llvm/ADT/STLExtras.h:20:
In file included from /w/src/llvm.org/include/llvm/ADT/Optional.h:22:
In file included from
/w/src/llvm.org/include/llvm/Support/type_traits.h:19:
/usr/include/c++/v1/utility:315:11: error: call to deleted constructor of
'llvm::Regex'
  : first(__p.first),
^ ~
/usr/include/c++/v1/memory:1747:31: note: in instantiation of member
function 'std::__1::pair::pair' requested here
  ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
^
/usr/include/c++/v1/memory:1658:18: note: in instantiation of function
template specialization 'std::__1::allocator >::construct,
const
std::__1::pair &>' requested here
  {__a.construct(__p, _VSTD::forward<_Args>(__args)...);}
   ^
/usr/include/c++/v1/memory:1504:14: note: in instantiation of function
template specialization

'std::__1::allocator_traits > >::__construct,
const std::__1::pair &>' requested here
  {__construct(__has_construct(),
   ^
/usr/include/c++/v1/memory:1620:17: note: in instantiation of function
template specialization

'std::__1::allocator_traits > >::construct,
const std::__1::pair &>'

[PATCH] D40381: Parse concept definition

2017-11-25 Thread changyu via Phabricator via cfe-commits
changyu planned changes to this revision.
changyu marked 22 inline comments as done.
changyu added inline comments.



Comment at: lib/Parse/ParseTemplate.cpp:374
+
+  ExprResult ConstraintExpr = ParseConstraintExpression();
+

saar.raz wrote:
> Add a check to ParseConstraintExpression that the type is either dependent or 
> bool, and add an apropriate diagnostic.
> 
> ```
> if (!ConstraintExpr->isTypeDependent() && ConstraintExpr->getType() != 
> Context.BoolTy) {
>   Diag(Init->getSourceRange().getBegin(),
>diag::err_concept_initialized_with_non_bool_type) << 
> Init->getType();
>   Concept->setInvalidDecl();
>   return;
> }
> ```
I'm guessing you meant for this to be in `class Sema` so I added this to 
`Sema::ActOnConceptDefinition`. Also what is `Init` here?



Comment at: lib/Parse/ParseTemplate.cpp:374
+
+  ExprResult ConstraintExpr = ParseConstraintExpression();
+

hubert.reinterpretcast wrote:
> changyu wrote:
> > saar.raz wrote:
> > > Add a check to ParseConstraintExpression that the type is either 
> > > dependent or bool, and add an apropriate diagnostic.
> > > 
> > > ```
> > > if (!ConstraintExpr->isTypeDependent() && ConstraintExpr->getType() 
> > > != Context.BoolTy) {
> > >   Diag(Init->getSourceRange().getBegin(),
> > >diag::err_concept_initialized_with_non_bool_type) << 
> > > Init->getType();
> > >   Concept->setInvalidDecl();
> > >   return;
> > > }
> > > ```
> > I'm guessing you meant for this to be in `class Sema` so I added this to 
> > `Sema::ActOnConceptDefinition`. Also what is `Init` here?
> I think that would still need a TODO to instead walk the constraint 
> expression for atomic constraints and diagnose those.
> ```
> template 
> concept C = 1 || T::value; // error
> ```
Why is that an error? [temp.constr.normal] in p0734r0 seems to say it's valid?



Comment at: lib/Sema/SemaTemplate.cpp:3903
+  // /*FoundD=*/nullptr, TemplateArgs);
+  return Template->getConstraintExpr();
+  return true;

hubert.reinterpretcast wrote:
> Add more comments here. It looks like this allows us to get id-expressions 
> naming concepts defined with non-dependent `bool` constraint expressions to 
> "work" for now?
That's pretty much it.



Comment at: lib/Sema/SemaTemplate.cpp:3936
 
+  if (R.getAsSingle()) {
+return CheckConceptTemplateId(SS, R.getLookupNameInfo(),

Rakete wrote:
> saar.raz wrote:
> > We're gonna want to check
> > ```
> > !TemplateSpecializationType::anyDependentTemplateArguments(*TemplateArgs, 
> > InstantiationDependent)
> > ``` 
> > here as well - so that we can instantiate a ConceptSpecializationExpr later 
> > when we have it (we're not gonna want to instantiate a 
> > ConceptSpecializationExpr with dependent arguments.
> No braces here please.
I'm following the style of the surrounding code here. I can remove the braces 
if you insist though.



Comment at: lib/Sema/SemaTemplate.cpp:7693
+Decl *Sema::ActOnConceptDefinition(Scope *S,
+  MultiTemplateParamsArg TemplateParameterLists,
+   IdentifierInfo *Name, SourceLocation L,

Rakete wrote:
> Did you run this through clang-format?
No, when I run the file through clang-format (with no arguments except the 
file), it reformats the whole file. How should I be running clang-format?


https://reviews.llvm.org/D40381



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


[libcxx] r318990 - Fix copy/paste bug in test where we were putting a '3' into a vector. NFC.

2017-11-25 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Sat Nov 25 16:39:59 2017
New Revision: 318990

URL: http://llvm.org/viewvc/llvm-project?rev=318990&view=rev
Log:
Fix copy/paste bug in test where we were putting a '3' into a vector. NFC.

Modified:
libcxx/trunk/test/std/containers/sequences/vector.bool/size.pass.cpp

Modified: libcxx/trunk/test/std/containers/sequences/vector.bool/size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/size.pass.cpp?rev=318990&r1=318989&r2=318990&view=diff
==
--- libcxx/trunk/test/std/containers/sequences/vector.bool/size.pass.cpp 
(original)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/size.pass.cpp Sat 
Nov 25 16:39:59 2017
@@ -30,7 +30,7 @@ int main()
 assert(c.size() == 1);
 c.push_back(true);
 assert(c.size() == 2);
-c.push_back(C::value_type(3));
+c.push_back(false);
 assert(c.size() == 3);
 c.erase(c.begin());
 assert(c.size() == 2);
@@ -49,7 +49,7 @@ int main()
 assert(c.size() == 1);
 c.push_back(true);
 assert(c.size() == 2);
-c.push_back(C::value_type(3));
+c.push_back(false);
 assert(c.size() == 3);
 c.erase(c.begin());
 assert(c.size() == 2);


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


[PATCH] D40381: Parse concept definition

2017-11-25 Thread changyu via Phabricator via cfe-commits
changyu updated this revision to Diff 124268.
changyu marked 2 inline comments as done.

https://reviews.llvm.org/D40381

Files:
  include/clang/AST/DeclTemplate.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/DeclNodes.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TemplateKinds.h
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTDumper.cpp
  lib/AST/DeclBase.cpp
  lib/AST/DeclTemplate.cpp
  lib/CodeGen/CGDecl.cpp
  lib/Parse/ParseTemplate.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp
  test/Parser/cxx-concept-declaration.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -5906,6 +5906,7 @@
   case Decl::PragmaComment:
   case Decl::PragmaDetectMismatch:
   case Decl::UsingPack:
+  case Decl::Concept:
 return C;
 
   // Declaration kinds that don't make any sense here, but are
Index: test/Parser/cxx-concept-declaration.cpp
===
--- test/Parser/cxx-concept-declaration.cpp
+++ test/Parser/cxx-concept-declaration.cpp
@@ -1,7 +1,31 @@
 
 // Support parsing of concepts
-// Disabled for now.
-// expected-no-diagnostics
 
-// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
-// template concept C1 = true;
+// RUN:  %clang_cc1 -std=c++2a -fconcepts-ts -verify %s
+template concept C1 = true;
+
+// TODO: Following line should fail.
+template concept C1 = true;
+
+template concept D1 = true; // expected-error {{expected template parameter}}
+
+template concept C2 = 0.f; // expected-error {{constraint expression must be 'bool'}}
+
+struct S1 {
+  template concept C1 = true; // expected-error {{concept declarations may only appear in global or namespace scope}}
+};
+
+template
+template
+concept C4 = true; // expected-error {{extraneous template parameter list in concept definition}}
+
+template concept C5 = true; // expected-note {{previous}} expected-note {{previous}}
+int C5; // expected-error {{redefinition}}
+struct C5 {}; // expected-error {{redefinition}}
+
+// TODO: Last of the following two lines should fail.
+struct C6 {};
+template concept C6 = true;
+
+// TODO: Add test to prevent explicit specialization, partial specialization
+// and explicit instantiation of concepts.
Index: test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp
@@ -0,0 +1,5 @@
+// RUN:  %clang_cc1 -std=c++2a -fconcepts-ts -verify %s
+// expected-no-diagnostics
+
+template concept C = true;
+static_assert(C);
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -101,6 +101,7 @@
 void VisitBindingDecl(BindingDecl *D);
 void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D);
 void VisitTemplateDecl(TemplateDecl *D);
+void VisitConceptDecl(ConceptDecl *D);
 void VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D);
 void VisitClassTemplateDecl(ClassTemplateDecl *D);
 void VisitVarTemplateDecl(VarTemplateDecl *D);
@@ -1385,6 +1386,12 @@
   Record.AddTemplateParameterList(D->getTemplateParameters());
 }
 
+void ASTDeclWriter::VisitConceptDecl(ConceptDecl *D) {
+  VisitTemplateDecl(D);
+  Record.AddStmt(D->getConstraintExpr());
+  Code = serialization::DECL_CONCEPT;
+}
+
 void ASTDeclWriter::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) {
   VisitRedeclarable(D);
 
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -1277,6 +1277,7 @@
   RECORD(DECL_TEMPLATE_TYPE_PARM);
   RECORD(DECL_NON_TYPE_TEMPLATE_PARM);
   RECORD(DECL_TEMPLATE_TEMPLATE_PARM);
+  RECORD(DECL_CONCEPT);
   RECORD(DECL_TYPE_ALIAS_TEMPLATE);
   RECORD(DECL_STATIC_ASSERT);
   RECORD(DECL_CXX_BASE_SPECIFIERS);
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -337,6 +337,7 @@
 void VisitBindingDecl(BindingDecl *BD);
 void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D);
 DeclID VisitTemplateDecl(TemplateDecl *D);
+void VisitConceptDecl(ConceptDecl *D);
 RedeclarableResult VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D);
 void VisitClassTemplateDecl(ClassTemplateDecl *D);
 void V

[PATCH] D40381: Parse concept definition

2017-11-25 Thread changyu via Phabricator via cfe-commits
changyu added inline comments.



Comment at: include/clang/Sema/Sema.h:6194
+SourceLocation TemplateLoc,
+const TemplateArgumentListInfo *TemplateArgs);
+

hubert.reinterpretcast wrote:
> Indentation issue here too.
That last line is 79 characters long.


https://reviews.llvm.org/D40381



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


[libcxx] r318992 - More of P0600; marking allocation routines as [[nodiscard]]

2017-11-25 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Sat Nov 25 18:55:38 2017
New Revision: 318992

URL: http://llvm.org/viewvc/llvm-project?rev=318992&view=rev
Log:
More of P0600; marking allocation routines as [[nodiscard]]

Added:

libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size.fail.cpp

libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size_hint.fail.cpp

libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.fail.cpp

libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/allocate.fail.cpp
Modified:
libcxx/trunk/include/memory
libcxx/trunk/include/scoped_allocator

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=318992&r1=318991&r2=318992&view=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Sat Nov 25 18:55:38 2017
@@ -84,8 +84,8 @@ struct allocator_traits
 template  using rebind_alloc  = Alloc::rebind::other | 
Alloc;
 template  using rebind_traits = allocator_traits>;
 
-static pointer allocate(allocator_type& a, size_type n);
-static pointer allocate(allocator_type& a, size_type n, const_void_pointer 
hint);
+static pointer allocate(allocator_type& a, size_type n);   
   // [[nodiscard]] in C++20
+static pointer allocate(allocator_type& a, size_type n, const_void_pointer 
hint); // [[nodiscard]] in C++20
 
 static void deallocate(allocator_type& a, pointer p, size_type n) noexcept;
 
@@ -1536,10 +1536,10 @@ struct _LIBCPP_TEMPLATE_VIS allocator_tr
 {typedef allocator_traits::other> other;};
 #endif  // _LIBCPP_CXX03_LANG
 
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
 static pointer allocate(allocator_type& __a, size_type __n)
 {return __a.allocate(__n);}
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
 static pointer allocate(allocator_type& __a, size_type __n, 
const_void_pointer __hint)
 {return __allocate(__a, __n, __hint,
 __has_allocate_hint());}
@@ -1778,7 +1778,8 @@ public:
 {return _VSTD::addressof(__x);}
 _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const 
_NOEXCEPT
 {return _VSTD::addressof(__x);}
-_LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, 
allocator::const_pointer = 0)
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 
+pointer allocate(size_type __n, allocator::const_pointer = 0)
 {
 if (__n > max_size())
 __throw_length_error("allocator::allocate(size_t n)"

Modified: libcxx/trunk/include/scoped_allocator
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/scoped_allocator?rev=318992&r1=318991&r2=318992&view=diff
==
--- libcxx/trunk/include/scoped_allocator (original)
+++ libcxx/trunk/include/scoped_allocator Sat Nov 25 18:55:38 2017
@@ -68,8 +68,8 @@ public:
 outer_allocator_type& outer_allocator() noexcept;
 const outer_allocator_type& outer_allocator() const noexcept;
 
-pointer allocate(size_type n);
-pointer allocate(size_type n, const_void_pointer hint);
+pointer allocate(size_type n);   // [[nodiscard]] 
in C++20
+pointer allocate(size_type n, const_void_pointer hint);  // [[nodiscard]] 
in C++20
 void deallocate(pointer p, size_type n) noexcept;
 
 size_type max_size() const;
@@ -477,11 +477,11 @@ public:
 const outer_allocator_type& outer_allocator() const _NOEXCEPT
 {return base::outer_allocator();}
 
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
 pointer allocate(size_type __n)
 {return allocator_traits::
 allocate(outer_allocator(), __n);}
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
 pointer allocate(size_type __n, const_void_pointer __hint)
 {return allocator_traits::
 allocate(outer_allocator(), __n, __hint);}

Added: 
libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size.fail.cpp?rev=318992&view=auto
==
--- 
libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size.fail.cpp
 (added)
+++ 
libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size.fail.cpp
 Sat Nov 25 18:55:38 2017
@@ -0,0 +1,29 @@
+//===--===//
+//
+//

[PATCH] D40381: Parse concept definition

2017-11-25 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: include/clang/Sema/Sema.h:6194
+SourceLocation TemplateLoc,
+const TemplateArgumentListInfo *TemplateArgs);
+

changyu wrote:
> hubert.reinterpretcast wrote:
> > Indentation issue here too.
> That last line is 79 characters long.
clang-format is happy to give:
```
  ExprResult
  CheckConceptTemplateId(const CXXScopeSpec &SS,
 const DeclarationNameInfo &NameInfo,
 ConceptDecl *Template, SourceLocation TemplateLoc,
 const TemplateArgumentListInfo *TemplateArgs);
```

I'm no fan of blindly using clang-format, but its output is sometimes useful.



Comment at: lib/Parse/ParseTemplate.cpp:374
+
+  ExprResult ConstraintExpr = ParseConstraintExpression();
+

changyu wrote:
> hubert.reinterpretcast wrote:
> > changyu wrote:
> > > saar.raz wrote:
> > > > Add a check to ParseConstraintExpression that the type is either 
> > > > dependent or bool, and add an apropriate diagnostic.
> > > > 
> > > > ```
> > > > if (!ConstraintExpr->isTypeDependent() && ConstraintExpr->getType() 
> > > > != Context.BoolTy) {
> > > >   Diag(Init->getSourceRange().getBegin(),
> > > >diag::err_concept_initialized_with_non_bool_type) << 
> > > > Init->getType();
> > > >   Concept->setInvalidDecl();
> > > >   return;
> > > > }
> > > > ```
> > > I'm guessing you meant for this to be in `class Sema` so I added this to 
> > > `Sema::ActOnConceptDefinition`. Also what is `Init` here?
> > I think that would still need a TODO to instead walk the constraint 
> > expression for atomic constraints and diagnose those.
> > ```
> > template 
> > concept C = 1 || T::value; // error
> > ```
> Why is that an error? [temp.constr.normal] in p0734r0 seems to say it's valid?
From N4700 subclause 17.4.1.2 [temp.constr.atomic] paragraph 3:
[ ... ], and E shall be a constant expression of type bool

A search of "bool" in P0734R0 seems to indicate that is also the basis for the 
diagnostic Saar is requesting.

Although that wording only applies clearly when determining the satisfaction of 
C for some T, it would be good to catch it early. I believe that the 
particular case I presented falls under the "no valid specialization" wording 
in [temp.res].

I think there is a gap between the wording and the intent if overloaded binary 
logical operators, detectable without substitution, are not sufficiently wrong 
on the part of the user that a compiler may refuse to translate the program.



Comment at: lib/Sema/SemaTemplate.cpp:7693
+Decl *Sema::ActOnConceptDefinition(Scope *S,
+  MultiTemplateParamsArg TemplateParameterLists,
+   IdentifierInfo *Name, SourceLocation L,

changyu wrote:
> Rakete wrote:
> > Did you run this through clang-format?
> No, when I run the file through clang-format (with no arguments except the 
> file), it reformats the whole file. How should I be running clang-format?
One workflow that works is to clang-format the base file, clang-format with 
your changes, grab a patch and then apply it to the original base file 
(probably needs some manual work).


https://reviews.llvm.org/D40381



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