[PATCH] D38943: [ASTImporter] import SubStmt of CaseStmt

2018-03-27 Thread Rafael Stahl via Phabricator via cfe-commits
r.stahl added inline comments.
Herald added a subscriber: martong.



Comment at: cfe/trunk/unittests/AST/ASTImporterTest.cpp:100
 
+  // This traverses the AST to catch certain bugs like poorly or not
+  // implemented subtrees.

a.sidorin wrote:
> I just saw this change and I cannot find the reason, why do we need to print 
> the imported declaration after we have printed the entire translation unit? 
> Is there some special case?
Sorry for the late reply.

The particular bug here would only be detected when dumping, but not when 
printing. The output of printing was just not listing the missing AST nodes, 
but dumping crashed and therefore failed the test as expected.

I'm not familiar with the inner workings of print and dump, so I cannot explain 
why that is.


Repository:
  rL LLVM

https://reviews.llvm.org/D38943



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


[PATCH] D38943: [ASTImporter] import SubStmt of CaseStmt

2018-03-27 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: cfe/trunk/unittests/AST/ASTImporterTest.cpp:100
 
+  // This traverses the AST to catch certain bugs like poorly or not
+  // implemented subtrees.

r.stahl wrote:
> a.sidorin wrote:
> > I just saw this change and I cannot find the reason, why do we need to 
> > print the imported declaration after we have printed the entire translation 
> > unit? Is there some special case?
> Sorry for the late reply.
> 
> The particular bug here would only be detected when dumping, but not when 
> printing. The output of printing was just not listing the missing AST nodes, 
> but dumping crashed and therefore failed the test as expected.
> 
> I'm not familiar with the inner workings of print and dump, so I cannot 
> explain why that is.
I have a rough guess that this might be because the code buffer that is used in 
`vfs::InMemoryFileSystem` has a reference to the actual code string. That 
actual code string is a string literal in most of the cases which should be in 
the data segment, but there is no guarantee for that. E.g. some optimizing 
compilers might put it onto the stack.
We experienced a similar issue during building a test Fixture 
(https://reviews.llvm.org/D43967).

What I suggest is to build the `ASTTests` target with asan and ubsan enabled 
(set LLVM_USE_SANITIZER for cmake) and trigger the dump which caused the bug.


Repository:
  rL LLVM

https://reviews.llvm.org/D38943



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


[PATCH] D44831: [clang-format] Refine ObjC guesser to handle child lines of child lines

2018-03-27 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added inline comments.



Comment at: lib/Format/Format.cpp:1449
   const AdditionalKeywords &Keywords) {
+for (auto Line : AnnotatedLines)
+  if (LineContainsObjCCode(*Line, Keywords))

I would not create a second function here. Just iterate over the tokens here 
and call guessIsObjC recursively with Line->Children. That means we need one 
less for loop overall, I think (I might be missing something).



Comment at: lib/Format/Format.cpp:1455
+
+  static bool LineContainsObjCCode(const AnnotatedLine &Line,
+   const AdditionalKeywords &Keywords) {

Convention would be lineContainsObjCCode.


Repository:
  rC Clang

https://reviews.llvm.org/D44831



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


[PATCH] D44882: [clangd] Implementation of workspace/symbol request

2018-03-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

>>> - Current `fuzzyFind` implementation can only match qualifiers strictly 
>>> (i.e. st::vector won't match std::vector). Should we look into allowing 
>>> fuzzy matches for this feature?  (not in this patch, rather in the long 
>>> term).
>> 
>> I'm not sure, I'm thinking there should be a balance between how fuzzy it it 
>> and how much noise it generates. Right now I find it a bit too fuzzy since 
>> when I type "Draft" (to find DraftMgr), it picks up things like 
>> DocumentRangeFormattingParams. Adding fuzziness to the namespace would make 
>> this worse. Maybe with improved scoring it won't matter too much? I'll try 
>> FuzzyMatcher and see.
> 
> +1, I think experience with `workspaceSymbols` will help us answer this 
> question.

I was using an IDE that had fuzzy find for an equivalent of `workspaceSymbols` 
and found it to be an amazing experience. And having consistent behavior 
between different features is really nice.
Good ranking is a key to it being useful, though. If when typing `Draft` you 
get `DocumentRangeFormattingParams` ranked higher than `DraftMgr` that's a bug 
in FuzzyMatcher. If you have some not-very-nice results at the end of the list, 
this shouldn't be a problem in most cases.

I'm highly in favor of enabling fuzzy matching for `workspaceSymbols`.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44882



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


[PATCH] D44882: [clangd] Implementation of workspace/symbol request

2018-03-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

> I'm highly in favor of enabling fuzzy matching for `workspaceSymbols`.

At lest for the name themselves. Non-fuzzy matching of qualifiers does not look 
that important.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44882



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


[PATCH] D44826: Add -Wunused-using, a warning that finds unused using declarations.

2018-03-27 Thread Carlos Alberto Enciso via Phabricator via cfe-commits
CarlosAlbertoEnciso added a comment.

In https://reviews.llvm.org/D44826#1046906, @dblaikie wrote:

>


First of all, thanks very much for your feedback.

> While implementing the warning is great (wonder if there's any codebase
>  that isn't -Wunused-using clean, that we could use to compare Clang and
>  GCC's behavior broadly - make sure it's catching the same cases (or
>  justify/investigate differences)) - and using it to motivate the debug info
>  is an improvement to the debug info - it won't quite address all the wasted
>  debug info, unfortunately :/

You are making a very good point. The -Wunused-using is just addressing
one of the factors affecting the debug info size.

> Consider this:
> 
> namespace a {
> 
>   struct b;
> 
> };
>  namespace x {
> 
>   using a::b;
>   inline void f(b*) {
>   }
> 
> }
> 
> Now the using declaration is used, but if 'f' is never called in this
>  translation unit, it's a bit weird to produce debug info for the using decl
>  and could still substantially bloat debug info. (indeed most of the bloat
>  that the using decl/directive debug info is producing is probably from
>  directives that are used, but not in a way that's relevant to a certain
>  translation unit)

The modified patch catches that 'referenced' but 'unused' using declaration.

> I've not looked at the change yet, but if it's particularly
>  expensive/complicated to wire up the debug info side, it might not be worth
>  it given it's probably not a significant savings & somewhat of a dead-end
>  compared to what would be needed for a more complete fix. But I guess it's
>  probably not expensive/complicated, so probably some fine low hanging fruit
>  to pick until a more complete fix/improvement is implemented.

The warning generation check is done at the point where a lexical scope
is closed and it does not 'see' further changes on the same using after that
point.

The second part (do not generate debug info) uses a similar approach, with
the only difference that the checks and debug info generation is done at
the end of the compilation unit, when more information is available.


Repository:
  rC Clang

https://reviews.llvm.org/D44826



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


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

2018-03-27 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:2992
+  std::string NameString = Name.str();
+  llvm::raw_string_ostream ParameterizedName(NameString);
+  ParameterizedName << "<";

Why not use Name.str() directly?


Repository:
  rC Clang

https://reviews.llvm.org/D44842



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


[PATCH] D43281: [AMDGPU] fixes for lds f32 builtins

2018-03-27 Thread Daniil Fukalov via Phabricator via cfe-commits
dfukalov added a comment.

ping...


Repository:
  rC Clang

https://reviews.llvm.org/D43281



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


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

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



Comment at: docs/clang-tidy/checks/cppcoreguidelines-macro-usage.rst:24
+
+.. option:: CheckCapsOnly
+

Eugene.Zelenko wrote:
> Will be good idea to generalize this option with other check which deal with 
> macros.
I dont think that the bugprone- macro checks would benefit from such an option. 
They all address specific issues that can occur with macros and that occur even 
if you have restrained usage of macros.

The general goal of this check is to remove macros for pretty much everything. 
The Regex and CapsOnly option only try to lower the bar for enabling this check 
and allow gradual adoption.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41648



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


[PATCH] D38455: [clang-tidy] new cppcoreguidelines-narrowing-conversions check.

2018-03-27 Thread Clement Courbet via Phabricator via cfe-commits
courbet added a comment.

OK, here's an analysis of 100 instances of a check that would warn on all fully 
implicit (no C/static/reinterpret/...) casts from float/double to integral: 
link 

I don't expect the analysis to be perfect, but that gives us a better idea of 
what to expect.

- A bit more than 1/3 of instances are OK and should be using a cast.
- A bit less than 1/4 of instances is brittle code and should use int types.
- The two false positive cases are easy to handle.
- I was surprised about the "truth value of float" one. I think we should 
provide a fix to turn `!f` this into `f != 0.0f`.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38455



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


[PATCH] D44559: [Sema] Wrong width of result of mul operation

2018-03-27 Thread Andrew V. Tischenko via Phabricator via cfe-commits
avt77 added a comment.

> If that operation overflows, so be it — we're not going to warn about the 
> potential for overflow every time the user adds two ints, and by the same 
> token, it doesn't make any sense to warn about every time the user adds two 
> shorts just because the language made this otherwise-unimportant technical 
> decision to do the arithmetic in a wider type.

There is one comment only: this patch changes the 'mul' operation only and 
initially the change was done for X86 only because it clearly says about 
"doubling" of mul result width. And another comment: currently we have warning 
here:

  int c = a * b;
  T d1 = c; // expected-warning{{implicit conversion loses integer precision: 
'int' to 'char'}}

but we don't have it here:

T d2 = a * b; // when T is char

It's a potential problem from my point of view.
But I don't mind to close the review - and the corresponding bug of course.


https://reviews.llvm.org/D44559



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


r328618 - [ASTMatchers] Add isAssignmentOperator matcher

2018-03-27 Thread Peter Szecsi via cfe-commits
Author: szepet
Date: Tue Mar 27 05:11:46 2018
New Revision: 328618

URL: http://llvm.org/viewvc/llvm-project?rev=328618&view=rev
Log:
[ASTMatchers] Add isAssignmentOperator matcher

Adding a matcher for BinaryOperator and cxxOperatorCallExpr to be able to
decide whether it is any kind of assignment operator or not. This would be
useful since allows us to easily detect assignments via matchers for static
analysis (Tidy, SA) purposes.

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


Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=328618&r1=328617&r2=328618&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Tue Mar 27 05:11:46 2018
@@ -1926,6 +1926,19 @@ Example matches a || b (matcher = binary
 
 
 
+MatcherBinaryOperator>isAssignmentOperator
+Matches all 
kinds of assignment operators.
+
+Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
+  if (a == b)
+a += b;
+
+Example 2: matches s1 = s2 (matcher = 
cxxOperatorCallExpr(isAssignmentOperator()))
+  struct S { S& operator=(const S&); };
+  void x() { S s1, s2; s1 = s2; })
+
+
+
 MatcherCXXBoolLiteralExpr>equalsbool Value
 
 
@@ -2306,6 +2319,19 @@ Usable as: MatcherCXXOperatorCallExpr>isAssignmentOperator
+Matches all 
kinds of assignment operators.
+
+Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
+  if (a == b)
+a += b;
+
+Example 2: matches s1 = s2 (matcher = 
cxxOperatorCallExpr(isAssignmentOperator()))
+  struct S { S& operator=(const S&); };
+  void x() { S s1, s2; s1 = s2; })
+
+
+
 MatcherCXXRecordDecl>hasDefinition
 Matches a class 
declaration that is defined.
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=328618&r1=328617&r2=328618&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Tue Mar 27 05:11:46 2018
@@ -4003,6 +4003,26 @@ AST_POLYMORPHIC_MATCHER_P(hasOperatorNam
   return Name == Node.getOpcodeStr(Node.getOpcode());
 }
 
+/// \brief Matches on all kinds of assignment operators.
+///
+/// Example 1: matches a += b (matcher = 
binaryOperator(isAssignmentOperator()))
+/// \code
+///   if (a == b)
+/// a += b;
+/// \endcode
+///
+/// Example 2: matches s1 = s2
+///(matcher = cxxOperatorCallExpr(isAssignmentOperator()))
+/// \code
+///   struct S { S& operator=(const S&); };
+///   void x() { S s1, s2; s1 = s2; })
+/// \endcode
+AST_POLYMORPHIC_MATCHER(isAssignmentOperator,
+AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator,
+CXXOperatorCallExpr)) {
+  return Node.isAssignmentOp();
+}
+
 /// \brief Matches the left hand side of binary operator expressions.
 ///
 /// Example matches a (matcher = binaryOperator(hasLHS()))

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=328618&r1=328617&r2=328618&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Tue Mar 27 05:11:46 2018
@@ -322,6 +322,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(isAnyPointer);
   REGISTER_MATCHER(isArray);
   REGISTER_MATCHER(isArrow);
+  REGISTER_MATCHER(isAssignmentOperator);
   REGISTER_MATCHER(isBaseInitializer);
   REGISTER_MATCHER(isBitField);
   REGISTER_MATCHER(isCatchAll);

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp?rev=328618&r1=328617&r2=328618&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp Tue Mar 27 
05:11:46 2018
@@ -2139,5 +2139,20 @@ TEST(HasTrailingReturn, MatchesLambdaTra
   functionDecl(hasTrailingRetu

[PATCH] D44893: [ASTMatchers] Add isAssignmentOperator matcher

2018-03-27 Thread Peter Szecsi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC328618: [ASTMatchers] Add isAssignmentOperator matcher 
(authored by szepet, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44893?vs=139769&id=139900#toc

Repository:
  rC Clang

https://reviews.llvm.org/D44893

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -1926,6 +1926,19 @@
 
 
 
+MatcherBinaryOperator>isAssignmentOperator
+Matches all kinds of assignment operators.
+
+Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
+  if (a == b)
+a += b;
+
+Example 2: matches s1 = s2 (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
+  struct S { S& operator=(const S&); };
+  void x() { S s1, s2; s1 = s2; })
+
+
+
 MatcherCXXBoolLiteralExpr>equalsbool Value
 
 
@@ -2306,6 +2319,19 @@
 
 
 
+MatcherCXXOperatorCallExpr>isAssignmentOperator
+Matches all kinds of assignment operators.
+
+Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
+  if (a == b)
+a += b;
+
+Example 2: matches s1 = s2 (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
+  struct S { S& operator=(const S&); };
+  void x() { S s1, s2; s1 = s2; })
+
+
+
 MatcherCXXRecordDecl>hasDefinition
 Matches a class declaration that is defined.
 
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -4003,6 +4003,26 @@
   return Name == Node.getOpcodeStr(Node.getOpcode());
 }
 
+/// \brief Matches on all kinds of assignment operators.
+///
+/// Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
+/// \code
+///   if (a == b)
+/// a += b;
+/// \endcode
+///
+/// Example 2: matches s1 = s2
+///(matcher = cxxOperatorCallExpr(isAssignmentOperator()))
+/// \code
+///   struct S { S& operator=(const S&); };
+///   void x() { S s1, s2; s1 = s2; })
+/// \endcode
+AST_POLYMORPHIC_MATCHER(isAssignmentOperator,
+AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator,
+CXXOperatorCallExpr)) {
+  return Node.isAssignmentOp();
+}
+
 /// \brief Matches the left hand side of binary operator expressions.
 ///
 /// Example matches a (matcher = binaryOperator(hasLHS()))
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -322,6 +322,7 @@
   REGISTER_MATCHER(isAnyPointer);
   REGISTER_MATCHER(isArray);
   REGISTER_MATCHER(isArrow);
+  REGISTER_MATCHER(isAssignmentOperator);
   REGISTER_MATCHER(isBaseInitializer);
   REGISTER_MATCHER(isBitField);
   REGISTER_MATCHER(isCatchAll);
Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2139,5 +2139,20 @@
   functionDecl(hasTrailingReturn(;
 }
 
+TEST(IsAssignmentOperator, Basic) {
+  StatementMatcher BinAsgmtOperator = binaryOperator(isAssignmentOperator());
+  StatementMatcher CXXAsgmtOperator =
+  cxxOperatorCallExpr(isAssignmentOperator());
+
+  EXPECT_TRUE(matches("void x() { int a; a += 1; }", BinAsgmtOperator));
+  EXPECT_TRUE(matches("void x() { int a; a = 2; }", BinAsgmtOperator));
+  EXPECT_TRUE(matches("void x() { int a; a &= 3; }", BinAsgmtOperator));
+  EXPECT_TRUE(matches("struct S { S& operator=(const S&); };"
+  "void x() { S s1, s2; s1 = s2; }",
+  CXXAsgmtOperator));
+  EXPECT_TRUE(
+  notMatches("void x() { int a; if(a == 0) return; }", BinAsgmtOperator));
+}
+
 } // namespace ast_matchers
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r328619 - [analyzer] LoopUnrolling: update the matched assignment operators

2018-03-27 Thread Peter Szecsi via cfe-commits
Author: szepet
Date: Tue Mar 27 05:16:56 2018
New Revision: 328619

URL: http://llvm.org/viewvc/llvm-project?rev=328619&view=rev
Log:
[analyzer] LoopUnrolling: update the matched assignment operators

Extended the matched assignment operators when checking for bound changes in a 
body of the loop by using the freshly added isAssignmentOperator matcher.
This covers all the (current) possible assignments, tests added as well.

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


Modified:
cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
cfe/trunk/test/Analysis/loop-unrolling.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp?rev=328619&r1=328618&r2=328619&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp Tue Mar 27 05:16:56 2018
@@ -97,9 +97,7 @@ changeIntBoundNode(internal::Matcherhttp://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/loop-unrolling.cpp?rev=328619&r1=328618&r2=328619&view=diff
==
--- cfe/trunk/test/Analysis/loop-unrolling.cpp (original)
+++ cfe/trunk/test/Analysis/loop-unrolling.cpp Tue Mar 27 05:16:56 2018
@@ -99,13 +99,101 @@ int simple_no_unroll5() {
   return 0;
 }
 
+int no_unroll_assignment() {
+  for (int i = 0; i < 9; i++) {
+i = i + 1;
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+  }
+  return 0;
+}
+
+int no_unroll_assignment2() {
+  for (int i = 0; i < 9; i++) {
+i *= 2;
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+  }
+  return 0;
+}
+
+int no_unroll_assignment3() {
+  for (int i = 128; i > 0; i--) {
+i /= 2;
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+  }
+  return 0;
+}
+
+int no_unroll_assignment4() {
+  for (int i = 0; i < 9; i++) {
+i -= 2;
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+  }
+  return 0;
+}
+
+int no_unroll_assignment5() {
+  for (int i = 0; i < 9; i++) {
+i += 1;
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+  }
+  return 0;
+}
+
+int no_unroll_assignment6() {
+  for (int i = 128; i > 0; i--) {
+i >>= 1;
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+  }
+  return 0;
+}
+
+int no_unroll_assignment7() {
+  for (int i = 0; i < 512; i++) {
+i <<= 1;
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+  }
+  return 0;
+}
+
+int no_unroll_assignment8() {
+  for (int i = 0; i < 9; i++) {
+i %= 8;
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+  }
+  return 0;
+}
+
+int no_unroll_assignment9() {
+  for (int i = 0; i < 9; i++) {
+i &= 31;
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+  }
+  return 0;
+}
+
+int no_unroll_assignment10() {
+  for (int i = 0; i < 9; i++) {
+i |= 2;
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+  }
+  return 0;
+}
+
+int no_unroll_assignment11() {
+  for (int i = 0; i < 9; i++) {
+i ^= 2;
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+  }
+  return 0;
+}
+
 int make_new_branches_loop_cached() {
   for (int i = 0; i < 8; i++) {
 clang_analyzer_numTimesReached(); // expected-warning {{4}}
-if(getNum()){
-(void) i; // Since this Stmt does not change the State the analyzer
-  // won't make a new execution path but reuse the earlier 
nodes.
-  }
+if (getNum()) {
+  (void)i; // Since this Stmt does not change the State the analyzer
+   // won't make a new execution path but reuse the earlier nodes.
+}
   }
   clang_analyzer_warnIfReached(); // no-warning
   return 0;
@@ -115,7 +203,7 @@ int make_new_branches_loop_uncached() {
   int l = 2;
   for (int i = 0; i < 8; i++) {
 clang_analyzer_numTimesReached(); // expected-warning {{10}}
-if(getNum()){
+if (getNum()) {
   ++l;
 }
   }
@@ -127,7 +215,7 @@ int make_new_branches_loop_uncached2() {
   int l = 2;
   for (int i = 0; i < 8; i++) {
 clang_analyzer_numTimesReached(); // expected-warning {{10}}
-if(getNum()){
+if (getNum()) {
   ++l;
 }
 (void)&i; // This ensures that the loop won't be unrolled.
@@ -185,7 +273,7 @@ int nested_outer_unrolled() {
 for (j = 0; j < 9; ++j) {
   clang_analyzer_numTimesReached(); // expected-warning {{4}}
   a[j] = 22;
-  (void) &j; // ensures that the inner loop won't be unrolled
+  (void)&j; // ensures that the inner loop won't be unrolled
 }
 a[i] = 42;
   }
@@ -268,8 +356,8 @@ int recursion_unroll1(bool b) {
   int k = 2;
   for (int i = 0; i < 5; i++) {
 clang_analyzer_numTimesReached(); // expected-warning {{13}}
-if(i == 0 && b) // Splits the state in the first iteration but the 
recursion
-  

[PATCH] D38921: [analyzer] LoopUnrolling: update the matched assignment operators

2018-03-27 Thread Peter Szecsi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC328619: [analyzer] LoopUnrolling: update the matched 
assignment operators (authored by szepet, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D38921

Files:
  lib/StaticAnalyzer/Core/LoopUnrolling.cpp
  test/Analysis/loop-unrolling.cpp

Index: test/Analysis/loop-unrolling.cpp
===
--- test/Analysis/loop-unrolling.cpp
+++ test/Analysis/loop-unrolling.cpp
@@ -99,13 +99,101 @@
   return 0;
 }
 
+int no_unroll_assignment() {
+  for (int i = 0; i < 9; i++) {
+i = i + 1;
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+  }
+  return 0;
+}
+
+int no_unroll_assignment2() {
+  for (int i = 0; i < 9; i++) {
+i *= 2;
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+  }
+  return 0;
+}
+
+int no_unroll_assignment3() {
+  for (int i = 128; i > 0; i--) {
+i /= 2;
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+  }
+  return 0;
+}
+
+int no_unroll_assignment4() {
+  for (int i = 0; i < 9; i++) {
+i -= 2;
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+  }
+  return 0;
+}
+
+int no_unroll_assignment5() {
+  for (int i = 0; i < 9; i++) {
+i += 1;
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+  }
+  return 0;
+}
+
+int no_unroll_assignment6() {
+  for (int i = 128; i > 0; i--) {
+i >>= 1;
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+  }
+  return 0;
+}
+
+int no_unroll_assignment7() {
+  for (int i = 0; i < 512; i++) {
+i <<= 1;
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+  }
+  return 0;
+}
+
+int no_unroll_assignment8() {
+  for (int i = 0; i < 9; i++) {
+i %= 8;
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+  }
+  return 0;
+}
+
+int no_unroll_assignment9() {
+  for (int i = 0; i < 9; i++) {
+i &= 31;
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+  }
+  return 0;
+}
+
+int no_unroll_assignment10() {
+  for (int i = 0; i < 9; i++) {
+i |= 2;
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+  }
+  return 0;
+}
+
+int no_unroll_assignment11() {
+  for (int i = 0; i < 9; i++) {
+i ^= 2;
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+  }
+  return 0;
+}
+
 int make_new_branches_loop_cached() {
   for (int i = 0; i < 8; i++) {
 clang_analyzer_numTimesReached(); // expected-warning {{4}}
-if(getNum()){
-(void) i; // Since this Stmt does not change the State the analyzer
-  // won't make a new execution path but reuse the earlier nodes.
-  }
+if (getNum()) {
+  (void)i; // Since this Stmt does not change the State the analyzer
+   // won't make a new execution path but reuse the earlier nodes.
+}
   }
   clang_analyzer_warnIfReached(); // no-warning
   return 0;
@@ -115,7 +203,7 @@
   int l = 2;
   for (int i = 0; i < 8; i++) {
 clang_analyzer_numTimesReached(); // expected-warning {{10}}
-if(getNum()){
+if (getNum()) {
   ++l;
 }
   }
@@ -127,7 +215,7 @@
   int l = 2;
   for (int i = 0; i < 8; i++) {
 clang_analyzer_numTimesReached(); // expected-warning {{10}}
-if(getNum()){
+if (getNum()) {
   ++l;
 }
 (void)&i; // This ensures that the loop won't be unrolled.
@@ -185,7 +273,7 @@
 for (j = 0; j < 9; ++j) {
   clang_analyzer_numTimesReached(); // expected-warning {{4}}
   a[j] = 22;
-  (void) &j; // ensures that the inner loop won't be unrolled
+  (void)&j; // ensures that the inner loop won't be unrolled
 }
 a[i] = 42;
   }
@@ -268,8 +356,8 @@
   int k = 2;
   for (int i = 0; i < 5; i++) {
 clang_analyzer_numTimesReached(); // expected-warning {{13}}
-if(i == 0 && b) // Splits the state in the first iteration but the recursion
-// call will be unrolled anyway since the condition is known there.
+if (i == 0 && b)  // Splits the state in the first iteration but the recursion
+  // call will be unrolled anyway since the condition is known there.
   recursion_unroll1(false);
 clang_analyzer_numTimesReached(); // expected-warning {{14}}
   }
@@ -281,7 +369,7 @@
   int k = 0;
   for (int i = 0; i < 5; i++) {
 clang_analyzer_numTimesReached(); // expected-warning {{9}}
-if(i == 0 && b)
+if (i == 0 && b)
   recursion_unroll2(false);
 clang_analyzer_numTimesReached(); // expected-warning {{9}}
   }
@@ -307,7 +395,7 @@
   int k = 2;
   for (int i = 0; i < 5; i++) {
 clang_analyzer_numTimesReached(); // expected-warning {{13}}
-if(i == 0 && b) {
+if (i == 0 && b) {
   recursion_unroll4(false);
   continue;
 }
Index: lib/StaticAnalyzer/Core/LoopUnrolling.cpp
===
--- lib/StaticAnalyzer/Core/L

[PATCH] D44559: [Sema] Wrong width of result of mul operation

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

In https://reviews.llvm.org/D44559#1049049, @avt77 wrote:

> ...
>  But I don't mind to close the review - and the corresponding bug of course.


I disagree with closing the bug.
It's a real issue that is not detected/diagnosed by anything in clang 
(diagnostic, sanitizer).

It seems we are in a deadlock here :)


https://reviews.llvm.org/D44559



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


[PATCH] D44816: [clang-format] Do not insert space before closing brace in ObjC dict literal

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

Generally looks good, one minor simplification.




Comment at: lib/Format/TokenAnnotator.cpp:2484
+  if (Right.is(tok::r_brace) && Right.MatchingParen &&
+  Right.MatchingParen->is(TT_DictLiteral) &&
+  Right.MatchingParen->Previous &&

Could you use Right.MatchingParen->endsSequence(TT_DictLiteral, tok::at) here?


Repository:
  rC Clang

https://reviews.llvm.org/D44816



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


[PATCH] D44921: [PowerPC] Option for secure plt mode

2018-03-27 Thread Strahinja Petrovic via Phabricator via cfe-commits
spetrovic created this revision.
spetrovic added reviewers: jhibbits, nemanjai.
Herald added a subscriber: kbarton.

This patch enables option for secure plt mode in clang (-msecure-plt). This 
feature is supported in backend also (https://reviews.llvm.org/D42112).


https://reviews.llvm.org/D44921

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Arch/PPC.cpp
  lib/Driver/ToolChains/Arch/PPC.h
  test/Driver/ppc-features.cpp


Index: test/Driver/ppc-features.cpp
===
--- test/Driver/ppc-features.cpp
+++ test/Driver/ppc-features.cpp
@@ -22,6 +22,10 @@
 // RUN: %clang -target powerpc-unknown-linux-gnu %s -msoft-float -mhard-float 
-### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-SOFTHARD %s
 // CHECK-SOFTHARD-NOT: "-target-feature" "-hard-float"
 
+// check -msecure-plt option for ppc32
+// RUN: %clang -target powerpc-unknown-linux-gnu -msecure-plt %s  -### -o %t.o 
2>&1 | FileCheck --check-prefix=CHECK-SECUREPLT %s
+// CHECK-SECUREPLT: "-target-feature" "+secure-plt"
+
 // check -mfloat-abi=x option
 // RUN: %clang -target powerpc-unknown-linux-gnu %s -mfloat-abi=x -### -o %t.o 
2>&1 | FileCheck --check-prefix=CHECK-ERRMSG %s
 // CHECK-ERRMSG: error: invalid float ABI '-mfloat-abi=x'
Index: lib/Driver/ToolChains/Arch/PPC.h
===
--- lib/Driver/ToolChains/Arch/PPC.h
+++ lib/Driver/ToolChains/Arch/PPC.h
@@ -29,10 +29,17 @@
   Hard,
 };
 
+enum class ReadGOTPtrMode {
+  Bss,
+  SecurePlt,
+};
+
 FloatABI getPPCFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
 
 std::string getPPCTargetCPU(const llvm::opt::ArgList &Args);
 const char *getPPCAsmModeForCPU(StringRef Name);
+ReadGOTPtrMode getPPCReadGOTPtrMode(const Driver &D,
+   const llvm::opt::ArgList &Args);
 
 void getPPCTargetFeatures(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args,
Index: lib/Driver/ToolChains/Arch/PPC.cpp
===
--- lib/Driver/ToolChains/Arch/PPC.cpp
+++ lib/Driver/ToolChains/Arch/PPC.cpp
@@ -106,6 +106,17 @@
   ppc::FloatABI FloatABI = ppc::getPPCFloatABI(D, Args);
   if (FloatABI == ppc::FloatABI::Soft)
 Features.push_back("-hard-float");
+
+  ppc::ReadGOTPtrMode ReadGOT = ppc::getPPCReadGOTPtrMode(D, Args);
+  if (ReadGOT == ppc::ReadGOTPtrMode::SecurePlt)
+Features.push_back("+secure-plt");
+}
+
+ppc::ReadGOTPtrMode ppc::getPPCReadGOTPtrMode(const Driver &D, const ArgList 
&Args) {
+  ppc::ReadGOTPtrMode ReadGOT = ppc::ReadGOTPtrMode::Bss;
+  if (Args.getLastArg(options::OPT_msecure_plt))
+ReadGOT = ppc::ReadGOTPtrMode::SecurePlt;
+  return ReadGOT;
 }
 
 ppc::FloatABI ppc::getPPCFloatABI(const Driver &D, const ArgList &Args) {
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1938,6 +1938,7 @@
 def mno_altivec : Flag<["-"], "mno-altivec">, Group;
 def mvsx : Flag<["-"], "mvsx">, Group;
 def mno_vsx : Flag<["-"], "mno-vsx">, Group;
+def msecure_plt : Flag<["-"], "msecure-plt">, Group;
 def mpower8_vector : Flag<["-"], "mpower8-vector">,
 Group;
 def mno_power8_vector : Flag<["-"], "mno-power8-vector">,


Index: test/Driver/ppc-features.cpp
===
--- test/Driver/ppc-features.cpp
+++ test/Driver/ppc-features.cpp
@@ -22,6 +22,10 @@
 // RUN: %clang -target powerpc-unknown-linux-gnu %s -msoft-float -mhard-float -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-SOFTHARD %s
 // CHECK-SOFTHARD-NOT: "-target-feature" "-hard-float"
 
+// check -msecure-plt option for ppc32
+// RUN: %clang -target powerpc-unknown-linux-gnu -msecure-plt %s  -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-SECUREPLT %s
+// CHECK-SECUREPLT: "-target-feature" "+secure-plt"
+
 // check -mfloat-abi=x option
 // RUN: %clang -target powerpc-unknown-linux-gnu %s -mfloat-abi=x -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-ERRMSG %s
 // CHECK-ERRMSG: error: invalid float ABI '-mfloat-abi=x'
Index: lib/Driver/ToolChains/Arch/PPC.h
===
--- lib/Driver/ToolChains/Arch/PPC.h
+++ lib/Driver/ToolChains/Arch/PPC.h
@@ -29,10 +29,17 @@
   Hard,
 };
 
+enum class ReadGOTPtrMode {
+  Bss,
+  SecurePlt,
+};
+
 FloatABI getPPCFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
 
 std::string getPPCTargetCPU(const llvm::opt::ArgList &Args);
 const char *getPPCAsmModeForCPU(StringRef Name);
+ReadGOTPtrMode getPPCReadGOTPtrMode(const Driver &D,
+	const llvm::opt::ArgList &Args);
 
 void getPPCTargetFeatures(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args,
Index: lib/Driver/ToolChains/Arch/PPC.cpp

[PATCH] D44815: [AArch64]: Add support for parsing rN registers.

2018-03-27 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover added a comment.

The warning you're seeing is because without an operand modifier Clang always 
chooses an x-register in its textual assembly expansion. This 64-bit default is 
compared to the underlying C type to determine whether a warning should be 
emitted, and I think that's reasonable. The C type is all that's available for 
most uses (without a `register` keyword) and it seems consistent to use it even 
when `register` has been specified on the variable.

Where we might want to introduce a new warning is for a mismatch like:

  register uint64_t var asm("w0"); // 64-bits in a 32-bit register. Magic!

But that seems pretty separate to this patch really.

But


Repository:
  rC Clang

https://reviews.llvm.org/D44815



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


r328621 - Revert "[clang-format] Remove empty lines before }[; ] // comment"

2018-03-27 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Tue Mar 27 06:14:29 2018
New Revision: 328621

URL: http://llvm.org/viewvc/llvm-project?rev=328621&view=rev
Log:
Revert "[clang-format] Remove empty lines before }[;] // comment"

This reverts commit r327861.

The empty line before namespaces is desired in some places. We need a
better approach to handle this.

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

Modified: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp?rev=328621&r1=328620&r2=328621&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp Tue Mar 27 06:14:29 2018
@@ -1133,12 +1133,8 @@ void UnwrappedLineFormatter::formatFirst
   std::min(RootToken.NewlinesBefore, Style.MaxEmptyLinesToKeep + 1);
   // Remove empty lines before "}" where applicable.
   if (RootToken.is(tok::r_brace) &&
-  // Look for "}", "} // comment", "};" or "}; // comment".
   (!RootToken.Next ||
-   (RootToken.Next->is(tok::comment) && !RootToken.Next->Next) ||
-   (RootToken.Next->is(tok::semi) &&
-(!RootToken.Next->Next || (RootToken.Next->Next->is(tok::comment) &&
-   !RootToken.Next->Next->Next)
+   (RootToken.Next->is(tok::semi) && !RootToken.Next->Next)))
 Newlines = std::min(Newlines, 1u);
   // Remove empty lines at the start of nested blocks (lambdas/arrow functions)
   if (PreviousLine == nullptr && Line.Level > 0)

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=328621&r1=328620&r2=328621&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Mar 27 06:14:29 2018
@@ -276,6 +276,7 @@ TEST_F(FormatTest, RemovesEmptyLines) {
"\n"
"}"));
 
+  // FIXME: This is slightly inconsistent.
   FormatStyle LLVMWithNoNamespaceFix = getLLVMStyle();
   LLVMWithNoNamespaceFix.FixNamespaceComments = false;
   EXPECT_EQ("namespace {\n"
@@ -294,25 +295,12 @@ TEST_F(FormatTest, RemovesEmptyLines) {
"}"));
   EXPECT_EQ("namespace {\n"
 "int i;\n"
-"};",
-format("namespace {\n"
-   "int i;\n"
-   "\n"
-   "};"));
-  EXPECT_EQ("namespace {\n"
-"int i;\n"
+"\n"
 "} // namespace",
 format("namespace {\n"
"int i;\n"
"\n"
"}  // namespace"));
-  EXPECT_EQ("namespace {\n"
-"int i;\n"
-"}; // namespace",
-format("namespace {\n"
-   "int i;\n"
-   "\n"
-   "};  // namespace"));
 
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;


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


[PATCH] D44927: Enable msan unconditionally on Linux

2018-03-27 Thread vit9696 via Phabricator via cfe-commits
vit9696 created this revision.
vit9696 added a reviewer: eugenis.
Herald added a subscriber: cfe-commits.

Memeory sanitizer compatibility are already done in 
MemorySanitizer::doInitialization. It verifies whether the necessary offsets 
exist and bails out if not. For this reason it is no good to duplicate two 
checks in two projects. This patch removes clang check and postpones msan 
compatibility validation till MemorySanitizer::doInitialization.

Another reason for this patch is to allow using msan with any CPU (given 
compatible runtime) and custom mapping provided via the arguments added by 
https://reviews.llvm.org/D44926.


Repository:
  rC Clang

https://reviews.llvm.org/D44927

Files:
  lib/Driver/ToolChains/Linux.cpp


Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -863,16 +863,15 @@
   Res |= SanitizerKind::Fuzzer;
   Res |= SanitizerKind::FuzzerNoLink;
   Res |= SanitizerKind::KernelAddress;
+  Res |= SanitizerKind::Memory;
   Res |= SanitizerKind::Vptr;
   Res |= SanitizerKind::SafeStack;
   if (IsX86_64 || IsMIPS64 || IsAArch64)
 Res |= SanitizerKind::DataFlow;
   if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch || IsPowerPC64)
 Res |= SanitizerKind::Leak;
   if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64)
 Res |= SanitizerKind::Thread;
-  if (IsX86_64 || IsMIPS64 || IsPowerPC64 || IsAArch64)
-Res |= SanitizerKind::Memory;
   if (IsX86_64 || IsMIPS64)
 Res |= SanitizerKind::Efficiency;
   if (IsX86 || IsX86_64)


Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -863,16 +863,15 @@
   Res |= SanitizerKind::Fuzzer;
   Res |= SanitizerKind::FuzzerNoLink;
   Res |= SanitizerKind::KernelAddress;
+  Res |= SanitizerKind::Memory;
   Res |= SanitizerKind::Vptr;
   Res |= SanitizerKind::SafeStack;
   if (IsX86_64 || IsMIPS64 || IsAArch64)
 Res |= SanitizerKind::DataFlow;
   if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch || IsPowerPC64)
 Res |= SanitizerKind::Leak;
   if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64)
 Res |= SanitizerKind::Thread;
-  if (IsX86_64 || IsMIPS64 || IsPowerPC64 || IsAArch64)
-Res |= SanitizerKind::Memory;
   if (IsX86_64 || IsMIPS64)
 Res |= SanitizerKind::Efficiency;
   if (IsX86 || IsX86_64)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r328622 - [clang-move] Fix test failing due to clang-format change

2018-03-27 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Tue Mar 27 06:39:33 2018
New Revision: 328622

URL: http://llvm.org/viewvc/llvm-project?rev=328622&view=rev
Log:
[clang-move] Fix test failing due to clang-format change

r328621 reverted the removal of empty lines before the closing `}` in
namespaces.

Modified:
clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp

Modified: clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp?rev=328622&r1=328621&r2=328622&view=diff
==
--- clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp Tue Mar 
27 06:39:33 2018
@@ -335,6 +335,7 @@
 // CHECK-NEW-H-NEXT: void Fun1();
 // CHECK-NEW-H-SAME: {{[[:space:]]}}
 // CHECK-NEW-H-NEXT: inline void Fun2() {}
+// CHECK-NEW-H-SAME: {{[[:space:]]}}
 // CHECK-NEW-H-NEXT: } // namespace a
 
 
@@ -412,6 +413,7 @@
 // CHECK-NEW-CPP-NEXT: }
 // CHECK-NEW-CPP-SAME: {{[[:space:]]}}
 // CHECK-NEW-CPP-NEXT: void Fun1() { HelperFun5(); }
+// CHECK-NEW-CPP-SAME: {{[[:space:]]}}
 // CHECK-NEW-CPP-NEXT: } // namespace a
 // CHECK-NEW-CPP-SAME: {{[[:space:]]}}
 // CHECK-NEW-CPP-NEXT: namespace b {


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


r328623 - Move a ref-counted pointer instead of copying it. NFC.

2018-03-27 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Tue Mar 27 07:02:06 2018
New Revision: 328623

URL: http://llvm.org/viewvc/llvm-project?rev=328623&view=rev
Log:
Move a ref-counted pointer instead of copying it. NFC.

Modified:
cfe/trunk/lib/Tooling/Tooling.cpp

Modified: cfe/trunk/lib/Tooling/Tooling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=328623&r1=328622&r2=328623&view=diff
==
--- cfe/trunk/lib/Tooling/Tooling.cpp (original)
+++ cfe/trunk/lib/Tooling/Tooling.cpp Tue Mar 27 07:02:06 2018
@@ -361,7 +361,7 @@ ClangTool::ClangTool(const CompilationDa
  IntrusiveRefCntPtr BaseFS)
 : Compilations(Compilations), SourcePaths(SourcePaths),
   PCHContainerOps(std::move(PCHContainerOps)),
-  OverlayFileSystem(new vfs::OverlayFileSystem(BaseFS)),
+  OverlayFileSystem(new vfs::OverlayFileSystem(std::move(BaseFS))),
   InMemoryFileSystem(new vfs::InMemoryFileSystem),
   Files(new FileManager(FileSystemOptions(), OverlayFileSystem)) {
   OverlayFileSystem->pushOverlay(InMemoryFileSystem);


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


[PATCH] D44931: [WebAssembly] Use Windows EH instructions for Wasm EH

2018-03-27 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin created this revision.
aheejin added reviewers: majnemer, dschuff.
Herald added subscribers: cfe-commits, sunfish, jgravelle-google, sbc100, jfb.

Because wasm control flow needs to be structured, using WinEH
instructions to support wasm EH brings several benefits. This patch
makes wasm EH uses Windows EH instructions, with some changes:

1. Because wasm uses a single catch block to catch all C++ exceptions, this 
merges all catch clauses into a single catchpad, within which we test the EH 
selector as in Itanium EH.
2. Generates a call to `__clang_call_terminate` in case a cleanup throws. Wasm 
does not have a runtime to handle this.
3. In case there is no catch-all clause, inserts a call to `__cxa_rethrow` at 
the end of a catchpad in order to unwind to an enclosing EH scope.


Repository:
  rC Clang

https://reviews.llvm.org/D44931

Files:
  lib/CodeGen/CGCXXABI.h
  lib/CodeGen/CGCleanup.cpp
  lib/CodeGen/CGCleanup.h
  lib/CodeGen/CGException.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/wasm-eh.cpp

Index: test/CodeGenCXX/wasm-eh.cpp
===
--- /dev/null
+++ test/CodeGenCXX/wasm-eh.cpp
@@ -0,0 +1,346 @@
+// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 %s -triple wasm64-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
+
+void may_throw();
+void dont_throw() noexcept;
+
+struct Cleanup {
+  ~Cleanup() { dont_throw(); }
+};
+
+// Multiple catch clauses w/o catch-all
+void test0() {
+  try {
+may_throw();
+  } catch (int) {
+dont_throw();
+  } catch (double) {
+dont_throw();
+  }
+}
+
+// CHECK-LABEL: define void @_Z5test0v() {{.*}} personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+
+// CHECK:   %[[INT_ALLOCA:.*]] = alloca i32
+// CHECK:   invoke void @_Z9may_throwv()
+// CHECK-NEXT:   to label %[[NORMAL_BB:.*]] unwind label %[[CATCHDISPATCH_BB:.*]]
+
+// CHECK: [[CATCHDISPATCH_BB]]:
+// CHECK-NEXT:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* bitcast (i8** @_ZTIi to i8*), i8* bitcast (i8** @_ZTId to i8*)]
+// CHECK-NEXT:   %[[EXN:.*]] = call i8* @llvm.wasm.get.exception()
+// CHECK-NEXT:   store i8* %[[EXN]], i8** %exn.slot
+// CHECK-NEXT:   %[[SELECTOR:.*]] = call i32 @llvm.wasm.get.ehselector()
+// CHECK-NEXT:   %[[TYPEID:.*]] = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #2
+// CHECK-NEXT:   %[[MATCHES:.*]] = icmp eq i32 %[[SELECTOR]], %[[TYPEID]]
+// CHECK-NEXT:   br i1 %[[MATCHES]], label %[[CATCH_INT_BB:.*]], label %[[CATCH_FALLTHROUGH_BB:.*]]
+
+// CHECK: [[CATCH_INT_BB]]:
+// CHECK-NEXT:   %[[EXN:.*]] = load i8*, i8** %exn.slot
+// CHECK-NEXT:   %[[ADDR:.*]] = call i8* @__cxa_begin_catch(i8* %[[EXN]]) {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   %[[ADDR_CAST:.*]] = bitcast i8* %[[ADDR]] to i32*
+// CHECK-NEXT:   %[[INT_VAL:.*]] = load i32, i32* %[[ADDR_CAST]]
+// CHECK-NEXT:   store i32 %[[INT_VAL]], i32* %[[INT_ALLOCA]]
+// CHECK-NEXT:   call void @_Z10dont_throwv() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   call void @__cxa_end_catch() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   catchret from %[[CATCHPAD]] to label %[[CATCHRET_DEST_BB0:.*]]
+
+// CHECK: [[CATCHRET_DEST_BB0]]:
+// CHECK-NEXT:   br label %[[TRY_CONT_BB:.*]]
+
+// CHECK: [[CATCH_FALLTHROUGH_BB]]
+// CHECK-NEXT:   %[[TYPEID:.*]] = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTId to i8*)) #2
+// CHECK-NEXT:   %[[MATCHES:.*]] = icmp eq i32 %[[SELECTOR]], %[[TYPEID]]
+// CHECK-NEXT:   br i1 %[[MATCHES]], label %[[CATCH_FLOAT_BB:.*]], label %[[RETHROW_BB:.*]]
+
+// CHECK: [[CATCH_FLOAT_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label %[[CATCHRET_DEST_BB1:.*]]
+
+// CHECK: [[CATCHRET_DEST_BB1]]:
+// CHECK-NEXT:   br label %[[TRY_CONT_BB]]
+
+// CHECK: [[RETHROW_BB]]:
+// CHECK-NEXT:   call void @__cxa_rethrow() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   unreachable
+
+
+// Single catch-all
+void test1() {
+  try {
+may_throw();
+  } catch (...) {
+dont_throw();
+  }
+}
+
+// CATCH-LABEL: @_Z5test1v()
+
+// CHECK:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* null]
+// CHECK:   br label %[[CATCH_ALL_BB:.*]]
+
+// CHECK: [[CATCH_ALL_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label
+
+
+// Multiple catch clauses w/ catch-all
+void test2() {
+  try {
+may_throw();
+  } catch (int) {
+dont_throw();
+  } catch (...) {
+dont_throw();
+  }
+}
+
+// CHECK-LABEL: @_Z5test2v()
+
+// CHECK:   %[[CATCHSWITCH:.*]]

[PATCH] D44931: [WebAssembly] Use Windows EH instructions for Wasm EH

2018-03-27 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin updated this revision to Diff 139920.
aheejin added a comment.

- Comment fix


Repository:
  rC Clang

https://reviews.llvm.org/D44931

Files:
  lib/CodeGen/CGCXXABI.h
  lib/CodeGen/CGCleanup.cpp
  lib/CodeGen/CGCleanup.h
  lib/CodeGen/CGException.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/wasm-eh.cpp

Index: test/CodeGenCXX/wasm-eh.cpp
===
--- /dev/null
+++ test/CodeGenCXX/wasm-eh.cpp
@@ -0,0 +1,346 @@
+// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 %s -triple wasm64-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
+
+void may_throw();
+void dont_throw() noexcept;
+
+struct Cleanup {
+  ~Cleanup() { dont_throw(); }
+};
+
+// Multiple catch clauses w/o catch-all
+void test0() {
+  try {
+may_throw();
+  } catch (int) {
+dont_throw();
+  } catch (double) {
+dont_throw();
+  }
+}
+
+// CHECK-LABEL: define void @_Z5test0v() {{.*}} personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+
+// CHECK:   %[[INT_ALLOCA:.*]] = alloca i32
+// CHECK:   invoke void @_Z9may_throwv()
+// CHECK-NEXT:   to label %[[NORMAL_BB:.*]] unwind label %[[CATCHDISPATCH_BB:.*]]
+
+// CHECK: [[CATCHDISPATCH_BB]]:
+// CHECK-NEXT:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* bitcast (i8** @_ZTIi to i8*), i8* bitcast (i8** @_ZTId to i8*)]
+// CHECK-NEXT:   %[[EXN:.*]] = call i8* @llvm.wasm.get.exception()
+// CHECK-NEXT:   store i8* %[[EXN]], i8** %exn.slot
+// CHECK-NEXT:   %[[SELECTOR:.*]] = call i32 @llvm.wasm.get.ehselector()
+// CHECK-NEXT:   %[[TYPEID:.*]] = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #2
+// CHECK-NEXT:   %[[MATCHES:.*]] = icmp eq i32 %[[SELECTOR]], %[[TYPEID]]
+// CHECK-NEXT:   br i1 %[[MATCHES]], label %[[CATCH_INT_BB:.*]], label %[[CATCH_FALLTHROUGH_BB:.*]]
+
+// CHECK: [[CATCH_INT_BB]]:
+// CHECK-NEXT:   %[[EXN:.*]] = load i8*, i8** %exn.slot
+// CHECK-NEXT:   %[[ADDR:.*]] = call i8* @__cxa_begin_catch(i8* %[[EXN]]) {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   %[[ADDR_CAST:.*]] = bitcast i8* %[[ADDR]] to i32*
+// CHECK-NEXT:   %[[INT_VAL:.*]] = load i32, i32* %[[ADDR_CAST]]
+// CHECK-NEXT:   store i32 %[[INT_VAL]], i32* %[[INT_ALLOCA]]
+// CHECK-NEXT:   call void @_Z10dont_throwv() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   call void @__cxa_end_catch() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   catchret from %[[CATCHPAD]] to label %[[CATCHRET_DEST_BB0:.*]]
+
+// CHECK: [[CATCHRET_DEST_BB0]]:
+// CHECK-NEXT:   br label %[[TRY_CONT_BB:.*]]
+
+// CHECK: [[CATCH_FALLTHROUGH_BB]]
+// CHECK-NEXT:   %[[TYPEID:.*]] = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTId to i8*)) #2
+// CHECK-NEXT:   %[[MATCHES:.*]] = icmp eq i32 %[[SELECTOR]], %[[TYPEID]]
+// CHECK-NEXT:   br i1 %[[MATCHES]], label %[[CATCH_FLOAT_BB:.*]], label %[[RETHROW_BB:.*]]
+
+// CHECK: [[CATCH_FLOAT_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label %[[CATCHRET_DEST_BB1:.*]]
+
+// CHECK: [[CATCHRET_DEST_BB1]]:
+// CHECK-NEXT:   br label %[[TRY_CONT_BB]]
+
+// CHECK: [[RETHROW_BB]]:
+// CHECK-NEXT:   call void @__cxa_rethrow() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   unreachable
+
+
+// Single catch-all
+void test1() {
+  try {
+may_throw();
+  } catch (...) {
+dont_throw();
+  }
+}
+
+// CATCH-LABEL: @_Z5test1v()
+
+// CHECK:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* null]
+// CHECK:   br label %[[CATCH_ALL_BB:.*]]
+
+// CHECK: [[CATCH_ALL_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label
+
+
+// Multiple catch clauses w/ catch-all
+void test2() {
+  try {
+may_throw();
+  } catch (int) {
+dont_throw();
+  } catch (...) {
+dont_throw();
+  }
+}
+
+// CHECK-LABEL: @_Z5test2v()
+
+// CHECK:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* bitcast (i8** @_ZTIi to i8*), i8* null]
+// CHECK:   br i1 %{{.*}}, label %[[CATCH_INT_BB:.*]], label %[[CATCH_ALL_BB:.*]]
+
+// CHECK: [[CATCH_INT_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label
+
+// CHECK: [[CATCH_ALL_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label
+
+
+// Cleanup
+void test3() {
+  Cleanup c;
+  may_throw();
+}
+
+// CHECK-LABEL: @_Z5test3v()
+
+// CHECK:   invoke void @_Z9may_throwv()
+// CHECK-NEXT:   to label {{.*}} unwind label %[[EHCLEANUP_BB:.*]]
+
+// CHECK: [[EHCLEANUP_BB]

[PATCH] D44932: [CodeComplete] Fix completion in the middle of ident in ctor lists.

2018-03-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: sammccall, aaron.ballman, bkramer, sepavloff.

The example that was broken before (^ designate completion points):

  class Foo {
Foo() : fie^ld^() {} // no completions were provided here.
int field;
  };

To fix it we don't cut off lexing after an identifier followed by code
completion token is lexed. Instead we skip the rest of identifier and
continue lexing.
This is consistent with behavior of completion when completion token is
right before the identifier.


Repository:
  rC Clang

https://reviews.llvm.org/D44932

Files:
  lib/Lex/Lexer.cpp
  test/CodeCompletion/ctor-initializer.cpp


Index: test/CodeCompletion/ctor-initializer.cpp
===
--- test/CodeCompletion/ctor-initializer.cpp
+++ test/CodeCompletion/ctor-initializer.cpp
@@ -58,5 +58,9 @@
   // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:9 %s 
-o - | FileCheck -check-prefix=CHECK-CC7 %s
   // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:57:9 %s 
-o - | FileCheck -check-prefix=CHECK-CC7 %s
   // CHECK-CC7: COMPLETION: Pattern : member1(<#args#>
+  // Check in the middle and at the end of identifier too.
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:13 %s 
-o - | FileCheck -check-prefix=CHECK-CC8 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:16 %s 
-o - | FileCheck -check-prefix=CHECK-CC8 %s
+  // CHECK-CC8: COMPLETION: Pattern : member2(<#args#>
   int member1, member2;
 };
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -1656,7 +1656,17 @@
 && II->getObjCKeywordID() == tok::objc_not_keyword) {
   // Return the code-completion token.
   Result.setKind(tok::code_completion);
-  cutOffLexing();
+  // Skip the code-completion char and all immediate identifier characters.
+  // This ensures we get consistent behavior when completing at any point 
in
+  // an identifier (i.e. at the start, in the middle, at the end). Note 
that
+  // only simple cases (i.e. [a-zA-Z0-9_]) are supported to keep the code
+  // simpler.
+  assert(*CurPtr == 0 && "Completion character must be 0");
+  ++CurPtr;
+  assert(CurPtr < BufferEnd && "eof at completion point");
+  while (isIdentifierBody(*CurPtr))
+++CurPtr;
+  BufferPtr = CurPtr;
   return true;
 }
 return true;


Index: test/CodeCompletion/ctor-initializer.cpp
===
--- test/CodeCompletion/ctor-initializer.cpp
+++ test/CodeCompletion/ctor-initializer.cpp
@@ -58,5 +58,9 @@
   // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:9 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
   // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:57:9 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
   // CHECK-CC7: COMPLETION: Pattern : member1(<#args#>
+  // Check in the middle and at the end of identifier too.
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:13 %s -o - | FileCheck -check-prefix=CHECK-CC8 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:16 %s -o - | FileCheck -check-prefix=CHECK-CC8 %s
+  // CHECK-CC8: COMPLETION: Pattern : member2(<#args#>
   int member1, member2;
 };
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -1656,7 +1656,17 @@
 && II->getObjCKeywordID() == tok::objc_not_keyword) {
   // Return the code-completion token.
   Result.setKind(tok::code_completion);
-  cutOffLexing();
+  // Skip the code-completion char and all immediate identifier characters.
+  // This ensures we get consistent behavior when completing at any point in
+  // an identifier (i.e. at the start, in the middle, at the end). Note that
+  // only simple cases (i.e. [a-zA-Z0-9_]) are supported to keep the code
+  // simpler.
+  assert(*CurPtr == 0 && "Completion character must be 0");
+  ++CurPtr;
+  assert(CurPtr < BufferEnd && "eof at completion point");
+  while (isIdentifierBody(*CurPtr))
+++CurPtr;
+  BufferPtr = CurPtr;
   return true;
 }
 return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44480: [Sema] Don't skip function bodies with 'auto' without trailing return type

2018-03-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 139926.
ilya-biryukov added a comment.

- Replace auto with explicit type


Repository:
  rC Clang

https://reviews.llvm.org/D44480

Files:
  lib/Sema/SemaDecl.cpp
  test/CodeCompletion/crash-skipped-bodies-template-inst.cpp


Index: test/CodeCompletion/crash-skipped-bodies-template-inst.cpp
===
--- /dev/null
+++ test/CodeCompletion/crash-skipped-bodies-template-inst.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:24:5 %s -o - 2>&1 | 
FileCheck %s
+template 
+auto make_func() {
+  struct impl {
+impl* func() {
+  int x;
+  if (x = 10) {}
+  // Check that body of this function is actually skipped.
+  // CHECK-NOT: crash-skipped-bodies-template-inst.cpp:7:{{[0-9]+}}: 
warning: using the result of an assignment as a condition without parentheses
+  return this;
+}
+  };
+
+  int x;
+  if (x = 10) {}
+  // Check that this function is not skipped.
+  // CHECK: crash-skipped-bodies-template-inst.cpp:15:9: warning: using the 
result of an assignment as a condition without parentheses
+  return impl();
+}
+
+void foo() {
+  []() {
+make_func();
+m
+// CHECK: COMPLETION: make_func : [#auto#]make_func<<#class T#>>()
+  };
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -12603,9 +12603,15 @@
   // rest of the file.
   // We cannot skip the body of a function with an undeduced return type,
   // because any callers of that function need to know the type.
-  if (const FunctionDecl *FD = D->getAsFunction())
-if (FD->isConstexpr() || FD->getReturnType()->isUndeducedType())
+  if (const FunctionDecl *FD = D->getAsFunction()) {
+if (FD->isConstexpr())
   return false;
+// We can't simply call Type::isUndeducedType here, because it returns
+// false on C++14's auto return type without trailing return type.
+DeducedType *DT = FD->getReturnType()->getContainedDeducedType();
+if (DT && DT->getDeducedType().isNull())
+  return false;
+  }
   return Consumer.shouldSkipFunctionBody(D);
 }
 


Index: test/CodeCompletion/crash-skipped-bodies-template-inst.cpp
===
--- /dev/null
+++ test/CodeCompletion/crash-skipped-bodies-template-inst.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:24:5 %s -o - 2>&1 | FileCheck %s
+template 
+auto make_func() {
+  struct impl {
+impl* func() {
+  int x;
+  if (x = 10) {}
+  // Check that body of this function is actually skipped.
+  // CHECK-NOT: crash-skipped-bodies-template-inst.cpp:7:{{[0-9]+}}: warning: using the result of an assignment as a condition without parentheses
+  return this;
+}
+  };
+
+  int x;
+  if (x = 10) {}
+  // Check that this function is not skipped.
+  // CHECK: crash-skipped-bodies-template-inst.cpp:15:9: warning: using the result of an assignment as a condition without parentheses
+  return impl();
+}
+
+void foo() {
+  []() {
+make_func();
+m
+// CHECK: COMPLETION: make_func : [#auto#]make_func<<#class T#>>()
+  };
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -12603,9 +12603,15 @@
   // rest of the file.
   // We cannot skip the body of a function with an undeduced return type,
   // because any callers of that function need to know the type.
-  if (const FunctionDecl *FD = D->getAsFunction())
-if (FD->isConstexpr() || FD->getReturnType()->isUndeducedType())
+  if (const FunctionDecl *FD = D->getAsFunction()) {
+if (FD->isConstexpr())
   return false;
+// We can't simply call Type::isUndeducedType here, because it returns
+// false on C++14's auto return type without trailing return type.
+DeducedType *DT = FD->getReturnType()->getContainedDeducedType();
+if (DT && DT->getDeducedType().isNull())
+  return false;
+  }
   return Consumer.shouldSkipFunctionBody(D);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44480: [Sema] Don't skip function bodies with 'auto' without trailing return type

2018-03-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov marked an inline comment as done.
ilya-biryukov added a comment.

I hit that bug in practice a few days ago when playing around with a C++17 
codebase. It makes completion totally unusable when functions with auto-deduced 
return type are used.
@rsmith, any chance you could take a look? Or maybe suggest someone else as a 
reviewer?


Repository:
  rC Clang

https://reviews.llvm.org/D44480



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


[PATCH] D44934: [analyzer] Improve the modeling of `memset()`.

2018-03-27 Thread Henry Wong via Phabricator via cfe-commits
MTC created this revision.
MTC added reviewers: dcoughlin, NoQ, xazax.hun, a.sidorin.
Herald added subscribers: cfe-commits, rnkovacs, szepet.
Herald added a reviewer: george.karpenkov.

This patch originates from https://reviews.llvm.org/D31868. There are two key 
points in this 
patch:

- Add `OverwriteRegion()`, this method used to model `memset()` or something 
like that.
- Improve the modeling of `memset`.

For `OverwriteRegion()`, is basically invalidate region and bind default. But I 
think this 
method requires more in-depth thinking and more extensive testing.

For `evalMemset()`, this patch only considers the case where the buffer's 
offset is zero. And
if the whole region is `memset`ed, bind a default value. According to the value 
for 
overwriting, decide how to update the string length.

For `void *memset(void *dest, int ch, size_t count)`:

1). offset is 0, `ch` is `'\0'` and `count` < dest-buffer's length. 
Invalidate the buffer and set the string length to 0.

2). offset is 0, `ch` is `'\0'` and `count` == dest-buffer's length.
Bind `\0` to the buffer with default binding and set the string length to 0.

3). offset is 0, `ch` is not `'\0'` and `count` < dest-buffer's length.
Invalidate the buffer and set the string length >= `count`.

4). offset is 0, `ch` is not `'\0'` and `count` == dest-buffer's length.
Bind `ch` to the buffer and set the string length >= `count`.

I have tested this patch on `sqlite`, but there's no difference int the 
warnings.

Thanks in advance for the review!


Repository:
  rC Clang

https://reviews.llvm.org/D44934

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  lib/StaticAnalyzer/Core/ProgramState.cpp
  lib/StaticAnalyzer/Core/RegionStore.cpp
  lib/StaticAnalyzer/Core/Store.cpp
  test/Analysis/bstring.cpp
  test/Analysis/null-deref-ps-region.c
  test/Analysis/string.c

Index: test/Analysis/string.c
===
--- test/Analysis/string.c
+++ test/Analysis/string.c
@@ -1,7 +1,8 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_analyze_cc1 -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_analyze_cc1 -DVARIANT -analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_analyze_cc1 -DUSE_BUILTINS -DVARIANT -analyzer-checker=alpha.security.taint,core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.cstring,unix.Malloc,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_analyze_cc1 -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,unix.Malloc,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_analyze_cc1 -DVARIANT -analyzer-checker=core,unix.cstring,unix.Malloc,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_analyze_cc1 -DUSE_BUILTINS -DVARIANT -analyzer-checker=alpha.security.taint,core,unix.cstring,unix.Malloc,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_analyze_cc1 -DSUPPRESS_OUT_OF_BOUND -analyzer-checker=core,unix.cstring,unix.Malloc,alpha.unix.cstring.BufferOverlap,alpha.unix.cstring.NotNullTerminated,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s
 
 //===--===
 // Declarations
@@ -1159,6 +1160,248 @@
   clang_analyzer_eval(str[1] == 'b'); // expected-warning{{UNKNOWN}}
 }
 
+//===--===
+// memset()
+//===--===
+
+void *memset( void *dest, int ch, size_t count );
+
+void* malloc(size_t size);
+void free(void*);
+
+void memset1_char_array_null() {
+  char str[] = "abcd";
+  clang_analyzer_eval(strlen(str) == 4); // expected-warning{{TRUE}}
+  memset(str, '\0', 2);
+  clang_analyzer_eval(strlen(str) == 0); // expected-warning{{TRUE}}
+}
+
+void memset2_char_array_null() {
+  char str[] = "abcd";
+  clang_analyzer_eval(strlen(str) == 4); // expected-warning{{TRUE}}
+  memset(str, '\0', strlen(str) + 1);
+  clang_analyzer_eval(strlen(str) == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(str[2] == 0);  // expected-warning{{TRUE}}
+}
+
+void memset3_char_malloc_null() {
+  char *str = (char *)malloc(10 * sizeof(char));
+  memset(str + 1, '\0', 8);
+  clang

[PATCH] D44831: [clang-format] Refine ObjC guesser to handle child lines of child lines

2018-03-27 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton updated this revision to Diff 139929.
benhamilton marked 2 inline comments as done.
benhamilton added a comment.

- Simplify recursion. Remove static method LineContainsObjCCode().


Repository:
  rC Clang

https://reviews.llvm.org/D44831

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


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -12171,6 +12171,12 @@
 guessLanguage("foo.h", "#define FOO ({ std::string s; })"));
   EXPECT_EQ(FormatStyle::LK_ObjC,
 guessLanguage("foo.h", "#define FOO ({ NSString *s; })"));
+  EXPECT_EQ(
+  FormatStyle::LK_Cpp,
+  guessLanguage("foo.h", "#define FOO ({ foo(); ({ std::string s; }) })"));
+  EXPECT_EQ(
+  FormatStyle::LK_ObjC,
+  guessLanguage("foo.h", "#define FOO ({ foo(); ({ NSString *s; }) })"));
 }
 
 } // end namespace
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1514,8 +1514,8 @@
 "UIView",
 };
 
-auto LineContainsObjCCode = [&Keywords](const AnnotatedLine &Line) {
-  for (const FormatToken *FormatTok = Line.First; FormatTok;
+for (auto Line : AnnotatedLines) {
+  for (const FormatToken *FormatTok = Line->First; FormatTok;
FormatTok = FormatTok->Next) {
 if ((FormatTok->Previous && FormatTok->Previous->is(tok::at) &&
  (FormatTok->isObjCAtKeyword(tok::objc_interface) ||
@@ -1535,14 +1535,7 @@
TT_ObjCMethodSpecifier, TT_ObjCProperty)) {
   return true;
 }
-  }
-  return false;
-};
-for (auto Line : AnnotatedLines) {
-  if (LineContainsObjCCode(*Line))
-return true;
-  for (auto ChildLine : Line->Children) {
-if (LineContainsObjCCode(*ChildLine))
+if (guessIsObjC(Line->Children, Keywords))
   return true;
   }
 }


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -12171,6 +12171,12 @@
 guessLanguage("foo.h", "#define FOO ({ std::string s; })"));
   EXPECT_EQ(FormatStyle::LK_ObjC,
 guessLanguage("foo.h", "#define FOO ({ NSString *s; })"));
+  EXPECT_EQ(
+  FormatStyle::LK_Cpp,
+  guessLanguage("foo.h", "#define FOO ({ foo(); ({ std::string s; }) })"));
+  EXPECT_EQ(
+  FormatStyle::LK_ObjC,
+  guessLanguage("foo.h", "#define FOO ({ foo(); ({ NSString *s; }) })"));
 }
 
 } // end namespace
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1514,8 +1514,8 @@
 "UIView",
 };
 
-auto LineContainsObjCCode = [&Keywords](const AnnotatedLine &Line) {
-  for (const FormatToken *FormatTok = Line.First; FormatTok;
+for (auto Line : AnnotatedLines) {
+  for (const FormatToken *FormatTok = Line->First; FormatTok;
FormatTok = FormatTok->Next) {
 if ((FormatTok->Previous && FormatTok->Previous->is(tok::at) &&
  (FormatTok->isObjCAtKeyword(tok::objc_interface) ||
@@ -1535,14 +1535,7 @@
TT_ObjCMethodSpecifier, TT_ObjCProperty)) {
   return true;
 }
-  }
-  return false;
-};
-for (auto Line : AnnotatedLines) {
-  if (LineContainsObjCCode(*Line))
-return true;
-  for (auto ChildLine : Line->Children) {
-if (LineContainsObjCCode(*ChildLine))
+if (guessIsObjC(Line->Children, Keywords))
   return true;
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44831: [clang-format] Refine ObjC guesser to handle child lines of child lines

2018-03-27 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added inline comments.



Comment at: lib/Format/Format.cpp:1449
   const AdditionalKeywords &Keywords) {
+for (auto Line : AnnotatedLines)
+  if (LineContainsObjCCode(*Line, Keywords))

djasper wrote:
> I would not create a second function here. Just iterate over the tokens here 
> and call guessIsObjC recursively with Line->Children. That means we need one 
> less for loop overall, I think (I might be missing something).
Good call, done.

I don't know why I didn't do that first! For some reason, my brain thought 
`Line.Children` was an incompatible type..



Comment at: lib/Format/Format.cpp:1455
+
+  static bool LineContainsObjCCode(const AnnotatedLine &Line,
+   const AdditionalKeywords &Keywords) {

djasper wrote:
> Convention would be lineContainsObjCCode.
Removed.


Repository:
  rC Clang

https://reviews.llvm.org/D44831



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


[PATCH] D44816: [clang-format] Do not insert space before closing brace in ObjC dict literal

2018-03-27 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton updated this revision to Diff 139930.
benhamilton marked an inline comment as done.
benhamilton added a comment.

- Use `Right.MatchingParen->endsSequence(TT_DictLiteral, tok::at)`


Repository:
  rC Clang

https://reviews.llvm.org/D44816

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


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -1000,6 +1000,21 @@
   "  ( id)a : ( id),\n"
   "  ( id)aa : ( id)aa,\n"
   "};");
+  Style.ColumnLimit = 40;
+  verifyFormat("int Foo() {\n"
+   "  a12345 = @{a12345 : a12345};\n"
+   "}");
+  verifyFormat("int Foo() {\n"
+   "  a12345 = @{(Foo *)a12345 : @(a12345)};\n"
+   "}");
+  Style.SpacesInContainerLiterals = false;
+  verifyFormat("int Foo() {\n"
+   "  b12345 = @{b12345: b12345};\n"
+   "}");
+  verifyFormat("int Foo() {\n"
+   "  b12345 = @{(Foo *)b12345: @(b12345)};\n"
+   "}");
+  Style.SpacesInContainerLiterals = true;
 
   Style = getGoogleStyle(FormatStyle::LK_ObjC);
   verifyFormat(
@@ -1055,6 +1070,21 @@
   verifyFormat("[someFunction someLongParameter:@[\n"
"  NSBundle.mainBundle.infoDictionary[@\"a\"]\n"
"]];");
+  Style.ColumnLimit = 40;
+  verifyFormat("int Foo() {\n"
+   "  a12345 = @[ a12345, a12345 ];\n"
+   "}");
+  verifyFormat("int Foo() {\n"
+   "  a123 = @[ (Foo *)a12345, @(a12345) ];\n"
+   "}");
+  Style.SpacesInContainerLiterals = false;
+  verifyFormat("int Foo() {\n"
+   "  b12345 = @[b12345, b12345];\n"
+   "}");
+  verifyFormat("int Foo() {\n"
+   "  b12345 = @[(Foo *)b12345, @(b12345)];\n"
+   "}");
+  Style.SpacesInContainerLiterals = true;
   Style.ColumnLimit = 20;
   // We can't break string literals inside NSArray literals
   // (that raises -Wobjc-string-concatenation).
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2480,6 +2480,10 @@
 return false;
   if (Left.is(TT_TemplateCloser) && Right.is(tok::l_square))
 return false;
+  if (Right.is(tok::r_brace) && Right.MatchingParen &&
+  Right.MatchingParen->endsSequence(TT_DictLiteral, tok::at))
+// Objective-C dictionary literal -> no space before closing brace.
+return false;
   return true;
 }
 


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -1000,6 +1000,21 @@
   "  ( id)a : ( id),\n"
   "  ( id)aa : ( id)aa,\n"
   "};");
+  Style.ColumnLimit = 40;
+  verifyFormat("int Foo() {\n"
+   "  a12345 = @{a12345 : a12345};\n"
+   "}");
+  verifyFormat("int Foo() {\n"
+   "  a12345 = @{(Foo *)a12345 : @(a12345)};\n"
+   "}");
+  Style.SpacesInContainerLiterals = false;
+  verifyFormat("int Foo() {\n"
+   "  b12345 = @{b12345: b12345};\n"
+   "}");
+  verifyFormat("int Foo() {\n"
+   "  b12345 = @{(Foo *)b12345: @(b12345)};\n"
+   "}");
+  Style.SpacesInContainerLiterals = true;
 
   Style = getGoogleStyle(FormatStyle::LK_ObjC);
   verifyFormat(
@@ -1055,6 +1070,21 @@
   verifyFormat("[someFunction someLongParameter:@[\n"
"  NSBundle.mainBundle.infoDictionary[@\"a\"]\n"
"]];");
+  Style.ColumnLimit = 40;
+  verifyFormat("int Foo() {\n"
+   "  a12345 = @[ a12345, a12345 ];\n"
+   "}");
+  verifyFormat("int Foo() {\n"
+   "  a123 = @[ (Foo *)a12345, @(a12345) ];\n"
+   "}");
+  Style.SpacesInContainerLiterals = false;
+  verifyFormat("int Foo() {\n"
+   "  b12345 = @[b12345, b12345];\n"
+   "}");
+  verifyFormat("int Foo() {\n"
+   "  b12345 = @[(Foo *)b12345, @(b12345)];\n"
+   "}");
+  Style.SpacesInContainerLiterals = true;
   Style.ColumnLimit = 20;
   // We can't break string literals inside NSArray literals
   // (that raises -Wobjc-string-concatenation).
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2480,6 +2480,10 @@
 return false;
   if (Left.is(TT_TemplateCloser) && Right.is(tok::l_square))
 return false;
+  if (Right.is(tok::r_brace) && Right.MatchingParen &&
+  Right.MatchingParen->endsSequence(TT_DictLite

[PATCH] D44816: [clang-format] Do not insert space before closing brace in ObjC dict literal

2018-03-27 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added inline comments.



Comment at: lib/Format/TokenAnnotator.cpp:2484
+  if (Right.is(tok::r_brace) && Right.MatchingParen &&
+  Right.MatchingParen->is(TT_DictLiteral) &&
+  Right.MatchingParen->Previous &&

djasper wrote:
> Could you use Right.MatchingParen->endsSequence(TT_DictLiteral, tok::at) here?
Yes, done. I keep forgetting about the reverse order of that method (it makes 
sense, I just can't keep that info in my brain for some reason.)


Repository:
  rC Clang

https://reviews.llvm.org/D44816



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


[PATCH] D44831: [clang-format] Refine ObjC guesser to handle child lines of child lines

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


Repository:
  rC Clang

https://reviews.llvm.org/D44831



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


[PATCH] D44816: [clang-format] Do not insert space before closing brace in ObjC dict literal

2018-03-27 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.

Yeah, it's one of these things where neither way would be totally intuitive to 
everyone.


Repository:
  rC Clang

https://reviews.llvm.org/D44816



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


r328626 - Drop spurious break; NFC

2018-03-27 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Tue Mar 27 07:57:56 2018
New Revision: 328626

URL: http://llvm.org/viewvc/llvm-project?rev=328626&view=rev
Log:
Drop spurious break; NFC

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=328626&r1=328625&r2=328626&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Mar 27 07:57:56 2018
@@ -1209,7 +1209,6 @@ Sema::CheckBuiltinFunctionCall(FunctionD
 if (SemaOpenCLBuiltinKernelWorkGroupSize(*this, TheCall))
   return ExprError();
 break;
-break;
   case Builtin::BIget_kernel_max_sub_group_size_for_ndrange:
   case Builtin::BIget_kernel_sub_group_count_for_ndrange:
 if (SemaOpenCLBuiltinNDRangeAndBlock(*this, TheCall))


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


r328628 - [clang-format] Refine ObjC guesser to handle child lines of child lines

2018-03-27 Thread Ben Hamilton via cfe-commits
Author: benhamilton
Date: Tue Mar 27 08:01:21 2018
New Revision: 328628

URL: http://llvm.org/viewvc/llvm-project?rev=328628&view=rev
Log:
[clang-format] Refine ObjC guesser to handle child lines of child lines

Summary:
This fixes an issue brought up by djasper@ in his review of D44790. We
handled top-level child lines, but if those child lines themselves
had child lines, we didn't handle them.

Rather than use recursion (which could blow out the stack), I use a
DenseSet to hold the set of lines we haven't yet checked (since order
doesn't matter), and update the set to add the children of each
line as we check it.

Test Plan: New tests added. Confirmed tests failed before fix
  and passed after fix.

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

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

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=328628&r1=328627&r2=328628&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Tue Mar 27 08:01:21 2018
@@ -1514,8 +1514,8 @@ private:
 "UIView",
 };
 
-auto LineContainsObjCCode = [&Keywords](const AnnotatedLine &Line) {
-  for (const FormatToken *FormatTok = Line.First; FormatTok;
+for (auto Line : AnnotatedLines) {
+  for (const FormatToken *FormatTok = Line->First; FormatTok;
FormatTok = FormatTok->Next) {
 if ((FormatTok->Previous && FormatTok->Previous->is(tok::at) &&
  (FormatTok->isObjCAtKeyword(tok::objc_interface) ||
@@ -1535,14 +1535,7 @@ private:
TT_ObjCMethodSpecifier, TT_ObjCProperty)) {
   return true;
 }
-  }
-  return false;
-};
-for (auto Line : AnnotatedLines) {
-  if (LineContainsObjCCode(*Line))
-return true;
-  for (auto ChildLine : Line->Children) {
-if (LineContainsObjCCode(*ChildLine))
+if (guessIsObjC(Line->Children, Keywords))
   return true;
   }
 }

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=328628&r1=328627&r2=328628&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Mar 27 08:01:21 2018
@@ -12159,6 +12159,12 @@ TEST_F(FormatTest, GuessLanguageWithChil
 guessLanguage("foo.h", "#define FOO ({ std::string s; })"));
   EXPECT_EQ(FormatStyle::LK_ObjC,
 guessLanguage("foo.h", "#define FOO ({ NSString *s; })"));
+  EXPECT_EQ(
+  FormatStyle::LK_Cpp,
+  guessLanguage("foo.h", "#define FOO ({ foo(); ({ std::string s; }) })"));
+  EXPECT_EQ(
+  FormatStyle::LK_ObjC,
+  guessLanguage("foo.h", "#define FOO ({ foo(); ({ NSString *s; }) })"));
 }
 
 } // end namespace


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


r328627 - [clang-format] Do not insert space before closing brace in ObjC dict literal

2018-03-27 Thread Ben Hamilton via cfe-commits
Author: benhamilton
Date: Tue Mar 27 08:01:17 2018
New Revision: 328627

URL: http://llvm.org/viewvc/llvm-project?rev=328627&view=rev
Log:
[clang-format] Do not insert space before closing brace in ObjC dict literal

Summary:
Previously, `clang-format` would sometimes insert a space
before the closing brace in an Objective-C dictionary literal.

Unlike array literals (which obey `Style.SpacesInContainerLiterals`
to add a space after `[` and before `]`), Objective-C dictionary
literals currently are not meant to insert a space after `{` and before
`}`, regardless of `Style.SpacesInContainerLiterals`.

However, some constructs like `@{foo : @(bar)}` caused `clang-format`
to insert a space between `)` and `}`.

This fixes the issue and adds tests. (I understand the behavior is
not consistent between array literals and dictionary literals, but
that's existing behavior that's a much larger change.)

Test Plan: New tests added. Ran tests with:
  % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: djasper, jolesiak, Wizard

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=328627&r1=328626&r2=328627&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Mar 27 08:01:17 2018
@@ -2480,6 +2480,10 @@ bool TokenAnnotator::spaceRequiredBetwee
 return false;
   if (Left.is(TT_TemplateCloser) && Right.is(tok::l_square))
 return false;
+  if (Right.is(tok::r_brace) && Right.MatchingParen &&
+  Right.MatchingParen->endsSequence(TT_DictLiteral, tok::at))
+// Objective-C dictionary literal -> no space before closing brace.
+return false;
   return true;
 }
 

Modified: cfe/trunk/unittests/Format/FormatTestObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestObjC.cpp?rev=328627&r1=328626&r2=328627&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestObjC.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestObjC.cpp Tue Mar 27 08:01:17 2018
@@ -1000,6 +1000,21 @@ TEST_F(FormatTestObjC, ObjCDictLiterals)
   "  ( id)a : ( id),\n"
   "  ( id)aa : ( id)aa,\n"
   "};");
+  Style.ColumnLimit = 40;
+  verifyFormat("int Foo() {\n"
+   "  a12345 = @{a12345 : a12345};\n"
+   "}");
+  verifyFormat("int Foo() {\n"
+   "  a12345 = @{(Foo *)a12345 : @(a12345)};\n"
+   "}");
+  Style.SpacesInContainerLiterals = false;
+  verifyFormat("int Foo() {\n"
+   "  b12345 = @{b12345: b12345};\n"
+   "}");
+  verifyFormat("int Foo() {\n"
+   "  b12345 = @{(Foo *)b12345: @(b12345)};\n"
+   "}");
+  Style.SpacesInContainerLiterals = true;
 
   Style = getGoogleStyle(FormatStyle::LK_ObjC);
   verifyFormat(
@@ -1055,6 +1070,21 @@ TEST_F(FormatTestObjC, ObjCArrayLiterals
   verifyFormat("[someFunction someLongParameter:@[\n"
"  NSBundle.mainBundle.infoDictionary[@\"a\"]\n"
"]];");
+  Style.ColumnLimit = 40;
+  verifyFormat("int Foo() {\n"
+   "  a12345 = @[ a12345, a12345 ];\n"
+   "}");
+  verifyFormat("int Foo() {\n"
+   "  a123 = @[ (Foo *)a12345, @(a12345) ];\n"
+   "}");
+  Style.SpacesInContainerLiterals = false;
+  verifyFormat("int Foo() {\n"
+   "  b12345 = @[b12345, b12345];\n"
+   "}");
+  verifyFormat("int Foo() {\n"
+   "  b12345 = @[(Foo *)b12345, @(b12345)];\n"
+   "}");
+  Style.SpacesInContainerLiterals = true;
   Style.ColumnLimit = 20;
   // We can't break string literals inside NSArray literals
   // (that raises -Wobjc-string-concatenation).


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


[PATCH] D44816: [clang-format] Do not insert space before closing brace in ObjC dict literal

2018-03-27 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added a comment.

I filed https://bugs.llvm.org/show_bug.cgi?id=36919 to follow up and make ObjC 
dictionary literal spacing consistent with ObjC array literals.


Repository:
  rC Clang

https://reviews.llvm.org/D44816



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


[PATCH] D44816: [clang-format] Do not insert space before closing brace in ObjC dict literal

2018-03-27 Thread Ben Hamilton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC328627: [clang-format] Do not insert space before closing 
brace in ObjC dict literal (authored by benhamilton, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44816?vs=139930&id=139931#toc

Repository:
  rC Clang

https://reviews.llvm.org/D44816

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


Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2480,6 +2480,10 @@
 return false;
   if (Left.is(TT_TemplateCloser) && Right.is(tok::l_square))
 return false;
+  if (Right.is(tok::r_brace) && Right.MatchingParen &&
+  Right.MatchingParen->endsSequence(TT_DictLiteral, tok::at))
+// Objective-C dictionary literal -> no space before closing brace.
+return false;
   return true;
 }
 
Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -1000,6 +1000,21 @@
   "  ( id)a : ( id),\n"
   "  ( id)aa : ( id)aa,\n"
   "};");
+  Style.ColumnLimit = 40;
+  verifyFormat("int Foo() {\n"
+   "  a12345 = @{a12345 : a12345};\n"
+   "}");
+  verifyFormat("int Foo() {\n"
+   "  a12345 = @{(Foo *)a12345 : @(a12345)};\n"
+   "}");
+  Style.SpacesInContainerLiterals = false;
+  verifyFormat("int Foo() {\n"
+   "  b12345 = @{b12345: b12345};\n"
+   "}");
+  verifyFormat("int Foo() {\n"
+   "  b12345 = @{(Foo *)b12345: @(b12345)};\n"
+   "}");
+  Style.SpacesInContainerLiterals = true;
 
   Style = getGoogleStyle(FormatStyle::LK_ObjC);
   verifyFormat(
@@ -1055,6 +1070,21 @@
   verifyFormat("[someFunction someLongParameter:@[\n"
"  NSBundle.mainBundle.infoDictionary[@\"a\"]\n"
"]];");
+  Style.ColumnLimit = 40;
+  verifyFormat("int Foo() {\n"
+   "  a12345 = @[ a12345, a12345 ];\n"
+   "}");
+  verifyFormat("int Foo() {\n"
+   "  a123 = @[ (Foo *)a12345, @(a12345) ];\n"
+   "}");
+  Style.SpacesInContainerLiterals = false;
+  verifyFormat("int Foo() {\n"
+   "  b12345 = @[b12345, b12345];\n"
+   "}");
+  verifyFormat("int Foo() {\n"
+   "  b12345 = @[(Foo *)b12345, @(b12345)];\n"
+   "}");
+  Style.SpacesInContainerLiterals = true;
   Style.ColumnLimit = 20;
   // We can't break string literals inside NSArray literals
   // (that raises -Wobjc-string-concatenation).


Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2480,6 +2480,10 @@
 return false;
   if (Left.is(TT_TemplateCloser) && Right.is(tok::l_square))
 return false;
+  if (Right.is(tok::r_brace) && Right.MatchingParen &&
+  Right.MatchingParen->endsSequence(TT_DictLiteral, tok::at))
+// Objective-C dictionary literal -> no space before closing brace.
+return false;
   return true;
 }
 
Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -1000,6 +1000,21 @@
   "  ( id)a : ( id),\n"
   "  ( id)aa : ( id)aa,\n"
   "};");
+  Style.ColumnLimit = 40;
+  verifyFormat("int Foo() {\n"
+   "  a12345 = @{a12345 : a12345};\n"
+   "}");
+  verifyFormat("int Foo() {\n"
+   "  a12345 = @{(Foo *)a12345 : @(a12345)};\n"
+   "}");
+  Style.SpacesInContainerLiterals = false;
+  verifyFormat("int Foo() {\n"
+   "  b12345 = @{b12345: b12345};\n"
+   "}");
+  verifyFormat("int Foo() {\n"
+   "  b12345 = @{(Foo *)b12345: @(b12345)};\n"
+   "}");
+  Style.SpacesInContainerLiterals = true;
 
   Style = getGoogleStyle(FormatStyle::LK_ObjC);
   verifyFormat(
@@ -1055,6 +1070,21 @@
   verifyFormat("[someFunction someLongParameter:@[\n"
"  NSBundle.mainBundle.infoDictionary[@\"a\"]\n"
"]];");
+  Style.ColumnLimit = 40;
+  verifyFormat("int Foo() {\n"
+   "  a12345 = @[ a12345, a12345 ];\n"
+   "}");
+  verifyFormat("int Foo() {\n"
+   "  a123 = @[ (Foo *)a12345, @(a12345) ];\n"
+   "}");
+  Style.SpacesInContainerLiterals = false;
+  verifyFormat("int Foo() {\n"
+   "  b12345 = @[b12345, b12345];\n"
+   "}");
+  verifyFormat("int Foo() {\n"
+   "  b123

[PATCH] D44831: [clang-format] Refine ObjC guesser to handle child lines of child lines

2018-03-27 Thread Ben Hamilton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC328628: [clang-format] Refine ObjC guesser to handle child 
lines of child lines (authored by benhamilton, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44831?vs=139929&id=139932#toc

Repository:
  rC Clang

https://reviews.llvm.org/D44831

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


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -12159,6 +12159,12 @@
 guessLanguage("foo.h", "#define FOO ({ std::string s; })"));
   EXPECT_EQ(FormatStyle::LK_ObjC,
 guessLanguage("foo.h", "#define FOO ({ NSString *s; })"));
+  EXPECT_EQ(
+  FormatStyle::LK_Cpp,
+  guessLanguage("foo.h", "#define FOO ({ foo(); ({ std::string s; }) })"));
+  EXPECT_EQ(
+  FormatStyle::LK_ObjC,
+  guessLanguage("foo.h", "#define FOO ({ foo(); ({ NSString *s; }) })"));
 }
 
 } // end namespace
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1514,8 +1514,8 @@
 "UIView",
 };
 
-auto LineContainsObjCCode = [&Keywords](const AnnotatedLine &Line) {
-  for (const FormatToken *FormatTok = Line.First; FormatTok;
+for (auto Line : AnnotatedLines) {
+  for (const FormatToken *FormatTok = Line->First; FormatTok;
FormatTok = FormatTok->Next) {
 if ((FormatTok->Previous && FormatTok->Previous->is(tok::at) &&
  (FormatTok->isObjCAtKeyword(tok::objc_interface) ||
@@ -1535,14 +1535,7 @@
TT_ObjCMethodSpecifier, TT_ObjCProperty)) {
   return true;
 }
-  }
-  return false;
-};
-for (auto Line : AnnotatedLines) {
-  if (LineContainsObjCCode(*Line))
-return true;
-  for (auto ChildLine : Line->Children) {
-if (LineContainsObjCCode(*ChildLine))
+if (guessIsObjC(Line->Children, Keywords))
   return true;
   }
 }


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -12159,6 +12159,12 @@
 guessLanguage("foo.h", "#define FOO ({ std::string s; })"));
   EXPECT_EQ(FormatStyle::LK_ObjC,
 guessLanguage("foo.h", "#define FOO ({ NSString *s; })"));
+  EXPECT_EQ(
+  FormatStyle::LK_Cpp,
+  guessLanguage("foo.h", "#define FOO ({ foo(); ({ std::string s; }) })"));
+  EXPECT_EQ(
+  FormatStyle::LK_ObjC,
+  guessLanguage("foo.h", "#define FOO ({ foo(); ({ NSString *s; }) })"));
 }
 
 } // end namespace
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1514,8 +1514,8 @@
 "UIView",
 };
 
-auto LineContainsObjCCode = [&Keywords](const AnnotatedLine &Line) {
-  for (const FormatToken *FormatTok = Line.First; FormatTok;
+for (auto Line : AnnotatedLines) {
+  for (const FormatToken *FormatTok = Line->First; FormatTok;
FormatTok = FormatTok->Next) {
 if ((FormatTok->Previous && FormatTok->Previous->is(tok::at) &&
  (FormatTok->isObjCAtKeyword(tok::objc_interface) ||
@@ -1535,14 +1535,7 @@
TT_ObjCMethodSpecifier, TT_ObjCProperty)) {
   return true;
 }
-  }
-  return false;
-};
-for (auto Line : AnnotatedLines) {
-  if (LineContainsObjCCode(*Line))
-return true;
-  for (auto ChildLine : Line->Children) {
-if (LineContainsObjCCode(*ChildLine))
+if (guessIsObjC(Line->Children, Keywords))
   return true;
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44908: [ObjC++] Make parameter passing and function return compatible with ObjC

2018-03-27 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 139935.
ahatanak added a comment.

Make ClangABICompat a LangOption and remove ForcePassIndirectly. Move the logic 
in CodeGen that decides whether a parameter should be passed indirectly to Sema.


Repository:
  rC Clang

https://reviews.llvm.org/D44908

Files:
  include/clang/AST/Decl.h
  include/clang/AST/DeclCXX.h
  include/clang/AST/Type.h
  include/clang/Basic/LangOptions.def
  include/clang/Basic/LangOptions.h
  include/clang/Basic/TargetInfo.h
  include/clang/Frontend/CodeGenOptions.def
  lib/AST/ASTContext.cpp
  lib/AST/Decl.cpp
  lib/AST/DeclCXX.cpp
  lib/AST/Type.cpp
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets/X86.h
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
  test/CodeGenObjCXX/arc-special-member-functions.mm
  test/CodeGenObjCXX/objc-struct-cxx-abi.mm
  test/CodeGenObjCXX/property-dot-copy-elision.mm
  test/CodeGenObjCXX/trivial_abi.mm

Index: test/CodeGenObjCXX/property-dot-copy-elision.mm
===
--- test/CodeGenObjCXX/property-dot-copy-elision.mm
+++ test/CodeGenObjCXX/property-dot-copy-elision.mm
@@ -1,11 +1,13 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -std=c++1z -fobjc-arc -o - %s | FileCheck %s
 
 struct S0 {
+  ~S0();
   id f;
 };
 
 struct S1 {
   S1();
+  ~S1();
   S1(S0);
   id f;
 };
Index: test/CodeGenObjCXX/objc-struct-cxx-abi.mm
===
--- test/CodeGenObjCXX/objc-struct-cxx-abi.mm
+++ test/CodeGenObjCXX/objc-struct-cxx-abi.mm
@@ -1,27 +1,60 @@
 // RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++11 -fobjc-arc  -fobjc-weak -fobjc-runtime-has-weak -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++11 -fobjc-arc  -fobjc-weak -fobjc-runtime-has-weak -fclang-abi-compat=4.0 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++11 -fobjc-arc  -fobjc-weak -fobjc-runtime-has-weak -emit-llvm -o - -DTRIVIALABI %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++11 -fobjc-arc  -fobjc-weak -fobjc-runtime-has-weak -fclang-abi-compat=4.0 -emit-llvm -o - -DTRIVIALABI %s | FileCheck %s
+
+// Check that structs consisting solely of __strong or __weak pointer fields are
+// destructed in the callee function and structs consisting solely of __strong
+// pointer fields are passed directly.
 
 // CHECK: %[[STRUCT_STRONGWEAK:.*]] = type { i8*, i8* }
 // CHECK: %[[STRUCT_STRONG:.*]] = type { i8* }
 // CHECK: %[[STRUCT_S:.*]] = type { i8* }
+// CHECK: %[[STRUCT_CONTAINSNONTRIVIAL:.*]] = type { %{{.*}}, i8* }
 
+#ifdef TRIVIALABI
 struct __attribute__((trivial_abi)) StrongWeak {
+#else
+struct StrongWeak {
+#endif
   id fstrong;
   __weak id fweak;
 };
 
+#ifdef TRIVIALABI
 struct __attribute__((trivial_abi)) Strong {
+#else
+struct Strong {
+#endif
   id fstrong;
 };
 
 template
+#ifdef TRIVIALABI
 struct __attribute__((trivial_abi)) S {
+#else
+struct S {
+#endif
   T a;
 };
 
+struct NonTrivial {
+  NonTrivial();
+  NonTrivial(const NonTrivial &);
+  ~NonTrivial();
+  int *a;
+};
+
+// This struct is not passed directly nor destructed in the callee because f0
+// has type NonTrivial.
+struct ContainsNonTrivial {
+  NonTrivial f0;
+  id f1;
+};
+
 // CHECK: define void @_Z19testParamStrongWeak10StrongWeak(%[[STRUCT_STRONGWEAK]]* %{{.*}})
-// CHECK-NOT: call
-// CHECK: ret void
+// CHECK: call %struct.StrongWeak* @_ZN10StrongWeakD1Ev(
+// CHECK-NEXT: ret void
 
 void testParamStrongWeak(StrongWeak a) {
 }
@@ -33,7 +66,7 @@
 // CHECK: %[[V0:.*]] = load %[[STRUCT_STRONGWEAK]]*, %[[STRUCT_STRONGWEAK]]** %[[A_ADDR]], align 8
 // CHECK: %[[CALL:.*]] = call %[[STRUCT_STRONGWEAK]]* @_ZN10StrongWeakC1ERKS_(%[[STRUCT_STRONGWEAK]]* %[[AGG_TMP]], %[[STRUCT_STRONGWEAK]]* dereferenceable(16) %[[V0]])
 // CHECK: call void @_Z19testParamStrongWeak10StrongWeak(%[[STRUCT_STRONGWEAK]]* %[[AGG_TMP]])
-// CHECK: %[[CALL1:.*]] = call %[[STRUCT_STRONGWEAK]]* @_ZN10StrongWeakD1Ev(%[[STRUCT_STRONGWEAK]]* %[[AGG_TMP]])
+// CHECK-NOT: call
 // CHECK: ret void
 
 void testCallStrongWeak(StrongWeak *a) {
@@ -96,8 +129,23 @@
 }
 
 // CHECK: define void @_Z21testParamWeakTemplate1SIU6__weakP11objc_objectE(%[[STRUCT_S]]* %{{.*}})
+// CHECK: call %struct.S* @_ZN1SIU6__weakP11objc_objectED1Ev(
+// CHECK-NEXT: ret void
+
+void testParamWeakTemplate(S<__weak id> a) {
+}
+
+// CHECK: define void @_Z27testParamContainsNonTrivial18ContainsNonTrivial(%[[STRUCT_CONTAINSNONTRIVIAL]]* %{{.*}})
 // CHECK-NOT: call
 // CHECK: ret void
 
-void testParamWeakTemplate(S<__weak id> a) {
+void testParamContainsNonTrivial(ContainsNonTrivial a) {
+}
+
+// CHECK: 

[PATCH] D44906: [clang-tidy] Define __clang_analyzer__ macro for clang-tidy for compatibility with clang static analyzer

2018-03-27 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tidy/ClangTidy.cpp:490
+CommandLineArguments AdjustedArgs = Args;
+AdjustedArgs.emplace_back("-D__clang_analyzer__");
+return AdjustedArgs;

I wonder whether we should instead reuse the logic in the frontend 
(tools/clang/lib/Frontend/InitPreprocessor.cpp:970). This could be done by 
overriding ActionFactory::runInvocation and setting 
FrontendOptions::ProgramAction to frontend::RunAnalysis there. WDYT?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44906



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


[PATCH] D44906: [clang-tidy] Define __clang_analyzer__ macro for clang-tidy for compatibility with clang static analyzer

2018-03-27 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added inline comments.



Comment at: clang-tidy/ClangTidy.cpp:490
+CommandLineArguments AdjustedArgs = Args;
+AdjustedArgs.emplace_back("-D__clang_analyzer__");
+return AdjustedArgs;

alexfh wrote:
> I wonder whether we should instead reuse the logic in the frontend 
> (tools/clang/lib/Frontend/InitPreprocessor.cpp:970). This could be done by 
> overriding ActionFactory::runInvocation and setting 
> FrontendOptions::ProgramAction to frontend::RunAnalysis there. WDYT?
Thanks. I know about this code. But I'm not sure that we can reuse RunAnalysys 
action hre - we need to parse AST only, but RunAnalysys does a lot of other 
things we dont' need. Is it correct?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44906



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


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

2018-03-27 Thread Daniel Kolozsvari via Phabricator via cfe-commits
koldaniel added a comment.

Do you have any other comments, or could this change be accepted?


https://reviews.llvm.org/D35068



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


[PATCH] D44916: [Sema] Avoid crash for category implementation without interface

2018-03-27 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I think that's a fine place to add the check.


Repository:
  rC Clang

https://reviews.llvm.org/D44916



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


[PATCH] D44826: Add -Wunused-using, a warning that finds unused using declarations.

2018-03-27 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

You mention a missed case in the description - where the target of a using decl 
is used and that causes the unused-using not to warn about the using decl? That 
seems like a big limitation. Does that mean the 'used' bit is being tracked in 
the wrong place, on the target of the using decl instead of on the using decl 
itself?




Comment at: lib/Sema/MultiplexExternalSemaSource.cpp:278-279
+llvm::SmallSetVector &Decls) {
+  for(size_t i = 0; i < Sources.size(); ++i)
+Sources[i]->ReadUnusedUsingCandidates(Decls);
+}

Could you use a range-based-for here?



Comment at: lib/Serialization/ASTReader.cpp:8101-8103
+UsingDecl *D = dyn_cast_or_null(
+GetDecl(UnusedUsingCandidates[I]));
+if (D)

roll the declaration into the condition, perhaps:

  if (auto *D = dyn_cast_or_null...)
Decls.insert(D);



Comment at: test/Modules/warn-unused-using.cpp:5
+
+// For modules, the warning should only fire the first time, when the module is
+// built.

This would only warn for the unused local using, but wouldn't fire for an 
namespace-scoped unused using? Perhaps there should be a test for that?



Comment at: test/SemaCXX/warn-unused-using.cpp:6-8
+  typedef int INT;
+  typedef char CHAR;
+  typedef float FLOAT;

Do these need to be different types? Maybe just name them t1/t2/t3/t4, etc - or 
name them after their use in test cases to indicate what makes each type 
interesting/different, if that's suitable.



Comment at: test/SemaCXX/warn-unused-using.cpp:11-12
+
+using nsp::Print; // expected-warning {{unused using 'Print'}}
+using nsp::var; // expected-warning {{unused using 'var'}}
+

What's the difference between these two cases?



Comment at: test/SemaCXX/warn-unused-using.cpp:15-20
+  using nsp::Print; // expected-warning {{unused using 'Print'}}
+  {
+using nsp::var; // expected-warning {{unused using 'var'}}
+{
+  using nsp::INT; // expected-warning {{unused using 'INT'}}
+  using nsp::FLOAT; // expected-warning {{unused using 'FLOAT'}}

And these 4? (I guess one in a nested scope is significant in some way? But not 
sure about the second scope, and the two (rather than one) using decls in there)



Comment at: test/SemaCXX/warn-unused-using.cpp:28
+  FLOAT f;
+  f = 2.0;
+}

Probably don't need this use? (can turn off all the other warnings, rather than 
crafting warning-free code when testing only one warning)



Comment at: test/SemaCXX/warn-unused-using.cpp:35
+struct B : A {
+  using A::Foo;  // expected-warning {{unused using 'Foo'}}
+  virtual void Foo(double x) const;

This tests the fact that 'Foo' is overridden in B anyway, so this using decl 
doesn't bring anything in?

I'm assuming in the case where the using decl does bring at least one name in, 
this warning doesn't fire? (maybe test that?)



Comment at: test/SemaCXX/warn-unused-using.cpp:39-42
+void one() {
+  B b;
+  b.Foo(1.0);
+}

Does B need to be used at all, here? Oh, to demonstrate that 'Foo' is using one 
overload, but not using the using decl?


Repository:
  rC Clang

https://reviews.llvm.org/D44826



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


[PATCH] D44908: [ObjC++] Make parameter passing and function return compatible with ObjC

2018-03-27 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D44908



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


r328636 - [clang] Change std::sort to llvm::sort in response to r327219

2018-03-27 Thread Mandeep Singh Grang via cfe-commits
Author: mgrang
Date: Tue Mar 27 09:50:00 2018
New Revision: 328636

URL: http://llvm.org/viewvc/llvm-project?rev=328636&view=rev
Log:
[clang] Change std::sort to llvm::sort in response to r327219

r327219 added wrappers to std::sort which randomly shuffle the container before
sorting.  This will help in uncovering non-determinism caused due to undefined
sorting order of objects having the same key.

To make use of that infrastructure we need to invoke llvm::sort instead of
std::sort.

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Serialization/ContinuousRangeMap.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/VTableBuilder.cpp
cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
cfe/trunk/lib/Analysis/LiveVariables.cpp
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Format/FormatTokenLexer.cpp
cfe/trunk/lib/Format/WhitespaceManager.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp
cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp
cfe/trunk/lib/Tooling/Core/Replacement.cpp
cfe/trunk/tools/diagtool/DiagTool.cpp
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
cfe/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp
cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp
cfe/trunk/utils/TableGen/NeonEmitter.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=328636&r1=328635&r2=328636&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Mar 27 09:50:00 2018
@@ -1889,7 +1889,7 @@ def Target : InheritableAttr {
 template
 ParsedTargetAttr parse(Compare cmp) const {
   ParsedTargetAttr Attrs = parse();
-  std::sort(std::begin(Attrs.Features), std::end(Attrs.Features), cmp);
+  llvm::sort(std::begin(Attrs.Features), std::end(Attrs.Features), cmp);
   return Attrs;
 }
 

Modified: cfe/trunk/include/clang/Serialization/ContinuousRangeMap.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ContinuousRangeMap.h?rev=328636&r1=328635&r2=328636&view=diff
==
--- cfe/trunk/include/clang/Serialization/ContinuousRangeMap.h (original)
+++ cfe/trunk/include/clang/Serialization/ContinuousRangeMap.h Tue Mar 27 
09:50:00 2018
@@ -117,7 +117,7 @@ public:
 Builder &operator=(const Builder&) = delete;
 
 ~Builder() {
-  std::sort(Self.Rep.begin(), Self.Rep.end(), Compare());
+  llvm::sort(Self.Rep.begin(), Self.Rep.end(), Compare());
   std::unique(Self.Rep.begin(), Self.Rep.end(),
   [](const_reference A, const_reference B) {
 // FIXME: we should not allow any duplicate keys, but there are a lot 
of

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=328636&r1=328635&r2=328636&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Mar 27 09:50:00 2018
@@ -2186,7 +2186,7 @@ structHasUniqueObjectRepresentations(con
   }
 }
 
-std::sort(
+llvm::sort(
 Bases.begin(), Bases.end(), [&](const std::pair &L,
 const std::pair &R) 
{
   return Layout.getBaseClassOffset(L.first->getAsCXXRecordDecl()) <

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=328636&r1=328635&r2=328636&view=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Tue Mar 27 09:50:00 2018
@@ -323,7 +323,7 @@ class CXXNameMangler {
AdditionalAbiTags->end());
   }
 
-  std::sort(TagList.begin(), TagList.end());
+  llvm::sort(

[PATCH] D44883: [Sema] Extend -Wself-assign and -Wself-assign-field to warn on overloaded self-assignment (classes)

2018-03-27 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 139948.
lebedev.ri retitled this revision from "[Sema] Extend -Wself-assign with 
-Wself-assign-overloaded to warn on overloaded self-assignment (classes)" to 
"[Sema] Extend -Wself-assign and -Wself-assign-field to warn on overloaded 
self-assignment (classes)".
lebedev.ri edited the summary of this revision.
lebedev.ri added a comment.

- Dropped separate `-Wself-assign-builtin` and `-Wself-assign-overloaded` groups
- Simply updated the existing `-Wself-assign` and `-Wself-assign-field`.
- Significantly improved test coverage.
- `ninja check-clang` passes. Did not do stage2 build yet.
- `-Wself-assign-field` is rather neglected - unlike `-Wself-assign`, it does 
incorrectly warn on self-operations with `volatile` stores, and macros.


Repository:
  rC Clang

https://reviews.llvm.org/D44883

Files:
  docs/ReleaseNotes.rst
  lib/Sema/SemaExpr.cpp
  test/SemaCXX/implicit-exception-spec.cpp
  test/SemaCXX/member-init.cpp
  test/SemaCXX/warn-self-assign-builtin.cpp
  test/SemaCXX/warn-self-assign-field-builtin.cpp
  test/SemaCXX/warn-self-assign-field-overloaded.cpp
  test/SemaCXX/warn-self-assign-overloaded.cpp
  test/SemaCXX/warn-self-assign.cpp

Index: test/SemaCXX/warn-self-assign-overloaded.cpp
===
--- /dev/null
+++ test/SemaCXX/warn-self-assign-overloaded.cpp
@@ -0,0 +1,93 @@
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign -DDUMMY -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign -DV0 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign -DV1 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign -DV2 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign -DV3 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign -DV4 -verify %s
+
+#ifdef DUMMY
+struct S {};
+#else
+struct S {
+#if defined(V0)
+  S() = default;
+#elif defined(V1)
+  S &operator=(const S &) = default;
+#elif defined(V2)
+  S &operator=(S &) = default;
+#elif defined(V3)
+  S &operator=(const S &);
+#elif defined(V4)
+  S &operator=(S &);
+#else
+#error Define something!
+#endif
+  S &operator*=(const S &);
+  S &operator/=(const S &);
+  S &operator%=(const S &);
+  S &operator+=(const S &);
+  S &operator-=(const S &);
+  S &operator<<=(const S &);
+  S &operator>>=(const S &);
+  S &operator&=(const S &);
+  S &operator|=(const S &);
+  S &operator^=(const S &);
+  S &operator=(const volatile S &) volatile;
+};
+#endif
+
+void f() {
+  S a, b;
+  a = a; // expected-warning{{explicitly assigning}}
+  b = b; // expected-warning{{explicitly assigning}}
+  a = b;
+  b = a = b;
+  a = a = a; // expected-warning{{explicitly assigning}}
+  a = b = b = a;
+
+#ifndef DUMMY
+  a *= a;
+  a /= a; // expected-warning {{explicitly assigning}}
+  a %= a;
+  a += a;
+  a -= a; // expected-warning {{explicitly assigning}}
+  a <<= a;
+  a >>= a;
+  a &= a; // expected-warning {{explicitly assigning}}
+  a |= a; // expected-warning {{explicitly assigning}}
+  a ^= a; // expected-warning {{explicitly assigning}}
+#endif
+}
+
+void false_positives() {
+#define OP =
+#define LHS a
+#define RHS a
+  S a;
+  // These shouldn't warn due to the use of the preprocessor.
+  a OP a;
+  LHS = a;
+  a = RHS;
+  LHS OP RHS;
+#undef OP
+#undef LHS
+#undef RHS
+
+#ifndef DUMMY
+  // Volatile stores aren't side-effect free.
+  volatile S vol_a;
+  vol_a = vol_a;
+  volatile S &vol_a_ref = vol_a;
+  vol_a_ref = vol_a_ref;
+#endif
+}
+
+template 
+void g() {
+  T a;
+  a = a; // expected-warning{{explicitly assigning}}
+}
+void instantiate() {
+  g();
+  g();
+}
Index: test/SemaCXX/warn-self-assign-field-overloaded.cpp
===
--- /dev/null
+++ test/SemaCXX/warn-self-assign-field-overloaded.cpp
@@ -0,0 +1,142 @@
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign-field -DDUMMY -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign-field -DV0 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign-field -DV1 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign-field -DV2 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign-field -DV3 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign-field -DV4 -verify %s
+
+#ifdef DUMMY
+struct S {};
+#else
+struct S {
+#if defined(V0)
+  S() = default;
+#elif defined(V1)
+  S &operator=(const S &) = default;
+#elif defined(V2)
+  S &operator=(S &) = default;
+#elif defined(V3)
+  S &operator=(const S &);
+#elif defined(V4)
+  S &operator=(S &);
+#else
+#error Define something!
+#endif
+  S &operator*=(const S &);
+  S &operator/=(const S &);
+  S &operator%=(const S &);
+  S &operator+=(const S &);
+  S &operator-=(const S &);
+  S &operator<<=(const S &);
+  S &operator>>=(const S &);
+  S &operator&=(const S &);
+  S &operator|=(const S &);
+  S &operator^=(const S &);
+  S &operator=(const volatile S &) volatile;
+};
+#endif
+struct C {
+  S a;
+  S b;
+
+  void f() {
+a = a; // expected-warning {{assigning field to i

[PATCH] D44559: [Sema] Wrong width of result of mul operation

2018-03-27 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D44559#1049049, @avt77 wrote:

> > If that operation overflows, so be it — we're not going to warn about the 
> > potential for overflow every time the user adds two ints, and by the same 
> > token, it doesn't make any sense to warn about every time the user adds two 
> > shorts just because the language made this otherwise-unimportant technical 
> > decision to do the arithmetic in a wider type.
>
> There is one comment only: this patch changes the 'mul' operation only and 
> initially the change was done for X86 only because it clearly says about 
> "doubling" of mul result width.


Yes, I understand that addition was not changed by the patch.  I do not think 
that using different logic for multiplication is appropriate just because 
multiplication produces bigger values.  It is reasonable to multiply two 8-bit 
numbers and store the result in an 8-bit variable without a warning because the 
net effect is just doing a "closed" multiplication on an 8-bit type, which is a 
reasonable operation to want to do.  GCC is too noisy here.

There is nothing x86-specific about the supposed problem here, and using 
target-specific logic was always clearly inappropriate.

> And another comment: currently we have warning here:
> 
>   int c = a * b;
>   T d1 = c; // expected-warning{{implicit conversion loses integer precision: 
> 'int' to 'char'}}
>
> 
> but we don't have it here:
> 
> T d2 = a * b; // when T is char
> 
> It's a potential problem from my point of view.

All of these warnings are single-line analyses, which is unlikely to change 
absent massive architectural improvements to clang.  It has nothing to do with 
there being a multiplication; we would give you that exact same warning if you 
wrote `int c = a;`.

In https://reviews.llvm.org/D44559#1049057, @lebedev.ri wrote:

> In https://reviews.llvm.org/D44559#1049049, @avt77 wrote:
>
> > ...
> >  But I don't mind to close the review - and the corresponding bug of course.
>
>
> I disagree with closing the bug.
>  It's a real issue that is not detected/diagnosed by anything in clang 
> (diagnostic, sanitizer).
>
> It seems we are in a deadlock here :)


I don't have any special authority here besides having designed and implemented 
the current diagnostic.  You are welcome to start a thread on cfe-dev to gather 
support for changing the design of -Wconversion to always warn about the 
potential for overflow in sub-int multiplication. I will argue against you 
there, like I have here, but if there's consensus that we should warn about 
this, I'll abide by the community's judgment.


https://reviews.llvm.org/D44559



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


[PATCH] D33844: [clang-tidy] terminating continue check

2018-03-27 Thread Daniel Kolozsvari via Phabricator via cfe-commits
koldaniel updated this revision to Diff 139953.

https://reviews.llvm.org/D33844

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/TerminatingContinueCheck.cpp
  clang-tidy/misc/TerminatingContinueCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-terminating-continue.rst
  test/clang-tidy/misc-terminating-continue.cpp

Index: test/clang-tidy/misc-terminating-continue.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-terminating-continue.cpp
@@ -0,0 +1,65 @@
+// RUN: %check_clang_tidy %s misc-terminating-continue %t
+
+void f() {
+  do {
+continue;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'continue' in loop with false condition is equivalent to 'break' [misc-terminating-continue]
+// CHECK-FIXES: break;
+  } while(false);
+
+  do {
+continue;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'continue' in loop with false condition is equivalent to 'break' [misc-terminating-continue]
+// CHECK-FIXES: break;
+  } while(0);
+
+  do {
+continue;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'continue' in loop with false condition is equivalent to 'break' [misc-terminating-continue]
+// CHECK-FIXES: break;
+  } while(nullptr);
+
+  do {
+continue;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'continue' in loop with false condition is equivalent to 'break' [misc-terminating-continue]
+// CHECK-FIXES: break;
+  } while(__null);
+
+
+  do {
+int x = 1;
+if (x > 0) continue;
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'continue' in loop with false condition is equivalent to 'break' [misc-terminating-continue]
+// CHECK-FIXES: if (x > 0) break;
+  } while (false);
+}
+
+void g() {
+  do {
+do {
+  continue;
+  int x = 1;
+} while (1 == 1);
+  } while (false);
+
+  do {
+for (int i = 0; i < 1; ++i) {
+  continue;
+  int x = 1;
+}
+  } while (false);
+
+  do {
+while (true) {
+  continue;
+  int x = 1;
+}
+  } while (false);
+
+  int v[] = {1,2,3,34};
+  do {
+for (int n : v) {
+  if (n>2) continue;
+}
+  } while (false);
+}
Index: docs/clang-tidy/checks/misc-terminating-continue.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-terminating-continue.rst
@@ -0,0 +1,34 @@
+.. title:: clang-tidy - misc-terminating-continue
+
+misc-terminating-continue
+=
+
+Detects `do while` loops with a condition always evaluating to false that
+have a `continue` statement, as this `continue` terminates the loop
+effectively.
+
+.. code-block:: c++
+
+  Parser::TPResult Parser::TryParseProtocolQualifiers() {
+assert(Tok.is(tok::less) && "Expected '<' for qualifier list");
+ConsumeToken();
+do {
+  if (Tok.isNot(tok::identifier))
+return TPResult::Error;
+  ConsumeToken();
+
+  if (Tok.is(tok::comma)) {
+ConsumeToken();
+
+//Terminating continue
+continue;
+  }
+
+  if (Tok.is(tok::greater)) {
+ConsumeToken();
+return TPResult::Ambiguous;
+  }
+} while (false);
+
+return TPResult::Error;
+  }
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -149,6 +149,7 @@
misc-non-copyable-objects
misc-redundant-expression
misc-static-assert
+   misc-terminating-continue
misc-throw-by-value-catch-by-reference
misc-unconventional-assign-operator
misc-uniqueptr-reset-release
Index: clang-tidy/misc/TerminatingContinueCheck.h
===
--- /dev/null
+++ clang-tidy/misc/TerminatingContinueCheck.h
@@ -0,0 +1,36 @@
+//===--- TerminatingContinueCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_TERMINATING_CONTINUE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_TERMINATING_CONTINUE_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+/// Checks if a 'continue' statement terminates the loop (i.e. the loop has
+///	a condition which always evaluates to false).
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/misc-terminating-continue.html
+class TerminatingContinueCheck : public ClangTidyCheck {
+public:
+  TerminatingContinueCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::Ma

[PATCH] D37115: [coroutines] Do not attempt to typo-correct when coroutine is looking for required members

2018-03-27 Thread Brian Gesiak via Phabricator via cfe-commits
modocache accepted this revision.
modocache added a comment.
This revision is now accepted and ready to land.

Excellent, thanks!


https://reviews.llvm.org/D37115



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


r328641 - Update test after r328635 in LLVM

2018-03-27 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Tue Mar 27 10:17:39 2018
New Revision: 328641

URL: http://llvm.org/viewvc/llvm-project?rev=328641&view=rev
Log:
Update test after r328635 in LLVM

Modified:
cfe/trunk/test/CodeGen/alias.c

Modified: cfe/trunk/test/CodeGen/alias.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/alias.c?rev=328641&r1=328640&r2=328641&view=diff
==
--- cfe/trunk/test/CodeGen/alias.c (original)
+++ cfe/trunk/test/CodeGen/alias.c Tue Mar 27 10:17:39 2018
@@ -23,20 +23,20 @@ const int wacom_usb_ids[] = {1, 1, 2, 3,
 extern const int __mod_usb_device_table __attribute__ 
((alias("wacom_usb_ids")));
 // CHECKBASIC-DAG: @__mod_usb_device_table = alias i32, getelementptr inbounds 
([8 x i32], [8 x i32]* @wacom_usb_ids, i32 0, i32 0)
 // CHECKASM-DAG: .globl __mod_usb_device_table
-// CHECKASM-DAG: __mod_usb_device_table = wacom_usb_ids
+// CHECKASM-DAG: .set __mod_usb_device_table, wacom_usb_ids
 // CHECKASM-NOT: .size __mod_usb_device_table
 
 extern int g1;
 extern int g1 __attribute((alias("g0")));
 // CHECKBASIC-DAG: @g1 = alias i32, i32* @g0
 // CHECKASM-DAG: .globl g1
-// CHECKASM-DAG: g1 = g0
+// CHECKASM-DAG: .set g1, g0
 // CHECKASM-NOT: .size g1
 
 extern __thread int __libc_errno __attribute__ ((alias ("TL_WITH_ALIAS")));
 // CHECKBASIC-DAG: @__libc_errno = thread_local alias i32, i32* @TL_WITH_ALIAS
 // CHECKASM-DAG: .globl __libc_errno
-// CHECKASM-DAG: __libc_errno = TL_WITH_ALIAS
+// CHECKASM-DAG: .set __libc_errno, TL_WITH_ALIAS
 // CHECKASM-NOT: .size __libc_errno
 
 void f0(void) { }


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


[PATCH] D44189: [RISCV] Verify the input value of -march=

2018-03-27 Thread Ana Pazos via Phabricator via cfe-commits
apazos added inline comments.



Comment at: lib/Driver/ToolChains/Arch/RISCV.cpp:51
+  break;
+case 'g':
+  // g = imafd

One more question - how about non-standard extensions (vendor/custom) prefixed 
with X?
Shouldn't we add the logic to process 'Xext' occurrences in the march string as 
part of this patch?



Repository:
  rC Clang

https://reviews.llvm.org/D44189



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


[PATCH] D44788: Add an option to support debug fission on implicit ThinLTO.

2018-03-27 Thread Yunlian Jiang via Phabricator via cfe-commits
yunlian updated this revision to Diff 139956.

https://reviews.llvm.org/D44788

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/CommonArgs.cpp
  test/Driver/lto-dwo.c


Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -415,6 +415,16 @@
   if (IsThinLTO)
 CmdArgs.push_back("-plugin-opt=thinlto");
 
+  if (Arg *A = Args.getLastArg(options::OPT_glto_dwo_dir_EQ)) {
+const char *Objcopy =
+Args.MakeArgString(ToolChain.GetProgramPath(CLANG_DEFAULT_OBJCOPY));
+CmdArgs.push_back(
+Args.MakeArgString(Twine("-plugin-opt=objcopy=") + Objcopy));
+StringRef DWO_Dir = A->getValue();
+CmdArgs.push_back(
+Args.MakeArgString(Twine("-plugin-opt=dwo_dir=") + DWO_Dir));
+  }
+
   if (unsigned Parallelism = getLTOParallelism(Args, D))
 CmdArgs.push_back(
 Args.MakeArgString("-plugin-opt=jobs=" + Twine(Parallelism)));
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1700,6 +1700,7 @@
 def gcolumn_info : Flag<["-"], "gcolumn-info">, Group, 
Flags<[CoreOption]>;
 def gno_column_info : Flag<["-"], "gno-column-info">, Group, 
Flags<[CoreOption]>;
 def gsplit_dwarf : Flag<["-"], "gsplit-dwarf">, Group;
+def glto_dwo_dir_EQ : Joined<["-"], "glto-dwo-dir=">, Group;
 def ggnu_pubnames : Flag<["-"], "ggnu-pubnames">, Group, 
Flags<[CC1Option]>;
 def gdwarf_aranges : Flag<["-"], "gdwarf-aranges">, Group;
 def gmodules : Flag <["-"], "gmodules">, Group,
Index: docs/ClangCommandLineReference.rst
===
--- docs/ClangCommandLineReference.rst
+++ docs/ClangCommandLineReference.rst
@@ -2587,6 +2587,8 @@
 
 .. option:: -gstrict-dwarf, -gno-strict-dwarf
 
+.. option:: -glto-dwo-dir=
+
 .. option:: -gz
 
 DWARF debug sections compression type
Index: test/Driver/lto-dwo.c
===
--- /dev/null
+++ test/Driver/lto-dwo.c
@@ -0,0 +1,8 @@
+// Confirm that -glto-dwo-dir=DIR is passed to linker
+
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin 
-glto-dwo-dir=DIR 2> %t
+// RUN: FileCheck -check-prefix=CHECK-LINK-DWO-DIR < %t %s
+// RUN: FileCheck -check-prefix=CHECK-LINK-OBJCOPY < %t %s
+//
+// CHECK-LINK-DWO-DIR: "-plugin-opt=dwo_dir=DIR"
+// CHECK-LINK-OBJCOPY: "-plugin-opt=objcopy={{.*}}objcopy"


Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -415,6 +415,16 @@
   if (IsThinLTO)
 CmdArgs.push_back("-plugin-opt=thinlto");
 
+  if (Arg *A = Args.getLastArg(options::OPT_glto_dwo_dir_EQ)) {
+const char *Objcopy =
+Args.MakeArgString(ToolChain.GetProgramPath(CLANG_DEFAULT_OBJCOPY));
+CmdArgs.push_back(
+Args.MakeArgString(Twine("-plugin-opt=objcopy=") + Objcopy));
+StringRef DWO_Dir = A->getValue();
+CmdArgs.push_back(
+Args.MakeArgString(Twine("-plugin-opt=dwo_dir=") + DWO_Dir));
+  }
+
   if (unsigned Parallelism = getLTOParallelism(Args, D))
 CmdArgs.push_back(
 Args.MakeArgString("-plugin-opt=jobs=" + Twine(Parallelism)));
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1700,6 +1700,7 @@
 def gcolumn_info : Flag<["-"], "gcolumn-info">, Group, Flags<[CoreOption]>;
 def gno_column_info : Flag<["-"], "gno-column-info">, Group, Flags<[CoreOption]>;
 def gsplit_dwarf : Flag<["-"], "gsplit-dwarf">, Group;
+def glto_dwo_dir_EQ : Joined<["-"], "glto-dwo-dir=">, Group;
 def ggnu_pubnames : Flag<["-"], "ggnu-pubnames">, Group, Flags<[CC1Option]>;
 def gdwarf_aranges : Flag<["-"], "gdwarf-aranges">, Group;
 def gmodules : Flag <["-"], "gmodules">, Group,
Index: docs/ClangCommandLineReference.rst
===
--- docs/ClangCommandLineReference.rst
+++ docs/ClangCommandLineReference.rst
@@ -2587,6 +2587,8 @@
 
 .. option:: -gstrict-dwarf, -gno-strict-dwarf
 
+.. option:: -glto-dwo-dir=
+
 .. option:: -gz
 
 DWARF debug sections compression type
Index: test/Driver/lto-dwo.c
===
--- /dev/null
+++ test/Driver/lto-dwo.c
@@ -0,0 +1,8 @@
+// Confirm that -glto-dwo-dir=DIR is passed to linker
+
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -glto-dwo-dir=DIR 2> %t
+// RUN: FileCheck -check-prefix=CHECK-LINK-DWO-DIR < %t %s
+// RUN: FileCheck -check-prefix=CHECK-LINK-OBJCOPY < %t %s
+//
+// CHECK-LINK-DWO-DIR: "-plugin-opt=dwo_dir=DIR"
+// CHECK-LINK-OBJCOPY: "-plugin-opt=objcopy={{.*}

[PATCH] D44815: [AArch64]: Add support for parsing rN registers.

2018-03-27 Thread Peter Smith via Phabricator via cfe-commits
peter.smith added a comment.

Thanks for the clarification. With that in mind I'm much less concerned that 
adding "r" as an alias will make extra warnings more difficult.  I agree that 
there should be at least a warning for register long x asm ("wn") although that 
is separate from this patch. Has anyone else got any objections?


Repository:
  rC Clang

https://reviews.llvm.org/D44815



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


[PATCH] D44727: [RISCV] Implement getTargetDefines, handleTargetFeatures and hasFeature for RISCVTargetInfo

2018-03-27 Thread Ana Pazos via Phabricator via cfe-commits
apazos added inline comments.



Comment at: test/Preprocessor/riscv-target-features.c:9
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32im -x c -E -dM %s 
-o - | FileCheck --check-prefix=CHECK-M-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64im -x c -E -dM %s 
-o - | FileCheck --check-prefix=CHECK-M-EXT %s

Consider breaking  the long lines to be within 80 cols.


Repository:
  rC Clang

https://reviews.llvm.org/D44727



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


[PATCH] D33844: [clang-tidy] terminating continue check

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



Comment at: test/clang-tidy/misc-terminating-continue.cpp:7
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: terminating 'continue' 
[misc-terminating-continue]
+  } while(false);
+

Quuxplusone wrote:
> I initially expected to see tests also for
> 
> goto L1;
> while (false) {
> L1:
> continue;  // 'continue' is equivalent to 'break'
> }
> 
> int v = 0;
> goto L1;
> for (; false; ++v) {
> L1:
> continue;  // 'continue' is NOT equivalent to 'break'
> }
> 
> although I assume your current patch doesn't actually diagnose the former, 
> and that's probably fine.
I think both of your examples are out of scope for this check and are they 
realistic?

The usage of `goto` is addressed in `cppcoreguidelines-avoid-goto`


https://reviews.llvm.org/D33844



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


[clang-tools-extra] r328645 - Attempt to fix clangd test on Windows by wildcarding drive letters

2018-03-27 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Mar 27 10:44:12 2018
New Revision: 328645

URL: http://llvm.org/viewvc/llvm-project?rev=328645&view=rev
Log:
Attempt to fix clangd test on Windows by wildcarding drive letters

Modified:
clang-tools-extra/trunk/test/clangd/textdocument-didchange-fail.test

Modified: clang-tools-extra/trunk/test/clangd/textdocument-didchange-fail.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/textdocument-didchange-fail.test?rev=328645&r1=328644&r2=328645&view=diff
==
--- clang-tools-extra/trunk/test/clangd/textdocument-didchange-fail.test 
(original)
+++ clang-tools-extra/trunk/test/clangd/textdocument-didchange-fail.test Tue 
Mar 27 10:44:12 2018
@@ -19,7 +19,7 @@
 # CHECK-NEXT:  "line": 0
 # CHECK-NEXT:}
 # CHECK-NEXT:  },
-# CHECK-NEXT:  "uri": "file:///clangd-test/main.cpp"
+# CHECK-NEXT:  "uri": "file://{{.*}}/clangd-test/main.cpp"
 # CHECK-NEXT:}
 # CHECK-NEXT:  ]
 ---


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


Re: [clang-tools-extra] r328500 - [clangd] Support incremental document syncing

2018-03-27 Thread Reid Kleckner via cfe-commits
One of these new tests does not pass on Windows due to assumptions about
absolute path structure. The FileCheck output seems self-explanatory:

$ "FileCheck" "-strict-whitespace"
"C:\b\slave\clang-x86-windows-msvc2015\clang-x86-windows-msvc2015\llvm\tools\clang\tools\extra\test\clangd\textdocument-didchange-fail.test"
# command stderr:
C:\b\slave\clang-x86-windows-msvc2015\clang-x86-windows-msvc2015\llvm\tools\clang\tools\extra\test\clangd\textdocument-didchange-fail.test:22:20:
error: expected string not found in input
# CHECK-NEXT:  "uri": "file:///clangd-test/main.cpp"
   ^
:68:7: note: scanning from here
  "uri": "file:///C%3a/clangd-test/main.cpp"

I committed a speculative fix for this in r328645, hopefully it does the
job.

On Mon, Mar 26, 2018 at 7:32 PM Simon Marchi via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: simark
> Date: Mon Mar 26 07:41:40 2018
> New Revision: 328500
>
> URL: http://llvm.org/viewvc/llvm-project?rev=328500&view=rev
> Log:
> [clangd] Support incremental document syncing
>
> Summary:
> This patch adds support for incremental document syncing, as described
> in the LSP spec.  The protocol specifies ranges in terms of Position (a
> line and a character), and our drafts are stored as plain strings.  So I
> see two things that may not be super efficient for very large files:
>
> - Converting a Position to an offset (the positionToOffset function)
>   requires searching for end of lines until we reach the desired line.
> - When we update a range, we construct a new string, which implies
>   copying the whole document.
>
> However, for the typical size of a C++ document and the frequency of
> update (at which a user types), it may not be an issue.  This patch aims
> at getting the basic feature in, and we can always improve it later if
> we find it's too slow.
>
> Signed-off-by: Simon Marchi 
>
> Reviewers: malaperle, ilya-biryukov
>
> Reviewed By: ilya-biryukov
>
> Subscribers: MaskRay, klimek, mgorny, ilya-biryukov, jkorous-apple,
> ioeric, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D44272
>
> Added:
> clang-tools-extra/trunk/test/clangd/textdocument-didchange-fail.test
> clang-tools-extra/trunk/unittests/clangd/DraftStoreTests.cpp
> Modified:
> clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
> clang-tools-extra/trunk/clangd/DraftStore.cpp
> clang-tools-extra/trunk/clangd/DraftStore.h
> clang-tools-extra/trunk/clangd/Protocol.cpp
> clang-tools-extra/trunk/clangd/Protocol.h
> clang-tools-extra/trunk/test/clangd/initialize-params-invalid.test
> clang-tools-extra/trunk/test/clangd/initialize-params.test
> clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt
>
> Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=328500&r1=328499&r2=328500&view=diff
>
> ==
> --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
> +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Mon Mar 26 07:41:40
> 2018
> @@ -100,7 +100,7 @@ void ClangdLSPServer::onInitialize(Initi
>reply(json::obj{
>{{"capabilities",
>  json::obj{
> -{"textDocumentSync", 1},
> +{"textDocumentSync", (int)TextDocumentSyncKind::Incremental},
>  {"documentFormattingProvider", true},
>  {"documentRangeFormattingProvider", true},
>  {"documentOnTypeFormattingProvider",
> @@ -147,25 +147,30 @@ void ClangdLSPServer::onDocumentDidOpen(
>PathRef File = Params.textDocument.uri.file();
>std::string &Contents = Params.textDocument.text;
>
> -  DraftMgr.updateDraft(File, Contents);
> +  DraftMgr.addDraft(File, Contents);
>Server.addDocument(File, Contents, WantDiagnostics::Yes);
>  }
>
>  void ClangdLSPServer::onDocumentDidChange(DidChangeTextDocumentParams
> &Params) {
> -  if (Params.contentChanges.size() != 1)
> -return replyError(ErrorCode::InvalidParams,
> -  "can only apply one change at a time");
>auto WantDiags = WantDiagnostics::Auto;
>if (Params.wantDiagnostics.hasValue())
>  WantDiags = Params.wantDiagnostics.getValue() ? WantDiagnostics::Yes
>: WantDiagnostics::No;
>
>PathRef File = Params.textDocument.uri.file();
> -  std::string &Contents = Params.contentChanges[0].text;
> +  llvm::Expected Contents =
> +  DraftMgr.updateDraft(File, Params.contentChanges);
> +  if (!Contents) {
> +// If this fails, we are most likely going to be not in sync anymore
> with
> +// the client.  It is better to remove the draft and let further
> operations
> +// fail rather than giving wrong results.
> +DraftMgr.removeDraft(File);
> +Server.removeDocument(File);
> +log(llvm::toString(Contents.takeError()));
> +return;
> +  }
>
> -  // We

[PATCH] D44883: [Sema] Extend -Wself-assign and -Wself-assign-field to warn on overloaded self-assignment (classes)

2018-03-27 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/Sema/SemaExpr.cpp:12093
+break;
+  }
+

I think doing this here can result in double-warning if the overload resolves 
to a builtin operator.  Now, it might not actually be possible for that to 
combine with the requirements for self-assignment, but still, I think the right 
place to diagnose this for C++ is the same place we call DiagnoseSelfMove in 
CreateOverloadedBinOp.

Can CheckIdentityFieldAssignment just be integrated with DiagnoseSelfAssignment 
so that callers don't need to do call both?


Repository:
  rC Clang

https://reviews.llvm.org/D44883



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


[PATCH] D44888: [RISCV] Default enable linker relaxation and add -mno-relax flag to disable it

2018-03-27 Thread Ana Pazos via Phabricator via cfe-commits
apazos added inline comments.



Comment at: include/clang/Driver/Options.td:1874
 
+def mno_relax : Flag<["-"], "mno-relax">,
+Group;

I think we should define both -mrelax and -mno-relax flags



Comment at: lib/Driver/ToolChains/Arch/RISCV.cpp:55
   }
+  if (Args.getLastArg(options::OPT_mno_relax)) {
+// Not passing relax.

If we add both mrelax and mno-relax flags, we need to update this logic...

// -mrelax is default, unless -mno-relax is specified.
bool Relax = true;
if (auto *A = Args.getLastArg(options::OPT_mrelax, options::OPT_mno_relax))
  if(A->getOption().matches(options::OPT_mno_relax))
Relax = false;
if (Relax)
 Features.push_back("+relax");




Repository:
  rC Clang

https://reviews.llvm.org/D44888



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


[PATCH] D43322: Diagnose cases of "return x" that should be "return std::move(x)" for efficiency

2018-03-27 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone updated this revision to Diff 139961.
Quuxplusone edited the summary of this revision.
Quuxplusone added a comment.

Rebased on master.  AFAIK this is ready to go and I just need someone to land 
it for me... @rtrieu ping?

I believe the PR summary would be suitable as a commit message.


Repository:
  rC Clang

https://reviews.llvm.org/D43322

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaStmt.cpp
  test/SemaCXX/warn-return-std-move.cpp

Index: test/SemaCXX/warn-return-std-move.cpp
===
--- /dev/null
+++ test/SemaCXX/warn-return-std-move.cpp
@@ -0,0 +1,334 @@
+// RUN: %clang_cc1 -fsyntax-only -Wreturn-std-move -Wreturn-std-move-in-cxx11 -std=c++11 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wreturn-std-move -Wreturn-std-move-in-cxx11 -std=c++11 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+// definitions for std::move
+namespace std {
+inline namespace foo {
+template  struct remove_reference { typedef T type; };
+template  struct remove_reference { typedef T type; };
+template  struct remove_reference { typedef T type; };
+
+template  typename remove_reference::type &&move(T &&t);
+} // namespace foo
+} // namespace std
+
+struct Instrument {
+Instrument() {}
+Instrument(Instrument&&) { /* MOVE */ }
+Instrument(const Instrument&) { /* COPY */ }
+};
+struct ConvertFromBase { Instrument i; };
+struct ConvertFromDerived { Instrument i; };
+struct Base {
+Instrument i;
+operator ConvertFromBase() const& { return ConvertFromBase{i}; }
+operator ConvertFromBase() && { return ConvertFromBase{std::move(i)}; }
+};
+struct Derived : public Base {
+operator ConvertFromDerived() const& { return ConvertFromDerived{i}; }
+operator ConvertFromDerived() && { return ConvertFromDerived{std::move(i)}; }
+};
+struct ConstructFromBase {
+Instrument i;
+ConstructFromBase(const Base& b): i(b.i) {}
+ConstructFromBase(Base&& b): i(std::move(b.i)) {}
+};
+struct ConstructFromDerived {
+Instrument i;
+ConstructFromDerived(const Derived& d): i(d.i) {}
+ConstructFromDerived(Derived&& d): i(std::move(d.i)) {}
+};
+
+struct TrivialInstrument {
+int i = 42;
+};
+struct ConvertFromTrivialBase { TrivialInstrument i; };
+struct ConvertFromTrivialDerived { TrivialInstrument i; };
+struct TrivialBase {
+TrivialInstrument i;
+operator ConvertFromTrivialBase() const& { return ConvertFromTrivialBase{i}; }
+operator ConvertFromTrivialBase() && { return ConvertFromTrivialBase{std::move(i)}; }
+};
+struct TrivialDerived : public TrivialBase {
+operator ConvertFromTrivialDerived() const& { return ConvertFromTrivialDerived{i}; }
+operator ConvertFromTrivialDerived() && { return ConvertFromTrivialDerived{std::move(i)}; }
+};
+struct ConstructFromTrivialBase {
+TrivialInstrument i;
+ConstructFromTrivialBase(const TrivialBase& b): i(b.i) {}
+ConstructFromTrivialBase(TrivialBase&& b): i(std::move(b.i)) {}
+};
+struct ConstructFromTrivialDerived {
+TrivialInstrument i;
+ConstructFromTrivialDerived(const TrivialDerived& d): i(d.i) {}
+ConstructFromTrivialDerived(TrivialDerived&& d): i(std::move(d.i)) {}
+};
+
+Derived test1() {
+Derived d1;
+return d1;  // ok
+}
+Base test2() {
+Derived d2;
+return d2;  // e1
+// expected-warning@-1{{will be copied despite being returned by name}}
+// expected-note@-2{{to avoid copying}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d2)"
+}
+ConstructFromDerived test3() {
+Derived d3;
+return d3;  // e2-cxx11
+// expected-warning@-1{{would have been copied despite being returned by name}}
+// expected-note@-2{{to avoid copying on older compilers}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d3)"
+}
+ConstructFromBase test4() {
+Derived d4;
+return d4;  // e3
+// expected-warning@-1{{will be copied despite being returned by name}}
+// expected-note@-2{{to avoid copying}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d4)"
+}
+ConvertFromDerived test5() {
+Derived d5;
+return d5;  // e4
+// expected-warning@-1{{will be copied despite being returned by name}}
+// expected-note@-2{{to avoid copying}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d5)"
+}
+ConvertFromBase test6() {
+Derived d6;
+return d6;  // e5
+// expected-warning@-1{{will be copied despite being returned by name}}
+// expected-note@-2{{to avoid copying}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d6)"
+}
+
+// These test cases should not produce the warning.
+Derived ok1() { Derived d; return d; }
+Base ok2() { Derived d; return static_cast(d); }
+ConstructFromDerived ok3() { Derived d; return static_cast(d); }
+ConstructFromBase ok4() { Derived d; re

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

2018-03-27 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

@koldaniel Have you evaluated this checker? On which codebases? Were the 
warnings real security issues, or were they mostly spurious? The code seems 
fine, but I'm not sure whether it should be in `security` or in `alpha`.


https://reviews.llvm.org/D35068



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


[PATCH] D43871: [modules] No longer include stdlib.h from mm_malloc.h.

2018-03-27 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor updated this revision to Diff 139963.
teemperor added a comment.

- Added more test cases for reverse include order and clang modules.


https://reviews.llvm.org/D43871

Files:
  lib/Headers/mm_malloc.h
  lib/Sema/SemaExceptionSpec.cpp
  test/CXX/except/except.spec/Inputs/clang/mm_malloc.h
  test/CXX/except/except.spec/Inputs/clang/module.modulemap
  test/CXX/except/except.spec/Inputs/libc/module.modulemap
  test/CXX/except/except.spec/Inputs/libc/stdlib.h
  test/CXX/except/except.spec/libc-empty-except.cpp

Index: test/CXX/except/except.spec/libc-empty-except.cpp
===
--- /dev/null
+++ test/CXX/except/except.spec/libc-empty-except.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -std=c++11 -isystem %S/Inputs/clang -internal-externc-isystem %S/Inputs/libc -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -isystem %S/Inputs/clang -internal-externc-isystem %S/Inputs/libc -fexceptions -fcxx-exceptions -fsyntax-only -verify -DREVERSE %s
+// One of the headers is in a user include, so our redeclaration should fail.
+// RUN: not %clang_cc1 -std=c++11 -I %S/Inputs/clang -internal-externc-isystem %S/Inputs/libc -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
+// RUN: not %clang_cc1 -std=c++11 -isystem %S/Inputs/clang -I %S/Inputs/libc -fexceptions -fcxx-exceptions -fsyntax-only -verify -DREVERSE %s
+
+// The same test cases again with enabled modules.
+// The modules cases *all* pass because we marked both as [system].
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -fimplicit-module-maps -fmodules-cache-path=%t \
+// RUN:-std=c++11 -isystem %S/Inputs/clang -internal-externc-isystem %S/Inputs/libc -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -fimplicit-module-maps -fmodules-cache-path=%t \
+// RUN:-std=c++11 -isystem %S/Inputs/clang -internal-externc-isystem %S/Inputs/libc -fexceptions -fcxx-exceptions -fsyntax-only -verify -DREVERSE %s
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -fimplicit-module-maps -fmodules-cache-path=%t \
+// RUN:-std=c++11 -I %S/Inputs/clang -internal-externc-isystem %S/Inputs/libc -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -fimplicit-module-maps -fmodules-cache-path=%t \
+// RUN:-std=c++11 -isystem %S/Inputs/clang -I %S/Inputs/libc -fexceptions -fcxx-exceptions -fsyntax-only -verify -DREVERSE %s
+
+// expected-no-diagnostics
+#ifdef REVERSE
+#include "mm_malloc.h"
+#include "stdlib.h"
+#else
+#include "mm_malloc.h"
+#include "stdlib.h"
+#endif
+
+void f() {
+  free(nullptr);
+}
Index: test/CXX/except/except.spec/Inputs/libc/stdlib.h
===
--- /dev/null
+++ test/CXX/except/except.spec/Inputs/libc/stdlib.h
@@ -0,0 +1,2 @@
+// declare free like glibc with a empty exception specifier.
+extern "C" void free(void *ptr) throw();
Index: test/CXX/except/except.spec/Inputs/libc/module.modulemap
===
--- /dev/null
+++ test/CXX/except/except.spec/Inputs/libc/module.modulemap
@@ -0,0 +1,4 @@
+module libc [system] {
+  header "stdlib.h"
+  export *
+}
Index: test/CXX/except/except.spec/Inputs/clang/module.modulemap
===
--- /dev/null
+++ test/CXX/except/except.spec/Inputs/clang/module.modulemap
@@ -0,0 +1,4 @@
+module builtin [system] {
+  header "mm_malloc.h"
+  export *
+}
Index: test/CXX/except/except.spec/Inputs/clang/mm_malloc.h
===
--- /dev/null
+++ test/CXX/except/except.spec/Inputs/clang/mm_malloc.h
@@ -0,0 +1,3 @@
+// missing throw() is allowed in this case as we are in a system header.
+// This is a redeclaration possibly from glibc.
+extern "C" void free(void *ptr);
Index: lib/Sema/SemaExceptionSpec.cpp
===
--- lib/Sema/SemaExceptionSpec.cpp
+++ lib/Sema/SemaExceptionSpec.cpp
@@ -213,6 +213,7 @@
 const FunctionProtoType *New, SourceLocation NewLoc,
 bool *MissingExceptionSpecification = nullptr,
 bool *MissingEmptyExceptionSpecification = nullptr,
+bool *ExtraEmptyExceptionSpecification = nullptr,
 bool AllowNoexceptAllMatchWithNoSpec = false, bool IsOperatorNew = false);
 
 /// Determine whether a function has an implicitly-generated exception
@@ -236,6 +237,15 @@
   return !Ty->hasExceptionSpec();
 }
 
+/// Returns true if the given function is a function/builtin with C linkage
+/// and from a system header.
+static bool isCSystemFuncOrBuiltin(FunctionDecl *D, ASTContext &Context) {
+  return (D->getLocation().isInvalid() ||
+  Con

[PATCH] D43341: [clang-doc] Implement reducer portion of the frontend framework

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

It's surprisingly difficult to review this :/
Just by itself the logic is simple, but the amount of blocks/records/record 
types is kinda demoralizing.
I really hope it will be possible to somehow tablegen this later.




Comment at: clang-doc/BitcodeReader.cpp:363
+CommentInfo &
+ClangDocBitcodeReader::getCommentInfo(std::unique_ptr &I) {
+  I->Children.emplace_back(llvm::make_unique());

Hmm, why does this function exist?
The only difference from the previous one is the `std::unique_ptr<>`.



Comment at: clang-doc/BitcodeReader.cpp:488
+  // Sniff for the signature.
+  if (Stream.Read(8) != 'D' || Stream.Read(8) != 'O' || Stream.Read(8) != 'C' 
||
+  Stream.Read(8) != 'S')

This signature should be in one place (header?), and then just used here and in 
`ClangDocBitcodeWriter::emitHeader()`



Comment at: clang-doc/BitcodeWriter.cpp:537
 
+void ClangDocBitcodeWriter::emitInfoSet(InfoSet &ISet) {
+  for (const auto &I : ISet.getNamespaceInfos()) emitBlock(I);

It should be `void ClangDocBitcodeWriter::emitInfoSet(const InfoSet &ISet) {` 
then.



Comment at: clang-doc/BitcodeWriter.h:129
 // Check that the static size is large-enough.
 assert(Record.capacity() > BitCodeConstants::RecordSize);
   }

Isn't that the opposite of what was that assert supposed to do?
It would have been better to just `// disable` it, and add a `FIXME` note.



Comment at: clang-doc/tool/ClangDocMain.cpp:138
+llvm::outs() << "Writing intermediate results...\n";
+SmallString<4098> Buffer;
+llvm::BitstreamWriter Stream(Buffer);

`4096`?


https://reviews.llvm.org/D43341



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


r328654 - [Sema] Avoid crash for category implementation without interface

2018-03-27 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Tue Mar 27 11:58:28 2018
New Revision: 328654

URL: http://llvm.org/viewvc/llvm-project?rev=328654&view=rev
Log:
[Sema] Avoid crash for category implementation without interface

When we have a category implementation without a corresponding interface
(which is an error by itself), semantic checks for property accesses
will attempt to access a null interface declaration and then segfault.
Error out in such cases instead.

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

Added:
cfe/trunk/test/SemaObjC/undef-class-property-error.m
Modified:
cfe/trunk/lib/Sema/SemaExprMember.cpp

Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=328654&r1=328653&r2=328654&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprMember.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprMember.cpp Tue Mar 27 11:58:28 2018
@@ -1568,6 +1568,9 @@ static ExprResult LookupMemberExpr(Sema
   // Also must look for a getter name which uses property syntax.
   Selector Sel = S.PP.getSelectorTable().getNullarySelector(Member);
   ObjCInterfaceDecl *IFace = MD->getClassInterface();
+  if (!IFace)
+goto fail;
+
   ObjCMethodDecl *Getter;
   if ((Getter = IFace->lookupClassMethod(Sel))) {
 // Check the use of this method.

Added: cfe/trunk/test/SemaObjC/undef-class-property-error.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/undef-class-property-error.m?rev=328654&view=auto
==
--- cfe/trunk/test/SemaObjC/undef-class-property-error.m (added)
+++ cfe/trunk/test/SemaObjC/undef-class-property-error.m Tue Mar 27 11:58:28 
2018
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@implementation I (C) // expected-error {{cannot find interface declaration 
for 'I'}}
+
++ (void)f {
+  self.m; // expected-error {{member reference base type 'Class' is not a 
structure or union}}
+}
+
+@end


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


[PATCH] D44882: [clangd] Implementation of workspace/symbol request

2018-03-27 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle marked 9 inline comments as done.
malaperle added a comment.

In https://reviews.llvm.org/D44882#1048355, @sammccall wrote:

> Can we split this patch up (it's pretty large anyway) and land the 
> `workspaceSymbols` implementation first, without changing the indexer 
> behavior?
>
> I think the indexer changes are in the right direction, but I think 
> "ForCompletion" isn't quite enough metadata, and don't want to block 
> everything on that.


Sounds good. ForCompletion was more of a short term hack in my mind, we can try 
to split it and make proper metadata.

>> We have a lot more features in mind that will make the index much bigger, 
>> like adding all occurrences (maybe not in the current YAML though).
> 
> (tangential)
>  FWIW, I think *that* might be a case where we want quite a different API - I 
> think this is a file-major index operation (handful of results per file) 
> rather than a symbol-major one (results per symbol is essentially unbounded, 
> e.g. `std::string`). At the scale of google's internal codebase, this means 
> we need a different backend, and this may be the case for large open-source 
> codebases too (I know chromium hits scaling issues with indexers they try). 
>  There are also other operations where results are files rather than symbols: 
> which files include file x, etc.

Yeah, there needs to be an API to fetch things per file, such as the 
dependencies and the occurrences it contains (for updating when the file is 
deleted, etc). I'm not sure there needs to be an API that queries a file for a 
given USR though, I think that could be transparent to the caller and an 
implementation detail. The results could be grouped by file though. Good 
discussion for future patches :)

>> But having options to control the amount of information indexed sounds good 
>> to me as there can be a lot of different project sizes and there can be 
>> different tradeoffs. I had in mind to an option for including/excluding the 
>> occurrences because without them, you lose workspace/references, call 
>> hierarchy, etc, but you still have code completion and workspace/symbol, 
>> document/symbol, etc while making the index much smaller. But more options 
>> sounds good.
> 
> If we add options, someone has to actually set them.
>  Anything that's too big for google's internal index or similar can be 
> filtered out in the wrapping code (mapreduce) if the indexer exposes enough 
> information to do so.
>  We shouldn't have problems with the in-memory dynamic index.
>  Features that are off in the default static indexer configuration won't end 
> up getting used much.

I think everything should be ON by default but we can run into issues that the 
user wants to reduce index size and help indexing speed. We had such options in 
CDT since there are quite a few things that can make it big (macro expansion 
steps, all references, etc). But this can be added as needed later.

> So I can see a use for filters where the command-line indexer (YAML) would 
> run too slow otherwise, but a) let's cross that bridge when we come to it

Sounds good.

In https://reviews.llvm.org/D44882#1049007, @ilya-biryukov wrote:

> >>> - Current `fuzzyFind` implementation can only match qualifiers strictly 
> >>> (i.e. st::vector won't match std::vector). Should we look into allowing 
> >>> fuzzy matches for this feature?  (not in this patch, rather in the long 
> >>> term).
> >> 
> >> I'm not sure, I'm thinking there should be a balance between how fuzzy it 
> >> it and how much noise it generates. Right now I find it a bit too fuzzy 
> >> since when I type "Draft" (to find DraftMgr), it picks up things like 
> >> DocumentRangeFormattingParams. Adding fuzziness to the namespace would 
> >> make this worse. Maybe with improved scoring it won't matter too much? 
> >> I'll try FuzzyMatcher and see.
> > 
> > +1, I think experience with `workspaceSymbols` will help us answer this 
> > question.
>
> I was using an IDE that had fuzzy find for an equivalent of 
> `workspaceSymbols` and found it to be an amazing experience. And having 
> consistent behavior between different features is really nice.
>  Good ranking is a key to it being useful, though. If when typing `Draft` you 
> get `DocumentRangeFormattingParams` ranked higher than `DraftMgr` that's a 
> bug in FuzzyMatcher. If you have some not-very-nice results at the end of the 
> list, this shouldn't be a problem in most cases.
>
> I'm highly in favor of enabling fuzzy matching for `workspaceSymbols`.


I think it will be fine once we address the bug(s). As long as the exact 
matches are always first then there's no problem.




Comment at: clangd/ClangdLSPServer.cpp:99
   
Params.capabilities.textDocument.completion.completionItem.snippetSupport;
+  if (Params.capabilities.workspace && Params.capabilities.workspace->symbol &&
+  Params.capabilities.workspace->symbol->symbolKind)

sammccall wrote:
> This is the analogue to the on

[PATCH] D44916: [Sema] Avoid crash for category implementation without interface

2018-03-27 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL328654: [Sema] Avoid crash for category implementation 
without interface (authored by smeenai, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D44916

Files:
  cfe/trunk/lib/Sema/SemaExprMember.cpp
  cfe/trunk/test/SemaObjC/undef-class-property-error.m


Index: cfe/trunk/test/SemaObjC/undef-class-property-error.m
===
--- cfe/trunk/test/SemaObjC/undef-class-property-error.m
+++ cfe/trunk/test/SemaObjC/undef-class-property-error.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@implementation I (C) // expected-error {{cannot find interface declaration 
for 'I'}}
+
++ (void)f {
+  self.m; // expected-error {{member reference base type 'Class' is not a 
structure or union}}
+}
+
+@end
Index: cfe/trunk/lib/Sema/SemaExprMember.cpp
===
--- cfe/trunk/lib/Sema/SemaExprMember.cpp
+++ cfe/trunk/lib/Sema/SemaExprMember.cpp
@@ -1568,6 +1568,9 @@
   // Also must look for a getter name which uses property syntax.
   Selector Sel = S.PP.getSelectorTable().getNullarySelector(Member);
   ObjCInterfaceDecl *IFace = MD->getClassInterface();
+  if (!IFace)
+goto fail;
+
   ObjCMethodDecl *Getter;
   if ((Getter = IFace->lookupClassMethod(Sel))) {
 // Check the use of this method.


Index: cfe/trunk/test/SemaObjC/undef-class-property-error.m
===
--- cfe/trunk/test/SemaObjC/undef-class-property-error.m
+++ cfe/trunk/test/SemaObjC/undef-class-property-error.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@implementation I (C) // expected-error {{cannot find interface declaration for 'I'}}
+
++ (void)f {
+  self.m; // expected-error {{member reference base type 'Class' is not a structure or union}}
+}
+
+@end
Index: cfe/trunk/lib/Sema/SemaExprMember.cpp
===
--- cfe/trunk/lib/Sema/SemaExprMember.cpp
+++ cfe/trunk/lib/Sema/SemaExprMember.cpp
@@ -1568,6 +1568,9 @@
   // Also must look for a getter name which uses property syntax.
   Selector Sel = S.PP.getSelectorTable().getNullarySelector(Member);
   ObjCInterfaceDecl *IFace = MD->getClassInterface();
+  if (!IFace)
+goto fail;
+
   ObjCMethodDecl *Getter;
   if ((Getter = IFace->lookupClassMethod(Sel))) {
 // Check the use of this method.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2018-03-27 Thread Matthew Voss via Phabricator via cfe-commits
ormris added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:2992
+  std::string NameString = Name.str();
+  llvm::raw_string_ostream ParameterizedName(NameString);
+  ParameterizedName << "<";

JDevlieghere wrote:
> Why not use Name.str() directly?
I got "error: invalid initialization of non-const reference ... from rvalue 
...". Using NameString fixed the issue.


Repository:
  rC Clang

https://reviews.llvm.org/D44842



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


[PATCH] D44882: [clangd] Implementation of workspace/symbol request

2018-03-27 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle updated this revision to Diff 139968.
malaperle marked 4 inline comments as done.
malaperle added a comment.

Split the patch so that this part only has the workspace/symbol part
and the index model will be updated separately.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44882

Files:
  clangd/CMakeLists.txt
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/FindSymbols.cpp
  clangd/FindSymbols.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  clangd/XRefs.cpp
  clangd/index/SymbolCollector.cpp
  clangd/tool/ClangdMain.cpp
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test
  unittests/clangd/CMakeLists.txt
  unittests/clangd/FindSymbolsTests.cpp
  unittests/clangd/SyncAPI.cpp
  unittests/clangd/SyncAPI.h

Index: unittests/clangd/SyncAPI.h
===
--- unittests/clangd/SyncAPI.h
+++ unittests/clangd/SyncAPI.h
@@ -41,6 +41,10 @@
 
 std::string runDumpAST(ClangdServer &Server, PathRef File);
 
+llvm::Expected>
+runWorkspaceSymbols(ClangdServer &Server, StringRef Query,
+const WorkspaceSymbolOptions &Opts);
+
 } // namespace clangd
 } // namespace clang
 
Index: unittests/clangd/SyncAPI.cpp
===
--- unittests/clangd/SyncAPI.cpp
+++ unittests/clangd/SyncAPI.cpp
@@ -110,5 +110,13 @@
   return std::move(*Result);
 }
 
+llvm::Expected>
+runWorkspaceSymbols(ClangdServer &Server, StringRef Query,
+const WorkspaceSymbolOptions &Opts) {
+  llvm::Optional>> Result;
+  Server.workspaceSymbols(Query, Opts, capture(Result));
+  return std::move(*Result);
+}
+
 } // namespace clangd
 } // namespace clang
Index: unittests/clangd/FindSymbolsTests.cpp
===
--- /dev/null
+++ unittests/clangd/FindSymbolsTests.cpp
@@ -0,0 +1,380 @@
+//===-- FindSymbolsTests.cpp -*- C++ -*===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+#include "Annotations.h"
+#include "ClangdServer.h"
+#include "FindSymbols.h"
+#include "SyncAPI.h"
+#include "TestFS.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+
+void PrintTo(const SymbolInformation &I, std::ostream *O) {
+  llvm::raw_os_ostream OS(*O);
+  OS << I.containerName << I.name << " - " << toJSON(I);
+}
+
+namespace {
+
+using ::testing::AllOf;
+using ::testing::AnyOf;
+using ::testing::ElementsAre;
+using ::testing::IsEmpty;
+using ::testing::UnorderedElementsAre;
+
+class IgnoreDiagnostics : public DiagnosticsConsumer {
+  void onDiagnosticsReady(PathRef File,
+  std::vector Diagnostics) override {}
+};
+
+// GMock helpers for matching SymbolInfos items.
+MATCHER_P(Named, Name, "") { return arg.name == Name; }
+MATCHER_P(InContainer, ContainerName, "") {
+  return arg.containerName == ContainerName;
+}
+MATCHER_P(WithKind, Kind, "") { return arg.kind == Kind; }
+
+class WorkspaceSymbolsTest : public ::testing::Test {
+protected:
+  std::unique_ptr FSProvider;
+  std::unique_ptr CDB;
+  std::unique_ptr DiagConsumer;
+  std::unique_ptr Server;
+  std::unique_ptr Opts;
+
+  virtual void SetUp() override {
+FSProvider = llvm::make_unique();
+CDB = llvm::make_unique();
+DiagConsumer = llvm::make_unique();
+auto ServerOpts = ClangdServer::optsForTest();
+ServerOpts.BuildDynamicSymbolIndex = true;
+Server = llvm::make_unique(*CDB, *FSProvider, *DiagConsumer,
+ ServerOpts);
+Opts = llvm::make_unique();
+  }
+
+  std::vector getSymbols(StringRef Query) {
+EXPECT_TRUE(Server->blockUntilIdleForTest()) << "Waiting for preamble";
+auto SymbolInfos = runWorkspaceSymbols(*Server, Query, *Opts);
+EXPECT_TRUE(bool(SymbolInfos)) << "workspaceSymbols returned an error";
+return *SymbolInfos;
+  }
+
+  void addFile(StringRef FileName, StringRef Contents) {
+auto Path = testPath(FileName);
+FSProvider->Files[Path] = Contents;
+Server->addDocument(Path, Contents);
+  }
+};
+
+} // namespace
+
+TEST_F(WorkspaceSymbolsTest, NoMacro) {
+  addFile("foo.cpp", R"cpp(
+  #define MACRO X
+  )cpp");
+
+  // Macros are not in the index.
+  EXPECT_THAT(getSymbols("macro"), IsEmpty());
+}
+
+TEST_F(WorkspaceSymbolsTest, NoLocals) {
+  addFile("foo.cpp", R"cpp(
+  void test() {
+struct LocalClass {};
+int local_var;
+  })cpp");
+  EXPECT_THAT(getSymbols("local_var"), IsEmpty());
+  EXPECT_THAT(getSymbols("LocalClass"), IsEmpty());

[PATCH] D43341: [clang-doc] Implement reducer portion of the frontend framework

2018-03-27 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 139972.
juliehockett marked 4 inline comments as done.
juliehockett added a comment.

Small fixes to address comments


https://reviews.llvm.org/D43341

Files:
  clang-doc/BitcodeReader.cpp
  clang-doc/BitcodeReader.h
  clang-doc/BitcodeWriter.cpp
  clang-doc/BitcodeWriter.h
  clang-doc/CMakeLists.txt
  clang-doc/Reducer.cpp
  clang-doc/Reducer.h
  clang-doc/Representation.cpp
  clang-doc/Representation.h
  clang-doc/tool/ClangDocMain.cpp
  test/clang-doc/bc-comment.cpp
  test/clang-doc/bc-namespace.cpp
  test/clang-doc/bc-record.cpp

Index: test/clang-doc/bc-record.cpp
===
--- /dev/null
+++ test/clang-doc/bc-record.cpp
@@ -0,0 +1,178 @@
+// This test requires Linux due to the system-dependent USR for the
+// inner class in function H.
+// REQUIRES: system-linux
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/bc/docs.bc --dump | FileCheck %s
+
+union A { int X; int Y; };
+
+enum B { X, Y };
+
+enum class Bc { A, B };
+
+struct C { int i; };
+
+class D {};
+
+class E {
+public:
+  E() {}
+  ~E() {}
+
+protected:
+  void ProtectedMethod();
+};
+
+void E::ProtectedMethod() {}
+
+class F : virtual private D, public E {};
+
+class X {
+  class Y {};
+};
+
+void H() {
+  class I {};
+}
+
+// CHECK: 
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = 'E'
+  // CHECK-NEXT:  blob data = '289584A8E0FF4178A794622A547AA622503967A1'
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = '{{.*}}'
+  // CHECK-NEXT:  blob data = '289584A8E0FF4178A794622A547AA622503967A1'
+  // CHECK-NEXT: 
+// CHECK-NEXT:  blob data = 'void'
+  // CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = '~E'
+  // CHECK-NEXT:  blob data = '289584A8E0FF4178A794622A547AA622503967A1'
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = '{{.*}}'
+  // CHECK-NEXT:  blob data = '289584A8E0FF4178A794622A547AA622503967A1'
+  // CHECK-NEXT: 
+// CHECK-NEXT:  blob data = 'void'
+  // CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = 'ProtectedMethod'
+  // CHECK-NEXT:  blob data = '289584A8E0FF4178A794622A547AA622503967A1'
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = '{{.*}}'
+  // CHECK-NEXT:  blob data = '{{.*}}'
+  // CHECK-NEXT:  blob data = '289584A8E0FF4178A794622A547AA622503967A1'
+  // CHECK-NEXT: 
+// CHECK-NEXT:  blob data = 'void'
+  // CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = 'H'
+  // CHECK-NEXT:  blob data = '3433664532ABFCC39301646A10E768C1882BF194'
+  // CHECK-NEXT:  blob data = '{{.*}}'
+  // CHECK-NEXT: 
+// CHECK-NEXT:  blob data = 'void'
+  // CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = 'A'
+  // CHECK-NEXT:  blob data = '{{.*}}'
+  // CHECK-NEXT: 
+  // CHECK-NEXT: 
+// CHECK-NEXT:  blob data = 'int'
+// CHECK-NEXT:  blob data = 'A::X'
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+  // CHECK-NEXT: 
+// CHECK-NEXT:  blob data = 'int'
+// CHECK-NEXT:  blob data = 'A::Y'
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = 'C'
+  // CHECK-NEXT:  blob data = '{{.*}}'
+  // CHECK-NEXT: 
+// CHECK-NEXT:  blob data = 'int'
+// CHECK-NEXT:  blob data = 'C::i'
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = 'D'
+  // CHECK-NEXT:  blob data = 'E3B54702FABFF4037025BA194FC27C47006330B5'
+  // CHECK-NEXT:  blob data = '{{.*}}'
+  // CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = 'E'
+  // CHECK-NEXT:  blob data = 'E3B54702FABFF4037025BA194FC27C47006330B5'
+  // CHECK-NEXT:  blob data = 'DEB4AC1CD9253CD9EF7FBE6BCAC506D77984ABD4'
+  // CHECK-NEXT:  blob data = 'DEB4AC1CD9253CD9EF7FBE6BCAC506D77984ABD4'
+  // CHECK-NEXT:  blob data = 'BD2BDEBD423F80BACCEA75DE6D6622D355FC2D17'
+  // CHECK-NEXT:  blob data = 'BD2BDEBD423F80BACCEA75DE6D6622D355FC2D17'
+  // CHECK-NEXT:  blob data = '5093D428CDC62096A67547BA52566E4FB9404EEE'
+  // CHECK-NEXT:  blob data = '5093D428CDC62096A67547BA52566E4FB9404EEE'
+  // CHECK-NEXT:  blob data = '{{.*}}'
+  // CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = 'F'
+  // CHECK-NEXT:  blob data = '{{.*}}'
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = '289584A8E0FF4178A794622A547AA622503967A1'
+  // CHECK-NEXT:  blob data = '0921737541208B8FA9BB42B60F78AC1D779AA054'
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+  // CHECK-NEXT: 
+  // CHECK-NEXT:  blob data = 'X'
+  // CHECK-NEXT:  blob data = '641AB4A3D36399954ACDE29C7A8833032BF40

[PATCH] D43341: [clang-doc] Implement reducer portion of the frontend framework

2018-03-27 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added inline comments.



Comment at: clang-doc/BitcodeReader.cpp:27
+  assert(Record[0] == 20);
+  for (int I = 0, E = Record[0]; I < E; ++I)
+Field[I] = Record[I + 1];

lebedev.ri wrote:
> Ok, i don't understand what is going on here.
> Where is this `E` defined?
> This looks like `[0]` is the number of elements to read (always 20, sha1 
> blob?),
> and it copies Record[1]..Record[20] to Field[0]..Field[19] ?
> I think this can/should be rewritten clearer..
`Record[0]` holds the size of the array -- in this case, 20 -- in the bitstream 
representation of the array (see the array section [[ 
https://llvm.org/docs/BitCodeFormat.html#define-abbrev-encoding | here ]]). So, 
yes, it copies Record[1]...[20] to Field[0]...[19]. Not sure how that can be 
rewritten more clearly, but I'll add a clarifying comment!



Comment at: clang-doc/BitcodeWriter.h:129
 // Check that the static size is large-enough.
 assert(Record.capacity() > BitCodeConstants::RecordSize);
   }

lebedev.ri wrote:
> Isn't that the opposite of what was that assert supposed to do?
> It would have been better to just `// disable` it, and add a `FIXME` note.
I'm not sure I'm understanding you -- my understanding was that it existed to 
check that the record size was large enough.



Comment at: clang-doc/Reducer.cpp:18
+std::unique_ptr mergeInfos(tooling::ToolResults *Results) {
+  std::unique_ptr UniqueInfos = llvm::make_unique();
+  bool Err = false;

lebedev.ri wrote:
> I can see that you may `return nullptr;` in case of error here, thus it's 
> `std::unique_ptr<>`
> `InfoSet` internally is just a few `std::vector<>`s, so it should 
> `std::move()` efficiently.
> I'm wondering if `llvm::Optional` would work too?
Doesn't `llvm::Optional` imply that it *could* validly not exist though? This 
is trying to express here that that isn't a valid state.



Comment at: clang-doc/Representation.h:135
   Info() = default;
-  Info(Info &&Other) : Description(std::move(Other.Description)) {}
-  virtual ~Info() = default;
+  Info(Info &&Other)
+  : USR(Other.USR), Name(Other.Name), 
Namespace(std::move(Other.Namespace)),

lebedev.ri wrote:
> Why is the move constructor explicitly defined?
> Unless i'm missing something, the default one would do exactly the same.
> https://godbolt.org/g/XqsRuX
It's there (as is the CommentInfo one) because otherwise it was throwing 
errors. It appears that a copy constructor is called somewhere if this isn't 
specified.


https://reviews.llvm.org/D43341



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


[PATCH] D44723: Set dso_local when clearing dllimport

2018-03-27 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm

I'd add more tests but I can't think of ways to remove the dll attributes, only 
to flip them.

Do we already have dso_local tests for this similar case:

  __declspec(dllimport) void f();
  void g() { f(); } // use it
  void f() { }

It flips from dllimport to dllexport.


https://reviews.llvm.org/D44723



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


[PATCH] D43341: [clang-doc] Implement reducer portion of the frontend framework

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



Comment at: clang-doc/BitcodeWriter.h:129
 // Check that the static size is large-enough.
 assert(Record.capacity() > BitCodeConstants::RecordSize);
   }

juliehockett wrote:
> lebedev.ri wrote:
> > Isn't that the opposite of what was that assert supposed to do?
> > It would have been better to just `// disable` it, and add a `FIXME` note.
> I'm not sure I'm understanding you -- my understanding was that it existed to 
> check that the record size was large enough.
https://reviews.llvm.org/D41102?id=136520#inline-384087
```
#ifndef NDEBUG // Don't want explicit dtor unless needed
~ClangDocBitcodeWriter() {
  // Check that the static size is large-enough.
  assert(Record.capacity() == BitCodeConstants::RecordSize);
}
#endif
```
I.e. it checked that it still only had the static size, and did not transform 
into normal `vector` with data stored on heap-allocated buffer.


https://reviews.llvm.org/D43341



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


[PATCH] D44330: CMake option to allow enabling experimental new pass manager by default

2018-03-27 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: clang/CMakeLists.txt:215
 
+set(ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER FALSE CACHE BOOL
+  "Enable the experimental new pass manager by default.")

chandlerc wrote:
> Does it make sense to put the word `DEFAULT` into the variable name? I don't 
> feel strongly either way.
I was following the `ENABLE_X86_RELAX_RELOCATIONS` above which is a similar 
flag in terms of its effect on the driver. Would you prefer 
`ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER_BY_DEFAULT`? It's more descriptive but 
also rather long.


Repository:
  rC Clang

https://reviews.llvm.org/D44330



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


[PATCH] D44947: [Driver] Add fuzzer-no-link into the list of supported Fuchsia sanitizers

2018-03-27 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: mcgrathr, aarongreen.
Herald added a subscriber: cfe-commits.

This is needed in addition to fuzzer in order to use libFuzzer.


Repository:
  rC Clang

https://reviews.llvm.org/D44947

Files:
  clang/lib/Driver/ToolChains/Fuchsia.cpp


Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -280,6 +280,7 @@
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::Fuzzer;
+  Res |= SanitizerKind::FuzzerNoLink;
   Res |= SanitizerKind::SafeStack;
   Res |= SanitizerKind::Scudo;
   return Res;


Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -280,6 +280,7 @@
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::Fuzzer;
+  Res |= SanitizerKind::FuzzerNoLink;
   Res |= SanitizerKind::SafeStack;
   Res |= SanitizerKind::Scudo;
   return Res;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r328657 - AMDGPU: Update datalayout for stack alignment

2018-03-27 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Tue Mar 27 12:26:51 2018
New Revision: 328657

URL: http://llvm.org/viewvc/llvm-project?rev=328657&view=rev
Log:
AMDGPU: Update datalayout for stack alignment

Modified:
cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
cfe/trunk/test/CodeGen/target-data.c
cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgcn.cl

Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.cpp?rev=328657&r1=328656&r2=328657&view=diff
==
--- cfe/trunk/lib/Basic/Targets/AMDGPU.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AMDGPU.cpp Tue Mar 27 12:26:51 2018
@@ -30,12 +30,12 @@ namespace targets {
 
 static const char *const DataLayoutStringR600 =
 "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
-"-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5";
+"-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5";
 
 static const char *const DataLayoutStringAMDGCN =
 "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32"
 "-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
-"-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5";
+"-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5";
 
 const LangASMap AMDGPUTargetInfo::AMDGPUDefIsGenMap = {
 Generic,  // Default

Modified: cfe/trunk/test/CodeGen/target-data.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/target-data.c?rev=328657&r1=328656&r2=328657&view=diff
==
--- cfe/trunk/test/CodeGen/target-data.c (original)
+++ cfe/trunk/test/CodeGen/target-data.c Tue Mar 27 12:26:51 2018
@@ -124,20 +124,20 @@
 
 // RUN: %clang_cc1 -triple r600-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=R600
-// R600: target datalayout = 
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
+// R600: target datalayout = 
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
 
 // RUN: %clang_cc1 -triple r600-unknown -target-cpu cayman -o - -emit-llvm %s \
 // RUN: | FileCheck %s -check-prefix=R600D
-// R600D: target datalayout = 
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
+// R600D: target datalayout = 
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
 
 // RUN: %clang_cc1 -triple amdgcn-unknown -target-cpu hawaii -o - -emit-llvm 
%s \
 // RUN: | FileCheck %s -check-prefix=R600SI
-// R600SI: target datalayout = 
"e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
+// R600SI: target datalayout = 
"e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
 
 // Test default -target-cpu
 // RUN: %clang_cc1 -triple amdgcn-unknown -o - -emit-llvm %s \
 // RUN: | FileCheck %s -check-prefix=R600SIDefault
-// R600SIDefault: target datalayout = 
"e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
+// R600SIDefault: target datalayout = 
"e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
 
 // RUN: %clang_cc1 -triple arm64-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=AARCH64

Modified: cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgcn.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgcn.cl?rev=328657&r1=328656&r2=328657&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgcn.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgcn.cl Tue Mar 27 12:26:51 2018
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 %s -O0 -triple amdgcn -emit-llvm -o - | FileCheck %s
 // RUN: %clang_cc1 %s -O0 -triple amdgcn---opencl -emit-llvm -o - | FileCheck 
%s
 
-// CHECK: target datalayout = 
"e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
+// CHECK: target datalayout = 
"e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
 void foo(void) {}


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


[PATCH] D44589: [Sema] Make deprecation fix-it replace all multi-parameter ObjC method slots.

2018-03-27 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 139981.
vsapsai added a comment.

- More tweaks. Remove MultiSourceLocation as nobobody, including me, sees much 
value in it.


https://reviews.llvm.org/D44589

Files:
  clang/include/clang/Basic/CharInfo.h
  clang/include/clang/Sema/DelayedDiagnostic.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/DelayedDiagnostic.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/test/SemaObjC/attr-deprecated-replacement-fixit.m
  clang/unittests/Basic/CharInfoTest.cpp

Index: clang/unittests/Basic/CharInfoTest.cpp
===
--- clang/unittests/Basic/CharInfoTest.cpp
+++ clang/unittests/Basic/CharInfoTest.cpp
@@ -432,6 +432,7 @@
   EXPECT_TRUE(isValidIdentifier("z"));
   EXPECT_TRUE(isValidIdentifier("A"));
   EXPECT_TRUE(isValidIdentifier("Z"));
+  EXPECT_TRUE(isValidIdentifier("$", /*AllowDollar=*/true));
 
   // 2 characters, '_' suffix
   EXPECT_FALSE(isValidIdentifier("._"));
@@ -448,6 +449,7 @@
   EXPECT_TRUE(isValidIdentifier("z_"));
   EXPECT_TRUE(isValidIdentifier("A_"));
   EXPECT_TRUE(isValidIdentifier("Z_"));
+  EXPECT_TRUE(isValidIdentifier("$_", /*AllowDollar=*/true));
 
   // 2 characters, '_' prefix
   EXPECT_FALSE(isValidIdentifier("_."));
@@ -464,6 +466,7 @@
   EXPECT_TRUE(isValidIdentifier("_z"));
   EXPECT_TRUE(isValidIdentifier("_A"));
   EXPECT_TRUE(isValidIdentifier("_Z"));
+  EXPECT_TRUE(isValidIdentifier("_$", /*AllowDollar=*/true));
 
   // 3 characters, '__' prefix
   EXPECT_FALSE(isValidIdentifier("__."));
@@ -480,6 +483,7 @@
   EXPECT_TRUE(isValidIdentifier("__z"));
   EXPECT_TRUE(isValidIdentifier("__A"));
   EXPECT_TRUE(isValidIdentifier("__Z"));
+  EXPECT_TRUE(isValidIdentifier("__$", /*AllowDollar=*/true));
 
   // 3 characters, '_' prefix and suffix
   EXPECT_FALSE(isValidIdentifier("_._"));
@@ -496,4 +500,5 @@
   EXPECT_TRUE(isValidIdentifier("_z_"));
   EXPECT_TRUE(isValidIdentifier("_A_"));
   EXPECT_TRUE(isValidIdentifier("_Z_"));
+  EXPECT_TRUE(isValidIdentifier("_$_", /*AllowDollar=*/true));
 }
Index: clang/test/SemaObjC/attr-deprecated-replacement-fixit.m
===
--- /dev/null
+++ clang/test/SemaObjC/attr-deprecated-replacement-fixit.m
@@ -0,0 +1,177 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck --implicit-check-not fix-it: %s
+// RUN: cp %s %t
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -DIGNORE_UNSUCCESSFUL_RENAMES -fixit -x objective-c %t
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -DIGNORE_UNSUCCESSFUL_RENAMES -Werror -x objective-c %t
+
+#if !__has_feature(attribute_deprecated_with_replacement)
+#error "Missing __has_feature"
+#endif
+
+#if !__has_feature(attribute_availability_with_replacement)
+#error "Missing __has_feature"
+#endif
+
+#define DEPRECATED(replacement) __attribute__((deprecated("message", replacement)))
+
+@protocol SuccessfulMultiParameterRenames
+// expected-note@+1 {{has been explicitly marked deprecated here}}
+- (void)multi:(int)param1 parameter:(int)param2 replacement:(int)param3 DEPRECATED("multi_new:parameter_new:replace_new_ment:");
+- (void)multi_new:(int)param1 parameter_new:(int)param2 replace_new_ment:(int)param3;
+
+// expected-note@+1 {{has been explicitly marked deprecated here}}
+- (void)varArgs:(int)params, ... DEPRECATED("renameVarArgs:");
+- (void)renameVarArgs:(int)params, ...;
+
+// expected-note@+1 {{has been explicitly marked deprecated here}}
+- (void)leadingMinus:(int)param DEPRECATED("-leadingMinusRenamed:");
+- (void)leadingMinusRenamed:(int)param;
+
+// expected-note@+1 {{has been explicitly marked deprecated here}}
+- (void)leadingPlus:(int)param DEPRECATED("+leadingPlusRenamed:");
+- (void)leadingPlusRenamed:(int)param;
+
+// expected-note@+1 {{has been explicitly marked deprecated here}}
+- (void)sourceEmptyName:(int)param1 :(int)param2 DEPRECATED("renameEmptyName:toNonEmpty:");
+- (void)renameEmptyName:(int)param1 toNonEmpty:(int)param2;
+
+// expected-note@+1 {{has been explicitly marked deprecated here}}
+- (void)target:(int)param1 willBecomeEmpty:(int)param2 emptyName:(int)param3 DEPRECATED("target::emptyName:");
+- (void)target:(int)param1 :(int)param2 emptyName:(int)param3;
+
+// expected-note@+1 {{has been explicitly marked deprecated here}}
+- (void)extra:(int)param1 whiteSpace:(int)param2 DEPRECATED("renameExtra:whiteSpace:");
+- (void)renameExtra:(int)param1 whiteSpace:(int)param2;
+
+// Test renaming that was producing valid code earlier is still producing valid
+// code. The difference is that now we detect different number of parameters.
+//
+// expected-note@+1 {{has been explicitly marked deprecated here}}
+- (void)singleArgumentRegression:(int)param DEPRECATED("renameSingleArgument");
+- (void)renameSingleArgument:(int)param;
+@end
+
+void successfulRename

[PATCH] D44948: Add diagnostic -Waggregate-ctors, "aggregate type has user-declared constructors"

2018-03-27 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone created this revision.
Herald added a subscriber: cfe-commits.

This new warning diagnoses any aggregate class/struct/union type which has 
user-declared constructors, in order to test the hypothesis that real code does 
not (intentionally) contain such animals.

  

If no real code triggers this diagnostic, then it would be plausible to change 
the definition of "aggregate type" in C++2a so that types triggering this 
diagnostic would no longer be considered aggregate types at all.


Repository:
  rC Clang

https://reviews.llvm.org/D44948

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclCXX.cpp


Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -5907,6 +5907,10 @@
diag::warn_non_virtual_dtor) << Context.getRecordType(Record);
   }
 
+  if (Record->isAggregate() && Record->hasUserDeclaredConstructor()) {
+Diag(Record->getLocation(), 
diag::warn_aggregate_with_user_declared_constructor);
+  }
+
   if (Record->isAbstract()) {
 if (FinalAttr *FA = Record->getAttr()) {
   Diag(Record->getLocation(), diag::warn_abstract_final_class)
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -6466,6 +6466,9 @@
 def warn_jump_out_of_seh_finally : Warning<
   "jump out of __finally block has undefined behavior">,
   InGroup>;
+def warn_aggregate_with_user_declared_constructor : Warning<
+  "aggregate type has user-declared constructors">,
+  InGroup;
 def warn_non_virtual_dtor : Warning<
   "%0 has virtual functions but non-virtual destructor">,
   InGroup, DefaultIgnore;
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -99,6 +99,7 @@
 def DeleteIncomplete : DiagGroup<"delete-incomplete">;
 def DeleteNonVirtualDtor : DiagGroup<"delete-non-virtual-dtor">;
 def AbstractFinalClass : DiagGroup<"abstract-final-class">;
+def AggregateCtors : DiagGroup<"aggregate-ctors">;
 
 def CXX11CompatDeprecatedWritableStr :
   DiagGroup<"c++11-compat-deprecated-writable-strings">;


Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -5907,6 +5907,10 @@
diag::warn_non_virtual_dtor) << Context.getRecordType(Record);
   }
 
+  if (Record->isAggregate() && Record->hasUserDeclaredConstructor()) {
+Diag(Record->getLocation(), diag::warn_aggregate_with_user_declared_constructor);
+  }
+
   if (Record->isAbstract()) {
 if (FinalAttr *FA = Record->getAttr()) {
   Diag(Record->getLocation(), diag::warn_abstract_final_class)
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -6466,6 +6466,9 @@
 def warn_jump_out_of_seh_finally : Warning<
   "jump out of __finally block has undefined behavior">,
   InGroup>;
+def warn_aggregate_with_user_declared_constructor : Warning<
+  "aggregate type has user-declared constructors">,
+  InGroup;
 def warn_non_virtual_dtor : Warning<
   "%0 has virtual functions but non-virtual destructor">,
   InGroup, DefaultIgnore;
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -99,6 +99,7 @@
 def DeleteIncomplete : DiagGroup<"delete-incomplete">;
 def DeleteNonVirtualDtor : DiagGroup<"delete-non-virtual-dtor">;
 def AbstractFinalClass : DiagGroup<"abstract-final-class">;
+def AggregateCtors : DiagGroup<"aggregate-ctors">;
 
 def CXX11CompatDeprecatedWritableStr :
   DiagGroup<"c++11-compat-deprecated-writable-strings">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44747: Set calling convention for CUDA kernel

2018-03-27 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 3 inline comments as done.
yaxunl added inline comments.



Comment at: lib/Sema/SemaOverload.cpp:1492
+  Changed = true;
+}
+

rjmccall wrote:
> It's cheaper not to check the CUDA language mode here; pulling the CC out of 
> the FPT is easy.
> 
> Why is this necessary, anyway?  From the spec, it doesn't look to me like 
> kernel function pointers can be converted to ordinary function pointers.  A 
> kernel function pointer is supposed to be declared with something like 
> `__global__ void (*fn)(void)`.  You'll need to change your patch to SemaType 
> to apply the CC even when compiling for the host, of course.
> 
> I was going to say that you should use this CC in your validation that calls 
> with execution configurations go to kernel functions, but... I can't actually 
> find where you do that validation.
> 
> Do you need these function pointers to be a different size from the host 
> function pointer?
In CUDA, `__global__` can only be used with function declaration or definition. 
Using it in function pointer declaration will result in a warning: 'global' 
attribute only applies to functions.

Also, there is this lit test in SemaCUDA:

```
__global__ void kernel() {}

typedef void (*fn_ptr_t)();

__host__ fn_ptr_t get_ptr_h() {
  return kernel;
}

```
It allows implicit conversion of `__global__ void()` to void(*)(), therefore I 
need the above change to drop the CUDA kernel calling convention in such 
implicit conversion.


https://reviews.llvm.org/D44747



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


[PATCH] D44882: [clangd] Implementation of workspace/symbol request

2018-03-27 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> Have you considered also allowing '.' and ' ' (space) as separators in the 
> request? Having additional separators doesn't really hurt complexity of the 
> implementation, but allows to switch between tools for different languages 
> easier.

I would suggest allowing patterns containing space to match text without space, 
e.g. pattern `a b` can match text `aB`. The initial character of each word in 
the pattern should be seen as a `Head` position. This behavior matches many 
fuzzy matching plugins used in Emacs and Vim.




Comment at: clangd/SourceCode.cpp:110
+
+llvm::Optional offsetRangeToLocation(SourceManager &SourceMgr,
+   StringRef File,

May I ask a question about the conversion between SourceLocation and LSP 
location? When the document is slightly out of sync with the indexed version, 
what will be returned?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44882



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


[PATCH] D44747: Set calling convention for CUDA kernel

2018-03-27 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/Sema/SemaOverload.cpp:1492
+  Changed = true;
+}
+

yaxunl wrote:
> rjmccall wrote:
> > It's cheaper not to check the CUDA language mode here; pulling the CC out 
> > of the FPT is easy.
> > 
> > Why is this necessary, anyway?  From the spec, it doesn't look to me like 
> > kernel function pointers can be converted to ordinary function pointers.  A 
> > kernel function pointer is supposed to be declared with something like 
> > `__global__ void (*fn)(void)`.  You'll need to change your patch to 
> > SemaType to apply the CC even when compiling for the host, of course.
> > 
> > I was going to say that you should use this CC in your validation that 
> > calls with execution configurations go to kernel functions, but... I can't 
> > actually find where you do that validation.
> > 
> > Do you need these function pointers to be a different size from the host 
> > function pointer?
> In CUDA, `__global__` can only be used with function declaration or 
> definition. Using it in function pointer declaration will result in a 
> warning: 'global' attribute only applies to functions.
> 
> Also, there is this lit test in SemaCUDA:
> 
> ```
> __global__ void kernel() {}
> 
> typedef void (*fn_ptr_t)();
> 
> __host__ fn_ptr_t get_ptr_h() {
>   return kernel;
> }
> 
> ```
> It allows implicit conversion of `__global__ void()` to void(*)(), therefore 
> I need the above change to drop the CUDA kernel calling convention in such 
> implicit conversion.
I see.  I must have mis-read the specification, but I see that the code samples 
I can find online agree with that test case.  So `__global__` function pointers 
are just treated as function pointers, and it's simply undefined behavior if 
you try to call a function pointer that happens to be a kernel without an 
execution configuration, or contrariwise if you use an execution configuration 
to call a function pointer that isn't a kernel.

In that case, I think the best solution is to just immediately strip 
`__global__` from the type of a DRE to a kernel function, since `__global__` 
isn't supposed to be part of the user-facing type system.


https://reviews.llvm.org/D44747



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


[PATCH] D44927: Enable msan unconditionally on Linux

2018-03-27 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added a subscriber: kcc.
eugenis added a comment.

I too find these checks arbitrary and pointless. @kcc ?


Repository:
  rC Clang

https://reviews.llvm.org/D44927



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


[PATCH] D44882: [clangd] Implementation of workspace/symbol request

2018-03-27 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clangd/tool/ClangdMain.cpp:105
 
+static llvm::cl::opt LimitWorkspaceSymbolResult(
+"workspace-symbol-limit",

malaperle wrote:
> sammccall wrote:
> > the -completion-limit was mostly to control rollout, I'm not sure this 
> > needs to be a flag. If it does, can we make it the same flag as completions 
> > (and call it -limit or so?)
> I think it's quite similar to "completions", when you type just one letter 
> for example, you can get a lot of results and a lot of JSON output. So it 
> feels like the flag could apply to both completions and workspace symbols. 
> How about -limit-resuts? I think just -limit might be a bit too general as we 
> might want to limit other things.
Can these options be set by LSP initialization options?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44882



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


[PATCH] D44765: PR36643 Make clang-format support more generic TMarcos

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

I don't have preferences over names, but I agree with Alex that the option 
should have more detailed description.




Comment at: lib/Format/FormatToken.h:138
+  /// \brief Whether this is a string literal similar to _T("sdfsdf").
+  bool TMacroStringLiteral = false;
+

We don't strictly need this new field. We could do as in the old implementation 
and check if the string prefix is from a T macro in ContinuationIndenter.



Comment at: unittests/Format/FormatTest.cpp:10693
+
+  // FIXME: This is required because parsing a configuration simply overwrites
+  // the first N elements of the list instead of resetting it.

Why is the `FIXME` here? I suggest just use the pattern similar to the other 
cases here and just keep the test with 2 elements:
```
Style.TMacros.clear();
std::vector ExpectedTMacros = {"_T", "myT"};
CHECK_PARSE("TMacros: [_T, myT]", TMacros, ExpectedTMacros);
```


Repository:
  rC Clang

https://reviews.llvm.org/D44765



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


[PATCH] D44947: [Driver] Add fuzzer-no-link into the list of supported Fuchsia sanitizers

2018-03-27 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr accepted this revision.
mcgrathr added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rC Clang

https://reviews.llvm.org/D44947



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


[PATCH] D42034: [clang-format] In tests, expected code should be format-stable

2018-03-27 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir requested changes to this revision.
krasimir added a comment.
This revision now requires changes to proceed.

Thank you!
If this works, we should apply it to all files in `unittest/Format`.


Repository:
  rC Clang

https://reviews.llvm.org/D42034



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


r328663 - [coroutines] Do not attempt to typo-correct when coroutine is looking for required members

2018-03-27 Thread Gor Nishanov via cfe-commits
Author: gornishanov
Date: Tue Mar 27 13:38:19 2018
New Revision: 328663

URL: http://llvm.org/viewvc/llvm-project?rev=328663&view=rev
Log:
[coroutines] Do not attempt to typo-correct when coroutine is looking for 
required members

When SemaCoroutine looks for await_resume, it means it. No need for helpful: 
"Did you mean await_ready?" messages.

Fixes PR33477 and a couple of FIXMEs in test/SemaCXX/coroutines.cpp

Modified:
cfe/trunk/lib/Sema/SemaCoroutine.cpp
cfe/trunk/test/SemaCXX/coroutines.cpp

Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=328663&r1=328662&r2=328663&view=diff
==
--- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Tue Mar 27 13:38:19 2018
@@ -362,6 +362,15 @@ static ExprResult buildMemberCall(Sema &
   if (Result.isInvalid())
 return ExprError();
 
+  // We meant exactly what we asked for. No need for typo correction.
+  if (auto *TE = dyn_cast(Result.get())) {
+S.clearDelayedTypo(TE);
+S.Diag(Loc, diag::err_no_member)
+<< NameInfo.getName() << Base->getType()->getAsCXXRecordDecl()
+<< Base->getSourceRange();
+return ExprError();
+  }
+
   return S.ActOnCallExpr(nullptr, Result.get(), Loc, Args, Loc, nullptr);
 }
 

Modified: cfe/trunk/test/SemaCXX/coroutines.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutines.cpp?rev=328663&r1=328662&r2=328663&view=diff
==
--- cfe/trunk/test/SemaCXX/coroutines.cpp (original)
+++ cfe/trunk/test/SemaCXX/coroutines.cpp Tue Mar 27 13:38:19 2018
@@ -510,8 +510,7 @@ coro missing_get_return_o
 
 struct bad_promise_2 {
   coro get_return_object();
-  // FIXME: We shouldn't offer a typo-correction here!
-  suspend_always final_suspend(); // expected-note {{here}}
+  suspend_always final_suspend();
   void unhandled_exception();
   void return_void();
 };
@@ -522,8 +521,7 @@ coro missing_initial_susp
 
 struct bad_promise_3 {
   coro get_return_object();
-  // FIXME: We shouldn't offer a typo-correction here!
-  suspend_always initial_suspend(); // expected-note {{here}}
+  suspend_always initial_suspend();
   void unhandled_exception();
   void return_void();
 };
@@ -1378,3 +1376,22 @@ test_unused_warning() {
   co_await awaitable_unused_warn(); // expected-warning {{ignoring return 
value of function declared with 'nodiscard' attribute}}
   co_yield 42; // expected-warning {{ignoring return value of function 
declared with 'nodiscard' attribute}}
 }
+
+struct missing_await_ready {
+  void await_suspend(std::experimental::coroutine_handle<>);
+  void await_resume();
+};
+struct missing_await_suspend {
+  bool await_ready();
+  void await_resume();
+};
+struct missing_await_resume {
+  bool await_ready();
+  void await_suspend(std::experimental::coroutine_handle<>);
+};
+
+void test_missing_awaitable_members() {
+  co_await missing_await_ready{}; // expected-error {{no member named 
'await_ready' in 'missing_await_ready'}}
+  co_await missing_await_suspend{}; // expected-error {{no member named 
'await_suspend' in 'missing_await_suspend'}}
+  co_await missing_await_resume{}; // expected-error {{no member named 
'await_resume' in 'missing_await_resume'}}
+}


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


[PATCH] D44954: [clangd] [RFC] Add more symbols to the index

2018-03-27 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle created this revision.
Herald added subscribers: cfe-commits, MaskRay, ioeric, jkorous-apple, 
ilya-biryukov, klimek.

This adds more symbols to the index:

- member variables and functions
- symbols in main files
- enum constants in scoped enums

This is a WIP meant as a starting point for discussion towards a better
version.

Signed-off-by: Marc-Andre Laperle 


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44954

Files:
  clangd/CodeComplete.cpp
  clangd/index/Index.h
  clangd/index/MemIndex.cpp
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolYAML.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -60,6 +60,9 @@
  arg.Definition.EndOffset == Offsets.second;
 }
 MATCHER_P(Refs, R, "") { return int(arg.References) == R; }
+MATCHER_P(ForCompletion, ForCompletion, "") {
+  return arg.ForCompletion == ForCompletion;
+}
 
 namespace clang {
 namespace clangd {
@@ -191,25 +194,29 @@
 } // namespace foo
   )";
   runSymbolCollector(Header, /*Main=*/"");
-  EXPECT_THAT(Symbols,
-  UnorderedElementsAreArray(
-  {QName("Foo"), QName("f1"), QName("f2"), QName("KInt"),
-   QName("kStr"), QName("foo"), QName("foo::bar"),
-   QName("foo::int32"), QName("foo::int32_t"), QName("foo::v1"),
-   QName("foo::bar::v2"), QName("foo::baz")}));
+  EXPECT_THAT(
+  Symbols,
+  UnorderedElementsAreArray(
+  {QName("Foo"), QName("Foo::f"), QName("f1"), QName("f2"),
+   QName("KInt"), QName("kStr"), QName("foo"), QName("foo::bar"),
+   QName("foo::int32"), QName("foo::int32_t"), QName("foo::v1"),
+   QName("foo::bar::v2"), QName("foo::baz")}));
 }
 
 TEST_F(SymbolCollectorTest, Template) {
   Annotations Header(R"(
 // Template is indexed, specialization and instantiation is not.
-template  struct [[Tmpl]] {T x = 0;};
+template  struct [[Tmpl]] {T $xdecl[[x]] = 0;};
 template <> struct Tmpl {};
 extern template struct Tmpl;
 template struct Tmpl;
   )");
   runSymbolCollector(Header.code(), /*Main=*/"");
-  EXPECT_THAT(Symbols, UnorderedElementsAreArray({AllOf(
-   QName("Tmpl"), DeclRange(Header.offsetRange()))}));
+  EXPECT_THAT(
+  Symbols,
+  UnorderedElementsAreArray(
+  {AllOf(QName("Tmpl"), DeclRange(Header.offsetRange())),
+   AllOf(QName("Tmpl::x"), DeclRange(Header.offsetRange("xdecl")))}));
 }
 
 TEST_F(SymbolCollectorTest, Locations) {
@@ -228,7 +235,7 @@
 void $printdef[[print]]() {}
 
 // Declared/defined in main only.
-int Y;
+int $ydecl[[Y]];
   )cpp");
   runSymbolCollector(Header.code(), Main.code());
   EXPECT_THAT(
@@ -240,7 +247,8 @@
 DefRange(Main.offsetRange("clsdef"))),
   AllOf(QName("print"), DeclRange(Header.offsetRange("printdecl")),
 DefRange(Main.offsetRange("printdef"))),
-  AllOf(QName("Z"), DeclRange(Header.offsetRange("zdecl");
+  AllOf(QName("Z"), DeclRange(Header.offsetRange("zdecl"))),
+  AllOf(QName("Y"), DeclRange(Main.offsetRange("ydecl");
 }
 
 TEST_F(SymbolCollectorTest, References) {
@@ -262,10 +270,11 @@
   CollectorOpts.CountReferences = true;
   runSymbolCollector(Header, Main);
   EXPECT_THAT(Symbols,
-  UnorderedElementsAre(AllOf(QName("W"), Refs(1)),
-   AllOf(QName("X"), Refs(1)),
-   AllOf(QName("Y"), Refs(0)),
-   AllOf(QName("Z"), Refs(0)), QName("y")));
+  UnorderedElementsAre(
+  AllOf(QName("W"), Refs(1)), AllOf(QName("X"), Refs(1)),
+  AllOf(QName("Y"), Refs(0)), AllOf(QName("Z"), Refs(0)),
+  QName("y"), QName("w"), QName("w2"), QName("x"), QName("V"),
+  QName("v")));
 }
 
 TEST_F(SymbolCollectorTest, SymbolRelativeNoFallback) {
@@ -320,29 +329,31 @@
   Green
 };
 enum class Color2 {
-  Yellow // ignore
+  Yellow
 };
 namespace ns {
 enum {
   Black
 };
 }
   )";
   runSymbolCollector(Header, /*Main=*/"");
-  EXPECT_THAT(Symbols, UnorderedElementsAre(QName("Red"), QName("Color"),
-QName("Green"), QName("Color2"),
-QName("ns"), QName("ns::Black")));
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(QName("Red"), QName("Color"), QName("Green"),
+   QName("Color2"), QName("Color2::Yellow"),
+   QName("ns"), QName("ns::Black")));
 }
 
-TEST_F(SymbolCollectorTest, IgnoreNamelessSymbols) {
+TEST_F

[PATCH] D44955: [CFG] [analyzer] Work around a disappearing CXXBindTemporaryExpr.

2018-03-27 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet.
Herald added subscribers: cfe-commits, rnkovacs.

This is a CFG-side patch for the weird AST i encountered in 
http://lists.llvm.org/pipermail/cfe-dev/2018-March/057398.html . The omission 
of the `CXXBindTemporaryExpr` causes a crash because it produces an unexpected 
construction context for a temporary object that requires non-trivial 
destruction.

I removed the crashing assertion for now, together with the ill-formed 
construction context. Temporary destructor is still missing from the CFG in 
this case, so it was important to remove the construction context, so that not 
to try modeling the constructor when the destructor is completely missing.

CodeGen works fine because they defensively destroy everything they ever wanted 
to destroy at `ExprWithCleanups`.


Repository:
  rC Clang

https://reviews.llvm.org/D44955

Files:
  include/clang/Analysis/ConstructionContext.h
  lib/Analysis/CFG.cpp
  lib/Analysis/ConstructionContext.cpp
  test/Analysis/missing-bind-temporary.cpp

Index: test/Analysis/missing-bind-temporary.cpp
===
--- /dev/null
+++ test/Analysis/missing-bind-temporary.cpp
@@ -0,0 +1,130 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG %s > %t 2>&1
+// RUN: FileCheck --input-file=%t %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -std=c++14 -verify %s
+
+void clang_analyzer_eval(bool);
+
+int global;
+
+namespace variant_0 {
+// This variant of the code works correctly. Function foo() is not a template
+// function. Note that there are two destructors within foo().
+
+class A {
+public:
+  ~A() { ++global; }
+};
+
+class B {
+  A a;
+};
+
+// CHECK: void foo(int)
+// CHECK:   [B1]
+// CHECK-NEXT:1:  (CXXConstructExpr, [B1.2], class variant_0::B)
+// CHECK-NEXT:2: variant_0::B i;
+// CHECK-NEXT:3: operator=
+// CHECK-NEXT:4: [B1.3] (ImplicitCastExpr, FunctionToPointerDecay, class variant_0::B &(*)(class variant_0::B &&) noexcept)
+// CHECK-NEXT:5: i
+// CHECK-NEXT:6: {} (CXXConstructExpr, [B1.7], [B1.8], class variant_0::B)
+// CHECK-NEXT:7: [B1.6] (BindTemporary)
+// CHECK-NEXT:8: [B1.7]
+// CHECK-NEXT:9: [B1.5] = [B1.8] (OperatorCall)
+// CHECK-NEXT:   10: ~variant_0::B() (Temporary object destructor)
+// CHECK-NEXT:   11: [B1.2].~B() (Implicit destructor)
+void foo(int) {
+  B i;
+  i = {};
+}
+
+void bar() {
+  global = 0;
+  foo(1);
+  clang_analyzer_eval(global == 2); // expected-warning{{TRUE}}
+}
+
+} // end namespace variant_0
+
+namespace variant_1 {
+// Suddenly, if we turn foo() into a template, we are missing a
+// CXXBindTemporaryExpr in the AST, and therefore we're missing a
+// temporary destructor in the CFG.
+
+class A {
+public:
+  ~A() { ++global; }
+};
+
+class B {
+  A a;
+};
+
+// FIXME: Find the construction context for {} and enforce the temporary
+// destructor.
+// CHECK: template<> void foo(int)
+// CHECK:   [B1]
+// CHECK-NEXT:1:  (CXXConstructExpr, [B1.2], class variant_1::B)
+// CHECK-NEXT:2: variant_1::B i;
+// CHECK-NEXT:3: operator=
+// CHECK-NEXT:4: [B1.3] (ImplicitCastExpr, FunctionToPointerDecay, class variant_1::B &(*)(class variant_1::B &&) noexcept)
+// CHECK-NEXT:5: i
+// CHECK-NEXT:6: {} (CXXConstructExpr, class variant_1::B)
+// CHECK-NEXT:7: [B1.6]
+// CHECK-NEXT:8: [B1.5] = [B1.7] (OperatorCall)
+// CHECK-NEXT:9: [B1.2].~B() (Implicit destructor)
+template  void foo(T) {
+  B i;
+  i = {};
+}
+
+void bar() {
+  global = 0;
+  foo(1);
+  // FIXME: Should be TRUE, i.e. we should call (and inline) two destructors.
+  clang_analyzer_eval(global == 2); // expected-warning{{UNKNOWN}}
+}
+
+} // end namespace variant_1
+
+namespace variant_2 {
+// Making field 'a' in class 'B' public turns the class into an aggregate.
+// In this case there is no constructor at {} - only an aggregate
+// initialization. Aggregate initialization is unsupported for now.
+
+class A {
+public:
+  ~A() { ++global; }
+};
+
+class B {
+public:
+  A a;
+};
+
+// CHECK: template<> void foo(int)
+// CHECK:   [B1]
+// CHECK-NEXT:1:  (CXXConstructExpr, [B1.2], class variant_2::B)
+// CHECK-NEXT:2: variant_2::B i;
+// CHECK-NEXT:3: operator=
+// CHECK-NEXT:4: [B1.3] (ImplicitCastExpr, FunctionToPointerDecay, class variant_2::B &(*)(class variant_2::B &&) noexcept)
+// CHECK-NEXT:5: i
+// CHECK-NEXT:6: {}
+// CHECK-NEXT:7: {}
+// CHECK-NEXT:8: [B1.7] (BindTemporary)
+// CHECK-NEXT:9: [B1.8]
+// CHECK-NEXT:   10: [B1.5] = [B1.9] (OperatorCall)
+// CHECK-NEXT:   11: ~variant_2::B() (Temporary object destructor)
+// CHECK-NEXT:   12: [B1.2].~B() (Implicit destructor)
+template  void foo(T) {
+  B i;
+  i = {};
+}
+
+void bar() {
+  global = 0;
+  foo(1);
+  // FIXME: Should be TRUE, i.e. we should call (and inline) two destructors.
+  clang_analyzer_eval(global =

[PATCH] D44954: [clangd] [RFC] Add more symbols to the index

2018-03-27 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle planned changes to this revision.
malaperle added inline comments.



Comment at: clangd/index/Index.h:142
+  // Whether or not the symbol should be considered for completion.
+  bool ForCompletion = false;
   /// A brief description of the symbol that can be displayed in the completion

I'm thinking of replacing this with something like:
Decl::Kind DeclContextKind;
bool IsScoped (enum);
bool IsInMainFile;



Comment at: clangd/index/Index.h:255
+  /// A flag to restrict the results to completion matches.
+  bool CompletionMatchesOnly = false;
 };

Would be removed when "ForCompletion" is replaced.



Comment at: clangd/index/MemIndex.cpp:48
 continue;
+  if (Req.CompletionMatchesOnly && !Sym->ForCompletion)
+continue;

Would be removed when "ForCompletion" is replaced.



Comment at: clangd/index/SymbolCollector.cpp:124
+
+bool isForCompletion(const NamedDecl *ND, ASTContext *ASTCtx) {
+  using namespace clang::ast_matchers;

This code would be replaced with setting individual Symbol fields instead.



Comment at: clangd/index/SymbolCollector.cpp:342
+  if (isForCompletion(&ND, ASTCtx)) {
+S.ForCompletion = true;
+getLabelAndInsertText(*CCS, &Label, &SnippetInsertText,

Here we would set fields that will replace "ForCompletion"


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44954



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


[PATCH] D44882: [clangd] Implementation of workspace/symbol request

2018-03-27 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

The index changes are moved here: https://reviews.llvm.org/D44954 I haven't 
changed the patch yet though, I just removed it from this one.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44882



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


r328671 - [Sema] Emit -Winteger-overflow for arguments in function calls, ObjC messages.

2018-03-27 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Tue Mar 27 14:29:05 2018
New Revision: 328671

URL: http://llvm.org/viewvc/llvm-project?rev=328671&view=rev
Log:
[Sema] Emit -Winteger-overflow for arguments in function calls, ObjC messages.

rdar://problem/35539384

Reviewers: ahatanak, nicholas, rsmith, jkorous-apple

Reviewed By: jkorous-apple

Subscribers: cfe-commits, jkorous-apple

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


Added:
cfe/trunk/test/SemaObjC/integer-overflow.m
Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/integer-overflow.c
cfe/trunk/test/SemaCXX/integer-overflow.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=328671&r1=328670&r2=328671&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Mar 27 14:29:05 2018
@@ -10225,18 +10225,22 @@ void Sema::CheckForIntOverflow (Expr *E)
   SmallVector Exprs(1, E);
 
   do {
-Expr *E = Exprs.pop_back_val();
+Expr *OriginalE = Exprs.pop_back_val();
+Expr *E = OriginalE->IgnoreParenCasts();
 
-if (isa(E->IgnoreParenCasts())) {
-  E->IgnoreParenCasts()->EvaluateForOverflow(Context);
+if (isa(E)) {
+  E->EvaluateForOverflow(Context);
   continue;
 }
 
-if (auto InitList = dyn_cast(E))
+if (auto InitList = dyn_cast(OriginalE))
   Exprs.append(InitList->inits().begin(), InitList->inits().end());
-
-if (isa(E))
-  E->IgnoreParenCasts()->EvaluateForOverflow(Context);
+else if (isa(OriginalE))
+  E->EvaluateForOverflow(Context);
+else if (auto Call = dyn_cast(E))
+  Exprs.append(Call->arg_begin(), Call->arg_end());
+else if (auto Message = dyn_cast(E))
+  Exprs.append(Message->arg_begin(), Message->arg_end());
   } while (!Exprs.empty());
 }
 

Modified: cfe/trunk/test/Sema/integer-overflow.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/integer-overflow.c?rev=328671&r1=328670&r2=328671&view=diff
==
--- cfe/trunk/test/Sema/integer-overflow.c (original)
+++ cfe/trunk/test/Sema/integer-overflow.c Tue Mar 27 14:29:05 2018
@@ -158,6 +158,21 @@ uint64_t check_integer_overflows(int i)
   return ((4608 * 1024 * 1024) + ((uint64_t)(4608 * 1024 * 1024)));
 }
 
+void check_integer_overflows_in_function_calls() {
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 
'int'}}
+  (void)f0(4608 * 1024 * 1024);
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 
'int'}}
+  uint64_t x = f0(4608 * 1024 * 1024);
+
+// expected-warning@+2 {{overflow in expression; result is 536870912 with type 
'int'}}
+  uint64_t (*f0_ptr)(uint64_t) = &f0;
+  (void)(*f0_ptr)(4608 * 1024 * 1024);
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 
'int'}}
+  (void)f2(0, f0(4608 * 1024 * 1024));
+}
+
 struct s {
   unsigned x;
   unsigned y;

Modified: cfe/trunk/test/SemaCXX/integer-overflow.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/integer-overflow.cpp?rev=328671&r1=328670&r2=328671&view=diff
==
--- cfe/trunk/test/SemaCXX/integer-overflow.cpp (original)
+++ cfe/trunk/test/SemaCXX/integer-overflow.cpp Tue Mar 27 14:29:05 2018
@@ -169,3 +169,18 @@ uint64_t check_integer_overflows(int i)
 // expected-warning@+1 2{{overflow in expression; result is 536870912 with 
type 'int'}}
   return ((4608 * 1024 * 1024) + ((uint64_t)(4608 * 1024 * 1024)));
 }
+
+void check_integer_overflows_in_function_calls() {
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 
'int'}}
+  (void)f0(4608 * 1024 * 1024);
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 
'int'}}
+  uint64_t x = f0(4608 * 1024 * 1024);
+
+// expected-warning@+2 {{overflow in expression; result is 536870912 with type 
'int'}}
+  uint64_t (*f0_ptr)(uint64_t) = &f0;
+  (void)(*f0_ptr)(4608 * 1024 * 1024);
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 
'int'}}
+  (void)f2(0, f0(4608 * 1024 * 1024));
+}

Added: cfe/trunk/test/SemaObjC/integer-overflow.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/integer-overflow.m?rev=328671&view=auto
==
--- cfe/trunk/test/SemaObjC/integer-overflow.m (added)
+++ cfe/trunk/test/SemaObjC/integer-overflow.m Tue Mar 27 14:29:05 2018
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -Wno-objc-root-class -fsyntax-only -verify %s
+
+@interface Foo
+@end
+
+@implementation Foo
+- (int)add:(int)a with:(int)b {
+  return a + b;
+}
+
+- (void)testIntegerOverflows {
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 
'int'}}
+  (vo

[PATCH] D42938: [Sema] Emit -Winteger-overflow for arguments in function calls, ObjC messages.

2018-03-27 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL328671: [Sema] Emit -Winteger-overflow for arguments in 
function calls, ObjC messages. (authored by vsapsai, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42938?vs=132917&id=140006#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42938

Files:
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/Sema/integer-overflow.c
  cfe/trunk/test/SemaCXX/integer-overflow.cpp
  cfe/trunk/test/SemaObjC/integer-overflow.m

Index: cfe/trunk/test/SemaCXX/integer-overflow.cpp
===
--- cfe/trunk/test/SemaCXX/integer-overflow.cpp
+++ cfe/trunk/test/SemaCXX/integer-overflow.cpp
@@ -169,3 +169,18 @@
 // expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
   return ((4608 * 1024 * 1024) + ((uint64_t)(4608 * 1024 * 1024)));
 }
+
+void check_integer_overflows_in_function_calls() {
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+  (void)f0(4608 * 1024 * 1024);
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+  uint64_t x = f0(4608 * 1024 * 1024);
+
+// expected-warning@+2 {{overflow in expression; result is 536870912 with type 'int'}}
+  uint64_t (*f0_ptr)(uint64_t) = &f0;
+  (void)(*f0_ptr)(4608 * 1024 * 1024);
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+  (void)f2(0, f0(4608 * 1024 * 1024));
+}
Index: cfe/trunk/test/Sema/integer-overflow.c
===
--- cfe/trunk/test/Sema/integer-overflow.c
+++ cfe/trunk/test/Sema/integer-overflow.c
@@ -158,6 +158,21 @@
   return ((4608 * 1024 * 1024) + ((uint64_t)(4608 * 1024 * 1024)));
 }
 
+void check_integer_overflows_in_function_calls() {
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+  (void)f0(4608 * 1024 * 1024);
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+  uint64_t x = f0(4608 * 1024 * 1024);
+
+// expected-warning@+2 {{overflow in expression; result is 536870912 with type 'int'}}
+  uint64_t (*f0_ptr)(uint64_t) = &f0;
+  (void)(*f0_ptr)(4608 * 1024 * 1024);
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+  (void)f2(0, f0(4608 * 1024 * 1024));
+}
+
 struct s {
   unsigned x;
   unsigned y;
Index: cfe/trunk/test/SemaObjC/integer-overflow.m
===
--- cfe/trunk/test/SemaObjC/integer-overflow.m
+++ cfe/trunk/test/SemaObjC/integer-overflow.m
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -Wno-objc-root-class -fsyntax-only -verify %s
+
+@interface Foo
+@end
+
+@implementation Foo
+- (int)add:(int)a with:(int)b {
+  return a + b;
+}
+
+- (void)testIntegerOverflows {
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+  (void)[self add:0 with:4608 * 1024 * 1024];
+
+// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
+  (void)[self add:0 with:[self add:4608 * 1024 * 1024 with:0]];
+}
+@end
Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -10225,18 +10225,22 @@
   SmallVector Exprs(1, E);
 
   do {
-Expr *E = Exprs.pop_back_val();
+Expr *OriginalE = Exprs.pop_back_val();
+Expr *E = OriginalE->IgnoreParenCasts();
 
-if (isa(E->IgnoreParenCasts())) {
-  E->IgnoreParenCasts()->EvaluateForOverflow(Context);
+if (isa(E)) {
+  E->EvaluateForOverflow(Context);
   continue;
 }
 
-if (auto InitList = dyn_cast(E))
+if (auto InitList = dyn_cast(OriginalE))
   Exprs.append(InitList->inits().begin(), InitList->inits().end());
-
-if (isa(E))
-  E->IgnoreParenCasts()->EvaluateForOverflow(Context);
+else if (isa(OriginalE))
+  E->EvaluateForOverflow(Context);
+else if (auto Call = dyn_cast(E))
+  Exprs.append(Call->arg_begin(), Call->arg_end());
+else if (auto Message = dyn_cast(E))
+  Exprs.append(Message->arg_begin(), Message->arg_end());
   } while (!Exprs.empty());
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r328672 - [Driver] Add fuzzer-no-link into the list of supported Fuchsia sanitizers

2018-03-27 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Mar 27 14:33:12 2018
New Revision: 328672

URL: http://llvm.org/viewvc/llvm-project?rev=328672&view=rev
Log:
[Driver] Add fuzzer-no-link into the list of supported Fuchsia sanitizers

This is needed in addition to fuzzer in order to use libFuzzer.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp?rev=328672&r1=328671&r2=328672&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp Tue Mar 27 14:33:12 2018
@@ -280,6 +280,7 @@ SanitizerMask Fuchsia::getSupportedSanit
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::Fuzzer;
+  Res |= SanitizerKind::FuzzerNoLink;
   Res |= SanitizerKind::SafeStack;
   Res |= SanitizerKind::Scudo;
   return Res;


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


[PATCH] D44947: [Driver] Add fuzzer-no-link into the list of supported Fuchsia sanitizers

2018-03-27 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC328672: [Driver] Add fuzzer-no-link into the list of 
supported Fuchsia sanitizers (authored by phosek, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44947?vs=139978&id=140007#toc

Repository:
  rC Clang

https://reviews.llvm.org/D44947

Files:
  lib/Driver/ToolChains/Fuchsia.cpp


Index: lib/Driver/ToolChains/Fuchsia.cpp
===
--- lib/Driver/ToolChains/Fuchsia.cpp
+++ lib/Driver/ToolChains/Fuchsia.cpp
@@ -280,6 +280,7 @@
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::Fuzzer;
+  Res |= SanitizerKind::FuzzerNoLink;
   Res |= SanitizerKind::SafeStack;
   Res |= SanitizerKind::Scudo;
   return Res;


Index: lib/Driver/ToolChains/Fuchsia.cpp
===
--- lib/Driver/ToolChains/Fuchsia.cpp
+++ lib/Driver/ToolChains/Fuchsia.cpp
@@ -280,6 +280,7 @@
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::Fuzzer;
+  Res |= SanitizerKind::FuzzerNoLink;
   Res |= SanitizerKind::SafeStack;
   Res |= SanitizerKind::Scudo;
   return Res;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44931: [WebAssembly] Use Windows EH instructions for Wasm EH

2018-03-27 Thread David Majnemer via Phabricator via cfe-commits
majnemer added a comment.

Some quick first pass comments.




Comment at: lib/CodeGen/CGCleanup.cpp:985
+// does not have a runtime support for that.
+if (!Personality.usesFuncletPads() || Personality.isWasmPersonality()) {
+  EHStack.pushTerminate();

I think this condition can be simplified to `!isMSVCPersonality()` with a 
slight tweak of the comment.



Comment at: test/CodeGenCXX/wasm-eh.cpp:33
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* 
bitcast (i8** @_ZTIi to i8*), i8* bitcast (i8** @_ZTId to i8*)]
+// CHECK-NEXT:   %[[EXN:.*]] = call i8* @llvm.wasm.get.exception()
+// CHECK-NEXT:   store i8* %[[EXN]], i8** %exn.slot

I'd expect a funclet bundle operand here..


Repository:
  rC Clang

https://reviews.llvm.org/D44931



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


[PATCH] D44765: PR36643 Make clang-format support more generic TMarcos

2018-03-27 Thread Teodor Petrov via Phabricator via cfe-commits
obfuscated marked an inline comment as done.
obfuscated added inline comments.



Comment at: lib/Format/FormatToken.h:138
+  /// \brief Whether this is a string literal similar to _T("sdfsdf").
+  bool TMacroStringLiteral = false;
+

krasimir wrote:
> We don't strictly need this new field. We could do as in the old 
> implementation and check if the string prefix is from a T macro in 
> ContinuationIndenter.
Using a flag is more reliable and faster - the checks are done once, so they 
don't have to be repeated.

From the field layout in the struct and from the usage of bools I could only 
conclude that this is not a memory nor performance critical part of the code.




Comment at: unittests/Format/FormatTest.cpp:10693
+
+  // FIXME: This is required because parsing a configuration simply overwrites
+  // the first N elements of the list instead of resetting it.

krasimir wrote:
> Why is the `FIXME` here? I suggest just use the pattern similar to the other 
> cases here and just keep the test with 2 elements:
> ```
> Style.TMacros.clear();
> std::vector ExpectedTMacros = {"_T", "myT"};
> CHECK_PARSE("TMacros: [_T, myT]", TMacros, ExpectedTMacros);
> ```
I've copy pasted this from the foreach macro option.
I've not investigate why this fixme is there.


Repository:
  rC Clang

https://reviews.llvm.org/D44765



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


  1   2   >