[PATCH] D33000: Add support for pretty platform names to `@available`/`__builtin_available`

2017-05-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

We should allow macOS/iOS/tvOS/watchOS in `@available`/`__builtin_available`.


Repository:
  rL LLVM

https://reviews.llvm.org/D33000

Files:
  include/clang/Basic/Attr.td
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/FixIt/fixit-availability.c
  test/FixIt/fixit-availability.mm
  test/Parser/objc-available.m
  test/SemaObjC/unguarded-availability.m

Index: test/SemaObjC/unguarded-availability.m
===
--- test/SemaObjC/unguarded-availability.m
+++ test/SemaObjC/unguarded-availability.m
@@ -48,7 +48,7 @@
   } else
 func_10_11(); // expected-warning{{'func_10_11' is only available on macOS 10.11 or newer}} expected-note{{enclose 'func_10_11' in an @available check to silence this warning}}
 
-  if (@available(macos 10.11, *)) {
+  if (@available(macOS 10.11, *)) {
 if (@available(ios 8, *)) {
   func_10_11();
   func_10_12(); // expected-warning{{'func_10_12' is only available on macOS 10.12 or newer}} expected-note{{enclose}}
@@ -176,7 +176,7 @@
 }
 
 int instantiate_availability() {
-  if (@available(macos 10.12, *))
+  if (@available(macOS 10.12, *))
 with_availability_attr();
   else
 with_availability_attr(); // expected-warning{{'with_availability_attr' is only available on macOS 10.11 or newer}} expected-warning{{'int_10_12' is only available on macOS 10.12 or newer}} expected-note 2 {{enclose}}
Index: test/Parser/objc-available.m
===
--- test/Parser/objc-available.m
+++ test/Parser/objc-available.m
@@ -21,6 +21,12 @@
   (void)@available; // expected-error{{expected '('}}
 }
 
+void prettyPlatformNames() {
+  (void)@available(iOS 8, tvOS 10, watchOS 3, macOS 10.11, *);
+  (void)__builtin_available(iOSApplicationExtension 8, tvOSApplicationExtension 10,
+   watchOSApplicationExtension 3, macOSApplicationExtension 10.11, *);
+}
+
 #if __has_builtin(__builtin_available)
 #error expected
 // expected-error@-1 {{expected}}
Index: test/FixIt/fixit-availability.mm
===
--- test/FixIt/fixit-availability.mm
+++ test/FixIt/fixit-availability.mm
@@ -7,58 +7,58 @@
 
 int use() {
   function();
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:14-[[@LINE-2]]:14}:"\n  } else {\n  // Fallback on earlier versions\n  }"
   int y = function(), x = 0;
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:29-[[@LINE-2]]:29}:"\n  } else {\n  // Fallback on earlier versions\n  }"
   x += function();
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:19-[[@LINE-2]]:19}:"\n  } else {\n  // Fallback on earlier versions\n  }"
   if (1) {
 x = function();
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:5-[[@LINE-1]]:5}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:5-[[@LINE-1]]:5}:"if (@available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:20-[[@LINE-2]]:20}:"\n  } else {\n  // Fallback on earlier versions\n  }"
   }
   anotherFunction(function());
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:31-[[@LINE-2]]:31}:"\n  } else {\n  // Fallback on earlier versions\n  }"
   if (function()) {
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE+1]]:4-[[@LINE+1]]:4}:"\n  } else {\n  // Fallback on earlier versions\n  }"
   }
   while (function())
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE+1]]:6-[[@LINE+1]]:6}:"\n  } else {\n  // Fallback on earlier versions\n  }"
 ;
   do
 function();
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:5-[[@LINE-1]]:5}:"if (@available(macos 10.12, *)) {\n"
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:5-[[@LINE-1]]:5}:"if (@available(macOS 10.12, *)) {\n"
 // CHECK-NEXT: 

[PATCH] D32592: [Analyzer] Iterator Checker - Part 1: Minimal Checker for a Simple Test Case

2017-05-09 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In https://reviews.llvm.org/D32592#747132, @NoQ wrote:

> Then, in methods that deal with iterator `SVal`s directly, i wish we had 
> hints explaining what's going on in these ~7 cases. In my opinion, that'd 
> greatly help people understand the code later, and it'd help us understand 
> how to avoid this variety and provide checker authors with a better API as 
> soon as we get to this, so it's the biggest concern for me about this checker.


I am not sure which method do you mean? I think here the crucial functions are 
the setIteratorPosition() and the getIteratorPosition() functions which provide 
a common way to handle all these SVals.




Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:166-167
+
+static llvm::APSInt Zero = llvm::APSInt::get(0);
+static llvm::APSInt One = llvm::APSInt::get(1);
+

NoQ wrote:
> I've a bit of doubt about those. Would they call their constructors every 
> time clang starts, regardless of whether the analyzer or the checker is 
> enabled? Maybe having them as private variables inside the checker class 
> would be better?
> 
> As in http://llvm.org/docs/CodingStandards.html#do-not-use-static-constructors
Not needed in this patch. I delete them from here.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:219
+  OutOfRangeBugType.reset(
+  new BugType(this, "Iterator of out Range", "Misuse of STL APIs"));
+  OutOfRangeBugType->setSuppressOnSink(true);

baloghadamsoftware wrote:
> NoQ wrote:
> > Before we forget: Range -> range. As we've noticed recently in D32702 :), 
> > we don't capitalize every word in bug types and categories.
> Agree.
Also "out of" instead of "of out" :-)



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:294-297
+// Assumption: if return value is an iterator which is not yet bound to a
+// container, then look for the first iterator argument, and
+// bind the return value to the same container. This approach
+// works for STL algorithms.

NoQ wrote:
> baloghadamsoftware wrote:
> > NoQ wrote:
> > > I guess this deserves a test case (we could split this out as a separate 
> > > feature as well).
> > > 
> > > I'm also afraid that we can encounter false positives on functions that 
> > > are not STL algorithms. I suggest doing this by default only for STL 
> > > functions (or maybe for other specific classes of functions for which we 
> > > know it works this way) and do this for other functions under a checker 
> > > option (i.e. something like `-analyzer-config 
> > > IteratorChecker:AggressiveAssumptions=true`, similar to `MallocChecker`'s 
> > > "Optimistic" option).
> > I will check whether this piece of code could be moved in a later part of 
> > the checker. However, I suggest to first wait for the first false positives 
> > before we introduce such an option. This far the false positives in my 
> > initial tests had different reasons, not this one.
> Unfortunately, we've had a poor experience with this approach in other 
> checkers. You never know, and it seems that it's always better to have a safe 
> fallback mode available under a flag, because if a few classes of false 
> positives are found, and we are forced to reduce the checker to a safer 
> behavior, it'd be hard to remember all the places where unsafe heuristics 
> were used.
I think this heuristic is well marked by the comment, easy to find if it causes 
false positives. When I started working on Clang (Tidy first) reviewers 
discouraged me to add options before experiencing false positives.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:323-324
+
+void IteratorChecker::checkLiveSymbols(ProgramStateRef State,
+   SymbolReaper ) const {
+  // Keep symbolic expressions of iterator positions, container begins and ends

NoQ wrote:
> This callback is currently untested as well. I'm doing this bit of manual 
> "mutation testing" by removing pieces of code and re-running tests because 
> not only we'd rather keep every commit self-sufficient, but also we'd rather 
> make sure we didn't forget anything, which is much easier to do 
> patch-by-patch.
OK, removed from the first patch.



Comment at: test/Analysis/iterator-range.cpp:1-2
+// RUN: %clang_analyze_cc1 -std=c++11 
-analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange 
-analyzer-eagerly-assume -analyzer-config c++-container-inlining=false %s 
-verify
+// RUN: %clang_analyze_cc1 -std=c++11 
-analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange 
-analyzer-eagerly-assume -analyzer-config c++-container-inlining=true 
-DINLINE=1 %s -verify
+

NoQ wrote:
> Could we add run-lines without `-analyzer-eagerly-assume`? Currently all 
> variants are passing, but if new tests will fail, we could 

[PATCH] D32592: [Analyzer] Iterator Checker - Part 1: Minimal Checker for a Simple Test Case

2017-05-09 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 98275.
baloghadamsoftware marked 11 inline comments as done.
baloghadamsoftware added a comment.

Updated according to the review.


https://reviews.llvm.org/D32592

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp
  test/Analysis/Inputs/system-header-simulator-cxx.h
  test/Analysis/diagnostics/explicit-suppression.cpp
  test/Analysis/iterator-past-end.cpp
  test/Analysis/iterator-range.cpp

Index: test/Analysis/iterator-range.cpp
===
--- /dev/null
+++ test/Analysis/iterator-range.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-eagerly-assume -analyzer-config c++-container-inlining=false %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-eagerly-assume -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify
+
+#include "Inputs/system-header-simulator-cxx.h"
+
+void clang_analyzer_warnIfReached();
+
+void simple_good_end(const std::vector ) {
+  auto i = v.end();
+  if (i != v.end()) {
+clang_analyzer_warnIfReached();
+*i; // no-warning
+  }
+}
+
+void simple_bad_end(const std::vector ) {
+  auto i = v.end();
+  *i; // expected-warning{{Iterator accessed outside of its range}}
+}
Index: test/Analysis/iterator-past-end.cpp
===
--- test/Analysis/iterator-past-end.cpp
+++ /dev/null
@@ -1,205 +0,0 @@
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorPastEnd -analyzer-eagerly-assume -analyzer-config c++-container-inlining=false %s -verify
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorPastEnd -analyzer-eagerly-assume -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify
-
-#include "Inputs/system-header-simulator-cxx.h"
-
-void simple_good(const std::vector ) {
-  auto i = v.end();
-  if (i != v.end())
-*i; // no-warning
-}
-
-void simple_good_negated(const std::vector ) {
-  auto i = v.end();
-  if (!(i == v.end()))
-*i; // no-warning
-}
-
-void simple_bad(const std::vector ) {
-  auto i = v.end();
-  *i; // expected-warning{{Iterator accessed past its end}}
-}
-
-void copy(const std::vector ) {
-  auto i1 = v.end();
-  auto i2 = i1;
-  *i2; // expected-warning{{Iterator accessed past its end}}
-}
-
-void decrease(const std::vector ) {
-  auto i = v.end();
-  --i;
-  *i; // no-warning
-}
-
-void copy_and_decrease1(const std::vector ) {
-  auto i1 = v.end();
-  auto i2 = i1;
-  --i1;
-  *i1; // no-warning
-}
-
-void copy_and_decrease2(const std::vector ) {
-  auto i1 = v.end();
-  auto i2 = i1;
-  --i1;
-  *i2; // expected-warning{{Iterator accessed past its end}}
-}
-
-void copy_and_increase1(const std::vector ) {
-  auto i1 = v.begin();
-  auto i2 = i1;
-  ++i1;
-  if (i1 == v.end())
-*i2; // no-warning
-}
-
-void copy_and_increase2(const std::vector ) {
-  auto i1 = v.begin();
-  auto i2 = i1;
-  ++i1;
-  if (i2 == v.end())
-*i2; // expected-warning{{Iterator accessed past its end}}
-}
-
-void good_find(std::vector , int e) {
-  auto first = std::find(vec.begin(), vec.end(), e);
-  if (vec.end() != first)
-*first; // no-warning
-}
-
-void bad_find(std::vector , int e) {
-  auto first = std::find(vec.begin(), vec.end(), e);
-  *first; // expected-warning{{Iterator accessed past its end}}
-}
-
-void good_find_end(std::vector , std::vector ) {
-  auto last = std::find_end(vec.begin(), vec.end(), seq.begin(), seq.end());
-  if (vec.end() != last)
-*last; // no-warning
-}
-
-void bad_find_end(std::vector , std::vector ) {
-  auto last = std::find_end(vec.begin(), vec.end(), seq.begin(), seq.end());
-  *last; // expected-warning{{Iterator accessed past its end}}
-}
-
-void good_find_first_of(std::vector , std::vector ) {
-  auto first =
-  std::find_first_of(vec.begin(), vec.end(), seq.begin(), seq.end());
-  if (vec.end() != first)
-*first; // no-warning
-}
-
-void bad_find_first_of(std::vector , std::vector ) {
-  auto first = std::find_end(vec.begin(), vec.end(), seq.begin(), seq.end());
-  *first; // expected-warning{{Iterator accessed past its end}}
-}
-
-bool odd(int i) { return i % 2; }
-
-void good_find_if(std::vector ) {
-  auto first = std::find_if(vec.begin(), vec.end(), odd);
-  if (vec.end() != first)
-*first; // no-warning
-}
-
-void bad_find_if(std::vector , int e) {
-  auto first = std::find_if(vec.begin(), vec.end(), odd);
-  *first; // expected-warning{{Iterator accessed past its end}}
-}
-
-void good_find_if_not(std::vector ) {
-  auto first = std::find_if_not(vec.begin(), vec.end(), odd);
-  if (vec.end() != first)
-*first; // no-warning
-}
-

Re: [PATCH] D29877: Warn about unused static file scope function template declarations.

2017-05-09 Thread Vassil Vassilev via cfe-commits

On 11/04/17 22:25, Richard Smith wrote:
On 11 April 2017 at 08:35, Marshall Clow via Phabricator via 
cfe-commits > wrote:


mclow.lists added a comment.

Complete reproducer:

// Tested with with:  clang++ -std=c++14 -Wunused-function
UnusedFVassily.cpp
//
// UnusedFVassily.cpp:8:39: warning: unused function '__test'
[-Wunused-function]
// template  static __two __test(...);
//   ^
// UnusedFVassily.cpp:9:38: warning: unused function '__test'
[-Wunused-function]
// template  static char __test(typename
_Up::pointer* = 0);
//  ^
// 2 warnings generated.

#include 

namespace foo {

struct __two {char __lx; char __lxx;};
namespace __has_pointer_type_imp
{

  template  static __two __test(...);
  template  static char __test(typename _Up::pointer* = 0);

}

template 
struct __has_pointer_type

  : public std::integral_constant(0)) == 1>


This is a bug in libc++. If this header is included into two 
translation units, they will be referencing different __test functions 
here (because the template has internal linkage due to the 'static'), 
resulting in an ODR violation.
Richard, shall we warn on template definitions marked static? This would 
keep this pattern still working.



{
};

}

struct S1 {};
struct S2 { typedef void *pointer; };

int main () {
static_assert (!foo::__has_pointer_type::value, "" );
static_assert ( foo::__has_pointer_type::value, "" );
}


https://reviews.llvm.org/D29877 



___
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


[PATCH] D32989: Don't indent JavaScript IIFEs

2017-05-09 Thread Martin Probst via Phabricator via cfe-commits
mprobst added inline comments.



Comment at: lib/Format/UnwrappedLineParser.cpp:2362
+  ++I;
+  if (I->Tok->isNot(tok::l_paren))
+return false;

One more - do we want to support IIFEs that take arguments?


```
(function(global) {
  ...
}(window));
```


https://reviews.llvm.org/D32989



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


[PATCH] D32989: Don't indent JavaScript IIFEs

2017-05-09 Thread Martin Probst via Phabricator via cfe-commits
mprobst added inline comments.



Comment at: lib/Format/UnwrappedLineParser.cpp:2346
 
+bool UnwrappedLineParser::isIIFE() const {
+  // Look for the start of an immediately invoked anonymous function.

Why not just a static function?



Comment at: lib/Format/UnwrappedLineParser.cpp:2351
+  // Example: (function() { ... })()
+  // FIXME: check for the end invocation or alternate ways to start function
+  // expressions?

The question is whether we ever expect to find lines starting with `(function() 
{` that do not end up being an IIFE. I think that's very unlikely, so I think 
I'd even drop this FIXME. I wouldn't expect that to be something that needs 
fixing.

If you wanted to, you could check FormatToken.MatchingParen and then parse from 
there, but I'm not sure if that pointer is already set up at this point.



Comment at: lib/Format/UnwrappedLineParser.cpp:2353
+  // expressions?
+  if (Line->Tokens.size() < 5)
+return false;

There's a `startsSequenceInternal` on `Line` that might come in handy here?



Comment at: unittests/Format/FormatTestJS.cpp:371
+TEST_F(FormatTestJS, IIFE) {
+  verifyFormat("(function() {\n"
+   "var a = 1;\n"

consider adding a test with comments between the tokens (which should work with 
`startsSequence`).



Comment at: unittests/Format/FormatTestJS.cpp:374
+   "}())");
+  verifyFormat("(function() {\n"
+   "var b = 2;\n"

I find it hard to see how these cases are different - can you give them e.g. 
variable names that call out what's the point of the different cases?


https://reviews.llvm.org/D32989



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


[PATCH] D32997: clang-format: [JS] keep triple slash directives intact.

2017-05-09 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302523: clang-format: [JS] keep triple slash directives 
intact. (authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D32997?vs=98270=98272#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32997

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


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -637,9 +637,10 @@
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-// taze:, @tag followed by { for a lot of JSDoc tags, and @see, which is
-// commonly followed by overlong URLs.
-GoogleStyle.CommentPragmas = "(taze:|(@[A-Za-z_0-9-]+[ \\t]*{)|@see)";
+// taze:, triple slash directives (`/// <...`), @tag followed by { for a 
lot
+// of JSDoc tags, and @see, which is commonly followed by overlong URLs.
+GoogleStyle.CommentPragmas =
+"(taze:|^/[ \t]*<|(@[A-Za-z_0-9-]+[ \\t]*{)|@see)";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1785,6 +1785,7 @@
   verifyFormat("import {x} from 'x';  // from some location",
getGoogleJSStyleWithColumns(25));
   verifyFormat("// taze: x from 'location'", getGoogleJSStyleWithColumns(10));
+  verifyFormat("/// ", 
getGoogleJSStyleWithColumns(10));
 }
 
 TEST_F(FormatTestJS, Exponentiation) {


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -637,9 +637,10 @@
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-// taze:, @tag followed by { for a lot of JSDoc tags, and @see, which is
-// commonly followed by overlong URLs.
-GoogleStyle.CommentPragmas = "(taze:|(@[A-Za-z_0-9-]+[ \\t]*{)|@see)";
+// taze:, triple slash directives (`/// <...`), @tag followed by { for a lot
+// of JSDoc tags, and @see, which is commonly followed by overlong URLs.
+GoogleStyle.CommentPragmas =
+"(taze:|^/[ \t]*<|(@[A-Za-z_0-9-]+[ \\t]*{)|@see)";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1785,6 +1785,7 @@
   verifyFormat("import {x} from 'x';  // from some location",
getGoogleJSStyleWithColumns(25));
   verifyFormat("// taze: x from 'location'", getGoogleJSStyleWithColumns(10));
+  verifyFormat("/// ", getGoogleJSStyleWithColumns(10));
 }
 
 TEST_F(FormatTestJS, Exponentiation) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r302523 - clang-format: [JS] keep triple slash directives intact.

2017-05-09 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Tue May  9 07:45:48 2017
New Revision: 302523

URL: http://llvm.org/viewvc/llvm-project?rev=302523=rev
Log:
clang-format: [JS] keep triple slash directives intact.

Summary:
TypeScript uses triple slash directives of the form:
/// 

For various non-source instructions that should not be wrapped.

Reference:
https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

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

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=302523=302522=302523=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Tue May  9 07:45:48 2017
@@ -637,9 +637,10 @@ FormatStyle getGoogleStyle(FormatStyle::
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-// taze:, @tag followed by { for a lot of JSDoc tags, and @see, which is
-// commonly followed by overlong URLs.
-GoogleStyle.CommentPragmas = "(taze:|(@[A-Za-z_0-9-]+[ \\t]*{)|@see)";
+// taze:, triple slash directives (`/// <...`), @tag followed by { for a 
lot
+// of JSDoc tags, and @see, which is commonly followed by overlong URLs.
+GoogleStyle.CommentPragmas =
+"(taze:|^/[ \t]*<|(@[A-Za-z_0-9-]+[ \\t]*{)|@see)";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=302523=302522=302523=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue May  9 07:45:48 2017
@@ -1785,6 +1785,7 @@ TEST_F(FormatTestJS, ImportComments) {
   verifyFormat("import {x} from 'x';  // from some location",
getGoogleJSStyleWithColumns(25));
   verifyFormat("// taze: x from 'location'", getGoogleJSStyleWithColumns(10));
+  verifyFormat("/// ", 
getGoogleJSStyleWithColumns(10));
 }
 
 TEST_F(FormatTestJS, Exponentiation) {


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


[PATCH] D31867: Fix documentation for TargetOptions.

2017-05-09 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev added a comment.

Landed in r302521.


https://reviews.llvm.org/D31867



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


[PATCH] D32997: clang-format: [JS] keep triple slash directives intact.

2017-05-09 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good.


https://reviews.llvm.org/D32997



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


[clang-tools-extra] r302522 - [clang-tidy] Minor cleanup + a disabled test case for PR26228. NFC

2017-05-09 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Tue May  9 07:41:11 2017
New Revision: 302522

URL: http://llvm.org/viewvc/llvm-project?rev=302522=rev
Log:
[clang-tidy] Minor cleanup + a disabled test case for PR26228. NFC

Modified:

clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp?rev=302522=302521=302522=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp 
Tue May  9 07:41:11 2017
@@ -39,7 +39,7 @@ SourceLocation forwardSkipWhitespaceAndC
 const ASTContext *Context) {
   assert(Loc.isValid());
   for (;;) {
-while (isWhitespace(*FullSourceLoc(Loc, SM).getCharacterData()))
+while (isWhitespace(*SM.getCharacterData(Loc)))
   Loc = Loc.getLocWithOffset(1);
 
 tok::TokenKind TokKind = getTokenKind(Loc, SM, Context);
@@ -69,7 +69,6 @@ SourceLocation findEndLocation(SourceLoc
 
   Loc = Lexer::getLocForEndOfToken(Loc, 0, SM, Context->getLangOpts());
   // Loc points past the last token before end or after ';'.
-
   if (SkipEndWhitespaceAndComments) {
 Loc = forwardSkipWhitespaceAndComments(Loc, SM, Context);
 tok::TokenKind TokKind = getTokenKind(Loc, SM, Context);
@@ -79,10 +78,11 @@ SourceLocation findEndLocation(SourceLoc
 
   for (;;) {
 assert(Loc.isValid());
-while (isHorizontalWhitespace(*FullSourceLoc(Loc, SM).getCharacterData()))
+while (isHorizontalWhitespace(*SM.getCharacterData(Loc))) {
   Loc = Loc.getLocWithOffset(1);
+}
 
-if (isVerticalWhitespace(*FullSourceLoc(Loc, SM).getCharacterData())) {
+if (isVerticalWhitespace(*SM.getCharacterData(Loc))) {
   // EOL, insert brace before.
   break;
 }
@@ -159,7 +159,7 @@ void BracesAroundStatementsCheck::check(
   ForceBracesStmts.insert(Else);
 if (Else && !isa(Else)) {
   // Omit 'else if' statements here, they will be handled directly.
-  checkStmt(Result, Else, S->getElseLoc(), SourceLocation());
+  checkStmt(Result, Else, S->getElseLoc());
 }
   } else {
 llvm_unreachable("Invalid match");

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements.cpp?rev=302522=302521=302522=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements.cpp
 Tue May  9 07:41:11 2017
@@ -172,6 +172,17 @@ void test() {
   // CHECK-FIXES-NEXT: }
 }
 
+void f(const char *p) {
+  if (!p)
+f("\
+");
+  // CHECK-MESSAGES: :[[@LINE-3]]:10: warning: statement should be inside 
braces
+  // CHECK-FIXES:  {{^  }}if (!p) {{{$}}
+  // CHECK-FIXES-NEXT: {{^}}f("\{{$}}
+  // CHECK-FIXES-_NEXT: {{^}}");{{$}} FIXME: This breaks 
(http://llvm.org/PR26228)
+  // CHECK-FIXES-_NEXT: {{^}}}{{$}}
+}
+
 #define M(x) x
 
 int test_macros(bool b) {


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


r302521 - PR5935: Adjust documentation.

2017-05-09 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue May  9 07:37:15 2017
New Revision: 302521

URL: http://llvm.org/viewvc/llvm-project?rev=302521=rev
Log:
PR5935: Adjust documentation.

https://reviews.llvm.org/D31867

Patch by Johannes Altmanninger!

Modified:
cfe/trunk/include/clang/Basic/TargetOptions.h

Modified: cfe/trunk/include/clang/Basic/TargetOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetOptions.h?rev=302521=302520=302521=diff
==
--- cfe/trunk/include/clang/Basic/TargetOptions.h (original)
+++ cfe/trunk/include/clang/Basic/TargetOptions.h Tue May  9 07:37:15 2017
@@ -24,8 +24,7 @@ namespace clang {
 /// \brief Options for controlling the target.
 class TargetOptions {
 public:
-  /// If given, the name of the target triple to compile for. If not given the
-  /// target will be selected to match the host.
+  /// The name of the target triple to compile for.
   std::string Triple;
 
   /// When compiling for the device side, contains the triple used to compile


___
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-05-09 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Paweł, are you planning to finish this patch?


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] D32997: clang-format: [JS] keep triple slash directives intact.

2017-05-09 Thread Martin Probst via Phabricator via cfe-commits
mprobst created this revision.
Herald added a subscriber: klimek.

TypeScript uses triple slash directives of the form:

  /// 

For various non-source instructions that should not be wrapped.

Reference:
https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html


https://reviews.llvm.org/D32997

Files:
  lib/Format/Format.cpp
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1785,6 +1785,7 @@
   verifyFormat("import {x} from 'x';  // from some location",
getGoogleJSStyleWithColumns(25));
   verifyFormat("// taze: x from 'location'", getGoogleJSStyleWithColumns(10));
+  verifyFormat("/// ", 
getGoogleJSStyleWithColumns(10));
 }
 
 TEST_F(FormatTestJS, Exponentiation) {
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -637,9 +637,10 @@
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-// taze:, @tag followed by { for a lot of JSDoc tags, and @see, which is
-// commonly followed by overlong URLs.
-GoogleStyle.CommentPragmas = "(taze:|(@[A-Za-z_0-9-]+[ \\t]*{)|@see)";
+// taze:, triple slash directives (`/// <...`), @tag followed by { for a 
lot
+// of JSDoc tags, and @see, which is commonly followed by overlong URLs.
+GoogleStyle.CommentPragmas =
+"(taze:|^/[ \t]*<|(@[A-Za-z_0-9-]+[ \\t]*{)|@see)";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1785,6 +1785,7 @@
   verifyFormat("import {x} from 'x';  // from some location",
getGoogleJSStyleWithColumns(25));
   verifyFormat("// taze: x from 'location'", getGoogleJSStyleWithColumns(10));
+  verifyFormat("/// ", getGoogleJSStyleWithColumns(10));
 }
 
 TEST_F(FormatTestJS, Exponentiation) {
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -637,9 +637,10 @@
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-// taze:, @tag followed by { for a lot of JSDoc tags, and @see, which is
-// commonly followed by overlong URLs.
-GoogleStyle.CommentPragmas = "(taze:|(@[A-Za-z_0-9-]+[ \\t]*{)|@see)";
+// taze:, triple slash directives (`/// <...`), @tag followed by { for a lot
+// of JSDoc tags, and @see, which is commonly followed by overlong URLs.
+GoogleStyle.CommentPragmas =
+"(taze:|^/[ \t]*<|(@[A-Za-z_0-9-]+[ \\t]*{)|@see)";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32900: [mips] Impose a threshold for coercion of aggregates

2017-05-09 Thread Stefan Maksimovic via Phabricator via cfe-commits
smaksimovic updated this revision to Diff 98269.
smaksimovic added a comment.
Herald added a subscriber: krytarowski.

Thanks, fixed.


https://reviews.llvm.org/D32900

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/mips-aggregate-arg.c


Index: test/CodeGen/mips-aggregate-arg.c
===
--- test/CodeGen/mips-aggregate-arg.c
+++ test/CodeGen/mips-aggregate-arg.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple mipsel-unknown-linux-gnu -S -emit-llvm -o - %s | 
FileCheck -check-prefix=O32 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n32 | FileCheck -check-prefix=N32-N64 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n64 | FileCheck -check-prefix=N32-N64 %s
+
+struct t1 {
+  char t1[10];
+};
+
+struct t2 {
+  char t2[20];
+};
+
+struct t3 {
+  char t3[65];
+};
+
+extern struct t1 g1;
+extern struct t2 g2;
+extern struct t3 g3;
+extern void f1(struct t1);
+extern void f2(struct t2);
+extern void f3(struct t3);
+
+void f() {
+
+// O32:  call void @f1(i32 inreg %3, i32 inreg %5, i16 inreg %7)
+// O32:  call void @f2(%struct.t2* byval align 4 %tmp)
+// O32:  call void @f3(%struct.t3* byval align 4 %tmp1)
+
+// N32-N64:  call void @f1(i64 inreg %3, i16 inreg %5)
+// N32-N64:  call void @f2(i64 inreg %9, i64 inreg %11, i32 inreg %13)
+// N32-N64:  call void @f3(%struct.t3* byval align 8 %tmp)
+
+  f1(g1);
+  f2(g2);
+  f3(g3);
+}
+
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -6696,6 +6696,14 @@
   return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory);
 }
 
+// Use indirect if the aggregate cannot fit into registers for
+// passing arguments according to the ABI
+unsigned Threshold = IsO32 ? 16 : 64;
+
+if(getContext().getTypeSizeInChars(Ty) > 
CharUnits::fromQuantity(Threshold))
+  return ABIArgInfo::getIndirect(CharUnits::fromQuantity(Align), true,
+ getContext().getTypeAlign(Ty) / 8 > 
Align);
+
 // If we have reached here, aggregates are passed directly by coercing to
 // another structure type. Padding is inserted if the offset of the
 // aggregate is unaligned.


Index: test/CodeGen/mips-aggregate-arg.c
===
--- test/CodeGen/mips-aggregate-arg.c
+++ test/CodeGen/mips-aggregate-arg.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple mipsel-unknown-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefix=O32 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  -target-abi n32 | FileCheck -check-prefix=N32-N64 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  -target-abi n64 | FileCheck -check-prefix=N32-N64 %s
+
+struct t1 {
+  char t1[10];
+};
+
+struct t2 {
+  char t2[20];
+};
+
+struct t3 {
+  char t3[65];
+};
+
+extern struct t1 g1;
+extern struct t2 g2;
+extern struct t3 g3;
+extern void f1(struct t1);
+extern void f2(struct t2);
+extern void f3(struct t3);
+
+void f() {
+
+// O32:  call void @f1(i32 inreg %3, i32 inreg %5, i16 inreg %7)
+// O32:  call void @f2(%struct.t2* byval align 4 %tmp)
+// O32:  call void @f3(%struct.t3* byval align 4 %tmp1)
+
+// N32-N64:  call void @f1(i64 inreg %3, i16 inreg %5)
+// N32-N64:  call void @f2(i64 inreg %9, i64 inreg %11, i32 inreg %13)
+// N32-N64:  call void @f3(%struct.t3* byval align 8 %tmp)
+
+  f1(g1);
+  f2(g2);
+  f3(g3);
+}
+
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -6696,6 +6696,14 @@
   return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory);
 }
 
+// Use indirect if the aggregate cannot fit into registers for
+// passing arguments according to the ABI
+unsigned Threshold = IsO32 ? 16 : 64;
+
+if(getContext().getTypeSizeInChars(Ty) > CharUnits::fromQuantity(Threshold))
+  return ABIArgInfo::getIndirect(CharUnits::fromQuantity(Align), true,
+ getContext().getTypeAlign(Ty) / 8 > Align);
+
 // If we have reached here, aggregates are passed directly by coercing to
 // another structure type. Padding is inserted if the offset of the
 // aggregate is unaligned.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29877: Warn about unused static file scope function template declarations.

2017-05-09 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev added a comment.

Relanded in r302518.


https://reviews.llvm.org/D29877



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


r302518 - Reland "Warn about unused static file scope function template declarations."

2017-05-09 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue May  9 06:25:41 2017
New Revision: 302518

URL: http://llvm.org/viewvc/llvm-project?rev=302518=rev
Log:
Reland "Warn about unused static file scope function template declarations."

This patch reinstates r299930, reverted in r299956, as a separate diagnostic
option (-Wunused-template). 

Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/warn-unused-filescoped.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=302518=302517=302518=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue May  9 06:25:41 2017
@@ -486,6 +486,7 @@ def UnneededInternalDecl : DiagGroup<"un
 def UnneededMemberFunction : DiagGroup<"unneeded-member-function">;
 def UnusedPrivateField : DiagGroup<"unused-private-field">;
 def UnusedFunction : DiagGroup<"unused-function", [UnneededInternalDecl]>;
+def UnusedTemplate : DiagGroup<"unused-template", [UnneededInternalDecl]>;
 def UnusedMemberFunction : DiagGroup<"unused-member-function",
  [UnneededMemberFunction]>;
 def UnusedLabel : DiagGroup<"unused-label">;
@@ -627,6 +628,7 @@ def Conversion : DiagGroup<"conversion",
 def Unused : DiagGroup<"unused",
[UnusedArgument, UnusedFunction, UnusedLabel,
 // UnusedParameter, (matches GCC's behavior)
+// UnusedTemplate, (clean-up libc++ before enabling)
 // UnusedMemberFunction, (clean-up llvm before 
enabling)
 UnusedPrivateField, UnusedLambdaCapture,
 UnusedLocalTypedef, UnusedValue, UnusedVariable,

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=302518=302517=302518=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue May  9 06:25:41 
2017
@@ -303,6 +303,8 @@ def note_empty_parens_zero_initialize :
   "replace parentheses with an initializer to declare a variable">;
 def warn_unused_function : Warning<"unused function %0">,
   InGroup, DefaultIgnore;
+def warn_unused_template : Warning<"unused %select{function|variable}0 
template %1">,
+  InGroup, DefaultIgnore;
 def warn_unused_member_function : Warning<"unused member function %0">,
   InGroup, DefaultIgnore;
 def warn_used_but_marked_unused: Warning<"%0 was marked unused but was used">,

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=302518=302517=302518=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Tue May  9 06:25:41 2017
@@ -477,6 +477,13 @@ static bool ShouldRemoveFromUnused(Sema
 return true;
 
   if (const FunctionDecl *FD = dyn_cast(D)) {
+// If this is a function template and none of its specializations is used,
+// we should warn.
+if (FunctionTemplateDecl *Template = FD->getDescribedFunctionTemplate())
+  for (const auto *Spec : Template->specializations())
+if (ShouldRemoveFromUnused(SemaRef, Spec))
+  return true;
+
 // UnusedFileScopedDecls stores the first declaration.
 // The declaration may have become definition so check again.
 const FunctionDecl *DeclToCheck;
@@ -500,6 +507,13 @@ static bool ShouldRemoveFromUnused(Sema
 VD->isUsableInConstantExpressions(SemaRef->Context))
   return true;
 
+if (VarTemplateDecl *Template = VD->getDescribedVarTemplate())
+  // If this is a variable template and none of its specializations is 
used,
+  // we should warn.
+  for (const auto *Spec : Template->specializations())
+if (ShouldRemoveFromUnused(SemaRef, Spec))
+  return true;
+
 // UnusedFileScopedDecls stores the first declaration.
 // The declaration may have become definition so check again.
 const VarDecl *DeclToCheck = VD->getDefinition();
@@ -905,10 +919,14 @@ void Sema::ActOnEndOfTranslationUnit() {
<< /*function*/0 << DiagD->getDeclName();
   }
 } else {
-  Diag(DiagD->getLocation(),
-   isa(DiagD) ? diag::warn_unused_member_function
- : diag::warn_unused_function)
-<< DiagD->getDeclName();
+  if (FD->getDescribedFunctionTemplate())
+Diag(DiagD->getLocation(), 

[libcxx] r302517 - docs: Fix Sphinx detection with out-of-tree builds

2017-05-09 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Tue May  9 06:18:03 2017
New Revision: 302517

URL: http://llvm.org/viewvc/llvm-project?rev=302517=rev
Log:
docs: Fix Sphinx detection with out-of-tree builds

Adapt to changes made in r302499.

Modified:
libcxx/trunk/docs/CMakeLists.txt

Modified: libcxx/trunk/docs/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/CMakeLists.txt?rev=302517=302516=302517=diff
==
--- libcxx/trunk/docs/CMakeLists.txt (original)
+++ libcxx/trunk/docs/CMakeLists.txt Tue May  9 06:18:03 2017
@@ -1,9 +1,9 @@
 
 if (LLVM_ENABLE_SPHINX)
+  include(AddSphinxTarget)
   if (SPHINX_FOUND)
-include(AddSphinxTarget)
 if (${SPHINX_OUTPUT_HTML})
   add_sphinx_target(html libcxx)
 endif()
   endif()
-endif()
\ No newline at end of file
+endif()


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


[clang-tools-extra] r302516 - docs: Fix Sphinx detection with out-of-tree builds

2017-05-09 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Tue May  9 06:11:52 2017
New Revision: 302516

URL: http://llvm.org/viewvc/llvm-project?rev=302516=rev
Log:
docs: Fix Sphinx detection with out-of-tree builds

Adapt to changes made in r302499.

Modified:
clang-tools-extra/trunk/docs/CMakeLists.txt

Modified: clang-tools-extra/trunk/docs/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/CMakeLists.txt?rev=302516=302515=302516=diff
==
--- clang-tools-extra/trunk/docs/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/docs/CMakeLists.txt Tue May  9 06:11:52 2017
@@ -90,8 +90,8 @@ if (DOXYGEN_FOUND)
 endif()
 
 if (LLVM_ENABLE_SPHINX)
+  include(AddSphinxTarget)
   if (SPHINX_FOUND)
-include(AddSphinxTarget)
 if (${SPHINX_OUTPUT_HTML})
   add_sphinx_target(html clang-tools)
 endif()


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


[PATCH] D32900: [mips] Impose a threshold for coercion of aggregates

2017-05-09 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a comment.

Spotted a minor nit.




Comment at: test/CodeGen/mips-aggregate-arg.c:36
+  f2(g2);
+  f3(g3);  
+}

Nit: spurious whitespace here.


https://reviews.llvm.org/D32900



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


[PATCH] D32900: [mips] Impose a threshold for coercion of aggregates

2017-05-09 Thread Simon Dardis via Phabricator via cfe-commits
sdardis accepted this revision.
sdardis added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: test/CodeGen/mips-aggregate-arg.c:3
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n32 | FileCheck -check-prefix=N32-N64 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n64| FileCheck -check-prefix=N32-N64 %s
+

Space after the -target-abi n64


https://reviews.llvm.org/D32900



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


[PATCH] D31588: Fix PR25627: Certain constant local variables must be usable as template arguments (without being odr-used)

2017-05-09 Thread Faisal Vali via Phabricator via cfe-commits
faisalv added a comment.

*ping*


https://reviews.llvm.org/D31588



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


[PATCH] D32543: [X86] Clang option -fuse-init-array has no effect when generating for MCU target

2017-05-09 Thread Nikolai Bozhenov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302513: [X86] Clang option -fuse-init-array has no effect 
when generating for MCU target (authored by n.bozhenov).

Changed prior to commit:
  https://reviews.llvm.org/D32543?vs=97866=98262#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32543

Files:
  llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
  llvm/trunk/test/CodeGen/X86/constructor.ll


Index: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
===
--- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
+++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
@@ -87,7 +87,7 @@
 
   if (TT.isOSFreeBSD())
 return llvm::make_unique();
-  if (TT.isOSLinux() || TT.isOSNaCl())
+  if (TT.isOSLinux() || TT.isOSNaCl() || TT.isOSIAMCU())
 return llvm::make_unique();
   if (TT.isOSFuchsia())
 return llvm::make_unique();
Index: llvm/trunk/test/CodeGen/X86/constructor.ll
===
--- llvm/trunk/test/CodeGen/X86/constructor.ll
+++ llvm/trunk/test/CodeGen/X86/constructor.ll
@@ -3,6 +3,8 @@
 ; RUN: llc -mtriple x86_64-pc-linux < %s | FileCheck --check-prefix=INIT-ARRAY 
%s
 ; RUN: llc -mtriple x86_64-unknown-freebsd < %s | FileCheck 
--check-prefix=INIT-ARRAY %s
 ; RUN: llc -mtriple x86_64-unknown-nacl < %s | FileCheck --check-prefix=NACL %s
+; RUN: llc -mtriple i586-intel-elfiamcu -use-ctors < %s | FileCheck %s 
--check-prefix=MCU-CTORS
+; RUN: llc -mtriple i586-intel-elfiamcu < %s | FileCheck %s 
--check-prefix=MCU-INIT-ARRAY
 @llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }] [{ i32, 
void ()*, i8* } { i32 65535, void ()* @f, i8* null}, { i32, void ()*, i8* } { 
i32 15, void ()* @g, i8* @v }]
 
 @v = weak_odr global i8 0
@@ -37,3 +39,6 @@
 ; NACL-NEXT:   .section.init_array,"aw",@init_array
 ; NACL-NEXT:   .p2align2
 ; NACL-NEXT:   .long   f
+
+; MCU-CTORS: .section.ctors,"aw",@progbits
+; MCU-INIT-ARRAY:.section.init_array,"aw",@init_array


Index: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
===
--- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
+++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
@@ -87,7 +87,7 @@
 
   if (TT.isOSFreeBSD())
 return llvm::make_unique();
-  if (TT.isOSLinux() || TT.isOSNaCl())
+  if (TT.isOSLinux() || TT.isOSNaCl() || TT.isOSIAMCU())
 return llvm::make_unique();
   if (TT.isOSFuchsia())
 return llvm::make_unique();
Index: llvm/trunk/test/CodeGen/X86/constructor.ll
===
--- llvm/trunk/test/CodeGen/X86/constructor.ll
+++ llvm/trunk/test/CodeGen/X86/constructor.ll
@@ -3,6 +3,8 @@
 ; RUN: llc -mtriple x86_64-pc-linux < %s | FileCheck --check-prefix=INIT-ARRAY %s
 ; RUN: llc -mtriple x86_64-unknown-freebsd < %s | FileCheck --check-prefix=INIT-ARRAY %s
 ; RUN: llc -mtriple x86_64-unknown-nacl < %s | FileCheck --check-prefix=NACL %s
+; RUN: llc -mtriple i586-intel-elfiamcu -use-ctors < %s | FileCheck %s --check-prefix=MCU-CTORS
+; RUN: llc -mtriple i586-intel-elfiamcu < %s | FileCheck %s --check-prefix=MCU-INIT-ARRAY
 @llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @f, i8* null}, { i32, void ()*, i8* } { i32 15, void ()* @g, i8* @v }]
 
 @v = weak_odr global i8 0
@@ -37,3 +39,6 @@
 ; NACL-NEXT:	.section	.init_array,"aw",@init_array
 ; NACL-NEXT:	.p2align	2
 ; NACL-NEXT:	.long	f
+
+; MCU-CTORS: .section.ctors,"aw",@progbits
+; MCU-INIT-ARRAY:.section.init_array,"aw",@init_array
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32350: [Analyzer] Exception checker for misuse: uncaught/noncompliant throws

2017-05-09 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/ExceptionMisuseChecker.cpp:105
+  ReportExnSpec(ReportExnSpec) {
+  // In the beginning we have to parse list formatted options
+  SmallVector EnabledFuncsVec;

All comments should be full sentences starting with a capital letter and ending 
with a period. 



Comment at: lib/StaticAnalyzer/Checkers/ExceptionMisuseChecker.cpp:109
+  EnabledFuncs.insert(EnabledFuncsVec.begin(), EnabledFuncsVec.end());
+  EnabledFuncs.insert("swap");
+  EnabledFuncs.insert("main");

whisperity wrote:
> Why is `swap` hardcoded as an "enabledfunc"?
It is always possible to implement swap in a non-throwing way, and some 
implementations that are using the copy and swap idiom, expecting swap to be 
no-throw. 



Comment at: test/Analysis/exception-misuse.cpp:26
+
+~Y() {  // expected-warning{{This function should not throw}}
+// nesting

whisperity wrote:
> whisperity wrote:
> > Yet again, better wording: _Destructor not marked `noexcept(false)` should 
> > not throw_ (this is true since `C++11`, maybe this needs to be based on a 
> > conditional in the checker!)
> > 
> > @xazax.hun, any idea on what a good error message here should be?
> Also, a test case for a throwing, and `noexcept(false)`-specified dtor is 
> missing.
In fact,  the function can throw, if the exception is catched before leaving 
the function body. And in case the function does not throw but a called 
function do, that is also an error. So maybe something like exception are not 
allowed to leave this function? 


https://reviews.llvm.org/D32350



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


[PATCH] D28953: [analyzer] Eliminate analyzer limitations on symbolic constraint generation

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

Do you have a benchmark how this affects the performance and memory usage when 
the old constraint manager is used? I wonder if most of people are using the 
old one, it might make no sense to generate symbolic expressions that can not 
be solved anyway.
Maybe the analyzer could only generate these symbolic expressions when Z3 is 
used?


https://reviews.llvm.org/D28953



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


[PATCH] D32751: [ASTImporter] Support new kinds of declarations (mostly Using*)

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

Looks good for me, I only have a few questions. Could you reupload the diff 
with contexts? It might make the review easier for others.




Comment at: lib/AST/ASTImporter.cpp:1311
+  EmptyDecl *ToD = EmptyDecl::Create(Importer.getToContext(), DC, Loc);
+  ToD->setLexicalDeclContext(LexicalDC);
+  LexicalDC->addDeclInternal(ToD);

Don't we need an Importer.Imported call here? 



Comment at: lib/AST/ASTImporter.cpp:1461
+
+  // NOTE: No any conflict resolution is done for namespace aliases.
+

Minor nit: do we need the any in this sentence?


https://reviews.llvm.org/D32751



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


[PATCH] D32350: [Analyzer] Exception Checker

2017-05-09 Thread Whisperity via Phabricator via cfe-commits
whisperity added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/ExceptionMisuseChecker.cpp:80
+  bool WasReThrow;
+  Types CurrentThrows; // actually alive exceptions
+  FunctionExceptionsMap

There are some comment formatting issues along these lines.



Comment at: lib/StaticAnalyzer/Checkers/ExceptionMisuseChecker.cpp:84
+  std::vector CallStack;// trace call hierarchy
+  SmallSet EnabledFuncs;  // allowed functions
+  SmallSet IgnoredExceptions; // ignored exceptions

I had to stop here for a moment and heavily think what this variable (and the 
relevant command-line argument) is used for.

Maybe this calls for a comment then. What is "allowed function"? One that is 
**explicitly** allowed to throw, based on the user's decision? This should be 
explained here.



Comment at: lib/StaticAnalyzer/Checkers/ExceptionMisuseChecker.cpp:109
+  EnabledFuncs.insert(EnabledFuncsVec.begin(), EnabledFuncsVec.end());
+  EnabledFuncs.insert("swap");
+  EnabledFuncs.insert("main");

Why is `swap` hardcoded as an "enabledfunc"?



Comment at: lib/StaticAnalyzer/Checkers/ExceptionMisuseChecker.cpp:329
+  const FunctionDecl *callee = C->getDirectCallee();
+  // if is not exist body for this function we do not care about
+  if (!callee || !callee->hasBody()) {

The phrasing should be fixed here for easier understanding.



Comment at: lib/StaticAnalyzer/Checkers/ExceptionMisuseChecker.cpp:336
+  FunctionExceptionsMap::const_iterator fnIt = ExceptionsThrown.find(name);
+  // already processed?
+  if (fnIt == ExceptionsThrown.end()) {

`already processed` what? A given exception type from a given function?



Comment at: lib/StaticAnalyzer/Checkers/ExceptionMisuseChecker.cpp:468
+  const auto *D = pNode.get();
+  if (D == nullptr)
+return false;

`if (!D)`



Comment at: test/Analysis/exception-misuse.cpp:18
+
+Y(Y&&) { // expected-warning{{This function should not throw}}
+throw data;

I would use a much more descriptive error message here. E.g., explicitly say, 
that `move (constructor|operator=) should not throw`.



Comment at: test/Analysis/exception-misuse.cpp:26
+
+~Y() {  // expected-warning{{This function should not throw}}
+// nesting

Yet again, better wording: _Destructor not marked `noexcept(false)` should not 
throw_ (this is true since `C++11`, maybe this needs to be based on a 
conditional in the checker!)

@xazax.hun, any idea on what a good error message here should be?



Comment at: test/Analysis/exception-misuse.cpp:26
+
+~Y() {  // expected-warning{{This function should not throw}}
+// nesting

whisperity wrote:
> Yet again, better wording: _Destructor not marked `noexcept(false)` should 
> not throw_ (this is true since `C++11`, maybe this needs to be based on a 
> conditional in the checker!)
> 
> @xazax.hun, any idea on what a good error message here should be?
Also, a test case for a throwing, and `noexcept(false)`-specified dtor is 
missing.


https://reviews.llvm.org/D32350



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


[PATCH] D32825: [clang-format] Improve understanding of combined typedef+record declarations

2017-05-09 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes added a comment.

Ping :)


https://reviews.llvm.org/D32825



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


<    1   2