[PATCH] D30733: [Driver] Add arch-specific rpath for libc++

2017-03-11 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

Installing libc++ along clang makes a lot of sense for non-system compilers. It 
doesn't imply any version locking like in GCC, i.e. you are still free to 
install whatever version of libunwind and libc++ you want. I'm somewhat 
conflicted about this patch. I think it is an actual improvement for some 
deployment cases, but I also consider it a bit of an abuse of the ressource 
directory. I'm not sure we have a better mechanism at hand right now though.


https://reviews.llvm.org/D30733



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


[PATCH] D30733: [Driver] Add arch-specific rpath for libc++

2017-03-11 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

I'm sorry, I've completely forgot that the path contains version number. In 
this case, it indeed probably doesn't make much sense to add rpath for that.


https://reviews.llvm.org/D30733



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


[PATCH] D30773: Make git-clang-format python 3 compatible

2017-03-11 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: tools/clang-format/git-clang-format:306
+try:
+return to_string(bytes.decode('utf-8'))
+except AttributeError: # 'str' object has no attribute 'decode'.

mgorny wrote:
> EricWF wrote:
> > mgorny wrote:
> > > This logic looks really weird to me. What is the purpose of having both 
> > > `to_string()` and `convert_string()`? Why do `to_bytes()` and 
> > > `to_string()` use `isinstance()` to recognize types, and here you rely on 
> > > exceptions? Why is `to_string()` called after decoding?
> > `to_string` is called after decoding because in python2 the result of 
> > decoding is a `unicode` type, and we need to encode it a `str` type. Hense 
> > to_string.
> No offense intended but this sounds really horrible. In modern Python, 
> everything is either `bytes` or `unicode`. The difference basically is that 
> `str` in py2 was pretty much `bytes` (except that `bytes` explicitly removes 
> some operations that are unsuitable for bytestrings), and that `str` in py3 
> is equivalent to `unicode` before.
> 
> So if you are specifically converting to `str`, it means that you want to 
> have two distinct types in py2/py3. Which really sounds like you're doing 
> something wrong.
No offence taken. I had to do way to much work to answer your questions 
accurately which means the code is way too complicated or non-obvious.

However there are a couple of things you got wrong. In python2 everything is 
normally `bytes`, `str`, or `unicode`. The `to_string` method converts both 
`unicode` and `bytes` to the type `str`. 

> So if you are specifically converting to str, it means that you want to have 
> two distinct types in py2/py3. Which really sounds like you're doing 
> something wrong.

I don't think having the Python library return different types in py2/py3 means 
something is wrong. In fact that's exactly what's happening and  that's exactly 
what `convert_string` is trying to fix. In python 2 `stdout, stderr, and stdin` 
return strings, but in python 3 they return `bytes`. `convert_string` is meant 
to transform these different types into `str`.

Regardless I'll remove the call to `to_bytes` from inside `to_string` because 
it's too confusing.


https://reviews.llvm.org/D30773



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


[PATCH] D30773: Make git-clang-format python 3 compatible

2017-03-11 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 91456.
EricWF added a comment.

- Rewrite `to_string` for clarities sake.


https://reviews.llvm.org/D30773

Files:
  tools/clang-format/git-clang-format

Index: tools/clang-format/git-clang-format
===
--- tools/clang-format/git-clang-format
+++ tools/clang-format/git-clang-format
@@ -23,6 +23,7 @@
 Requires Python 2.7  
 """   
 
+from __future__ import print_function
 import argparse
 import collections
 import contextlib
@@ -138,15 +139,15 @@
   if opts.verbose >= 1:
 ignored_files.difference_update(changed_lines)
 if ignored_files:
-  print 'Ignoring changes in the following files (wrong extension):'
+  print('Ignoring changes in the following files (wrong extension):')
   for filename in ignored_files:
-print '   ', filename
+print('%s' % filename)
 if changed_lines:
-  print 'Running clang-format on the following files:'
+  print('Running clang-format on the following files:')
   for filename in changed_lines:
-print '   ', filename
+print('%s' % filename)
   if not changed_lines:
-print 'no modified files to format'
+print('no modified files to format')
 return
   # The computed diff outputs absolute paths, so we must cd before accessing
   # those files.
@@ -163,20 +164,20 @@
  binary=opts.binary,
  style=opts.style)
   if opts.verbose >= 1:
-print 'old tree:', old_tree
-print 'new tree:', new_tree
+print('old tree: %s' % old_tree)
+print('new tree: %s' % new_tree)
   if old_tree == new_tree:
 if opts.verbose >= 0:
-  print 'clang-format did not modify any files'
+  print('clang-format did not modify any files')
   elif opts.diff:
 print_diff(old_tree, new_tree)
   else:
 changed_files = apply_changes(old_tree, new_tree, force=opts.force,
   patch_mode=opts.patch)
 if (opts.verbose >= 0 and not opts.patch) or opts.verbose >= 1:
-  print 'changed files:'
+  print('changed files:')
   for filename in changed_files:
-print '   ', filename
+print('%s' % filename)
 
 
 def load_git_config(non_string_options=None):
@@ -257,7 +258,7 @@
   stdout, stderr = p.communicate()
   if p.returncode != 0:
 return None
-  return stdout.strip()
+  return convert_string(stdout.strip())
 
 
 def compute_diff_and_extract_lines(commits, files):
@@ -300,6 +301,7 @@
   list of line `Range`s."""
   matches = {}
   for line in patch_file:
+line = convert_string(line)
 match = re.search(r'^\+\+\+\ [^/]+/(.*)', line)
 if match:
   filename = match.group(1).rstrip('\r\n')
@@ -320,7 +322,7 @@
   `allowed_extensions` must be a collection of lowercase file extensions,
   excluding the period."""
   allowed_extensions = frozenset(allowed_extensions)
-  for filename in dictionary.keys():
+  for filename in list(dictionary.keys()):
 base_ext = filename.rsplit('.', 1)
 if len(base_ext) == 1 or base_ext[1].lower() not in allowed_extensions:
   del dictionary[filename]
@@ -345,7 +347,7 @@
 
   Returns the object ID (SHA-1) of the created tree."""
   def index_info_generator():
-for filename, line_ranges in changed_lines.iteritems():
+for filename, line_ranges in changed_lines.items():
   if revision:
 git_metadata_cmd = ['git', 'ls-tree',
 '%s:%s' % (revision, os.path.dirname(filename)),
@@ -356,6 +358,9 @@
 mode = oct(int(stdout.split()[0], 8))
   else:
 mode = oct(os.stat(filename).st_mode)
+  # Adjust python3 octal format so that it matches what git expects
+  if mode.startswith('0o'):
+  mode = '0' + mode[2:]
   blob_id = clang_format_to_blob(filename, line_ranges,
  revision=revision,
  binary=binary,
@@ -376,7 +381,7 @@
   with temporary_index_file():
 p = subprocess.Popen(cmd, stdin=subprocess.PIPE)
 for line in input_lines:
-  p.stdin.write('%s\0' % line)
+  p.stdin.write(to_bytes('%s\0' % line))
 p.stdin.close()
 if p.wait() != 0:
   die('`%s` failed' % ' '.join(cmd))
@@ -431,7 +436,7 @@
 die('`%s` failed' % ' '.join(clang_format_cmd))
   if git_show and git_show.wait() != 0:
 die('`%s` failed' % ' '.join(git_show_cmd))
-  return stdout.rstrip('\r\n')
+  return convert_string(stdout).rstrip('\r\n')
 
 
 @contextlib.contextmanager
@@ -488,10 +493,10 @@
   if not force:
 unstaged_files = run('git', 'diff-files', '--name-status', *changed_files)
 if unstaged_files:
-  print >>sys.stderr, ('The following files would be modified but '
-   'have unstaged changes:')
-  print >>sys.stderr, unstaged_files
-  print >>s

[PATCH] D30841: [clang-tidy] readability-misleading-indentation: fix chained if

2017-03-11 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Functionally LGTM!

Note that while the traversal of AST Matchers are not defined in general, in 
this particular case of chained ifs, it is guaranteed that parent nodes will be 
matched before the child nodes. For this reason I think it is ok to have a 
state like this. Maybe this worth a comment.

Performance wise maybe an llvm::DenseMap would perform better, according to the 
LLVM Programmer's Manual, it is a great data structure to map pointers to 
pointers.


https://reviews.llvm.org/D30841



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


[PATCH] D30773: Make git-clang-format python 3 compatible

2017-03-11 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: tools/clang-format/git-clang-format:306
+try:
+return to_string(bytes.decode('utf-8'))
+except AttributeError: # 'str' object has no attribute 'decode'.

EricWF wrote:
> mgorny wrote:
> > EricWF wrote:
> > > mgorny wrote:
> > > > This logic looks really weird to me. What is the purpose of having both 
> > > > `to_string()` and `convert_string()`? Why do `to_bytes()` and 
> > > > `to_string()` use `isinstance()` to recognize types, and here you rely 
> > > > on exceptions? Why is `to_string()` called after decoding?
> > > `to_string` is called after decoding because in python2 the result of 
> > > decoding is a `unicode` type, and we need to encode it a `str` type. 
> > > Hense to_string.
> > No offense intended but this sounds really horrible. In modern Python, 
> > everything is either `bytes` or `unicode`. The difference basically is that 
> > `str` in py2 was pretty much `bytes` (except that `bytes` explicitly 
> > removes some operations that are unsuitable for bytestrings), and that 
> > `str` in py3 is equivalent to `unicode` before.
> > 
> > So if you are specifically converting to `str`, it means that you want to 
> > have two distinct types in py2/py3. Which really sounds like you're doing 
> > something wrong.
> No offence taken. I had to do way to much work to answer your questions 
> accurately which means the code is way too complicated or non-obvious.
> 
> However there are a couple of things you got wrong. In python2 everything is 
> normally `bytes`, `str`, or `unicode`. The `to_string` method converts both 
> `unicode` and `bytes` to the type `str`. 
> 
> > So if you are specifically converting to str, it means that you want to 
> > have two distinct types in py2/py3. Which really sounds like you're doing 
> > something wrong.
> 
> I don't think having the Python library return different types in py2/py3 
> means something is wrong. In fact that's exactly what's happening and  that's 
> exactly what `convert_string` is trying to fix. In python 2 `stdout, stderr, 
> and stdin` return strings, but in python 3 they return `bytes`. 
> `convert_string` is meant to transform these different types into `str`.
> 
> Regardless I'll remove the call to `to_bytes` from inside `to_string` because 
> it's too confusing.
In Python 2, `bytes` and `str` is the same type, e.g.:
```
In [13]: bytes('foo').__class__
Out[13]: str
```

In other words, in each version of Python there are two kinds of strings: 
binary strings (`std::string` in C++) and Unicode strings (alike 
`std::u32string`). In Python 2, `str` is binary string (`bytes` is also 
accepted for compatibility) and `unicode` is the Unicode string. In Python 3, 
`bytes` is binary string and `str` is Unicode string.

---

Now, let's consider subprocess streams. In Python 2 they use `str` -- which 
means binary strings. In Python 3 they use `bytes` -- i.e. also binary strings. 
So there's really no change here, except that Python 3 is more strict in 
handling different types.

So if you plan to use the data as binary data, you can just use the data 
directly. If you need to use Unicode strings, you can reliably use `.decode()` 
and `.encode()` to convert. If you really believe you need to use `str` (i.e. 
two distinct types at the same time), it just means that the code is most 
likely wrong and partially relies on characteristic of one type, and partially 
on the other.

---

For completeness, I should also mention that string types used by standard 
system streams (i.e. `sys.std*`) *have* changed between Python 2 and 3. Python 
2 is operating them in `bytes` mode by default, while Python 3 is operating 
them (transcoding) in `str` (i.e. unicode) mode. In the latter case, you can 
use the `.buffer` attribute to access the underlying `bytes` stream -- e.g. 
`sys.stdin.buffer` will yield bytes.


https://reviews.llvm.org/D30773



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


[PATCH] D30859: [coroutines] Implement unhandled_exception changes.

2017-03-11 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.
Herald added a subscriber: mehdi_amini.

This patch adopts the recent changes that renamed 
`set_exception(exception_pointer)` to `unhandled_exception()`.

Additionally `unhandled_exception()` is now required, and so an error is 
emitted when exceptions are enabled but the promise type does not provide the 
member.
When exceptions are disabled a warning is emitted instead of an error, The 
warning notes that the `unhandled_exception()` function is required when 
exceptions are enabled.


https://reviews.llvm.org/D30859

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaCoroutine.cpp
  test/SemaCXX/Inputs/std-coroutine.h
  test/SemaCXX/coreturn.cpp
  test/SemaCXX/coroutine-unhandled_exception-warning.cpp
  test/SemaCXX/coroutines.cpp

Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -verify %s -fcxx-exceptions
+// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -verify %s -fcxx-exceptions -fexceptions
 
 void no_coroutine_traits_bad_arg_await() {
   co_await a; // expected-error {{include }}
@@ -101,13 +101,15 @@
   awaitable yield_value(yielded_thing); // expected-note 2{{candidate}}
   not_awaitable yield_value(void()); // expected-note 2{{candidate}}
   void return_value(int); // expected-note 2{{here}}
+  void unhandled_exception();
 };
 
 struct promise_void {
   void get_return_object();
   suspend_always initial_suspend();
   suspend_always final_suspend();
   void return_void();
+  void unhandled_exception();
 };
 
 void no_coroutine_handle() { // expected-error {{std::experimental::coroutine_handle type was not found; include  before defining a coroutine}}
@@ -344,13 +346,15 @@
 transformed initial_suspend();
 ::adl_ns::coawait_arg_type final_suspend();
 transformed await_transform(transform_awaitable);
+void unhandled_exception();
   };
   template 
   struct basic_promise {
 typedef AwaitArg await_arg;
 coro get_return_object();
 awaitable initial_suspend();
 awaitable final_suspend();
+void unhandled_exception();
   };
 
   awaitable operator co_await(await_arg_1);
@@ -435,6 +439,7 @@
 suspend_never initial_suspend();
 suspend_never final_suspend();
 void get_return_object();
+void unhandled_exception();
   };
 };
 
@@ -467,6 +472,7 @@
 struct bad_promise_1 {
   suspend_always initial_suspend();
   suspend_always final_suspend();
+  void unhandled_exception();
 };
 coro missing_get_return_object() { // expected-error {{no member named 'get_return_object' in 'bad_promise_1'}}
   co_await a;
@@ -476,6 +482,7 @@
   coro get_return_object();
   // FIXME: We shouldn't offer a typo-correction here!
   suspend_always final_suspend(); // expected-note {{here}}
+  void unhandled_exception();
 };
 // FIXME: This shouldn't happen twice
 coro missing_initial_suspend() { // expected-error {{no member named 'initial_suspend' in 'bad_promise_2'}}
@@ -486,6 +493,7 @@
   coro get_return_object();
   // FIXME: We shouldn't offer a typo-correction here!
   suspend_always initial_suspend(); // expected-note {{here}}
+  void unhandled_exception();
 };
 coro missing_final_suspend() { // expected-error {{no member named 'final_suspend' in 'bad_promise_3'}}
   co_await a;
@@ -517,6 +525,7 @@
   coro get_return_object();
   suspend_always initial_suspend();
   suspend_always final_suspend();
+  void unhandled_exception();
   void return_void();
   void return_value(int) const;
   void return_value(int);
@@ -530,33 +539,27 @@
   suspend_always initial_suspend();
   suspend_always final_suspend();
   void return_void();
-  void set_exception(int *);
 };
-coro no_std_current_exc() {
-  // expected-error@-1 {{you need to include  before defining a coroutine that implicitly uses 'set_exception'}}
+coro no_unhandled_exception() { // expected-error {{'bad_promise_7' is required to declare the member 'unhandled_exception()'}}
   co_await a;
 }
 
-namespace std {
-int *current_exception();
-}
-
 struct bad_promise_base {
 private:
   void return_void();
 };
 struct bad_promise_8 : bad_promise_base {
   coro get_return_object();
   suspend_always initial_suspend();
   suspend_always final_suspend();
-  void set_exception();   // expected-note {{function not viable}}
-  void set_exception(int *) __attribute__((unavailable)); // expected-note {{explicitly made unavailable}}
-  void set_exception(void *); // expected-note {{candidate function}}
+  void unhandled_exception() __attribute__((unavailable)); // expected-note {{made unavailable}}
+  void unhandled_exception() const;// expected-note {{candidate}}
+  void unhandled_exception(void *) const;  // expected-note {{requires 1 argument, but 0 were provided}}
 };
-coro cal

[PATCH] D30860: Add more examples and fix a bug in the py generation script

2017-03-11 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru created this revision.
Herald added a subscriber: klimek.

https://reviews.llvm.org/D30860

Files:
  docs/ClangFormatStyleOptions.rst
  docs/tools/dump_format_style.py
  include/clang/Format/Format.h

Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -136,6 +136,12 @@
 
   /// \brief Allow putting all parameters of a function declaration onto
   /// the next line even if ``BinPackParameters`` is ``false``.
+  /// \code
+  ///   true:   false:
+  ///   myFunction(foo, vs. myFunction(foo, bar, plop);
+  ///  bar,
+  ///  plop);
+  /// \endcode
   bool AllowAllParametersOfDeclarationOnNextLine;
 
   /// \brief Allows contracting simple braced statements to a single line.
@@ -334,23 +340,133 @@
   /// \brief Different ways to attach braces to their surrounding context.
   enum BraceBreakingStyle {
 /// Always attach braces to surrounding context.
+/// \code
+///   try {
+/// foo();
+///   } catch () {
+///   }
+///   void foo() { bar(); }
+///   class foo {};
+///   if (foo()) {
+///   } else {
+///   }
+///   enum X : int { A, B };
+/// \endcode
 BS_Attach,
 /// Like ``Attach``, but break before braces on function, namespace and
 /// class definitions.
+/// \code
+///   try {
+/// foo();
+///   } catch () {
+///   }
+///   void foo() { bar(); }
+///   class foo
+///   {
+///   };
+///   if (foo()) {
+///   } else {
+///   }
+///   enum X : int { A, B };
+/// \endcode
 BS_Linux,
 /// Like ``Attach``, but break before braces on enum, function, and record
 /// definitions.
+/// \code
+///   try {
+/// foo();
+///   } catch () {
+///   }
+///   void foo() { bar(); }
+///   class foo
+///   {
+///   };
+///   if (foo()) {
+///   } else {
+///   }
+///   enum X : int { A, B };
+/// \endcode
 BS_Mozilla,
 /// Like ``Attach``, but break before function definitions, ``catch``, and
 /// ``else``.
+/// \code
+///   try {
+/// foo();
+///   } catch () {
+///   }
+///   void foo() { bar(); }
+///   class foo
+///   {
+///   };
+///   if (foo()) {
+///   } else {
+///   }
+///   enum X : int
+///   {
+/// A,
+/// B
+///   };
+/// \endcode
 BS_Stroustrup,
 /// Always break before braces.
+/// \code
+///   try {
+/// foo();
+///   }
+///   catch () {
+///   }
+///   void foo() { bar(); }
+///   class foo {
+///   };
+///   if (foo()) {
+///   }
+///   else {
+///   }
+///   enum X : int { A, B };
+/// \endcode
 BS_Allman,
 /// Always break before braces and add an extra level of indentation to
 /// braces of control statements, not to those of class, function
 /// or other definitions.
+/// \code
+///   try
+/// {
+///   foo();
+/// }
+///   catch ()
+/// {
+/// }
+///   void foo() { bar(); }
+///   class foo
+///   {
+///   };
+///   if (foo())
+/// {
+/// }
+///   else
+/// {
+/// }
+///   enum X : int
+///   {
+/// A,
+/// B
+///   };
+/// \endcode
 BS_GNU,
 /// Like ``Attach``, but break before functions.
+/// \code
+///   try {
+/// foo();
+///   } catch () {
+///   }
+///   void foo() { bar(); }
+///   class foo {
+///   };
+///   if (foo()) {
+///   } else {
+///   }
+///   enum X : int { A, B };
+/// \endcode
 BS_WebKit,
 /// Configure each individual brace in `BraceWrapping`.
 BS_Custom
@@ -360,26 +476,144 @@
   BraceBreakingStyle BreakBeforeBraces;
 
   /// \brief Precise control over the wrapping of braces.
+  /// \code
+  ///   # Should be declared this way:
+  ///   BreakBeforeBraces: Custom
+  ///   BraceWrapping:
+  ///   AfterClass: true
+  /// \endcode
   struct BraceWrappingFlags {
 /// \brief Wrap class definitions.
+/// \code
+///   true:
+///   class foo {};
+///
+///   false:
+///   class foo
+///   {};
+/// \endcode
 bool AfterClass;
 /// \brief Wrap control statements (``if``/``for``/``while``/``switch``/..).
+/// \code
+///   true:
+///   if (foo())
+///   {
+///   } else
+///   {}
+///   for (int i = 0; i < 10; ++i)
+///   {}
+///
+///   false:
+///   if (foo()) {
+///   } else {
+///   }
+///   for (int i = 0; i < 10; ++i) {
+///   }
+/// \endcode
 bool AfterControlStatement;
 /// \brief Wrap enum definitions.
+/// \code
+///   true:
+///   enum X : int
+///   {

[PATCH] D30860: [clang-format] Add more examples and fix a bug in the py generation script

2017-03-11 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added inline comments.



Comment at: docs/tools/dump_format_style.py:67
   def __str__(self):
-return '* ``%s`` %s' % (self.name, doxygen2rst(self.comment))
+return '\n* ``%s`` %s' % (self.name, doxygen2rst(self.comment))
 

This is needed to fix a bug in the generation of BraceWrappingFlags
The generation was failing because of a missing empty line with:



> docs/ClangFormatStyleOptions.rst:480: (WARNING/2) Explicit markup ends 
> without a blank line; unexpected unindent.


Let me know if you prefer to see that in a separate patch



https://reviews.llvm.org/D30860



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


[PATCH] D30863: [clang-format] make docs/tools/{dump_format_style.py, dump_ast_matchers.py} flake8 compliant

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

no functional changes


https://reviews.llvm.org/D30863

Files:
  docs/tools/dump_ast_matchers.py
  docs/tools/dump_format_style.py

Index: docs/tools/dump_format_style.py
===
--- docs/tools/dump_format_style.py
+++ docs/tools/dump_format_style.py
@@ -3,10 +3,8 @@
 # documentation in ../ClangFormatStyleOptions.rst automatically.
 # Run from the directory in which this file is located to update the docs.
 
-import collections
 import os
 import re
-import urllib2
 
 CLANG_DIR = os.path.join(os.path.dirname(__file__), '../..')
 FORMAT_STYLE_FILE = os.path.join(CLANG_DIR, 'include/clang/Format/Format.h')
@@ -14,176 +12,195 @@
 
 
 def substitute(text, tag, contents):
-  replacement = '\n.. START_%s\n\n%s\n\n.. END_%s\n' % (tag, contents, tag)
-  pattern = r'\n\.\. START_%s\n.*\n\.\. END_%s\n' % (tag, tag)
-  return re.sub(pattern, '%s', text, flags=re.S) % replacement
+replacement = '\n.. START_%s\n\n%s\n\n.. END_%s\n' % (tag, contents, tag)
+pattern = r'\n\.\. START_%s\n.*\n\.\. END_%s\n' % (tag, tag)
+return re.sub(pattern, '%s', text, flags=re.S) % replacement
 
+
 def doxygen2rst(text):
-  text = re.sub(r'\s*(.*?)\s*<\/tt>', r'``\1``', text)
-  text = re.sub(r'\\c ([^ ,;\.]+)', r'``\1``', text)
-  text = re.sub(r'\\\w+ ', '', text)
-  return text
+text = re.sub(r'\s*(.*?)\s*<\/tt>', r'``\1``', text)
+text = re.sub(r'\\c ([^ ,;\.]+)', r'``\1``', text)
+text = re.sub(r'\\\w+ ', '', text)
+return text
 
+
 def indent(text, columns):
-  indent = ' ' * columns
-  s = re.sub(r'\n([^\n])', '\n' + indent + '\\1', text, flags=re.S)
-  if s.startswith('\n'):
-return s
-  return indent + s
+indent = ' ' * columns
+s = re.sub(r'\n([^\n])', '\n' + indent + '\\1', text, flags=re.S)
+if s.startswith('\n'):
+return s
+return indent + s
 
+
 class Option:
-  def __init__(self, name, type, comment):
-self.name = name
-self.type = type
-self.comment = comment.strip()
-self.enum = None
-self.nested_struct = None
 
-  def __str__(self):
-s = '**%s** (``%s``)\n%s' % (self.name, self.type,
- doxygen2rst(indent(self.comment, 2)))
-if self.enum:
-  s += indent('\n\nPossible values:\n\n%s\n' % self.enum, 2)
-if self.nested_struct:
-  s += indent('\n\nNested configuration flags:\n\n%s\n' %self.nested_struct,
-  2)
-return s
+def __init__(self, name, type, comment):
+self.name = name
+self.type = type
+self.comment = comment.strip()
+self.enum = None
+self.nested_struct = None
 
+def __str__(self):
+s = '**%s** (``%s``)\n%s' % (self.name, self.type,
+ doxygen2rst(indent(self.comment, 2)))
+if self.enum:
+s += indent('\n\nPossible values:\n\n%s\n' % self.enum, 2)
+if self.nested_struct:
+s += indent(
+'\n\nNested configuration flags:\n\n%s\n' % self.nested_struct,
+2)
+return s
+
+
 class NestedStruct:
-  def __init__(self, name, comment):
-self.name = name
-self.comment = comment.strip()
-self.values = []
 
-  def __str__(self):
-return '\n'.join(map(str, self.values))
+def __init__(self, name, comment):
+self.name = name
+self.comment = comment.strip()
+self.values = []
 
+def __str__(self):
+return '\n'.join(map(str, self.values))
+
+
 class NestedField:
-  def __init__(self, name, comment):
-self.name = name
-self.comment = comment.strip()
 
-  def __str__(self):
-return '* ``%s`` %s' % (self.name, doxygen2rst(self.comment))
+def __init__(self, name, comment):
+self.name = name
+self.comment = comment.strip()
 
+def __str__(self):
+return '* ``%s`` %s' % (self.name, doxygen2rst(self.comment))
+
+
 class Enum:
-  def __init__(self, name, comment):
-self.name = name
-self.comment = comment.strip()
-self.values = []
 
-  def __str__(self):
-return '\n'.join(map(str, self.values))
+def __init__(self, name, comment):
+self.name = name
+self.comment = comment.strip()
+self.values = []
 
+def __str__(self):
+return '\n'.join(map(str, self.values))
+
+
 class EnumValue:
-  def __init__(self, name, comment):
-self.name = name
-self.comment = comment
 
-  def __str__(self):
-return '* ``%s`` (in configuration: ``%s``)\n%s' % (
-self.name,
-re.sub('.*_', '', self.name),
-doxygen2rst(indent(self.comment, 2)))
+def __init__(self, name, comment):
+self.name = name
+self.comment = comment
 
+def __str__(self):
+return '* ``%s`` (in configuration: ``%s``)\n%s' % (
+self.name,
+re.sub('.*_', '', self.name),
+doxygen2rst(indent(self.comment, 2)))
+
+
 def clean_comment_line(li

[PATCH] D30748: [Lexer] Finding beginning of token with escaped new line

2017-03-11 Thread Paweł Żukowski via Phabricator via cfe-commits
idlecode marked 3 inline comments as done.
idlecode added inline comments.



Comment at: lib/Lex/Lexer.cpp:457
+static bool isNewLineEscaped(const char *BufferStart, const char *Str) {
+  while (Str > BufferStart && isWhitespace(*Str))
+--Str;

alexfh wrote:
> We only care about two specific sequences here: `\\\r\n` or `\\\n`, not a 
> backslash followed by arbitrary whitespace.
I just saw that some functions (e.g. line 1285 in this file) accept whitespaces 
between escape character and new line. How about now?


https://reviews.llvm.org/D30748



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


[PATCH] D30748: [Lexer] Finding beginning of token with escaped new line

2017-03-11 Thread Paweł Żukowski via Phabricator via cfe-commits
idlecode updated this revision to Diff 91466.
idlecode added a comment.

Addressed Alexander's comments


https://reviews.llvm.org/D30748

Files:
  lib/Lex/Lexer.cpp
  unittests/Lex/LexerTest.cpp

Index: unittests/Lex/LexerTest.cpp
===
--- unittests/Lex/LexerTest.cpp
+++ unittests/Lex/LexerTest.cpp
@@ -380,4 +380,34 @@
   EXPECT_EQ(SourceMgr.getFileIDSize(SourceMgr.getFileID(helper1ArgLoc)), 8U);
 }
 
+TEST_F(LexerTest, GetBeginningOfTokenWithEscapedNewLine) {
+  // Each line should have the same length for
+  // further offset calculation to be more straightforward.
+  const unsigned IdentifierLength = 8;
+  std::string TextToLex = "rabarbar\n"
+  "foo\\\nbar\n"
+  "foo\\\rbar\n"
+  "fo\\\r\nbar\n"
+  "foo\\\n\rba\n";
+  std::vector ExpectedTokens{5, tok::identifier};
+  std::vector LexedTokens = CheckLex(TextToLex, ExpectedTokens);
+
+  for (const Token &Tok : LexedTokens) {
+std::pair OriginalLocation =
+SourceMgr.getDecomposedLoc(Tok.getLocation());
+for (unsigned Offset = 0; Offset < IdentifierLength; ++Offset) {
+  SourceLocation LookupLocation =
+  Tok.getLocation().getLocWithOffset(Offset);
+
+  std::pair FoundLocation =
+  SourceMgr.getDecomposedExpansionLoc(
+  Lexer::GetBeginningOfToken(LookupLocation, SourceMgr, LangOpts));
+
+  // Check that location returned by the GetBeginningOfToken
+  // is the same as original token location reported by Lexer.
+  EXPECT_EQ(FoundLocation.second, OriginalLocation.second);
+}
+  }
+}
+
 } // anonymous namespace
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -452,39 +452,56 @@
   return false;
 }
 
+/// \brief Check if new line pointed by Str is escaped.
+static bool isNewLineEscaped(const char *BufferStart, const char *Str) {
+  assert(isVerticalWhitespace(Str[0]));
+  if (Str - 1 < BufferStart)
+return false;
+  if (Str[-1] == '\\')
+return true;
+  if (!isVerticalWhitespace(Str[-1]))
+return false;
+  if (Str - 2 < BufferStart)
+return false;
+  if (Str[-2] == '\\')
+return true;
+  return false;
+}
+
 static SourceLocation getBeginningOfFileToken(SourceLocation Loc,
   const SourceManager &SM,
   const LangOptions &LangOpts) {
   assert(Loc.isFileID());
   std::pair LocInfo = SM.getDecomposedLoc(Loc);
   if (LocInfo.first.isInvalid())
 return Loc;
-  
+
   bool Invalid = false;
   StringRef Buffer = SM.getBufferData(LocInfo.first, &Invalid);
   if (Invalid)
 return Loc;
 
   // Back up from the current location until we hit the beginning of a line
   // (or the buffer). We'll relex from that point.
-  const char *BufStart = Buffer.data();
   if (LocInfo.second >= Buffer.size())
 return Loc;
-  
-  const char *StrData = BufStart+LocInfo.second;
-  if (StrData[0] == '\n' || StrData[0] == '\r')
-return Loc;
+
+  const char *BufStart = Buffer.data();
+  const char *StrData = BufStart + LocInfo.second;
 
   const char *LexStart = StrData;
-  while (LexStart != BufStart) {
-if (LexStart[0] == '\n' || LexStart[0] == '\r') {
-  ++LexStart;
-  break;
-}
+  for (; LexStart != BufStart; --LexStart) {
+if (!isVerticalWhitespace(LexStart[0]))
+  continue;
 
---LexStart;
+if (isNewLineEscaped(BufStart, LexStart))
+  continue;
+
+// LexStart should point at first character of logical line.
+++LexStart;
+break;
   }
-  
+
   // Create a lexer starting at the beginning of this token.
   SourceLocation LexerStartLoc = Loc.getLocWithOffset(-LocInfo.second);
   Lexer TheLexer(LexerStartLoc, LangOpts, BufStart, LexStart, Buffer.end());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30859: [coroutines] Implement unhandled_exception changes.

2017-03-11 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 91468.
EricWF added a comment.

- Remove unused diagnostics about `set_exception` and `current_exception`.


https://reviews.llvm.org/D30859

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaCoroutine.cpp
  test/SemaCXX/Inputs/std-coroutine.h
  test/SemaCXX/coreturn.cpp
  test/SemaCXX/coroutine-unhandled_exception-warning.cpp
  test/SemaCXX/coroutines.cpp

Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -verify %s -fcxx-exceptions
+// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -verify %s -fcxx-exceptions -fexceptions
 
 void no_coroutine_traits_bad_arg_await() {
   co_await a; // expected-error {{include }}
@@ -101,13 +101,15 @@
   awaitable yield_value(yielded_thing); // expected-note 2{{candidate}}
   not_awaitable yield_value(void()); // expected-note 2{{candidate}}
   void return_value(int); // expected-note 2{{here}}
+  void unhandled_exception();
 };
 
 struct promise_void {
   void get_return_object();
   suspend_always initial_suspend();
   suspend_always final_suspend();
   void return_void();
+  void unhandled_exception();
 };
 
 void no_coroutine_handle() { // expected-error {{std::experimental::coroutine_handle type was not found; include  before defining a coroutine}}
@@ -344,13 +346,15 @@
 transformed initial_suspend();
 ::adl_ns::coawait_arg_type final_suspend();
 transformed await_transform(transform_awaitable);
+void unhandled_exception();
   };
   template 
   struct basic_promise {
 typedef AwaitArg await_arg;
 coro get_return_object();
 awaitable initial_suspend();
 awaitable final_suspend();
+void unhandled_exception();
   };
 
   awaitable operator co_await(await_arg_1);
@@ -435,6 +439,7 @@
 suspend_never initial_suspend();
 suspend_never final_suspend();
 void get_return_object();
+void unhandled_exception();
   };
 };
 
@@ -467,6 +472,7 @@
 struct bad_promise_1 {
   suspend_always initial_suspend();
   suspend_always final_suspend();
+  void unhandled_exception();
 };
 coro missing_get_return_object() { // expected-error {{no member named 'get_return_object' in 'bad_promise_1'}}
   co_await a;
@@ -476,6 +482,7 @@
   coro get_return_object();
   // FIXME: We shouldn't offer a typo-correction here!
   suspend_always final_suspend(); // expected-note {{here}}
+  void unhandled_exception();
 };
 // FIXME: This shouldn't happen twice
 coro missing_initial_suspend() { // expected-error {{no member named 'initial_suspend' in 'bad_promise_2'}}
@@ -486,6 +493,7 @@
   coro get_return_object();
   // FIXME: We shouldn't offer a typo-correction here!
   suspend_always initial_suspend(); // expected-note {{here}}
+  void unhandled_exception();
 };
 coro missing_final_suspend() { // expected-error {{no member named 'final_suspend' in 'bad_promise_3'}}
   co_await a;
@@ -517,6 +525,7 @@
   coro get_return_object();
   suspend_always initial_suspend();
   suspend_always final_suspend();
+  void unhandled_exception();
   void return_void();
   void return_value(int) const;
   void return_value(int);
@@ -530,33 +539,27 @@
   suspend_always initial_suspend();
   suspend_always final_suspend();
   void return_void();
-  void set_exception(int *);
 };
-coro no_std_current_exc() {
-  // expected-error@-1 {{you need to include  before defining a coroutine that implicitly uses 'set_exception'}}
+coro no_unhandled_exception() { // expected-error {{'bad_promise_7' is required to declare the member 'unhandled_exception()'}}
   co_await a;
 }
 
-namespace std {
-int *current_exception();
-}
-
 struct bad_promise_base {
 private:
   void return_void();
 };
 struct bad_promise_8 : bad_promise_base {
   coro get_return_object();
   suspend_always initial_suspend();
   suspend_always final_suspend();
-  void set_exception();   // expected-note {{function not viable}}
-  void set_exception(int *) __attribute__((unavailable)); // expected-note {{explicitly made unavailable}}
-  void set_exception(void *); // expected-note {{candidate function}}
+  void unhandled_exception() __attribute__((unavailable)); // expected-note {{made unavailable}}
+  void unhandled_exception() const;// expected-note {{candidate}}
+  void unhandled_exception(void *) const;  // expected-note {{requires 1 argument, but 0 were provided}}
 };
-coro calls_set_exception() {
-  // expected-error@-1 {{call to unavailable member function 'set_exception'}}
+coro calls_unhandled_exception() {
+  // expected-error@-1 {{call to unavailable member function 'unhandled_exception'}}
   // FIXME: also warn about private 'return_void' here. Even though building
-  // the call to set_exception has already failed.
+  // the call to unhand

[PATCH] D30854: [ASTMatchers] Add ObjC matchers for fundamental decls

2017-03-11 Thread Dave Lee via Phabricator via cfe-commits
kastiglione added a comment.

Thanks @malcolm.parsons. I don't have commit access, will you be able to commit 
this?


https://reviews.llvm.org/D30854



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


[PATCH] D30859: [coroutines] Implement unhandled_exception changes.

2017-03-11 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov accepted this revision.
GorNishanov added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D30859



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


[PATCH] D30841: [clang-tidy] readability-misleading-indentation: fix chained if

2017-03-11 Thread Florian Gross via Phabricator via cfe-commits
fgross updated this revision to Diff 91473.
fgross added a comment.

Replaced std::map with llvm::DenseMap, added comment about traversal.

I just assumed it would traverse in the "right" way, is there any documentation 
about AST / matcher traversal?


https://reviews.llvm.org/D30841

Files:
  clang-tidy/readability/MisleadingIndentationCheck.cpp
  clang-tidy/readability/MisleadingIndentationCheck.h
  test/clang-tidy/readability-misleading-indentation.cpp


Index: test/clang-tidy/readability-misleading-indentation.cpp
===
--- test/clang-tidy/readability-misleading-indentation.cpp
+++ test/clang-tidy/readability-misleading-indentation.cpp
@@ -76,5 +76,31 @@
 {
 }
 
+  if(cond1) {
+  }
+  else if (cond2) {
+  }
+  else {
+  }
+
+  if(cond1) {
+  }
+  else if (cond2) {
+  }
+   else {
+  }
+  // CHECK-MESSAGES: :[[@LINE-2]]:8: warning: different indentation for 'if' 
and corresponding 'else' [readability-misleading-indentation]
+  
+  if (cond1) {
+if (cond1) {
+}
+else if (cond2) {
+}
+else {
+}
+  }
+  else if (cond2) {
+  }
+
   BLOCK
 }
Index: clang-tidy/readability/MisleadingIndentationCheck.h
===
--- clang-tidy/readability/MisleadingIndentationCheck.h
+++ clang-tidy/readability/MisleadingIndentationCheck.h
@@ -11,6 +11,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_MISLEADING_INDENTATION_H
 
 #include "../ClangTidy.h"
+#include "llvm/ADT/DenseMap.h"
 
 namespace clang {
 namespace tidy {
@@ -32,6 +33,10 @@
 private:
   void danglingElseCheck(const SourceManager &SM, const IfStmt *If);
   void missingBracesCheck(const SourceManager &SM, const CompoundStmt *CStmt);
+
+  /// Key: Chained If
+  /// Value: Preceding If
+  llvm::DenseMap ChainedIfs;
 };
 
 } // namespace readability
Index: clang-tidy/readability/MisleadingIndentationCheck.cpp
===
--- clang-tidy/readability/MisleadingIndentationCheck.cpp
+++ clang-tidy/readability/MisleadingIndentationCheck.cpp
@@ -25,10 +25,22 @@
   if (IfLoc.isMacroID() || ElseLoc.isMacroID())
 return;
 
+  if (const auto *ChainedIf = dyn_cast(If->getElse())) {
+if (SM.getExpansionLineNumber(ElseLoc) ==
+SM.getExpansionLineNumber(ChainedIf->getIfLoc()))
+   ChainedIfs.insert({ ChainedIf, If });
+  }
+
   if (SM.getExpansionLineNumber(If->getThen()->getLocEnd()) ==
   SM.getExpansionLineNumber(ElseLoc))
 return;
 
+  // Find location of first 'if' in a 'if else if' chain.
+  // Works because parent nodes will be matched before child nodes.
+  for (auto Iter = ChainedIfs.find(If); Iter != ChainedIfs.end();
+   Iter = ChainedIfs.find(Iter->second))
+IfLoc = Iter->second->getIfLoc();
+
   if (SM.getExpansionColumnNumber(IfLoc) !=
   SM.getExpansionColumnNumber(ElseLoc))
 diag(ElseLoc, "different indentation for 'if' and corresponding 'else'");


Index: test/clang-tidy/readability-misleading-indentation.cpp
===
--- test/clang-tidy/readability-misleading-indentation.cpp
+++ test/clang-tidy/readability-misleading-indentation.cpp
@@ -76,5 +76,31 @@
 {
 }
 
+  if(cond1) {
+  }
+  else if (cond2) {
+  }
+  else {
+  }
+
+  if(cond1) {
+  }
+  else if (cond2) {
+  }
+   else {
+  }
+  // CHECK-MESSAGES: :[[@LINE-2]]:8: warning: different indentation for 'if' and corresponding 'else' [readability-misleading-indentation]
+  
+  if (cond1) {
+if (cond1) {
+}
+else if (cond2) {
+}
+else {
+}
+  }
+  else if (cond2) {
+  }
+
   BLOCK
 }
Index: clang-tidy/readability/MisleadingIndentationCheck.h
===
--- clang-tidy/readability/MisleadingIndentationCheck.h
+++ clang-tidy/readability/MisleadingIndentationCheck.h
@@ -11,6 +11,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_MISLEADING_INDENTATION_H
 
 #include "../ClangTidy.h"
+#include "llvm/ADT/DenseMap.h"
 
 namespace clang {
 namespace tidy {
@@ -32,6 +33,10 @@
 private:
   void danglingElseCheck(const SourceManager &SM, const IfStmt *If);
   void missingBracesCheck(const SourceManager &SM, const CompoundStmt *CStmt);
+
+  /// Key: Chained If
+  /// Value: Preceding If
+  llvm::DenseMap ChainedIfs;
 };
 
 } // namespace readability
Index: clang-tidy/readability/MisleadingIndentationCheck.cpp
===
--- clang-tidy/readability/MisleadingIndentationCheck.cpp
+++ clang-tidy/readability/MisleadingIndentationCheck.cpp
@@ -25,10 +25,22 @@
   if (IfLoc.isMacroID() || ElseLoc.isMacroID())
 return;
 
+  if (const auto *ChainedIf = dyn_cast(If->getElse())) {
+if (SM.getExpansionLineNumber(ElseLoc) ==
+SM.getExpansionLineNumber(ChainedIf->getIfLoc()))
+		ChainedIfs.insert({ ChainedIf, If });
+  }
+
   if (SM.getExpans

[PATCH] D30593: Add correct "-isystem"/"-isysroot" warning handling to static analysis' BugReporter.

2017-03-11 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

Thank you!


Repository:
  rL LLVM

https://reviews.llvm.org/D30593



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


[PATCH] D30798: [analyzer] Turn suppress-c++-stdlib on by default

2017-03-11 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

Correct, this will suppress some valid warnings that occur due to user errors 
and valid warnings coming from the standard library.

However, I believe this is the right choice right now since we know that the 
analyzer is not currently effective in understanding invariants coming from 
libc++ headers and users have no ability to help the analyzer (ex: by inserting 
assertions). This results in a wave of false positives every time the headers 
change. Furthermore, we do not perform sufficient evaluation and testing for 
every new version of the headers.


Repository:
  rL LLVM

https://reviews.llvm.org/D30798



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


[PATCH] D30809: [coroutines] Add codegen for await and yield expressions

2017-03-11 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov added a comment.

+ @majnemer who is most familiar with LLVM Coroutines representation.


https://reviews.llvm.org/D30809



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


[PATCH] D29221: clang-format-vsix: "format on save" feature

2017-03-11 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added a comment.

In https://reviews.llvm.org/D29221#688697, @hans wrote:

> >>> My only nit is that I'd prefer "clang-format" instead of "ClangFormat".
> >>> 
> >>> Manuel: the menu options under Tools currently say "Clang Format 
> >>> {Selection,Document}". What do you think about using "clang-format" here 
> >>> instead? That is the name of the tool after all, and I think it also 
> >>> works nicely as a verb.
> >>> 
> >>> I realize the actual extension is called ClangFormat, but maybe there 
> >>> were reasons for that, or we have to live with it?
> >> 
> >> I would also like clang-format in there rather than ClangFormat. One thing 
> >> to validate is whether this change would mean people would lose their 
> >> changes to the defaults in the configuration panel. I'll run some tests 
> >> and see if this is indeed the case. Maybe there's a way to keep the 
> >> internal name the same for config purposes, but change the displayed name 
> >> instead. Will get back to you.
> > 
> > Okay, I looked into it, and the good news is that changing the name of the 
> > category from ClangFormat to clang-format doesn't reset the previously 
> > saved changes made in the options menu. I also changed the menu item names. 
> > Here's what both would look like:
> > 
> > F3119242: pasted_file 
> > 
> > F3119244: pasted_file 
> > 
> > Now having said that, I'm not sure if this is the best change because of a 
> > few things:
> > 
> > 1. The extension's name itself is ClangFormat, which was recently added to 
> > the Visual Studio market place here: 
> > https://marketplace.visualstudio.com/items?itemName=HansWennborg.ClangFormat
> >  . Consequently, the extension appears with this name in the Visual Studio 
> > extensions dialog: F3119249: pasted_file 
> > . I don't think it would be easy to 
> > change this. You cannot really take down an extension page on the 
> > marketplace once it's there; you'd have to document that it has been 
> > deprecated and provide a link to a new page. When searching for it in the 
> > Extensions dialog in VS, though, both the old and new extension would show 
> > up.
> > 2. Although the name of the executable is indeed "clang-format", the 
> > documentation here  uses the 
> > name ClangFormat: F3119251: pasted_file 
> > 
> >   So I leave it up to you whether you really want this change or not. We 
> > can also decide later rather than fold it into this change.
>
> Personally I think we should refer to the tool and the action of formatting 
> as "clang-format" as much as possible. It's unfortunate we can't rename the 
> extension, but maybe that slight inconsistency isn't the end of the world.
>
> Manuel, Daniel: I'd like to hear your opinions here.


Hey guys, any feedback on this? About 1.5 weeks ago, @hans asked @klimek and 
@djasper for their opinions on "clang-format" vs "ClangFormat". Thanks!


https://reviews.llvm.org/D29221



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


[PATCH] D30848: Implement DR 373 "Lookup on namespace qualified name in using-directive"

2017-03-11 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

Functionally, this looks good. How do the diagnostics look in the case where 
lookup only finds a non-namespace name? Eg,

  struct A { struct B {}; };
  namespace X = A::B;


https://reviews.llvm.org/D30848



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


Re: Disable fms-extensions?

2017-03-11 Thread Andrey Bokhanko via cfe-commits
Hi Zahira,

-fms-extensions can obviously be disabled with -fno-ms-extensions. This
won't necessarily mirrors /Za exactly, though -- as according to MS, /Za
disables *all* C++ extensions, not only MS-specific ones. I doubt anyone
tried to implement a mode that mirrors /Za exactly.

Yours,
Andrey
---
Compiler Architect
NXP

On Tue, Mar 7, 2017 at 9:10 PM, Ammarguellat, Zahira via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hello,
>
> Clang implements MS extensions when using -fms-extension. On windows this
> option is enabled by default.
> Is there any way of disabling it to mirror the behavior of the /Za
> (-permissive-) option of CL?
> Thanks,
> -Zahira
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [cfe-dev] Disable fms-extensions?

2017-03-11 Thread Nico Weber via cfe-commits
In addition to that: If I remember correctly, -fms-extensions is only
enabled if your triple's OS is win32 and your triple's environment is MSVC.
It's not enabled when targeting MinGW for example. The reason it's enabled
with an foo-windows-msvc triple is that it's required to parse the system's
headers in that environment.

On Sat, Mar 11, 2017 at 2:32 PM, Andrey Bokhanko via cfe-dev <
cfe-...@lists.llvm.org> wrote:

> Hi Zahira,
>
> -fms-extensions can obviously be disabled with -fno-ms-extensions. This
> won't necessarily mirrors /Za exactly, though -- as according to MS, /Za
> disables *all* C++ extensions, not only MS-specific ones. I doubt anyone
> tried to implement a mode that mirrors /Za exactly.
>
> Yours,
> Andrey
> ---
> Compiler Architect
> NXP
>
> On Tue, Mar 7, 2017 at 9:10 PM, Ammarguellat, Zahira via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Hello,
>>
>> Clang implements MS extensions when using -fms-extension. On windows this
>> option is enabled by default.
>> Is there any way of disabling it to mirror the behavior of the /Za
>> (-permissive-) option of CL?
>> Thanks,
>> -Zahira
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>>
>
> ___
> cfe-dev mailing list
> cfe-...@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29772: Create msbuild only when using MSVC

2017-03-11 Thread Mateusz Mikuła via Phabricator via cfe-commits
mati865 added a subscriber: asl.
mati865 added a comment.

@asl it is still not commited.
Something went wrong?


Repository:
  rL LLVM

https://reviews.llvm.org/D29772



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


[PATCH] D30841: [clang-tidy] readability-misleading-indentation: fix chained if

2017-03-11 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D30841#698634, @fgross wrote:

> I just assumed it would traverse in the "right" way, is there any 
> documentation about AST / matcher traversal?


I do not know of any, but I remember having some non-determinism across 
platforms, but I think matching parent before children is a safe assumption for 
all platforms.

The patch now looks good to me, but lets wait what @alexfh says.


https://reviews.llvm.org/D30841



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


[PATCH] D30809: [coroutines] Add codegen for await and yield expressions

2017-03-11 Thread David Majnemer via Phabricator via cfe-commits
majnemer added inline comments.



Comment at: lib/CodeGen/CGCoroutine.cpp:26
+enum class AwaitKind { Init, Normal, Yield, Final };
+char const *AwaitKindStr[] = {"init", "await", "yield", "final"};
+}

I'd move this into buildSuspendSuffixStr.



Comment at: lib/CodeGen/CGCoroutine.cpp:32
 
 struct CGCoroData {
+  AwaitKind CurrentAwaitKind = AwaitKind::Init;

Shouldn't this struct be in an anonymous namespace?



Comment at: lib/CodeGen/CGCoroutine.cpp:86-88
+  switch (Kind) {
+  default:
+break;

I'd just make this fully covered, it's just two more cases.



Comment at: lib/CodeGen/CGExprScalar.cpp:279-282
+  Value *VisitCoawaitExpr(CoawaitExpr* S) {
+return CGF.EmitCoawaitExpr(*S);
+  }
+  Value *VisitCoyieldExpr(CoyieldExpr* S) {

Pointers should lean right.



Comment at: lib/CodeGen/CGExprScalar.cpp:285
+  }
+  Value *VisitUnaryCoawait  (const UnaryOperator *E) {
+return Visit(E->getSubExpr());

Formatting looks off.


https://reviews.llvm.org/D30809



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


[PATCH] D30809: [coroutines] Add codegen for await and yield expressions

2017-03-11 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov updated this revision to Diff 91486.
GorNishanov added a comment.

Addressed review feedback

- clang-format three functions in CGExprScalar.cpp
- got rid of AwaitKindStr array and select appropriate string in the switch 
statement in buildAwaitKindPrefix


https://reviews.llvm.org/D30809

Files:
  lib/CodeGen/CGCoroutine.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGenCoroutines/coro-await.cpp

Index: test/CodeGenCoroutines/coro-await.cpp
===
--- /dev/null
+++ test/CodeGenCoroutines/coro-await.cpp
@@ -0,0 +1,134 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s
+
+namespace std {
+namespace experimental {
+template 
+struct coroutine_traits;
+
+template  struct coroutine_handle;
+
+template <>
+struct coroutine_handle {
+  void *ptr;
+  static coroutine_handle from_address(void *);
+};
+
+template 
+struct coroutine_handle : coroutine_handle<> {
+  static coroutine_handle from_address(void *);
+};
+
+}
+}
+
+struct suspend_always {
+  int stuff;
+  bool await_ready();
+  void await_suspend(std::experimental::coroutine_handle<>);
+  void await_resume();
+};
+
+template<>
+struct std::experimental::coroutine_traits {
+  struct promise_type {
+void get_return_object();
+suspend_always initial_suspend();
+suspend_always final_suspend();
+void return_void();
+  };
+};
+
+// CHECK-LABEL: f0(
+extern "C" void f0() {
+
+  co_await suspend_always{};
+  // See if we need to suspend:
+  // --
+  // CHECK: %[[READY:.+]] = call zeroext i1 @_ZN14suspend_always11await_readyEv(%struct.suspend_always* %[[AWAITABLE:.+]])
+  // CHECK: br i1 %[[READY]], label %[[READY_BB:.+]], label %[[SUSPEND_BB:.+]]
+
+  // If we are suspending:
+  // -
+  // CHECK: [[SUSPEND_BB]]:
+  // CHECK: %[[SUSPEND_ID:.+]] = call token @llvm.coro.save(
+  // ---
+  // Build the coroutine handle and pass it to await_suspend
+  // ---
+  // CHECK: %[[FRAME:.+]] = call i8* @llvm.coro.frame()
+  // CHECK: call i8* @_ZNSt12experimental16coroutine_handleINS_16coroutine_traitsIJvEE12promise_typeEE12from_addressEPv(i8* %[[FRAME]])
+  //   ... many lines of code to coerce coroutine_handle into an i8* scalar
+  // CHECK: %[[CH:.+]] = load i8*, i8** %{{.+}}
+  // CHECK: call void @_ZN14suspend_always13await_suspendENSt12experimental16coroutine_handleIvEE(%struct.suspend_always* %[[AWAITABLE]], i8* %[[CH]])
+  // -
+  // Generate a suspend point:
+  // -
+  // CHECK: %[[OUTCOME:.+]] = call i8 @llvm.coro.suspend(token %[[SUSPEND_ID]], i1 false)
+  // CHECK: switch i8 %[[OUTCOME]], label %[[RET_BB:.+]] [
+  // CHECK:   i8 0, label %[[READY_BB]]
+  // CHECK:   i8 1, label %[[CLEANUP_BB:.+]]
+  // CHECK: ]
+
+  // Cleanup code goes here:
+  // ---
+  // CHECK: [[CLEANUP_BB]]:
+  
+  // When coroutine is resumed, call await_resume
+  // --
+  // CHECK: [[READY_BB]]:
+  // CHECK:  call void @_ZN14suspend_always12await_resumeEv(%struct.suspend_always* %[[AWAITABLE]])
+}
+
+struct suspend_maybe {
+  float stuff;
+  ~suspend_maybe();
+  bool await_ready();
+  bool await_suspend(std::experimental::coroutine_handle<>);
+  void await_resume();
+};
+
+
+template<>
+struct std::experimental::coroutine_traits {
+  struct promise_type {
+void get_return_object();
+suspend_always initial_suspend();
+suspend_always final_suspend();
+void return_void();
+suspend_maybe yield_value(int);
+  };
+};
+
+// CHECK-LABEL: f1(
+extern "C" void f1(int) {
+  co_yield 42;
+  // CHECK: %[[PROMISE:.+]] = alloca %"struct.std::experimental::coroutine_traits::promise_type"
+  // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJviEE12promise_type11yield_valueEi(%struct.suspend_maybe* sret %[[AWAITER:.+]], %"struct.std::experimental::coroutine_traits::promise_type"* %[[PROMISE]], i32 42)
+
+  // See if we need to suspend:
+  // --
+  // CHECK: %[[READY:.+]] = call zeroext i1 @_ZN13suspend_maybe11await_readyEv(%struct.suspend_maybe* %[[AWAITABLE]])
+  // CHECK: br i1 %[[READY]], label %[[READY_BB:.+]], label %[[SUSPEND_BB:.+]]
+
+  // If we are suspending:
+  // -
+  // CHECK: [[SUSPEND_BB]]:
+  // CHECK: %[[SUSPEND_ID:.+]] = call token @llvm.coro.save(
+  // ---
+  // Build the coroutine handle and pass it to await_suspend
+  // ---
+  // CHECK: %[[FRAME:.+]] = call i8* @llvm.coro.frame()
+  // CHECK: call i8* @_ZNSt12experimental16coroutine_handleINS_16coroutine_traitsIJviEE12promise_typeEE12from_addressEPv(i8* %[[FRAME]])
+  //   ... many lines of code to coerce coroutine_handle into an i8* scalar
+  // CHECK: %[[CH:.+]] = load i8*, i8** %{{.+}}
+  // CHECK: %[[

[PATCH] D30809: [coroutines] Add codegen for await and yield expressions

2017-03-11 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov marked 4 inline comments as done.
GorNishanov added inline comments.



Comment at: lib/CodeGen/CGCoroutine.cpp:32
 
 struct CGCoroData {
+  AwaitKind CurrentAwaitKind = AwaitKind::Init;

majnemer wrote:
> Shouldn't this struct be in an anonymous namespace?
It is forward declared in CodeGenFunction.h and CodeGenFunction class holds a 
unique_ptr to CGCoroData as a member.
Here is the snippet from CodeGenFunction.h:

```
  // Holds coroutine data if the current function is a coroutine. We use a
  // wrapper to manage its lifetime, so that we don't have to define CGCoroData
  // in this header.
  struct CGCoroInfo {
std::unique_ptr Data;
CGCoroInfo();
~CGCoroInfo();
  };
  CGCoroInfo CurCoro;
```


https://reviews.llvm.org/D30809



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


[PATCH] D30809: [coroutines] Add codegen for await and yield expressions

2017-03-11 Thread David Majnemer via Phabricator via cfe-commits
majnemer added inline comments.



Comment at: lib/CodeGen/CGCoroutine.cpp:85
+  unsigned No = 0;
+  const char* AwaitKindStr = 0;
+  switch (Kind) {

I'd use a StringRef here.


https://reviews.llvm.org/D30809



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