Re: r319297 - Toolchain: Normalize dwarf, sjlj and seh eh

2017-12-01 Thread Martell Malone via cfe-commits
Just catching up on this now.
r319363 looks good to me, It makes little sense to use GNU SEH in that case.

My remaining concern is mostly about why we still need the workaround for
> x86 in the function getting the default (returning None instead of WinEH
> for that case). But as long as this works and the rest of this change can
> settle, we can look at that later if any further change is warranted at all.
>
It seemed to work fine but the sanitizer does not support this setup for
x86 quite yet.
It is a little outside my scope of focus right now so will probably come
back to it much later.


On Wed, Nov 29, 2017 at 2:07 PM, Martin Storsjö  wrote:

> On Wed, 29 Nov 2017, Martin Storsjö via cfe-commits wrote:
>
> On Wed, 29 Nov 2017, Reid Kleckner wrote:
>>
>> On Wed, Nov 29, 2017 at 12:21 PM, Martin Storsjö 
>>> wrote:
>>>   On Wed, 29 Nov 2017, Martell Malone via cfe-commits wrote:
>>> Thanks for letting me know Reid.
>>> I’ll in work and won’t be able to access the repo
>>> until lunch time. (~3
>>> hours)
>>> Feel free to revert if it is not trivial.
>>>
>>> The easy fix might be to change to == x86_64 from !=
>>> x86 For is Windows in
>>> the default toolchain. That should restore the old
>>> behavior.
>>>
>>>
>>>   My suggestion would be to just return None for all architectures
>>>   for the default windows (msvc) case. We didn't use to set any
>>>   defines to indicate EH mode there before anyway, so setting it
>>>   to None should make things behave just as before, right?
>>>
>>>
>>> I did this slightly differently in r319363, but maybe that's silly. My
>>> reasoning was that `clang -cc1 -fseh-exceptions -fexceptions` in the MSVC
>>> environment should still use __CxxFrameHandler3. -fseh-exceptions
>>> indicates
>>> what format of unwind information we should use, and we're still using
>>> the
>>> normal SEH .xdata opcodes.
>>>
>>
>> No, I think this change makes sense - I was just about to write a comment
>> pointing out this spot in the code but was waiting for a compile to finish
>> before posting.
>>
>> Alternatively, you could view -fseh-exceptions, -fdwarf-exceptions, and
>>> -fsjlj-exceptions as choices of EH personality function,
>>>
>>
>> No, I don't think that'd make sense
>>
>
> FWIW, another reason I don't think that makes sense, is that making a
> GNU_CPlusPlus_SEH + MSVC combination probably would require quite a bit
> more changes as well.
>
> When I tested the same in a build with assertions enabled, I didn't get
> the references to _Unwind_Resume as you did, but the compilation failed on
> some internal assertion. So making GNU_CPlusPlus_SEH usable with the
> microsoft C++ ABI would probably require a significant amount of more work,
> for very little value.
>
> // Martin
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang-tools-extra] r319557 - [clangd] Fuzzy match scorer

2017-12-01 Thread Sam McCall via cfe-commits
Great! Unfortunately it broke old GCC, and it doesn't seem possible to
satisfy both.
So r319608 removes the enum altogether.

On Sat, Dec 2, 2017 at 4:54 AM, Yung, Douglas  wrote:

> That fixed it, thanks!
>
>
>
> Douglas Yung
>
>
>
> *From:* Sam McCall [mailto:sam.mcc...@gmail.com]
> *Sent:* Friday, December 01, 2017 19:38
> *To:* Yung, Douglas
> *Cc:* cfe-commits
> *Subject:* Re: [clang-tools-extra] r319557 - [clangd] Fuzzy match scorer
>
>
>
> r319606 should fix that one, if I've understood the problem right.
>
>
>
> On Sat, Dec 2, 2017 at 3:50 AM, Yung, Douglas 
> wrote:
>
> Hi Sam, the FuzzyMatch tests you added in this commit seem to be failing
> on the Windows bot:
>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_
> 64-scei-ps4-windows10pro-fast/builds/13869
>
> Can you take a look?
>
> Douglas Yung
>
> > -Original Message-
> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
> Of Sam
> > McCall via cfe-commits
> > Sent: Friday, December 01, 2017 9:08
> > To: cfe-commits@lists.llvm.org
> > Subject: [clang-tools-extra] r319557 - [clangd] Fuzzy match scorer
> >
> > Author: sammccall
> > Date: Fri Dec  1 09:08:02 2017
> > New Revision: 319557
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=319557=rev
> > Log:
> > [clangd] Fuzzy match scorer
> >
> > Summary:
> > This will be used for rescoring code completion results based on partial
> > identifiers.
> > Short-term use:
> >   - we want to limit the number of code completion results returned to
> >   improve performance of global completion. The scorer will be used to
> >   rerank the results to return when the user has applied a filter.
> >   - ranking of completion results from in-memory index
> >   - merging of completion results from multiple sources (merging usually
> > Long-term use case:
> >   works best when done at the component-score level, rescoring the
> >   fuzzy-match quality avoids different backends needing to have
> >   comparable scores)
> >
> > Reviewers: ilya-biryukov
> >
> > Subscribers: cfe-commits, mgorny
> >
> > Differential Revision: https://reviews.llvm.org/D40060
> >
> > Added:
> > clang-tools-extra/trunk/clangd/FuzzyMatch.cpp
> > clang-tools-extra/trunk/clangd/FuzzyMatch.h
> > clang-tools-extra/trunk/unittests/clangd/FuzzyMatchTests.cpp
> > Modified:
> > clang-tools-extra/trunk/clangd/CMakeLists.txt
> > clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt
> >
> > Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
> > URL: http://llvm.org/viewvc/llvm-project/clang-tools-
> > extra/trunk/clangd/CMakeLists.txt?rev=319557=319556=
> 319557=diff
> > 
> ==
> > --- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
> > +++ clang-tools-extra/trunk/clangd/CMakeLists.txt Fri Dec  1 09:08:02
> > +++ 2017
> > @@ -8,6 +8,7 @@ add_clang_library(clangDaemon
> >ClangdUnit.cpp
> >ClangdUnitStore.cpp
> >DraftStore.cpp
> > +  FuzzyMatch.cpp
> >GlobalCompilationDatabase.cpp
> >JSONExpr.cpp
> >JSONRPCDispatcher.cpp
> >
> > Added: clang-tools-extra/trunk/clangd/FuzzyMatch.cpp
> > URL: http://llvm.org/viewvc/llvm-project/clang-tools-
> > extra/trunk/clangd/FuzzyMatch.cpp?rev=319557=auto
> > 
> ==
> > --- clang-tools-extra/trunk/clangd/FuzzyMatch.cpp (added)
> > +++ clang-tools-extra/trunk/clangd/FuzzyMatch.cpp Fri Dec  1 09:08:02
> > +++ 2017
> > @@ -0,0 +1,373 @@
> > +//===--- FuzzyMatch.h - Approximate identifier matching  -*-
> > +C++-*-===// //
> > +// The LLVM Compiler Infrastructure
> > +//
> > +// This file is distributed under the University of Illinois Open
> > +Source // License. See LICENSE.TXT for details.
> > +//
> > +//===--
> > +===//
> > +//
> > +// To check for a match between a Pattern ('u_p') and a Word
> > +('unique_ptr'), // we consider the possible partial match states:
> > +//
> > +// u n i q u e _ p t r
> > +//   +-
> > +//   |A . . . . . . . . . .
> > +//  u|
> > +//   |. . . . . . . . . . .
> > +//  _|
> > +//   |. . . . . . . O . . .
> > +//  p|
> > +//   |. . . . . . . . . . B
> > +//
> > +// Each dot represents some prefix of the pattern being matched against
> > +some // prefix of the word.
> > +//   - A is the initial state: '' matched against ''
> > +//   - O is an intermediate state: 'u_' matched against 'unique_'
> > +//   - B is the target state: 'u_p' matched against 'unique_ptr'
> > +//
> > +// We aim to find the best path from A->B.
> > +//  - Moving right (consuming a word character)
> > +//Always legal: not all word characters must match.
> > +//  - Moving diagonally (consuming both a word and pattern character)
> > +//Legal if the characters match.
> > +//  - Moving down (consuming a 

[clang-tools-extra] r319608 - [clangd] Avoid enum in bitfields, can't satisfy old GCC and new MSVC

2017-12-01 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Fri Dec  1 20:15:55 2017
New Revision: 319608

URL: http://llvm.org/viewvc/llvm-project?rev=319608=rev
Log:
[clangd] Avoid enum in bitfields, can't satisfy old GCC and new MSVC

Modified:
clang-tools-extra/trunk/clangd/FuzzyMatch.h

Modified: clang-tools-extra/trunk/clangd/FuzzyMatch.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FuzzyMatch.h?rev=319608=319607=319608=diff
==
--- clang-tools-extra/trunk/clangd/FuzzyMatch.h (original)
+++ clang-tools-extra/trunk/clangd/FuzzyMatch.h Fri Dec  1 20:15:55 2017
@@ -45,7 +45,11 @@ private:
   constexpr static int MaxPat = 63, MaxWord = 127;
   enum CharRole : unsigned char; // For segmentation.
   enum CharType : unsigned char; // For segmentation.
-  enum Action : unsigned char { Miss = 0, Match = 1 };
+  // Action should be an enum, but this causes bitfield problems:
+  //   - for MSVC the enum type must be explicitly unsigned for correctness
+  //   - GCC 4.8 complains not all values fit if the type is unsigned
+  using Action = bool;
+  constexpr static Action Miss = false, Match = true;
 
   bool init(llvm::StringRef Word);
   void buildGraph();


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


Re: [clang-tools-extra] r319557 - [clangd] Fuzzy match scorer

2017-12-01 Thread Sam McCall via cfe-commits
r319606 should fix that one, if I've understood the problem right.

On Sat, Dec 2, 2017 at 3:50 AM, Yung, Douglas  wrote:

> Hi Sam, the FuzzyMatch tests you added in this commit seem to be failing
> on the Windows bot:
>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_
> 64-scei-ps4-windows10pro-fast/builds/13869
>
> Can you take a look?
>
> Douglas Yung
>
> > -Original Message-
> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
> Of Sam
> > McCall via cfe-commits
> > Sent: Friday, December 01, 2017 9:08
> > To: cfe-commits@lists.llvm.org
> > Subject: [clang-tools-extra] r319557 - [clangd] Fuzzy match scorer
> >
> > Author: sammccall
> > Date: Fri Dec  1 09:08:02 2017
> > New Revision: 319557
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=319557=rev
> > Log:
> > [clangd] Fuzzy match scorer
> >
> > Summary:
> > This will be used for rescoring code completion results based on partial
> > identifiers.
> > Short-term use:
> >   - we want to limit the number of code completion results returned to
> >   improve performance of global completion. The scorer will be used to
> >   rerank the results to return when the user has applied a filter.
> >   - ranking of completion results from in-memory index
> >   - merging of completion results from multiple sources (merging usually
> > Long-term use case:
> >   works best when done at the component-score level, rescoring the
> >   fuzzy-match quality avoids different backends needing to have
> >   comparable scores)
> >
> > Reviewers: ilya-biryukov
> >
> > Subscribers: cfe-commits, mgorny
> >
> > Differential Revision: https://reviews.llvm.org/D40060
> >
> > Added:
> > clang-tools-extra/trunk/clangd/FuzzyMatch.cpp
> > clang-tools-extra/trunk/clangd/FuzzyMatch.h
> > clang-tools-extra/trunk/unittests/clangd/FuzzyMatchTests.cpp
> > Modified:
> > clang-tools-extra/trunk/clangd/CMakeLists.txt
> > clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt
> >
> > Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
> > URL: http://llvm.org/viewvc/llvm-project/clang-tools-
> > extra/trunk/clangd/CMakeLists.txt?rev=319557=319556=
> 319557=diff
> > 
> ==
> > --- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
> > +++ clang-tools-extra/trunk/clangd/CMakeLists.txt Fri Dec  1 09:08:02
> > +++ 2017
> > @@ -8,6 +8,7 @@ add_clang_library(clangDaemon
> >ClangdUnit.cpp
> >ClangdUnitStore.cpp
> >DraftStore.cpp
> > +  FuzzyMatch.cpp
> >GlobalCompilationDatabase.cpp
> >JSONExpr.cpp
> >JSONRPCDispatcher.cpp
> >
> > Added: clang-tools-extra/trunk/clangd/FuzzyMatch.cpp
> > URL: http://llvm.org/viewvc/llvm-project/clang-tools-
> > extra/trunk/clangd/FuzzyMatch.cpp?rev=319557=auto
> > 
> ==
> > --- clang-tools-extra/trunk/clangd/FuzzyMatch.cpp (added)
> > +++ clang-tools-extra/trunk/clangd/FuzzyMatch.cpp Fri Dec  1 09:08:02
> > +++ 2017
> > @@ -0,0 +1,373 @@
> > +//===--- FuzzyMatch.h - Approximate identifier matching  -*-
> > +C++-*-===// //
> > +// The LLVM Compiler Infrastructure
> > +//
> > +// This file is distributed under the University of Illinois Open
> > +Source // License. See LICENSE.TXT for details.
> > +//
> > +//===--
> > +===//
> > +//
> > +// To check for a match between a Pattern ('u_p') and a Word
> > +('unique_ptr'), // we consider the possible partial match states:
> > +//
> > +// u n i q u e _ p t r
> > +//   +-
> > +//   |A . . . . . . . . . .
> > +//  u|
> > +//   |. . . . . . . . . . .
> > +//  _|
> > +//   |. . . . . . . O . . .
> > +//  p|
> > +//   |. . . . . . . . . . B
> > +//
> > +// Each dot represents some prefix of the pattern being matched against
> > +some // prefix of the word.
> > +//   - A is the initial state: '' matched against ''
> > +//   - O is an intermediate state: 'u_' matched against 'unique_'
> > +//   - B is the target state: 'u_p' matched against 'unique_ptr'
> > +//
> > +// We aim to find the best path from A->B.
> > +//  - Moving right (consuming a word character)
> > +//Always legal: not all word characters must match.
> > +//  - Moving diagonally (consuming both a word and pattern character)
> > +//Legal if the characters match.
> > +//  - Moving down (consuming a pattern character) is never legal.
> > +//Never legal: all pattern characters must match something.
> > +//
> > +// The scoring is based on heuristics:
> > +//  - when matching a character, apply a bonus or penalty depending on
> the
> > +//match quality (does case match, do word segments align, etc)
> > +//  - when skipping a character, apply a penalty if it hurts the match
> > +//(it starts a word segment, or splits the matched region, etc)
> > +//
> > +// These 

[clang-tools-extra] r319606 - [clangd] Fix FuzzyMatch tests on windows, NFC

2017-12-01 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Fri Dec  1 19:35:19 2017
New Revision: 319606

URL: http://llvm.org/viewvc/llvm-project?rev=319606=rev
Log:
[clangd] Fix FuzzyMatch tests on windows, NFC

Without specifying the signedness of the underlying type for Action,
packing it in a 1-bit field may restrict its range to [-1, 0] which
can't represent Match.

Modified:
clang-tools-extra/trunk/clangd/FuzzyMatch.cpp
clang-tools-extra/trunk/clangd/FuzzyMatch.h

Modified: clang-tools-extra/trunk/clangd/FuzzyMatch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FuzzyMatch.cpp?rev=319606=319605=319606=diff
==
--- clang-tools-extra/trunk/clangd/FuzzyMatch.cpp (original)
+++ clang-tools-extra/trunk/clangd/FuzzyMatch.cpp Fri Dec  1 19:35:19 2017
@@ -115,7 +115,7 @@ Optional FuzzyMatcher::match(Stri
 // It's not obvious how to segment digits, we treat them as lowercase letters.
 // As we don't decode UTF-8, we treat bytes over 127 as lowercase too.
 // This means we require exact (case-sensitive) match.
-enum FuzzyMatcher::CharType : char {
+enum FuzzyMatcher::CharType : unsigned char {
   Empty = 0,   // Before-the-start and after-the-end (and control chars).
   Lower = 1,   // Lowercase letters, digits, and non-ASCII bytes.
   Upper = 2,   // Uppercase letters.
@@ -144,7 +144,7 @@ constexpr static uint8_t CharTypes[] = {
 // e.g. XMLHttpRequest_Async
 //  +--+---+-- +
 //  ^Head   ^Tail ^Separator
-enum FuzzyMatcher::CharRole : char {
+enum FuzzyMatcher::CharRole : unsigned char {
   Unknown = 0,   // Stray control characters or impossible states.
   Tail = 1,  // Part of a word segment, but not the first character.
   Head = 2,  // The first character of a word segment.

Modified: clang-tools-extra/trunk/clangd/FuzzyMatch.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FuzzyMatch.h?rev=319606=319605=319606=diff
==
--- clang-tools-extra/trunk/clangd/FuzzyMatch.h (original)
+++ clang-tools-extra/trunk/clangd/FuzzyMatch.h Fri Dec  1 19:35:19 2017
@@ -43,9 +43,9 @@ public:
 private:
   // We truncate the pattern and the word to bound the cost of matching.
   constexpr static int MaxPat = 63, MaxWord = 127;
-  enum CharRole : char; // For segmentation.
-  enum CharType : char; // For segmentation.
-  enum Action { Miss = 0, Match = 1 };
+  enum CharRole : unsigned char; // For segmentation.
+  enum CharType : unsigned char; // For segmentation.
+  enum Action : unsigned char { Miss = 0, Match = 1 };
 
   bool init(llvm::StringRef Word);
   void buildGraph();


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


RE: [clang-tools-extra] r319557 - [clangd] Fuzzy match scorer

2017-12-01 Thread Yung, Douglas via cfe-commits
Hi Sam, the FuzzyMatch tests you added in this commit seem to be failing on the 
Windows bot:

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/13869

Can you take a look?

Douglas Yung

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of Sam
> McCall via cfe-commits
> Sent: Friday, December 01, 2017 9:08
> To: cfe-commits@lists.llvm.org
> Subject: [clang-tools-extra] r319557 - [clangd] Fuzzy match scorer
> 
> Author: sammccall
> Date: Fri Dec  1 09:08:02 2017
> New Revision: 319557
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=319557=rev
> Log:
> [clangd] Fuzzy match scorer
> 
> Summary:
> This will be used for rescoring code completion results based on partial
> identifiers.
> Short-term use:
>   - we want to limit the number of code completion results returned to
>   improve performance of global completion. The scorer will be used to
>   rerank the results to return when the user has applied a filter.
>   - ranking of completion results from in-memory index
>   - merging of completion results from multiple sources (merging usually
> Long-term use case:
>   works best when done at the component-score level, rescoring the
>   fuzzy-match quality avoids different backends needing to have
>   comparable scores)
> 
> Reviewers: ilya-biryukov
> 
> Subscribers: cfe-commits, mgorny
> 
> Differential Revision: https://reviews.llvm.org/D40060
> 
> Added:
> clang-tools-extra/trunk/clangd/FuzzyMatch.cpp
> clang-tools-extra/trunk/clangd/FuzzyMatch.h
> clang-tools-extra/trunk/unittests/clangd/FuzzyMatchTests.cpp
> Modified:
> clang-tools-extra/trunk/clangd/CMakeLists.txt
> clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt
> 
> Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-
> extra/trunk/clangd/CMakeLists.txt?rev=319557=319556=319557=diff
> ==
> --- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
> +++ clang-tools-extra/trunk/clangd/CMakeLists.txt Fri Dec  1 09:08:02
> +++ 2017
> @@ -8,6 +8,7 @@ add_clang_library(clangDaemon
>ClangdUnit.cpp
>ClangdUnitStore.cpp
>DraftStore.cpp
> +  FuzzyMatch.cpp
>GlobalCompilationDatabase.cpp
>JSONExpr.cpp
>JSONRPCDispatcher.cpp
> 
> Added: clang-tools-extra/trunk/clangd/FuzzyMatch.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-
> extra/trunk/clangd/FuzzyMatch.cpp?rev=319557=auto
> ==
> --- clang-tools-extra/trunk/clangd/FuzzyMatch.cpp (added)
> +++ clang-tools-extra/trunk/clangd/FuzzyMatch.cpp Fri Dec  1 09:08:02
> +++ 2017
> @@ -0,0 +1,373 @@
> +//===--- FuzzyMatch.h - Approximate identifier matching  -*-
> +C++-*-===// //
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is distributed under the University of Illinois Open
> +Source // License. See LICENSE.TXT for details.
> +//
> +//===--
> +===//
> +//
> +// To check for a match between a Pattern ('u_p') and a Word
> +('unique_ptr'), // we consider the possible partial match states:
> +//
> +// u n i q u e _ p t r
> +//   +-
> +//   |A . . . . . . . . . .
> +//  u|
> +//   |. . . . . . . . . . .
> +//  _|
> +//   |. . . . . . . O . . .
> +//  p|
> +//   |. . . . . . . . . . B
> +//
> +// Each dot represents some prefix of the pattern being matched against
> +some // prefix of the word.
> +//   - A is the initial state: '' matched against ''
> +//   - O is an intermediate state: 'u_' matched against 'unique_'
> +//   - B is the target state: 'u_p' matched against 'unique_ptr'
> +//
> +// We aim to find the best path from A->B.
> +//  - Moving right (consuming a word character)
> +//Always legal: not all word characters must match.
> +//  - Moving diagonally (consuming both a word and pattern character)
> +//Legal if the characters match.
> +//  - Moving down (consuming a pattern character) is never legal.
> +//Never legal: all pattern characters must match something.
> +//
> +// The scoring is based on heuristics:
> +//  - when matching a character, apply a bonus or penalty depending on the
> +//match quality (does case match, do word segments align, etc)
> +//  - when skipping a character, apply a penalty if it hurts the match
> +//(it starts a word segment, or splits the matched region, etc)
> +//
> +// These heuristics require the ability to "look backward" one
> +character, to // see whether it was matched or not. Therefore the
> +dynamic-programming matrix // has an extra dimension (last character
> matched).
> +// Each entry also has an additional flag indicating whether the
> +last-but-one // character matched, which is needed to trace back
> +through the scoring table // and reconstruct the 

r319605 - PR35456: Track definedness of variable template specializations separately from

2017-12-01 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Dec  1 18:48:42 2017
New Revision: 319605

URL: http://llvm.org/viewvc/llvm-project?rev=319605=rev
Log:
PR35456: Track definedness of variable template specializations separately from
whether they have an initializer.

We cannot distinguish between a declaration of a variable template
specialization and a definition of one that lacks an initializer without this,
and would previously mistake the latter for the former.

Modified:
cfe/trunk/include/clang/AST/DeclTemplate.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/CodeGenCXX/cxx1y-variable-template.cpp
cfe/trunk/test/CodeGenCXX/dllexport.cpp

Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=319605=319604=319605=diff
==
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Fri Dec  1 18:48:42 2017
@@ -2540,6 +2540,12 @@ class VarTemplateSpecializationDecl : pu
   /// Really a value of type TemplateSpecializationKind.
   unsigned SpecializationKind : 3;
 
+  /// \brief Whether this declaration is a complete definition of the
+  /// variable template specialization. We can't otherwise tell apart
+  /// an instantiated declaration from an instantiated definition with
+  /// no initializer.
+  unsigned IsCompleteDefinition : 1;
+
 protected:
   VarTemplateSpecializationDecl(Kind DK, ASTContext , DeclContext *DC,
 SourceLocation StartLoc, SourceLocation IdLoc,
@@ -2553,6 +2559,7 @@ protected:
 public:
   friend class ASTDeclReader;
   friend class ASTDeclWriter;
+  friend class VarDecl;
 
   static VarTemplateSpecializationDecl *
   Create(ASTContext , DeclContext *DC, SourceLocation StartLoc,
@@ -2616,6 +2623,8 @@ public:
 PointOfInstantiation = Loc;
   }
 
+  void setCompleteDefinition() { IsCompleteDefinition = true; }
+
   /// \brief If this variable template specialization is an instantiation of
   /// a template (rather than an explicit specialization), return the
   /// variable template or variable template partial specialization from which

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=319605=319604=319605=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Fri Dec  1 18:48:42 2017
@@ -2029,9 +2029,12 @@ VarDecl::isThisDeclarationADefinition(AS
   // A variable template specialization (other than a static data member
   // template or an explicit specialization) is a declaration until we
   // instantiate its initializer.
-  if (isa(this) &&
-  getTemplateSpecializationKind() != TSK_ExplicitSpecialization)
-return DeclarationOnly;
+  if (auto *VTSD = dyn_cast(this)) {
+if (VTSD->getTemplateSpecializationKind() != TSK_ExplicitSpecialization &&
+!isa(VTSD) &&
+!VTSD->IsCompleteDefinition)
+  return DeclarationOnly;
+  }
 
   if (hasExternalStorage())
 return DeclarationOnly;

Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=319605=319604=319605=diff
==
--- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
+++ cfe/trunk/lib/AST/DeclTemplate.cpp Fri Dec  1 18:48:42 2017
@@ -1043,13 +1043,13 @@ VarTemplateSpecializationDecl::VarTempla
   SpecializedTemplate->getIdentifier(), T, TInfo, S),
   SpecializedTemplate(SpecializedTemplate),
   TemplateArgs(TemplateArgumentList::CreateCopy(Context, Args)),
-  SpecializationKind(TSK_Undeclared) {}
+  SpecializationKind(TSK_Undeclared), IsCompleteDefinition(false) {}
 
 VarTemplateSpecializationDecl::VarTemplateSpecializationDecl(Kind DK,
  ASTContext )
 : VarDecl(DK, C, nullptr, SourceLocation(), SourceLocation(), nullptr,
   QualType(), nullptr, SC_None),
-  SpecializationKind(TSK_Undeclared) {}
+  SpecializationKind(TSK_Undeclared), IsCompleteDefinition(false) {}
 
 VarTemplateSpecializationDecl *VarTemplateSpecializationDecl::Create(
 ASTContext , DeclContext *DC, SourceLocation StartLoc,

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=319605=319604=319605=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Fri Dec  

Re: [clang-tools-extra] r319557 - [clangd] Fuzzy match scorer

2017-12-01 Thread Sam McCall via cfe-commits
Apologies. This is a GCC bug I wasn't familiar with, and my first guess at
a fix was wrong. (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58541)
r319604 should fix this.

On Fri, Dec 1, 2017 at 10:20 PM, Galina Kistanova 
wrote:

> Hello Sam,
>
> This commit broke one of our bots:
> http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-test/builds/18908
>
> . . .
> FAILED: 
> tools/clang/tools/extra/clangd/CMakeFiles/clangDaemon.dir/FuzzyMatch.cpp.o
>
> /usr/bin/c++   -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE
> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
> -Itools/clang/tools/extra/clangd -I/home/buildslave/
> buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd
> -I/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/include
> -Itools/clang/include -Iinclude -I/home/buildslave/
> buildslave1a/clang-x86_64-linux-abi-test/llvm/include -fPIC
> -fvisibility-inlines-hidden -std=c++11 -Wall -W -Wno-unused-parameter
> -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic
> -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor
> -Wno-comment -ffunction-sections -fdata-sections -fno-common
> -Woverloaded-virtual -fno-strict-aliasing -O3-UNDEBUG  -fno-exceptions
> -fno-rtti -MD -MT 
> tools/clang/tools/extra/clangd/CMakeFiles/clangDaemon.dir/FuzzyMatch.cpp.o
> -MF 
> tools/clang/tools/extra/clangd/CMakeFiles/clangDaemon.dir/FuzzyMatch.cpp.o.d
> -o tools/clang/tools/extra/clangd/CMakeFiles/clangDaemon.dir/FuzzyMatch.cpp.o
> -c /home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/
> llvm/tools/clang/tools/extra/clangd/FuzzyMatch.cpp
> /home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/
> llvm/tools/clang/tools/extra/clangd/FuzzyMatch.cpp:64:25: error:
> redeclaration ‘clang::clangd::FuzzyMatcher::MaxPat’ differs in ‘constexpr’
>  const int FuzzyMatcher::MaxPat;
>  ^
> In file included from /home/buildslave/buildslave1a/
> clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/
> clangd/FuzzyMatch.cpp:57:0:
> /home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/
> llvm/tools/clang/tools/extra/clangd/FuzzyMatch.h:45:24: error: from
> previous declaration ‘clang::clangd::FuzzyMatcher::MaxPat’
>constexpr static int MaxPat = 63, MaxWord = 127;
> ^
> /home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/
> llvm/tools/clang/tools/extra/clangd/FuzzyMatch.cpp:64:25: error:
> declaration of ‘constexpr const int clang::clangd::FuzzyMatcher::MaxPat’
> outside of class is not definition [-fpermissive]
>  const int FuzzyMatcher::MaxPat;
>  ^
> /home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/
> llvm/tools/clang/tools/extra/clangd/FuzzyMatch.cpp:65:25: error:
> redeclaration ‘clang::clangd::FuzzyMatcher::MaxWord’ differs in
> ‘constexpr’
>  const int FuzzyMatcher::MaxWord;
>  ^
> In file included from /home/buildslave/buildslave1a/
> clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/
> clangd/FuzzyMatch.cpp:57:0:
> /home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/
> llvm/tools/clang/tools/extra/clangd/FuzzyMatch.h:45:37: error: from
> previous declaration ‘clang::clangd::FuzzyMatcher::MaxWord’
>constexpr static int MaxPat = 63, MaxWord = 127;
>  ^
> /home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/
> llvm/tools/clang/tools/extra/clangd/FuzzyMatch.cpp:65:25: error:
> declaration of ‘constexpr const int clang::clangd::FuzzyMatcher::MaxWord’
> outside of class is not definition [-fpermissive]
>  const int FuzzyMatcher::MaxWord;
>  ^
>
> Please have a look?
>
> Thanks
>
> Galina
>
> On Fri, Dec 1, 2017 at 9:08 AM, Sam McCall via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: sammccall
>> Date: Fri Dec  1 09:08:02 2017
>> New Revision: 319557
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=319557=rev
>> Log:
>> [clangd] Fuzzy match scorer
>>
>> Summary:
>> This will be used for rescoring code completion results based on partial
>> identifiers.
>> Short-term use:
>>   - we want to limit the number of code completion results returned to
>>   improve performance of global completion. The scorer will be used to
>>   rerank the results to return when the user has applied a filter.
>> Long-term use case:
>>   - ranking of completion results from in-memory index
>>   - merging of completion results from multiple sources (merging usually
>>   works best when done at the component-score level, rescoring the
>>   fuzzy-match quality avoids different backends needing to have
>>   comparable scores)
>>
>> Reviewers: ilya-biryukov
>>
>> Subscribers: cfe-commits, mgorny
>>
>> Differential Revision: https://reviews.llvm.org/D40060
>>
>> Added:
>> clang-tools-extra/trunk/clangd/FuzzyMatch.cpp
>> clang-tools-extra/trunk/clangd/FuzzyMatch.h
>> 

[clang-tools-extra] r319604 - [clangd] Try to appease gcc constexpr bug (58541)

2017-12-01 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Fri Dec  1 18:28:29 2017
New Revision: 319604

URL: http://llvm.org/viewvc/llvm-project?rev=319604=rev
Log:
[clangd] Try to appease gcc constexpr bug (58541)

Modified:
clang-tools-extra/trunk/clangd/FuzzyMatch.cpp

Modified: clang-tools-extra/trunk/clangd/FuzzyMatch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FuzzyMatch.cpp?rev=319604=319603=319604=diff
==
--- clang-tools-extra/trunk/clangd/FuzzyMatch.cpp (original)
+++ clang-tools-extra/trunk/clangd/FuzzyMatch.cpp Fri Dec  1 18:28:29 2017
@@ -62,8 +62,8 @@ namespace clang {
 namespace clangd {
 using namespace llvm;
 
-const int FuzzyMatcher::MaxPat;
-const int FuzzyMatcher::MaxWord;
+constexpr int FuzzyMatcher::MaxPat;
+constexpr int FuzzyMatcher::MaxWord;
 
 static char lower(char C) { return C >= 'A' && C <= 'Z' ? C + ('a' - 'A') : C; 
}
 // A "negative infinity" score that won't overflow.


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


[PATCH] D40762: [CMake] Don't use comma as an alternate separator

2017-12-01 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
Herald added a subscriber: mgorny.

Using comma can break in cases when we're passing flags that already
use comma as a separator.

Fixes PR35504.


Repository:
  rC Clang

https://reviews.llvm.org/D40762

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -655,7 +655,7 @@
   foreach(variableName ${variableNames})
 if(variableName MATCHES "^BOOTSTRAP_")
   string(SUBSTRING ${variableName} 10 -1 varName)
-  string(REPLACE ";" "," value "${${variableName}}")
+  string(REPLACE ";" "|" value "${${variableName}}")
   list(APPEND PASSTHROUGH_VARIABLES
 -D${varName}=${value})
 endif()
@@ -671,7 +671,7 @@
   if("${${variableName}}" STREQUAL "")
 set(value "")
   else()
-string(REPLACE ";" "," value "${${variableName}}")
+string(REPLACE ";" "|" value "${${variableName}}")
   endif()
   list(APPEND PASSTHROUGH_VARIABLES
 -D${variableName}=${value})
@@ -699,7 +699,7 @@
 USES_TERMINAL_CONFIGURE 1
 USES_TERMINAL_BUILD 1
 USES_TERMINAL_INSTALL 1
-LIST_SEPARATOR ,
+LIST_SEPARATOR |
 )
 
   # exclude really-install from main target


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -655,7 +655,7 @@
   foreach(variableName ${variableNames})
 if(variableName MATCHES "^BOOTSTRAP_")
   string(SUBSTRING ${variableName} 10 -1 varName)
-  string(REPLACE ";" "," value "${${variableName}}")
+  string(REPLACE ";" "|" value "${${variableName}}")
   list(APPEND PASSTHROUGH_VARIABLES
 -D${varName}=${value})
 endif()
@@ -671,7 +671,7 @@
   if("${${variableName}}" STREQUAL "")
 set(value "")
   else()
-string(REPLACE ";" "," value "${${variableName}}")
+string(REPLACE ";" "|" value "${${variableName}}")
   endif()
   list(APPEND PASSTHROUGH_VARIABLES
 -D${variableName}=${value})
@@ -699,7 +699,7 @@
 USES_TERMINAL_CONFIGURE 1
 USES_TERMINAL_BUILD 1
 USES_TERMINAL_INSTALL 1
-LIST_SEPARATOR ,
+LIST_SEPARATOR |
 )
 
   # exclude really-install from main target
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r319601 - Move comment back to being next to the code it's a comment for.

2017-12-01 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Dec  1 16:55:48 2017
New Revision: 319601

URL: http://llvm.org/viewvc/llvm-project?rev=319601=rev
Log:
Move comment back to being next to the code it's a comment for.

Modified:
cfe/trunk/lib/AST/Decl.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=319601=319600=319601=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Fri Dec  1 16:55:48 2017
@@ -1974,6 +1974,9 @@ VarDecl *VarDecl::getCanonicalDecl() { r
 
 VarDecl::DefinitionKind
 VarDecl::isThisDeclarationADefinition(ASTContext ) const {
+  if (isThisDeclarationADemotedDefinition())
+return DeclarationOnly;
+
   // C++ [basic.def]p2:
   //   A declaration is a definition unless [...] it contains the 'extern'
   //   specifier or a linkage-specification and neither an initializer [...],
@@ -1987,9 +1990,6 @@ VarDecl::isThisDeclarationADefinition(AS
   //
   // FIXME: How do you declare (but not define) a partial specialization of
   // a static data member template outside the containing class?
-  if (isThisDeclarationADemotedDefinition())
-return DeclarationOnly;
-
   if (isStaticDataMember()) {
 if (isOutOfLine() &&
 !(getCanonicalDecl()->isInline() &&


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


[PATCH] D20124: [PCH] Serialize skipped preprocessor ranges

2017-12-01 Thread Cameron via Phabricator via cfe-commits
cameron314 added a comment.

Brilliant, didn't know `isInPreambleFileID` existed. All my tests pass for me 
now with that change, thanks :-)
I'll update the patch on Monday.


https://reviews.llvm.org/D20124



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


[PATCH] D40625: Harmonizing attribute GNU/C++ spellings

2017-12-01 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added inline comments.



Comment at: include/clang/Basic/Attr.td:602
 def AnalyzerNoReturn : InheritableAttr {
-  let Spellings = [GNU<"analyzer_noreturn">];
+  let Spellings = [Clang<"analyzer_noreturn">];
   let Documentation = [Undocumented];

aaron.ballman wrote:
> dcoughlin wrote:
> > aaron.ballman wrote:
> > > rsmith wrote:
> > > > Hmm, should the clang static analyzer reuse the `clang::` namespace, or 
> > > > should it get its own?
> > > Good question, I don't have strong opinions on the answer here, but 
> > > perhaps @dcoughlin does?
> > > 
> > > If we want to use a separate namespace for the analyzer, would we want to 
> > > use that same namespace for any clang-tidy specific attributes? Or should 
> > > clang-tidy get its own namespace? (Do we ever plan to execute clang-tidy 
> > > through the clang driver? That might change our answer.)
> > How would this look if we added a special namespace for the clang static 
> > analyzer? Would this lead to duplication (say, 
> > [[clang_analyzer::analyzer_noreturn]]) so that we keep the "analyzer_" 
> > prefix for __attribute__((analyzer_noreturn))? Or could we have the 
> > "analyzer_" prefix only for GNU-style attributes but not for C++ (for 
> > example, [[clang_analyzer::noreturn]])?
> > 
> > As for clang-tidy, I think it probably makes sense for it to have its own 
> > namespace, but we should ask @alexfh.
> > How would this look if we added a special namespace for the clang static 
> > analyzer? Would this lead to duplication (say, 
> > [[clang_analyzer::analyzer_noreturn]]) so that we keep the "analyzer_" 
> > prefix for attribute((analyzer_noreturn))? Or could we have the "analyzer_" 
> > prefix only for GNU-style attributes but not for C++ (for example, 
> > [[clang_analyzer::noreturn]])?
> 
> We have the ability to do whatever we'd like there. Given that the semantics 
> are so similar to `[[noreturn]]`, I think it would be reasonable to use 
> `[[clang_analyzer::noreturn]]` and `__attribute__((analyzer_noreturn))` if 
> that's the direction you think is best.
> 
> > As for clang-tidy, I think it probably makes sense for it to have its own 
> > namespace, but we should ask @alexfh.
> 
> I'm less enthusiastic about giving clang-tidy a vendor namespace that's 
> separate from the static analyzer, should the need arise. My biggest concern 
> there is that I would *really* like to see clang-tidy be more tightly 
> integrated with the clang driver (so users don't have to manually execute a 
> secondary tool). If that were to happen, then the user experience would be 
> that there are two vendor namespaces both related to analyzer attributes.
> 
> That said, I would also not be opposed to putting all of these attributes 
> under the `clang` vendor namespace and not having a separate vendor for the 
> analyzer or clang-tidy.
I would be find with keeping all of these things under the `clang` namespace, 
too.

That said, I do think there is some value in having a namespace for analyzer 
attributes separate from clang proper because the namespace would make it more 
clear that the attribute doesn't affect code generation.


https://reviews.llvm.org/D40625



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


[PATCH] D40568: design document for a hardware-assisted memory safety (HWAMS) tool, similar to AddressSanitizer

2017-12-01 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis accepted this revision.
eugenis added a comment.
This revision is now accepted and ready to land.

Looks great!


Repository:
  rC Clang

https://reviews.llvm.org/D40568



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


r319594 - [AST] Try to fix build bot with modules broken r319589. However real fix may belong to other place.

2017-12-01 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Fri Dec  1 15:23:28 2017
New Revision: 319594

URL: http://llvm.org/viewvc/llvm-project?rev=319594=rev
Log:
[AST] Try to fix build bot with modules broken r319589. However real fix may 
belong to other place.

Modified:
cfe/trunk/include/clang/AST/DeclContextInternals.h

Modified: cfe/trunk/include/clang/AST/DeclContextInternals.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclContextInternals.h?rev=319594=319593=319594=diff
==
--- cfe/trunk/include/clang/AST/DeclContextInternals.h (original)
+++ cfe/trunk/include/clang/AST/DeclContextInternals.h Fri Dec  1 15:23:28 2017
@@ -17,6 +17,7 @@
 
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclarationName.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/PointerIntPair.h"


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


[PATCH] D40044: [CodeGen] convert math libcalls/builtins to equivalent LLVM intrinsics

2017-12-01 Thread Sanjay Patel via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC319593: [CodeGen] convert math libcalls/builtins to 
equivalent LLVM intrinsics (authored by spatel).

Repository:
  rC Clang

https://reviews.llvm.org/D40044

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/builtin-sqrt.c
  test/CodeGen/builtins.c
  test/CodeGen/libcalls.c
  test/CodeGen/math-builtins.c
  test/CodeGen/math-libcalls.c

Index: test/CodeGen/libcalls.c
===
--- test/CodeGen/libcalls.c
+++ test/CodeGen/libcalls.c
@@ -105,19 +105,19 @@
   double exp_ = exp(d);
   long double expl_ = expl(ld);
   float expf_ = expf(f);
-// CHECK-NO: declare double @exp(double) [[NUW_RN]]
-// CHECK-NO: declare x86_fp80 @expl(x86_fp80) [[NUW_RN]]
-// CHECK-NO: declare float @expf(float) [[NUW_RN]]
+// CHECK-NO: declare double @llvm.exp.f64(double) [[NUW_RNI]]
+// CHECK-NO: declare x86_fp80 @llvm.exp.f80(x86_fp80) [[NUW_RNI]]
+// CHECK-NO: declare float @llvm.exp.f32(float) [[NUW_RNI]]
 // CHECK-YES-NOT: declare double @exp(double) [[NUW_RN]]
 // CHECK-YES-NOT: declare x86_fp80 @expl(x86_fp80) [[NUW_RN]]
 // CHECK-YES-NOT: declare float @expf(float) [[NUW_RN]]
 
   double log_ = log(d);
   long double logl_ = logl(ld);
   float logf_ = logf(f);
-// CHECK-NO: declare double @log(double) [[NUW_RN]]
-// CHECK-NO: declare x86_fp80 @logl(x86_fp80) [[NUW_RN]]
-// CHECK-NO: declare float @logf(float) [[NUW_RN]]
+// CHECK-NO: declare double @llvm.log.f64(double) [[NUW_RNI]]
+// CHECK-NO: declare x86_fp80 @llvm.log.f80(x86_fp80) [[NUW_RNI]]
+// CHECK-NO: declare float @llvm.log.f32(float) [[NUW_RNI]]
 // CHECK-YES-NOT: declare double @log(double) [[NUW_RN]]
 // CHECK-YES-NOT: declare x86_fp80 @logl(x86_fp80) [[NUW_RN]]
 // CHECK-YES-NOT: declare float @logf(float) [[NUW_RN]]
Index: test/CodeGen/builtin-sqrt.c
===
--- test/CodeGen/builtin-sqrt.c
+++ test/CodeGen/builtin-sqrt.c
@@ -1,17 +1,15 @@
 // RUN: %clang_cc1 -fmath-errno -triple x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s --check-prefix=HAS_ERRNO
 // RUN: %clang_cc1  -triple x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s --check-prefix=NO_ERRNO
 
-// FIXME: If the builtin does not set errno, it should be converted to an LLVM intrinsic.
-
 float foo(float X) {
   // HAS_ERRNO: call float @sqrtf(float
-  // NO_ERRNO: call float @sqrtf(float
+  // NO_ERRNO: call float @llvm.sqrt.f32(float
   return __builtin_sqrtf(X);
 }
 
 // HAS_ERRNO: declare float @sqrtf(float) [[ATTR:#[0-9]+]]
 // HAS_ERRNO-NOT: attributes [[ATTR]] = {{{.*}} readnone
 
-// NO_ERRNO: declare float @sqrtf(float) [[ATTR:#[0-9]+]]
+// NO_ERRNO: declare float @llvm.sqrt.f32(float) [[ATTR:#[0-9]+]]
 // NO_ERRNO: attributes [[ATTR]] = { nounwind readnone {{.*}}}
 
Index: test/CodeGen/math-builtins.c
===
--- test/CodeGen/math-builtins.c
+++ test/CodeGen/math-builtins.c
@@ -192,9 +192,9 @@
 
   __builtin_cos(f);__builtin_cosf(f);   __builtin_cosl(f); 
 
-// NO__ERRNO: declare double @cos(double) [[READNONE]]
-// NO__ERRNO: declare float @cosf(float) [[READNONE]]
-// NO__ERRNO: declare x86_fp80 @cosl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare double @llvm.cos.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare float @llvm.cos.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare x86_fp80 @llvm.cos.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare double @cos(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare float @cosf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare x86_fp80 @cosl(x86_fp80) [[NOT_READNONE]]
@@ -228,18 +228,18 @@
 
   __builtin_exp(f);__builtin_expf(f);   __builtin_expl(f);
 
-// NO__ERRNO: declare double @exp(double) [[READNONE]]
-// NO__ERRNO: declare float @expf(float) [[READNONE]]
-// NO__ERRNO: declare x86_fp80 @expl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare double @llvm.exp.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare float @llvm.exp.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare x86_fp80 @llvm.exp.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare double @exp(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare float @expf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare x86_fp80 @expl(x86_fp80) [[NOT_READNONE]]
 
   __builtin_exp2(f);   __builtin_exp2f(f);  __builtin_exp2l(f); 
 
-// NO__ERRNO: declare double @exp2(double) [[READNONE]]
-// NO__ERRNO: declare float @exp2f(float) [[READNONE]]
-// NO__ERRNO: declare x86_fp80 @exp2l(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare double @llvm.exp2.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare float @llvm.exp2.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare x86_fp80 @llvm.exp2.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare double @exp2(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare float @exp2f(float) [[NOT_READNONE]]
 

[PATCH] D40044: [CodeGen] convert math libcalls/builtins to equivalent LLVM intrinsics

2017-12-01 Thread Sanjay Patel via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319593: [CodeGen] convert math libcalls/builtins to 
equivalent LLVM intrinsics (authored by spatel).

Changed prior to commit:
  https://reviews.llvm.org/D40044?vs=122881=125230#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40044

Files:
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/test/CodeGen/builtin-sqrt.c
  cfe/trunk/test/CodeGen/builtins.c
  cfe/trunk/test/CodeGen/libcalls.c
  cfe/trunk/test/CodeGen/math-builtins.c
  cfe/trunk/test/CodeGen/math-libcalls.c

Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -854,6 +854,179 @@
Result.Val.getFloat()));
   }
 
+  // Math builtins have the same semantics as their math library twins.
+  // There are LLVM math intrinsics corresponding to math library functions
+  // except the intrinsic will never set errno while the math library might.
+  // Thus, we can transform math library and builtin calls to their
+  // semantically-equivalent LLVM intrinsic counterparts if the call is marked
+  // 'const' (it is known to never set errno).
+  if (FD->hasAttr()) {
+switch (BuiltinID) {
+case Builtin::BIceil:
+case Builtin::BIceilf:
+case Builtin::BIceill:
+case Builtin::BI__builtin_ceil:
+case Builtin::BI__builtin_ceilf:
+case Builtin::BI__builtin_ceill:
+  return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::ceil));
+
+case Builtin::BIcopysign:
+case Builtin::BIcopysignf:
+case Builtin::BIcopysignl:
+case Builtin::BI__builtin_copysign:
+case Builtin::BI__builtin_copysignf:
+case Builtin::BI__builtin_copysignl:
+  return RValue::get(emitBinaryBuiltin(*this, E, Intrinsic::copysign));
+
+case Builtin::BIcos:
+case Builtin::BIcosf:
+case Builtin::BIcosl:
+case Builtin::BI__builtin_cos:
+case Builtin::BI__builtin_cosf:
+case Builtin::BI__builtin_cosl:
+  return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::cos));
+
+case Builtin::BIexp:
+case Builtin::BIexpf:
+case Builtin::BIexpl:
+case Builtin::BI__builtin_exp:
+case Builtin::BI__builtin_expf:
+case Builtin::BI__builtin_expl:
+  return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::exp));
+
+case Builtin::BIexp2:
+case Builtin::BIexp2f:
+case Builtin::BIexp2l:
+case Builtin::BI__builtin_exp2:
+case Builtin::BI__builtin_exp2f:
+case Builtin::BI__builtin_exp2l:
+  return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::exp2));
+
+case Builtin::BIfabs:
+case Builtin::BIfabsf:
+case Builtin::BIfabsl:
+case Builtin::BI__builtin_fabs:
+case Builtin::BI__builtin_fabsf:
+case Builtin::BI__builtin_fabsl:
+  return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::fabs));
+
+case Builtin::BIfloor:
+case Builtin::BIfloorf:
+case Builtin::BIfloorl:
+case Builtin::BI__builtin_floor:
+case Builtin::BI__builtin_floorf:
+case Builtin::BI__builtin_floorl:
+  return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::floor));
+
+case Builtin::BIfma:
+case Builtin::BIfmaf:
+case Builtin::BIfmal:
+case Builtin::BI__builtin_fma:
+case Builtin::BI__builtin_fmaf:
+case Builtin::BI__builtin_fmal:
+  return RValue::get(emitTernaryBuiltin(*this, E, Intrinsic::fma));
+
+case Builtin::BIfmax:
+case Builtin::BIfmaxf:
+case Builtin::BIfmaxl:
+case Builtin::BI__builtin_fmax:
+case Builtin::BI__builtin_fmaxf:
+case Builtin::BI__builtin_fmaxl:
+  return RValue::get(emitBinaryBuiltin(*this, E, Intrinsic::maxnum));
+
+case Builtin::BIfmin:
+case Builtin::BIfminf:
+case Builtin::BIfminl:
+case Builtin::BI__builtin_fmin:
+case Builtin::BI__builtin_fminf:
+case Builtin::BI__builtin_fminl:
+  return RValue::get(emitBinaryBuiltin(*this, E, Intrinsic::minnum));
+
+case Builtin::BIlog:
+case Builtin::BIlogf:
+case Builtin::BIlogl:
+case Builtin::BI__builtin_log:
+case Builtin::BI__builtin_logf:
+case Builtin::BI__builtin_logl:
+  return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::log));
+
+case Builtin::BIlog10:
+case Builtin::BIlog10f:
+case Builtin::BIlog10l:
+case Builtin::BI__builtin_log10:
+case Builtin::BI__builtin_log10f:
+case Builtin::BI__builtin_log10l:
+  return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::log10));
+
+case Builtin::BIlog2:
+case Builtin::BIlog2f:
+case Builtin::BIlog2l:
+case Builtin::BI__builtin_log2:
+case Builtin::BI__builtin_log2f:
+case Builtin::BI__builtin_log2l:
+  return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::log2));
+
+case Builtin::BInearbyint:
+case Builtin::BInearbyintf:
+case Builtin::BInearbyintl:
+case 

r319593 - [CodeGen] convert math libcalls/builtins to equivalent LLVM intrinsics

2017-12-01 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Fri Dec  1 15:15:52 2017
New Revision: 319593

URL: http://llvm.org/viewvc/llvm-project?rev=319593=rev
Log:
[CodeGen] convert math libcalls/builtins to equivalent LLVM intrinsics

There are 20 LLVM math intrinsics that correspond to mathlib calls according to 
the LangRef:
http://llvm.org/docs/LangRef.html#standard-c-library-intrinsics

We were only converting 3 mathlib calls (sqrt, fma, pow) and 12 builtin calls 
(ceil, copysign, 
fabs, floor, fma, fmax, fmin, nearbyint, pow, rint, round, trunc) to their 
intrinsic-equivalents.

This patch pulls the transforms together and handles all 20 cases. The switch 
is guarded by a 
check for const-ness to make sure we're not doing the transform if errno could 
possibly be set by
the libcall or builtin.

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

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtin-sqrt.c
cfe/trunk/test/CodeGen/builtins.c
cfe/trunk/test/CodeGen/libcalls.c
cfe/trunk/test/CodeGen/math-builtins.c
cfe/trunk/test/CodeGen/math-libcalls.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=319593=319592=319593=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Dec  1 15:15:52 2017
@@ -854,6 +854,179 @@ RValue CodeGenFunction::EmitBuiltinExpr(
Result.Val.getFloat()));
   }
 
+  // Math builtins have the same semantics as their math library twins.
+  // There are LLVM math intrinsics corresponding to math library functions
+  // except the intrinsic will never set errno while the math library might.
+  // Thus, we can transform math library and builtin calls to their
+  // semantically-equivalent LLVM intrinsic counterparts if the call is marked
+  // 'const' (it is known to never set errno).
+  if (FD->hasAttr()) {
+switch (BuiltinID) {
+case Builtin::BIceil:
+case Builtin::BIceilf:
+case Builtin::BIceill:
+case Builtin::BI__builtin_ceil:
+case Builtin::BI__builtin_ceilf:
+case Builtin::BI__builtin_ceill:
+  return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::ceil));
+
+case Builtin::BIcopysign:
+case Builtin::BIcopysignf:
+case Builtin::BIcopysignl:
+case Builtin::BI__builtin_copysign:
+case Builtin::BI__builtin_copysignf:
+case Builtin::BI__builtin_copysignl:
+  return RValue::get(emitBinaryBuiltin(*this, E, Intrinsic::copysign));
+
+case Builtin::BIcos:
+case Builtin::BIcosf:
+case Builtin::BIcosl:
+case Builtin::BI__builtin_cos:
+case Builtin::BI__builtin_cosf:
+case Builtin::BI__builtin_cosl:
+  return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::cos));
+
+case Builtin::BIexp:
+case Builtin::BIexpf:
+case Builtin::BIexpl:
+case Builtin::BI__builtin_exp:
+case Builtin::BI__builtin_expf:
+case Builtin::BI__builtin_expl:
+  return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::exp));
+
+case Builtin::BIexp2:
+case Builtin::BIexp2f:
+case Builtin::BIexp2l:
+case Builtin::BI__builtin_exp2:
+case Builtin::BI__builtin_exp2f:
+case Builtin::BI__builtin_exp2l:
+  return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::exp2));
+
+case Builtin::BIfabs:
+case Builtin::BIfabsf:
+case Builtin::BIfabsl:
+case Builtin::BI__builtin_fabs:
+case Builtin::BI__builtin_fabsf:
+case Builtin::BI__builtin_fabsl:
+  return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::fabs));
+
+case Builtin::BIfloor:
+case Builtin::BIfloorf:
+case Builtin::BIfloorl:
+case Builtin::BI__builtin_floor:
+case Builtin::BI__builtin_floorf:
+case Builtin::BI__builtin_floorl:
+  return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::floor));
+
+case Builtin::BIfma:
+case Builtin::BIfmaf:
+case Builtin::BIfmal:
+case Builtin::BI__builtin_fma:
+case Builtin::BI__builtin_fmaf:
+case Builtin::BI__builtin_fmal:
+  return RValue::get(emitTernaryBuiltin(*this, E, Intrinsic::fma));
+
+case Builtin::BIfmax:
+case Builtin::BIfmaxf:
+case Builtin::BIfmaxl:
+case Builtin::BI__builtin_fmax:
+case Builtin::BI__builtin_fmaxf:
+case Builtin::BI__builtin_fmaxl:
+  return RValue::get(emitBinaryBuiltin(*this, E, Intrinsic::maxnum));
+
+case Builtin::BIfmin:
+case Builtin::BIfminf:
+case Builtin::BIfminl:
+case Builtin::BI__builtin_fmin:
+case Builtin::BI__builtin_fminf:
+case Builtin::BI__builtin_fminl:
+  return RValue::get(emitBinaryBuiltin(*this, E, Intrinsic::minnum));
+
+case Builtin::BIlog:
+case Builtin::BIlogf:
+case Builtin::BIlogl:
+case Builtin::BI__builtin_log:
+case Builtin::BI__builtin_logf:
+case Builtin::BI__builtin_logl:
+  return 

[PATCH] D40746: Correctly handle line table entries without filenames during AST serialization

2017-12-01 Thread Hans Wennborg via Phabricator via cfe-commits
hans updated this revision to Diff 125227.
hans retitled this revision from "Correctly handle line directives without 
filenames that come first in the file" to "Correctly handle line table entries 
without filenames during AST serialization".
hans edited the summary of this revision.

https://reviews.llvm.org/D40746

Files:
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  test/PCH/line-directive-nofilename.c
  test/PCH/line-directive-nofilename.h


Index: test/PCH/line-directive-nofilename.h
===
--- /dev/null
+++ test/PCH/line-directive-nofilename.h
@@ -0,0 +1,5 @@
+#line 42
+int foo; // This should appear as at line-directive-nofilename.h:42
+
+#line 100 "foobar.h"
+int bar; // This should appear as at foobar.h:100
Index: test/PCH/line-directive-nofilename.c
===
--- /dev/null
+++ test/PCH/line-directive-nofilename.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-pch -o %t %S/line-directive-nofilename.h
+// RUN: not %clang_cc1 -include-pch %t -fsyntax-only %s 2>&1 | FileCheck %s
+
+// This causes an "error: redefinition" diagnostic. The notes will have the
+// locations of the declarations from the PCH file.
+double foo, bar;
+
+// CHECK: line-directive-nofilename.h:42:5: note: previous definition is here
+// CHECK: foobar.h:100:5: note: previous definition is here
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -2363,12 +2363,13 @@
 
 // Emit the needed file names.
 llvm::DenseMap FilenameMap;
+FilenameMap[-1] = -1; // For unspecified filenames.
 for (const auto  : LineTable) {
   if (L.first.ID < 0)
 continue;
   for (auto  : L.second) {
 if (FilenameMap.insert(std::make_pair(LE.FilenameID,
-  FilenameMap.size())).second)
+  FilenameMap.size() - 1)).second)
   AddPath(LineTable.getFilename(LE.FilenameID), Record);
   }
 }
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -1220,6 +1220,7 @@
 
   // Parse the file names
   std::map FileIDs;
+  FileIDs[-1] = -1; // For unspecified filenames.
   for (unsigned I = 0; Record[Idx]; ++I) {
 // Extract the file name
 auto Filename = ReadPath(F, Record, Idx);


Index: test/PCH/line-directive-nofilename.h
===
--- /dev/null
+++ test/PCH/line-directive-nofilename.h
@@ -0,0 +1,5 @@
+#line 42
+int foo; // This should appear as at line-directive-nofilename.h:42
+
+#line 100 "foobar.h"
+int bar; // This should appear as at foobar.h:100
Index: test/PCH/line-directive-nofilename.c
===
--- /dev/null
+++ test/PCH/line-directive-nofilename.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-pch -o %t %S/line-directive-nofilename.h
+// RUN: not %clang_cc1 -include-pch %t -fsyntax-only %s 2>&1 | FileCheck %s
+
+// This causes an "error: redefinition" diagnostic. The notes will have the
+// locations of the declarations from the PCH file.
+double foo, bar;
+
+// CHECK: line-directive-nofilename.h:42:5: note: previous definition is here
+// CHECK: foobar.h:100:5: note: previous definition is here
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -2363,12 +2363,13 @@
 
 // Emit the needed file names.
 llvm::DenseMap FilenameMap;
+FilenameMap[-1] = -1; // For unspecified filenames.
 for (const auto  : LineTable) {
   if (L.first.ID < 0)
 continue;
   for (auto  : L.second) {
 if (FilenameMap.insert(std::make_pair(LE.FilenameID,
-  FilenameMap.size())).second)
+  FilenameMap.size() - 1)).second)
   AddPath(LineTable.getFilename(LE.FilenameID), Record);
   }
 }
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -1220,6 +1220,7 @@
 
   // Parse the file names
   std::map FileIDs;
+  FileIDs[-1] = -1; // For unspecified filenames.
   for (unsigned I = 0; Record[Idx]; ++I) {
 // Extract the file name
 auto Filename = ReadPath(F, Record, Idx);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38425: [clangd] Document highlights for clangd

2017-12-01 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 125228.
Nebiroth added a comment.

Minor code cleanup
unparse and parse methods for JSON are updated


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38425

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  test/clangd/documenthighlight.test
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test

Index: test/clangd/initialize-params.test
===
--- test/clangd/initialize-params.test
+++ test/clangd/initialize-params.test
@@ -20,6 +20,7 @@
 # CHECK-NEXT:  },
 # CHECK-NEXT:  "definitionProvider": true,
 # CHECK-NEXT:  "documentFormattingProvider": true,
+# CHECK-NEXT:  "documentHighlightProvider": true,
 # CHECK-NEXT:  "documentOnTypeFormattingProvider": {
 # CHECK-NEXT:"firstTriggerCharacter": "}",
 # CHECK-NEXT:"moreTriggerCharacter": []
Index: test/clangd/initialize-params-invalid.test
===
--- test/clangd/initialize-params-invalid.test
+++ test/clangd/initialize-params-invalid.test
@@ -20,6 +20,7 @@
 # CHECK-NEXT:  },
 # CHECK-NEXT:  "definitionProvider": true,
 # CHECK-NEXT:  "documentFormattingProvider": true,
+# CHECK-NEXT:  "documentHighlightProvider": true,
 # CHECK-NEXT:  "documentOnTypeFormattingProvider": {
 # CHECK-NEXT:"firstTriggerCharacter": "}",
 # CHECK-NEXT:"moreTriggerCharacter": []
Index: test/clangd/documenthighlight.test
===
--- /dev/null
+++ test/clangd/documenthighlight.test
@@ -0,0 +1,42 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 479
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"#define MACRO 1\nnamespace ns1 {\nstruct MyClass {\nint xasd;\nvoid anotherOperation() {\n}\nstatic int foo(MyClass*) {\nreturn 0;\n}\n\n};\nstruct Foo {\nint xasd;\n};\n}\nint main() {\nint bonjour;\nbonjour = 2;\nint test1 = bonjour;\nns1::Foo bar = { xasd : 1};\nbar.xasd = 3;\nns1::MyClass* Params;\nParams->anotherOperation();\n}\n"}}}
+
+Content-Length: 156
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":17,"character":2}}}
+# Verify local variable 
+# CHECK: {"id":1,"jsonrpc":"2.0","result":[{"kind":1,"range":{"end":{"character":11,"line":16},"start":{"character":4,"line":16}}},{"kind":3,"range":{"end":{"character":7,"line":17},"start":{"character":0,"line":17}}},{"kind":2,"range":{"end":{"character":19,"line":18},"start":{"character":12,"line":18}}}]}
+
+Content-Length: 157
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":18,"character":17}}}
+# Verify struct highlight
+# CHECK: {"id":1,"jsonrpc":"2.0","result":[{"kind":1,"range":{"end":{"character":11,"line":16},"start":{"character":4,"line":16}}},{"kind":3,"range":{"end":{"character":7,"line":17},"start":{"character":0,"line":17}}},{"kind":2,"range":{"end":{"character":19,"line":18},"start":{"character":12,"line":18}}}]}
+
+Content-Length: 157
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":21,"character":10}}}
+# Verify method highlight
+# CHECK: {"id":1,"jsonrpc":"2.0","result":[{"kind":1,"range":{"end":{"character":14,"line":2},"start":{"character":7,"line":2}}},{"kind":1,"range":{"end":{"character":22,"line":6},"start":{"character":15,"line":6}}},{"kind":1,"range":{"end":{"character":12,"line":21},"start":{"character":5,"line":21}}}]}
+
+Content-Length: 157
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":18,"character":14}}}
+# Verify Read-access of a symbol (kind = 2) 
+# CHECK: {"id":1,"jsonrpc":"2.0","result":[{"kind":1,"range":{"end":{"character":11,"line":16},"start":{"character":4,"line":16}}},{"kind":3,"range":{"end":{"character":7,"line":17},"start":{"character":0,"line":17}}},{"kind":2,"range":{"end":{"character":19,"line":18},"start":{"character":12,"line":18}}}]}
+
+Content-Length: 48
+
+{"jsonrpc":"2.0","id":1,"method":"shutdown"}
+
+Content-Length: 33
+
+{"jsonrpc":"2.0":"method":"exit"}			
\ No newline at end of file
Index: clangd/ProtocolHandlers.h

[PATCH] D40746: Correctly handle line directives without filenames that come first in the file

2017-12-01 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In https://reviews.llvm.org/D40746#942824, @rsmith wrote:

> The intent is to use a `FilenameID` of -1 to represent this situation; see 
> the documentation of the `LineEntry::FilenameID` member. Users of that field 
> are expected to deal with that value (see the handling of that case in 
> `SourceManager::getPresumedLoc` for example). I think we need to handle it 
> that way, rather than mapping to the main file name as this patch does, for 
> correctness in the PCH case -- we don't actually *know* the correct main file 
> name at the point where the line directive appears.
>
> I imagine the cause of the crash is that the AST writer blindly calls 
> `LineTableInfo::getFilename(LE.FilenameID)` without checking for this case?


Yes, exactly.

I suppose the right thing to do is to just make the -1 values survive 
serialization, and the correct filename can be figured out when the 
deserialized pch gets used? Patch coming up.


https://reviews.llvm.org/D40746



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


[PATCH] D39455: [CodeGen] Add initial support for union members in TBAA

2017-12-01 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added a comment.

After this patch, a couple of gcc torture tests started to fail. Could you 
possibly look at this? https://bugs.llvm.org/show_bug.cgi?id=35503


Repository:
  rL LLVM

https://reviews.llvm.org/D39455



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


[PATCH] D40673: Add _Float128 as alias to __float128 to enable compilations on Fedora27/glibc2-26

2017-12-01 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: lib/Frontend/InitPreprocessor.cpp:817
   DefineFloatMacros(Builder, "LDBL", (), "L");
+  DefineFloatMacros(Builder, "FLT128", (), "Q");
+

GCC //does// define these macros under with C++ mode when it would for the C 
mode, but with the `F128` suffix (that it then interprets as a user-defined 
literal suffix). Use of these macros under C++ mode would behave differently 
between GCC and Clang until `Q` is replaced with `F128`.

In my experience, GCC on //does not// define these macros on platforms where 
`__float128` is unsupported. This includes `powerpc64le-linux-gnu` without the 
`-mfloat128` option.



Comment at: test/Sema/_Float128.c:2
+// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -triple powerpc64-linux -verify %s

Duplicate run line



Comment at: test/Sema/_Float128.c:17
+#else
+_Float128 f;  // expected-error {{__float128 is not supported on this target}}
+int g(int x, _Float128 *y) {  // expected-error {{__float128 is not supported 
on this target}}

Add test that `__FLT128_EPSILON__` is not defined?


Repository:
  rL LLVM

https://reviews.llvm.org/D40673



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


[PATCH] D35894: [clangd] Code hover for Clangd

2017-12-01 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 125224.
Nebiroth added a comment.

Minor code cleanup
Merge with master


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D35894

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  test/clangd/hover.test
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test

Index: test/clangd/initialize-params.test
===
--- test/clangd/initialize-params.test
+++ test/clangd/initialize-params.test
@@ -30,6 +30,7 @@
 # CHECK-NEXT:  "clangd.applyFix"
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
+# CHECK-NEXT:	   "hoverProvider": true,
 # CHECK-NEXT:  "renameProvider": true,
 # CHECK-NEXT:  "signatureHelpProvider": {
 # CHECK-NEXT:"triggerCharacters": [
Index: test/clangd/initialize-params-invalid.test
===
--- test/clangd/initialize-params-invalid.test
+++ test/clangd/initialize-params-invalid.test
@@ -30,6 +30,7 @@
 # CHECK-NEXT:  "clangd.applyFix"
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
+# CHECK-NEXT:	   "hoverProvider": true,
 # CHECK-NEXT:  "renameProvider": true,
 # CHECK-NEXT:  "signatureHelpProvider": {
 # CHECK-NEXT:"triggerCharacters": [
Index: test/clangd/hover.test
===
--- /dev/null
+++ test/clangd/hover.test
@@ -0,0 +1,56 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 611
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"#define MACRO 1\nnamespace ns1 {\nint test = 5;\nstruct MyClass {\nint xasd;\nvoid anotherOperation() {\n}\nstatic int foo(MyClass*) {\nreturn 0;\n}\n\n};}\n//comments test\ntemplate\nT templateTest(T foo) {\nreturn foo;}\ntemplate\nclass classTemplateTest {\npublic: T test;};\nint main() {\nint a;\na;\nint b = ns1::test;\nns1::MyClass* Params;\nParams->anotherOperation();\nMACRO;\nint temp = 5;\ntemplateTest(temp);classTemplateTest test;}\n"}}}
+
+Content-Length: 144
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":0,"character":12}}}
+# CHECK: {"id":1,"jsonrpc":"2.0","result":{"contents":[{"language":"C++","value":"#define MACRO 1"}],"range":{"end":{"character":15,"line":0},"start":{"character":8,"line":0
+
+Content-Length: 144
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":21,"character":1}}}
+# CHECK: {"id":1,"jsonrpc":"2.0","result":{"contents":[{"language":"C++","value":"int a"}],"range":{"end":{"character":5,"line":20},"start":{"character":0,"line":20
+
+Content-Length: 145
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":22,"character":15}}}
+# CHECK: {"id":1,"jsonrpc":"2.0","result":{"contents":[{"language":"C++","value":"In ns1"},{"language":"C++","value":"int test = 5"}],"range":{"end":{"character":12,"line":2},"start":{"character":0,"line":2
+
+Content-Length: 145
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":23,"character":10}}}
+# CHECK: {"id":1,"jsonrpc":"2.0","result":{"contents":[{"language":"C++","value":"In ns1"},{"language":"C++","value":"struct MyClass {"}],"range":{"end":{"character":16,"line":3},"start":{"character":0,"line":3
+
+Content-Length: 145
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":24,"character":13}}}
+# CHECK: {"id":1,"jsonrpc":"2.0","result":{"contents":[{"language":"C++","value":"In ns1::MyClass"},{"language":"C++","value":"void anotherOperation() {"}],"range":{"end":{"character":25,"line":5},"start":{"character":0,"line":5
+
+Content-Length: 144
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":25,"character":1}}}
+# CHECK: {"id":1,"jsonrpc":"2.0","result":{"contents":[{"language":"C++","value":"#define MACRO 1"}],"range":{"end":{"character":15,"line":0},"start":{"character":8,"line":0
+
+Content-Length: 144
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":26,"character":8}}}
+# CHECK: 

[PATCH] D40746: Correctly handle line directives without filenames that come first in the file

2017-12-01 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

The intent is to use a `FilenameID` of -1 to represent this situation; see the 
documentation of the `LineEntry::FilenameID` member. Users of that field are 
expected to deal with that value (see the handling of that case in 
`SourceManager::getPresumedLoc` for example). I think we need to handle it that 
way, rather than mapping to the main file name as this patch does, for 
correctness in the PCH case -- we don't actually *know* the correct main file 
name at the point where the line directive appears.

I imagine the cause of the crash is that the AST writer blindly calls 
`LineTableInfo::getFilename(LE.FilenameID)` without checking for this case?


https://reviews.llvm.org/D40746



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


[PATCH] D39694: [VerifyDiagnosticConsumer] support -verify=

2017-12-01 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny updated this revision to Diff 125223.
jdenny added a comment.

Rebased on master/trunk fetched today.


https://reviews.llvm.org/D39694

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Basic/DiagnosticOptions.h
  include/clang/Driver/CC1Options.td
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/VerifyDiagnosticConsumer.cpp
  test/Frontend/verify-prefixes.c
  test/Sema/tautological-constant-compare.c
  test/Sema/tautological-constant-enum-compare.c
  test/Sema/tautological-unsigned-enum-zero-compare.c
  test/Sema/tautological-unsigned-enum-zero-compare.cpp
  test/Sema/tautological-unsigned-zero-compare.c

Index: test/Sema/tautological-unsigned-zero-compare.c
===
--- test/Sema/tautological-unsigned-zero-compare.c
+++ test/Sema/tautological-unsigned-zero-compare.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -DTEST -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify %s
-// RUN: %clang_cc1 -fsyntax-only -DTEST -verify -x c++ %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify=silence %s
+// RUN: %clang_cc1 -fsyntax-only -verify -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify=silence -x c++ %s
 
 unsigned uvalue(void);
 signed int svalue(void);
@@ -13,13 +13,8 @@
 void TFunc() {
   // Make sure that we do warn for normal variables in template functions !
   unsigned char c = svalue();
-#ifdef TEST
   if (c < 0) // expected-warning {{comparison of unsigned expression < 0 is always false}}
   return;
-#else
-  if (c < 0)
-  return;
-#endif
 
   if (c < macro(0))
   return;
@@ -39,7 +34,8 @@
 
   unsigned un = uvalue();
 
-#ifdef TEST
+  // silence-no-diagnostics
+
   if (un == 0)
   return 0;
   if (un != 0)
@@ -91,65 +87,10 @@
   return 0;
   if (0UL >= un)
   return 0;
-#else
-// expected-no-diagnostics
-  if (un == 0)
-  return 0;
-  if (un != 0)
-  return 0;
-  if (un < 0)
-  return 0;
-  if (un <= 0)
-  return 0;
-  if (un > 0)
-  return 0;
-  if (un >= 0)
-  return 0;
-
-  if (0 == un)
-  return 0;
-  if (0 != un)
-  return 0;
-  if (0 < un)
-  return 0;
-  if (0 <= un)
-  return 0;
-  if (0 > un)
-  return 0;
-  if (0 >= un)
-  return 0;
-
-  if (un == 0UL)
-  return 0;
-  if (un != 0UL)
-  return 0;
-  if (un < 0UL)
-  return 0;
-  if (un <= 0UL)
-  return 0;
-  if (un > 0UL)
-  return 0;
-  if (un >= 0UL)
-  return 0;
-
-  if (0UL == un)
-  return 0;
-  if (0UL != un)
-  return 0;
-  if (0UL < un)
-  return 0;
-  if (0UL <= un)
-  return 0;
-  if (0UL > un)
-  return 0;
-  if (0UL >= un)
-  return 0;
-#endif
 
 
   signed int a = svalue();
 
-#ifdef TEST
   if (a == 0)
   return 0;
   if (a != 0)
@@ -201,60 +142,6 @@
   return 0;
   if (0UL >= a)
   return 0;
-#else
-// expected-no-diagnostics
-  if (a == 0)
-  return 0;
-  if (a != 0)
-  return 0;
-  if (a < 0)
-  return 0;
-  if (a <= 0)
-  return 0;
-  if (a > 0)
-  return 0;
-  if (a >= 0)
-  return 0;
-
-  if (0 == a)
-  return 0;
-  if (0 != a)
-  return 0;
-  if (0 < a)
-  return 0;
-  if (0 <= a)
-  return 0;
-  if (0 > a)
-  return 0;
-  if (0 >= a)
-  return 0;
-
-  if (a == 0UL)
-  return 0;
-  if (a != 0UL)
-  return 0;
-  if (a < 0UL)
-  return 0;
-  if (a <= 0UL)
-  return 0;
-  if (a > 0UL)
-  return 0;
-  if (a >= 0UL)
-  return 0;
-
-  if (0UL == a)
-  return 0;
-  if (0UL != a)
-  return 0;
-  if (0UL < a)
-  return 0;
-  if (0UL <= a)
-  return 0;
-  if (0UL > a)
-  return 0;
-  if (0UL >= a)
-  return 0;
-#endif
 
 
   float fl = 0;
Index: test/Sema/tautological-unsigned-enum-zero-compare.cpp
===
--- test/Sema/tautological-unsigned-enum-zero-compare.cpp
+++ test/Sema/tautological-unsigned-enum-zero-compare.cpp
@@ -1,6 +1,10 @@
-// RUN: %clang_cc1 -std=c++11 -triple=x86_64-pc-linux-gnu -fsyntax-only -DUNSIGNED -verify %s
-// RUN: %clang_cc1 -std=c++11 -triple=x86_64-pc-win32 -fsyntax-only -DSIGNED -verify %s
-// RUN: %clang_cc1 -std=c++11 -triple=x86_64-pc-win32 -fsyntax-only -DSILENCE -Wno-tautological-unsigned-enum-zero-compare -verify %s
+// RUN: %clang_cc1 -std=c++11 -triple=x86_64-pc-linux-gnu -fsyntax-only \
+// RUN:-verify=unsigned,unsigned-signed,expected %s
+// RUN: %clang_cc1 -std=c++11 -triple=x86_64-pc-win32 -fsyntax-only \
+// RUN:-verify=unsigned-signed,signed-silence,expected %s
+// RUN: %clang_cc1 -std=c++11 -triple=x86_64-pc-win32 -fsyntax-only \
+// RUN:-Wno-tautological-unsigned-enum-zero-compare \
+// RUN:

r319589 - [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

2017-12-01 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Fri Dec  1 14:04:49 2017
New Revision: 319589

URL: http://llvm.org/viewvc/llvm-project?rev=319589=rev
Log:
[AST] Fix some Clang-tidy modernize and Include What You Use warnings; other 
minor fixes (NFC).

Modified:
cfe/trunk/include/clang/AST/DeclContextInternals.h
cfe/trunk/include/clang/AST/GlobalDecl.h
cfe/trunk/include/clang/AST/TypeLoc.h
cfe/trunk/include/clang/AST/VTTBuilder.h
cfe/trunk/lib/AST/TypeLoc.cpp
cfe/trunk/lib/AST/VTTBuilder.cpp

Modified: cfe/trunk/include/clang/AST/DeclContextInternals.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclContextInternals.h?rev=319589=319588=319589=diff
==
--- cfe/trunk/include/clang/AST/DeclContextInternals.h (original)
+++ cfe/trunk/include/clang/AST/DeclContextInternals.h Fri Dec  1 14:04:49 2017
@@ -1,4 +1,4 @@
-//===-- DeclContextInternals.h - DeclContext Representation -*- C++ 
-*-===//
+//===- DeclContextInternals.h - DeclContext Representation --*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -11,17 +11,19 @@
 //  of DeclContext.
 //
 
//===--===//
+
 #ifndef LLVM_CLANG_AST_DECLCONTEXTINTERNALS_H
 #define LLVM_CLANG_AST_DECLCONTEXTINTERNALS_H
 
 #include "clang/AST/Decl.h"
-#include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclarationName.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/SmallVector.h"
 #include 
+#include 
 
 namespace clang {
 
@@ -30,21 +32,20 @@ class DependentDiagnostic;
 /// \brief An array of decls optimized for the common case of only containing
 /// one entry.
 struct StoredDeclsList {
-
   /// \brief When in vector form, this is what the Data pointer points to.
-  typedef SmallVector DeclsTy;
+  using DeclsTy = SmallVector;
 
   /// \brief A collection of declarations, with a flag to indicate if we have
   /// further external declarations.
-  typedef llvm::PointerIntPair DeclsAndHasExternalTy;
+  using DeclsAndHasExternalTy = llvm::PointerIntPair;
 
   /// \brief The stored data, which will be either a pointer to a NamedDecl,
   /// or a pointer to a vector with a flag to indicate if there are further
   /// external declarations.
-  llvm::PointerUnion Data;
+  llvm::PointerUnion Data;
 
 public:
-  StoredDeclsList() {}
+  StoredDeclsList() = default;
 
   StoredDeclsList(StoredDeclsList &) : Data(RHS.Data) {
 RHS.Data = (NamedDecl *)nullptr;
@@ -186,7 +187,6 @@ public:
 
   /// AddSubsequentDecl - This is called on the second and later decl when it 
is
   /// not a redeclaration to merge it into the appropriate place in our list.
-  ///
   void AddSubsequentDecl(NamedDecl *D) {
 assert(!isNull() && "don't AddSubsequentDecl when we have no decls");
 
@@ -237,28 +237,28 @@ public:
 };
 
 class StoredDeclsMap
-  : public llvm::SmallDenseMap {
-
+: public llvm::SmallDenseMap {
 public:
   static void DestroyAll(StoredDeclsMap *Map, bool Dependent);
 
 private:
   friend class ASTContext; // walks the chain deleting these
   friend class DeclContext;
+
   llvm::PointerIntPair Previous;
 };
 
 class DependentStoredDeclsMap : public StoredDeclsMap {
 public:
-  DependentStoredDeclsMap() : FirstDiagnostic(nullptr) {}
+  DependentStoredDeclsMap() = default;
 
 private:
-  friend class DependentDiagnostic;
   friend class DeclContext; // iterates over diagnostics
+  friend class DependentDiagnostic;
 
-  DependentDiagnostic *FirstDiagnostic;
+  DependentDiagnostic *FirstDiagnostic = nullptr;
 };
 
-} // end namespace clang
+} // namespace clang
 
-#endif
+#endif // LLVM_CLANG_AST_DECLCONTEXTINTERNALS_H

Modified: cfe/trunk/include/clang/AST/GlobalDecl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/GlobalDecl.h?rev=319589=319588=319589=diff
==
--- cfe/trunk/include/clang/AST/GlobalDecl.h (original)
+++ cfe/trunk/include/clang/AST/GlobalDecl.h Fri Dec  1 14:04:49 2017
@@ -1,4 +1,4 @@
-//===--- GlobalDecl.h - Global declaration holder ---*- C++ 
-*-===//
+//===- GlobalDecl.h - Global declaration holder -*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -19,6 +19,12 @@
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclOpenMP.h"
 #include "clang/Basic/ABI.h"
+#include "clang/Basic/LLVM.h"
+#include "llvm/ADT/DenseMapInfo.h"
+#include "llvm/ADT/PointerIntPair.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/type_traits.h"
+#include 
 
 namespace clang {
 
@@ -27,7 +33,7 @@ namespace clang {
 /// a CXXDestructorDecl and the destructor type 

[PATCH] D40698: [ubsan] Diagnose noreturn functions which return

2017-12-01 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 125221.
vsk edited the summary of this revision.
vsk added a comment.

- Diagnose in the scenario Eli pointed out, by stripping the 'noreturn' 
attribute and emitting a check after the call.
- Test updates.


https://reviews.llvm.org/D40698

Files:
  docs/UndefinedBehaviorSanitizer.rst
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGException.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGObjCGNU.cpp
  lib/CodeGen/CGObjCMac.cpp
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGen/ubsan-noreturn.c
  test/CodeGenCXX/ubsan-unreachable.cpp

Index: test/CodeGenCXX/ubsan-unreachable.cpp
===
--- /dev/null
+++ test/CodeGenCXX/ubsan-unreachable.cpp
@@ -0,0 +1,74 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=unreachable | FileCheck %s
+
+extern void __attribute__((noreturn)) abort();
+
+// CHECK-LABEL: define void @_Z14calls_noreturnv
+void calls_noreturn() {
+  abort();
+
+  // Check that there are no attributes on the call site.
+  // CHECK-NOT: call void @_Z5abortv{{.*}}#
+
+  // CHECK: __ubsan_handle_builtin_unreachable
+  // CHECK: unreachable
+}
+
+struct A {
+  // Test regular members.
+  void __attribute__((noreturn)) does_not_return1() {
+// CHECK-NOT: call void @_Z5abortv(){{.*}}#
+abort();
+  }
+
+  // CHECK: declare void @_Z5abortv{{.*}} [[ABORT_ATTR:#[0-9]+]]
+
+  // CHECK-LABEL: define linkonce_odr void @_ZN1A5call1Ev
+  void call1() {
+// CHECK-NOT: call void @_ZN1A16does_not_return1Ev{{.*}}#
+does_not_return1();
+
+// CHECK: __ubsan_handle_builtin_unreachable
+// CHECK: unreachable
+  }
+
+  // Test static members.
+  static void __attribute__((noreturn)) does_not_return2() {
+// CHECK-NOT: call void @_Z5abortv{{.*}}#
+abort();
+  }
+
+  // CHECK-LABEL: define linkonce_odr void @_ZN1A5call2Ev
+  void call2() {
+// CHECK-NOT: call void @_ZN1A16does_not_return2Ev{{.*}}#
+does_not_return2();
+
+// CHECK: __ubsan_handle_builtin_unreachable
+// CHECK: unreachable
+  }
+
+  // Test calls through pointers to non-static member functions.
+  typedef void __attribute__((noreturn)) (A::*MemFn)();
+
+  // CHECK-LABEL: define linkonce_odr void @_ZN1A5call3Ev
+  void call3() {
+MemFn MF = ::does_not_return1;
+(this->*MF)();
+
+// CHECK-NOT: call void %{{.*}}#
+// CHECK: __ubsan_handle_builtin_unreachable
+// CHECK: unreachable
+  }
+};
+
+// CHECK: define linkonce_odr void @_ZN1A16does_not_return1Ev{{.*}} [[DOES_NOT_RETURN_ATTR:#[0-9]+]]
+// CHECK: define linkonce_odr void @_ZN1A16does_not_return2Ev{{.*}} [[DOES_NOT_RETURN_ATTR]]
+
+void force_irgen() {
+  A a;
+  a.call1();
+  a.call2();
+  a.call3();
+}
+
+// CHECK-NOT: [[ABORT_ATTR]] = {{[^}]+}}noreturn
+// CHECK-NOT: [[DOES_NOT_RETURN_ATTR]] = {{[^}]+}}noreturn
Index: test/CodeGen/ubsan-noreturn.c
===
--- /dev/null
+++ test/CodeGen/ubsan-noreturn.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - | FileCheck %s
+
+// CHECK-LABEL: @f(
+void __attribute__((noreturn)) f() {
+  // CHECK: __ubsan_handle_builtin_unreachable
+  // CHECK: unreachable
+}
Index: lib/CodeGen/MicrosoftCXXABI.cpp
===
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -3941,7 +3941,7 @@
   CGCallee Callee = CGCallee::forDirect(CalleePtr, CD);
   const CGFunctionInfo  = CGM.getTypes().arrangeCXXConstructorCall(
   Args, CD, Ctor_Complete, ExtraArgs.Prefix, ExtraArgs.Suffix);
-  CGF.EmitCall(CalleeInfo, Callee, ReturnValueSlot(), Args);
+  CGF.EmitCall(CalleeInfo, Callee, ReturnValueSlot(), Args, SourceLocation());
 
   Cleanups.ForceCleanup();
 
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -3278,6 +3278,7 @@
   /// LLVM arguments and the types they were derived from.
   RValue EmitCall(const CGFunctionInfo , const CGCallee ,
   ReturnValueSlot ReturnValue, const CallArgList ,
+  SourceLocation Loc,
   llvm::Instruction **callOrInvoke = nullptr);
 
   RValue EmitCall(QualType FnType, const CGCallee , const CallExpr *E,
@@ -3736,6 +3737,10 @@
 llvm::ConstantInt *TypeId, llvm::Value *Ptr,
 ArrayRef StaticArgs);
 
+  /// Emit a reached-unreachable diagnostic if \p Loc is valid and runtime
+  /// checking is enabled. Otherwise, just emit an unreachable instruction.
+  void EmitUnreachable(SourceLocation Loc);
+
   /// \brief 

[PATCH] D40700: [ubsan] Diagnose noreturn functions which return (compiler-rt)

2017-12-01 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 125220.
vsk added a comment.

- Update to test diagnostics seen after a call to the noreturn function.


https://reviews.llvm.org/D40700

Files:
  lib/ubsan/ubsan_handlers.cc
  test/ubsan/TestCases/Misc/Inputs/returns-unexpectedly.c
  test/ubsan/TestCases/Misc/unreachable.cpp


Index: test/ubsan/TestCases/Misc/unreachable.cpp
===
--- test/ubsan/TestCases/Misc/unreachable.cpp
+++ test/ubsan/TestCases/Misc/unreachable.cpp
@@ -1,6 +1,25 @@
-// RUN: %clangxx -fsanitize=unreachable %s -O3 -o %t && not %run %t 2>&1 | 
FileCheck %s
+// RUN: %clang %S/Inputs/returns-unexpectedly.c -O3 -c -o %t.ru.o
+// RUN: %clangxx -fsanitize=unreachable -O3 -o %t %s %t.ru.o
+// RUN: not %run %t builtin 2>&1 | FileCheck %s -check-prefix=BUILTIN
+// RUN: not %run %t noreturn-callee-marked 2>&1 | FileCheck %s 
-check-prefix=NORETURN1
+// RUN: not %run %t noreturn-caller-marked 2>&1 | FileCheck %s 
-check-prefix=NORETURN2
+
+#include 
+
+void __attribute__((noreturn)) callee_marked_noreturn() {
+  // NORETURN1: unreachable.cpp:[[@LINE+1]]:1: runtime error: execution 
reached an unreachable program point
+}
+
+extern "C" void __attribute__((noreturn)) returns_unexpectedly();
 
 int main(int, char **argv) {
-  // CHECK: unreachable.cpp:5:3: runtime error: execution reached a 
__builtin_unreachable() call
-  __builtin_unreachable();
+  if (strcmp(argv[1], "builtin") == 0)
+// BUILTIN: unreachable.cpp:[[@LINE+1]]:5: runtime error: execution 
reached an unreachable program point
+__builtin_unreachable();
+  else if (strcmp(argv[1], "noreturn-callee-marked") == 0)
+callee_marked_noreturn();
+  else if (strcmp(argv[1], "noreturn-caller-marked") == 0)
+// NORETURN2: unreachable.cpp:[[@LINE+1]]:5: runtime error: execution 
reached an unreachable program point
+returns_unexpectedly();
+  return 0;
 }
Index: test/ubsan/TestCases/Misc/Inputs/returns-unexpectedly.c
===
--- /dev/null
+++ test/ubsan/TestCases/Misc/Inputs/returns-unexpectedly.c
@@ -0,0 +1 @@
+void returns_unexpectedly() {}
Index: lib/ubsan/ubsan_handlers.cc
===
--- lib/ubsan/ubsan_handlers.cc
+++ lib/ubsan/ubsan_handlers.cc
@@ -297,7 +297,7 @@
 static void handleBuiltinUnreachableImpl(UnreachableData *Data,
  ReportOptions Opts) {
   ScopedReport R(Opts, Data->Loc, ErrorType::UnreachableCall);
-  Diag(Data->Loc, DL_Error, "execution reached a __builtin_unreachable() 
call");
+  Diag(Data->Loc, DL_Error, "execution reached an unreachable program point");
 }
 
 void __ubsan::__ubsan_handle_builtin_unreachable(UnreachableData *Data) {


Index: test/ubsan/TestCases/Misc/unreachable.cpp
===
--- test/ubsan/TestCases/Misc/unreachable.cpp
+++ test/ubsan/TestCases/Misc/unreachable.cpp
@@ -1,6 +1,25 @@
-// RUN: %clangxx -fsanitize=unreachable %s -O3 -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clang %S/Inputs/returns-unexpectedly.c -O3 -c -o %t.ru.o
+// RUN: %clangxx -fsanitize=unreachable -O3 -o %t %s %t.ru.o
+// RUN: not %run %t builtin 2>&1 | FileCheck %s -check-prefix=BUILTIN
+// RUN: not %run %t noreturn-callee-marked 2>&1 | FileCheck %s -check-prefix=NORETURN1
+// RUN: not %run %t noreturn-caller-marked 2>&1 | FileCheck %s -check-prefix=NORETURN2
+
+#include 
+
+void __attribute__((noreturn)) callee_marked_noreturn() {
+  // NORETURN1: unreachable.cpp:[[@LINE+1]]:1: runtime error: execution reached an unreachable program point
+}
+
+extern "C" void __attribute__((noreturn)) returns_unexpectedly();
 
 int main(int, char **argv) {
-  // CHECK: unreachable.cpp:5:3: runtime error: execution reached a __builtin_unreachable() call
-  __builtin_unreachable();
+  if (strcmp(argv[1], "builtin") == 0)
+// BUILTIN: unreachable.cpp:[[@LINE+1]]:5: runtime error: execution reached an unreachable program point
+__builtin_unreachable();
+  else if (strcmp(argv[1], "noreturn-callee-marked") == 0)
+callee_marked_noreturn();
+  else if (strcmp(argv[1], "noreturn-caller-marked") == 0)
+// NORETURN2: unreachable.cpp:[[@LINE+1]]:5: runtime error: execution reached an unreachable program point
+returns_unexpectedly();
+  return 0;
 }
Index: test/ubsan/TestCases/Misc/Inputs/returns-unexpectedly.c
===
--- /dev/null
+++ test/ubsan/TestCases/Misc/Inputs/returns-unexpectedly.c
@@ -0,0 +1 @@
+void returns_unexpectedly() {}
Index: lib/ubsan/ubsan_handlers.cc
===
--- lib/ubsan/ubsan_handlers.cc
+++ lib/ubsan/ubsan_handlers.cc
@@ -297,7 +297,7 @@
 static void handleBuiltinUnreachableImpl(UnreachableData *Data,
  ReportOptions Opts) {
   ScopedReport R(Opts, Data->Loc, 

[PATCH] D35894: [clangd] Code hover for Clangd

2017-12-01 Thread William Enright via Phabricator via cfe-commits
Nebiroth added inline comments.



Comment at: clangd/Protocol.h:26
 #include "llvm/ADT/Optional.h"
-#include 
+#include "llvm/Support/YAMLParser.h"
 #include 

malaperle wrote:
> Nebiroth wrote:
> > malaperle wrote:
> > > revert this change?
> > #include  is not needed.
> I meant removing YAMLParser.h
That's what I figured. I'll remove that.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D35894



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


LLVM buildmaster will be OFF today at 3 PM Pacific for maintenance

2017-12-01 Thread Galina Kistanova via cfe-commits
Galina

Hello everyone,

LLVM buildmaster will be OFF today at 3 PM Pacific for maintenance for
about half an hour.
Thank you for for understanding.

Thanks

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


[PATCH] D40671: [clang-tidy] Support specific checks for NOLINT directive

2017-12-01 Thread Anton via Phabricator via cfe-commits
xgsa updated this revision to Diff 125216.
xgsa added a comment.

Minor change: update default value of SmallVector of check names.


https://reviews.llvm.org/D40671

Files:
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/nolint.cpp
  test/clang-tidy/nolintnextline.cpp

Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -250,6 +250,27 @@
   value:   'some value'
   ...
 
+Generally, there is no need to suppress :program:`clang-tidy` diagnostics. If
+there are false positives, either a bug should be reported or the code should be
+updated to be clear for both tool and developer. However, if there is a need to
+silent some diagnostics for a line of code, the ``NOLINT`` or ``NOLINTNEXTLINE``
+comments can be used. For example:
+
+.. code-block:: c++
+
+  class Foo
+  {
+// Skip all the diagnostics for the line
+Foo(int param); // NOLINT
+
+// Skip only the specified checks for the line
+Foo(double param); // NOLINT(google-explicit-constructor, google-runtime-int)
+
+// Skip only the specified diagnostics for the next line
+// NOLINTNEXTLINE (google-explicit-constructor, google-runtime-int)
+Foo(bool param); 
+  };
+
 .. _LibTooling: http://clang.llvm.org/docs/LibTooling.html
 .. _How To Setup Tooling For LLVM: http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
 
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -256,6 +256,9 @@
   - `hicpp-use-nullptr `_
   - `hicpp-vararg `_
 
+- The ``NOLINT`` and ``NOLINTNEXTLINE`` suppression comments were extended to support the list of checks
+  to disable in parentheses.
+
 Improvements to include-fixer
 -
 
Index: test/clang-tidy/nolint.cpp
===
--- test/clang-tidy/nolint.cpp
+++ test/clang-tidy/nolint.cpp
@@ -13,7 +13,18 @@
 
 class B { B(int i); }; // NOLINT
 
-class C { C(int i); }; // NOLINT(we-dont-care-about-categories-yet)
+class C { C(int i); }; // NOLINT(for-some-other-check)
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+class C1 { C1(int i); }; // NOLINT(*)
+
+class C2 { C2(int i); }; // NOLINT(not-closed-bracket-is-treated-as-skip-all
+
+class C3 { C3(int i); }; // NOLINT(google-explicit-constructor)
+
+class C4 { C4(int i); }; // NOLINT(some-check, google-explicit-constructor)
+
+class C5 { C5(int i); }; // NOLINT without-brackets-skip-all, another-check
 
 void f() {
   int i;
@@ -35,4 +46,4 @@
 #define DOUBLE_MACRO MACRO(H) // NOLINT
 DOUBLE_MACRO
 
-// CHECK-MESSAGES: Suppressed 8 warnings (8 NOLINT)
+// CHECK-MESSAGES: Suppressed 12 warnings (12 NOLINT)
Index: test/clang-tidy/nolintnextline.cpp
===
--- test/clang-tidy/nolintnextline.cpp
+++ test/clang-tidy/nolintnextline.cpp
@@ -4,8 +4,24 @@
 // NOLINTNEXTLINE
 class B { B(int i); };
 
-// NOLINTNEXTLINE(we-dont-care-about-categories-yet)
+// NOLINTNEXTLINE(for-some-other-check)
 class C { C(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+// NOLINTNEXTLINE(*)
+class C1 { C1(int i); };
+
+// NOLINTNEXTLINE(not-closed-bracket-is-treated-as-skip-all
+class C2 { C2(int i); };
+
+// NOLINTNEXTLINE(google-explicit-constructor)
+class C3 { C3(int i); };
+
+// NOLINTNEXTLINE(some-check, google-explicit-constructor)
+class C4 { C4(int i); };
+
+// NOLINTNEXTLINE without-brackets-skip-all, another-check
+class C5 { C5(int i); };
 
 
 // NOLINTNEXTLINE
@@ -28,6 +44,6 @@
 // NOLINTNEXTLINE
 MACRO_NOARG
 
-// CHECK-MESSAGES: Suppressed 4 warnings (4 NOLINT)
+// CHECK-MESSAGES: Suppressed 8 warnings (8 NOLINT)
 
 // RUN: %check_clang_tidy %s google-explicit-constructor %t --
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -21,6 +21,7 @@
 #include "clang/AST/ASTDiagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Frontend/DiagnosticRenderer.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include 
 #include 
@@ -290,7 +291,38 @@
   LastErrorPassesLineFilter = false;
 }
 
-static bool LineIsMarkedWithNOLINT(SourceManager , SourceLocation Loc) {
+static bool IsNOLINTFound(StringRef NolintMacro, StringRef Line,
+  unsigned DiagID, const ClangTidyContext ) {
+  const size_t NolintIndex = Line.find(NolintMacro);
+  if (NolintIndex != StringRef::npos) {
+   

[PATCH] D40580: [clang-tidy] Adding Fuchsia checker for multiple inheritance

2017-12-01 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added inline comments.



Comment at: clang-tidy/fuchsia/MultipleInheritanceCheck.cpp:60
+  // To be an interface, all base classes must be interfaces as well.
+  for (const auto  : Node->bases()) {
+const auto *Ty = I.getType()->getAs();

aaron.ballman wrote:
> What about virtual bases (`Node->vbases()`)? This would also be worth some 
> test cases.
Added test cases for virtual, but aren't virtual bases also included in 
`bases()`?



Comment at: clang-tidy/fuchsia/MultipleInheritanceCheck.cpp:77
+  // Match declarations which have definitions.
+  Finder->addMatcher(cxxRecordDecl(hasDefinition()).bind("decl"), this);
+}

aaron.ballman wrote:
> It might be nice to not bother matching class definitions that have no bases 
> or virtual bases rather than matching every class definition. However, this 
> could be done in a follow-up patch (it likely requires adding an AST matcher).
Good point -- will do.



Comment at: clang-tidy/fuchsia/MultipleInheritanceCheck.h:34-36
+  bool getInterfaceStatus(const CXXRecordDecl *Node, bool );
+  bool isCurrentClassInterface(const CXXRecordDecl *Node);
+  bool isInterface(const CXXRecordDecl *Node);

aaron.ballman wrote:
> I believe all these methods can be marked `const`.
getInterfaceStatus and isInterface can't be -- they update the map. The other 
ones yes though!


https://reviews.llvm.org/D40580



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


[PATCH] D40580: [clang-tidy] Adding Fuchsia checker for multiple inheritance

2017-12-01 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 125215.
juliehockett marked 7 inline comments as done.
juliehockett added a comment.

Updating tests


https://reviews.llvm.org/D40580

Files:
  clang-tidy/fuchsia/CMakeLists.txt
  clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
  clang-tidy/fuchsia/MultipleInheritanceCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/fuchsia-multiple-inheritance.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/fuchsia-multiple-inheritance.cpp

Index: test/clang-tidy/fuchsia-multiple-inheritance.cpp
===
--- /dev/null
+++ test/clang-tidy/fuchsia-multiple-inheritance.cpp
@@ -0,0 +1,126 @@
+// RUN: %check_clang_tidy %s fuchsia-multiple-inheritance %t
+
+class Base_A {
+public:
+  virtual int foo() { return 0; }
+};
+
+class Base_B {
+public:
+  virtual int bar() { return 0; }
+};
+
+class Base_A_child : public Base_A {
+public:
+  virtual int baz() { return 0; }
+};
+
+class Interface_A {
+public:
+  virtual int foo() = 0;
+};
+
+class Interface_B {
+public:
+  virtual int bar() = 0;
+};
+
+class Interface_C {
+public:
+  virtual int blat() = 0;
+};
+
+class Interface_A_with_member {
+public:
+  virtual int foo() = 0;
+  int val = 0;
+};
+
+class Interface_with_A_Parent : public Base_A {
+public:
+  virtual int baz() = 0;
+};
+
+class Interface_with_A_Virtual_Parent : public virtual Base_A {
+public:
+  virtual int baz() = 0;
+};
+
+// Inherits from multiple concrete classes.
+// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting mulitple classes which aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-NEXT: class Bad_Child1 : public Base_A, Base_B {};
+class Bad_Child1 : public Base_A, Base_B {};
+
+// CHECK-MESSAGES: [[@LINE+1]]:1: warning: inheriting mulitple classes which aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+class Bad_Child2 : public Base_A, Interface_A_with_member {
+  virtual int foo() override { return 0; }
+};
+
+// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting mulitple classes which aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-NEXT: class Bad_Child3 : public Interface_with_A_Parent, Base_B {
+class Bad_Child3 : public Interface_with_A_Parent, Base_B {
+  virtual int baz() override { return 0; }
+};
+
+// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting mulitple classes which aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-NEXT: class Bad_Child4 : public Interface_with_A_Virtual_Parent, Base_B {
+class Bad_Child4 : public Interface_with_A_Virtual_Parent, Base_B {
+  virtual int baz() override { return 0; }
+};
+
+// Easy cases of single inheritance
+class Simple_Child1 : public Base_A {};
+class Simple_Child2 : public Interface_A {
+  virtual int foo() override { return 0; }
+};
+
+// Valid uses of multiple inheritance
+class Good_Child1 : public Interface_A, Interface_B {
+  virtual int foo() override { return 0; }
+  virtual int bar() override { return 0; }
+};
+
+class Good_Child2 : public Base_A, Interface_B {
+  virtual int bar() override { return 0; }
+};
+
+class Good_Child3 : public Base_A_child, Interface_C, Interface_B {
+  virtual int bar() override { return 0; }
+  virtual int blat() override { return 0; }
+};
+
+// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting mulitple classes which aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-NEXT: class Virtual_Child1 : public virtual Base_A, public Base_B {};
+class Virtual_Child1 : public Base_A, public virtual Base_B {};
+
+// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting mulitple classes which aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-NEXT: class Virtual_Child1 : public virtual Base_A, Base_B {};
+class Virtual_Child2 : public virtual Base_A, Base_B {};
+
+struct B1 {
+  int x;
+};
+
+struct B2 {
+  int x;
+};
+
+// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting mulitple classes which aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-NEXT: struct D : B1, B2 {};
+struct D : B1, B2 {};
+
+int main(void) {
+  Bad_Child1 a;
+  Bad_Child2 b;
+  Bad_Child3 c;
+  Bad_Child4 x;
+  Simple_Child1 d;
+  Simple_Child2 e;
+  Good_Child1 f;
+  Good_Child2 g;
+  Good_Child3 h;
+  Virtual_Child1 i;
+  Virtual_Child2 j;
+  D k;
+  return 0;
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -69,6 +69,7 @@
cppcoreguidelines-slicing
cppcoreguidelines-special-member-functions
fuchsia-default-arguments
+   fuchsia-multiple-inheritance
google-build-explicit-make-pair
google-build-namespaces
google-build-using-namespace
Index: docs/clang-tidy/checks/fuchsia-multiple-inheritance.rst
===

[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix

2017-12-01 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

@alexfh any thoughts on this one?


Repository:
  rL LLVM

https://reviews.llvm.org/D36892



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


r319585 - [OPENMP] Emit `__tgt_target_teams` for all teams directives.

2017-12-01 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Dec  1 13:31:08 2017
New Revision: 319585

URL: http://llvm.org/viewvc/llvm-project?rev=319585=rev
Log:
[OPENMP] Emit `__tgt_target_teams` for all teams directives.

Previously we emitted `__tgt_target_teams` only for standalone teams
directives. This patch allows emit this function for all teams-based
directives.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/teams_distribute_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_collapse_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_dist_schedule_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_lastprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_collapse_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_copyin_codegen.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_dist_schedule_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_if_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_lastprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_num_threads_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_private_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_proc_bind_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_reduction_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_schedule_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_private_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_reduction_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=319585=319584=319585=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Dec  1 13:31:08 2017
@@ -5841,21 +5841,21 @@ emitNumTeamsForTargetDirective(CGOpenMPR
 
   const CapturedStmt  = *cast(D.getAssociatedStmt());
 
-  // FIXME: Accommodate other combined directives with teams when they become
-  // available.
-  if (auto *TeamsDir = dyn_cast_or_null(
+  if (auto *TeamsDir = dyn_cast_or_null(
   ignoreCompoundStmts(CS.getCapturedStmt( {
-if (auto *NTE = TeamsDir->getSingleClause()) {
-  CGOpenMPInnerExprInfo CGInfo(CGF, CS);
-  CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, );
-  llvm::Value *NumTeams = CGF.EmitScalarExpr(NTE->getNumTeams());
-  return Bld.CreateIntCast(NumTeams, CGF.Int32Ty,
-   /*IsSigned=*/true);
+if (isOpenMPTeamsDirective(TeamsDir->getDirectiveKind())) {
+  if (auto *NTE = TeamsDir->getSingleClause()) {
+CGOpenMPInnerExprInfo CGInfo(CGF, CS);
+CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, );
+llvm::Value *NumTeams = CGF.EmitScalarExpr(NTE->getNumTeams());
+return Bld.CreateIntCast(NumTeams, CGF.Int32Ty,
+ /*IsSigned=*/true);
+  }
+
+  // If we have an enclosed teams directive but no num_teams clause we use
+  // the default value 0.
+  return Bld.getInt32(0);
 }
-
-// If we have an enclosed teams directive but no num_teams clause we use
-// the default value 0.
-return Bld.getInt32(0);
   }
 
   // No teams associated with the directive.
@@ -5944,21 +5944,21 @@ emitNumThreadsForTargetDirective(CGOpenM
 
   const CapturedStmt  = *cast(D.getAssociatedStmt());
 
-  // FIXME: Accommodate other combined directives with teams when they become
-  // available.
-  if (auto *TeamsDir = dyn_cast_or_null(
+  if (auto *TeamsDir = dyn_cast_or_null(
   ignoreCompoundStmts(CS.getCapturedStmt( {
-if (auto *TLE = TeamsDir->getSingleClause()) {
-  CGOpenMPInnerExprInfo CGInfo(CGF, CS);
-  CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, );
-  llvm::Value *ThreadLimit = CGF.EmitScalarExpr(TLE->getThreadLimit());
-  return CGF.Builder.CreateIntCast(ThreadLimit, CGF.Int32Ty,
-   /*IsSigned=*/true);
-}
+if (isOpenMPTeamsDirective(TeamsDir->getDirectiveKind())) {
+  if (auto *TLE = TeamsDir->getSingleClause()) {
+CGOpenMPInnerExprInfo CGInfo(CGF, CS);
+CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, );
+llvm::Value *ThreadLimit = CGF.EmitScalarExpr(TLE->getThreadLimit());
+return CGF.Builder.CreateIntCast(ThreadLimit, CGF.Int32Ty,
+ /*IsSigned=*/true);
+  }
 
-// If we have an enclosed teams directive but no thread_limit clause we use
-// the default value 0.
-return CGF.Builder.getInt32(0);
+  // If we have an enclosed teams directive but 

[PATCH] D40682: [driver] Set the 'simulator' environment for Darwin when -msimulator-version-min is used

2017-12-01 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 125214.
arphaman marked an inline comment as done.
arphaman added a comment.

Add "-simulator" environment even when `-m*simulator-version-min` isn't used 
using the arch/OS heuristic.


Repository:
  rC Clang

https://reviews.llvm.org/D40682

Files:
  include/clang/Driver/ToolChain.h
  lib/CodeGen/CGObjCMac.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Darwin.cpp
  lib/Driver/ToolChains/Darwin.h
  lib/Frontend/InitPreprocessor.cpp
  test/Driver/darwin-sdkroot.c
  test/Driver/darwin-simulator-macro.c
  test/Driver/darwin-version.c
  test/Driver/fsanitize.c

Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -334,10 +334,10 @@
 // CHECK-TSAN-ARM-IOS: unsupported option '-fsanitize=thread' for target 'arm-apple-ios'
 
 // RUN: %clang -target i386-apple-iossimulator -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-I386-IOSSIMULATOR
-// CHECK-TSAN-I386-IOSSIMULATOR: unsupported option '-fsanitize=thread' for target 'i386-apple-iossimulator'
+// CHECK-TSAN-I386-IOSSIMULATOR: unsupported option '-fsanitize=thread' for target 'i386-apple-iossimulator-simulator'
 
 // RUN: %clang -target i386-apple-tvossimulator -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-I386-TVOSSIMULATOR
-// CHECK-TSAN-I386-TVOSSIMULATOR: unsupported option '-fsanitize=thread' for target 'i386-apple-tvossimulator'
+// CHECK-TSAN-I386-TVOSSIMULATOR: unsupported option '-fsanitize=thread' for target 'i386-apple-tvossimulator-simulator'
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=thread -fsanitize-thread-memory-access %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-MEMORY-ACCESS
 // CHECK-TSAN-MEMORY-ACCESS-NOT: -cc1{{.*}}tsan-instrument-memory-accesses=0
@@ -423,11 +423,11 @@
 
 // RUN: %clang -target i386-apple-iossimulator -fsanitize=efficiency-cache-frag %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ESAN-I386-IOSSIMULATOR
 // RUN: %clang -target i386-apple-iossimulator -fsanitize=efficiency-working-set %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ESAN-I386-IOSSIMULATOR
-// CHECK-ESAN-I386-IOSSIMULATOR: unsupported option '-fsanitize=efficiency-{{.*}}' for target 'i386-apple-iossimulator'
+// CHECK-ESAN-I386-IOSSIMULATOR: unsupported option '-fsanitize=efficiency-{{.*}}' for target 'i386-apple-iossimulator-simulator'
 
 // RUN: %clang -target i386-apple-tvossimulator -fsanitize=efficiency-cache-frag %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ESAN-I386-TVOSSIMULATOR
 // RUN: %clang -target i386-apple-tvossimulator -fsanitize=efficiency-working-set %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ESAN-I386-TVOSSIMULATOR
-// CHECK-ESAN-I386-TVOSSIMULATOR: unsupported option '-fsanitize=efficiency-{{.*}}' for target 'i386-apple-tvossimulator'
+// CHECK-ESAN-I386-TVOSSIMULATOR: unsupported option '-fsanitize=efficiency-{{.*}}' for target 'i386-apple-tvossimulator-simulator'
 
 
 
Index: test/Driver/darwin-version.c
===
--- test/Driver/darwin-version.c
+++ test/Driver/darwin-version.c
@@ -41,7 +41,7 @@
 
 // RUN: %clang -target x86_64-apple-darwin -mios-simulator-version-min=11.0 -c -### %s 2>&1 | \
 // RUN: FileCheck --check-prefix=CHECK-VERSION-IOS10 %s
-// CHECK-VERSION-IOS10: x86_64-apple-ios11.0.0
+// CHECK-VERSION-IOS10: x86_64-apple-ios11.0.0-simulator
 
 // RUN: %clang -target arm64-apple-ios11.1 -c -### %s 2>&1 | \
 // RUN: FileCheck --check-prefix=CHECK-VERSION-IOS11 %s
@@ -85,13 +85,13 @@
 // CHECK-VERSION-TVOS83: "thumbv7-apple-tvos8.3.0"
 // RUN: %clang -target i386-apple-darwin -mtvos-simulator-version-min=8.3 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-TVSIM83 %s
-// CHECK-VERSION-TVSIM83: "i386-apple-tvos8.3.0"
+// CHECK-VERSION-TVSIM83: "i386-apple-tvos8.3.0-simulator"
 // RUN: %clang -target armv7k-apple-darwin -mwatchos-version-min=2.0 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-WATCHOS20 %s
 // CHECK-VERSION-WATCHOS20: "thumbv7k-apple-watchos2.0.0"
 // RUN: %clang -target i386-apple-darwin -mwatchos-simulator-version-min=2.0 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-WATCHSIM20 %s
-// CHECK-VERSION-WATCHSIM20: "i386-apple-watchos2.0.0"
+// CHECK-VERSION-WATCHSIM20: "i386-apple-watchos2.0.0-simulator"
 
 // Check environment variable gets interpreted correctly
 // RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 IPHONEOS_DEPLOYMENT_TARGET=2.0 \
@@ -117,25 +117,25 @@
 // RUN: env TVOS_DEPLOYMENT_TARGET=8.3.1 \
 // RUN:   %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-TVOSSIM %s
-// CHECK-VERSION-TVOSSIM: "i386-apple-tvos8.3.1"
+// CHECK-VERSION-TVOSSIM: "i386-apple-tvos8.3.1-simulator"
 
 // RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 WATCHOS_DEPLOYMENT_TARGET=2.0 \
 // RUN:   %clang -target armv7-apple-darwin9 -c %s 

[PATCH] D35894: [clangd] Code hover for Clangd

2017-12-01 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added inline comments.



Comment at: clangd/Protocol.h:26
 #include "llvm/ADT/Optional.h"
-#include 
+#include "llvm/Support/YAMLParser.h"
 #include 

Nebiroth wrote:
> malaperle wrote:
> > revert this change?
> #include  is not needed.
I meant removing YAMLParser.h


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D35894



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


r319584 - [c++17] When deducing the type of a non-type template parameter from the type

2017-12-01 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Dec  1 13:24:36 2017
New Revision: 319584

URL: http://llvm.org/viewvc/llvm-project?rev=319584=rev
Log:
[c++17] When deducing the type of a non-type template parameter from the type
of its argument, perform function-to-pointer and array-to-pointer decay on the
parameter type first.

Otherwise deduction will fail, as the type of the argument will be decayed.

Modified:
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=319584=319583=319584=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Fri Dec  1 13:24:36 2017
@@ -354,8 +354,9 @@ static Sema::TemplateDeductionResult Ded
 // expanded NTTP should be a pack expansion type?
 return Sema::TDK_Success;
 
-  // Get the type of the parameter for deduction.
-  QualType ParamType = NTTP->getType();
+  // Get the type of the parameter for deduction. If it's a (dependent) array
+  // or function type, we will not have decayed it yet, so do that now.
+  QualType ParamType = S.Context.getAdjustedParameterType(NTTP->getType());
   if (auto *Expansion = dyn_cast(ParamType))
 ParamType = Expansion->getPattern();
 

Modified: cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp?rev=319584=319583=319584=diff
==
--- cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp (original)
+++ cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp Fri Dec  1 13:24:36 
2017
@@ -238,6 +238,10 @@ namespace Auto {
 constexpr char s[] = "test";
 template struct S { };
 S p;
+
+template struct A {};
+template void x(A a);
+void g(int) { x(A()); }
   }
 
   namespace DecltypeAuto {


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


[PATCH] D40673: Add _Float128 as alias to __float128 to enable compilations on Fedora27/glibc2-26

2017-12-01 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 125211.
mibintc added a comment.

I changed the patch to enable _Float128 only as keyword in mode "nocxx" - this 
is the same mode being used by _Bool. I changed the test from .cpp to .c; I run 
check-all and saw only the usual suspects fail.  What do you think?


Repository:
  rL LLVM

https://reviews.llvm.org/D40673

Files:
  include/clang/Basic/TokenKinds.def
  lib/Frontend/InitPreprocessor.cpp
  test/Preprocessor/cuda-types.cu
  test/Sema/_Float128.c

Index: test/Sema/_Float128.c
===
--- /dev/null
+++ test/Sema/_Float128.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -triple powerpc64-linux -verify %s
+// RUN: %clang_cc1 -triple i686-windows-gnu -verify %s
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -verify %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -verify %s
+
+#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
+_Float128 f;
+_Float128 tiny = __FLT128_EPSILON__;
+int g(int x, _Float128 *y) {
+  return x + *y;
+}
+
+// expected-no-diagnostics
+#else
+_Float128 f;  // expected-error {{__float128 is not supported on this target}}
+int g(int x, _Float128 *y) {  // expected-error {{__float128 is not supported on this target}}
+  return x + *y;
+}
+
+#endif  // defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
Index: test/Preprocessor/cuda-types.cu
===
--- test/Preprocessor/cuda-types.cu
+++ test/Preprocessor/cuda-types.cu
@@ -9,40 +9,40 @@
 
 // RUN: %clang --cuda-host-only -nocudainc -target i386-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/i386-host-defines-filtered
+// RUN:   | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/i386-host-defines-filtered
 // RUN: %clang --cuda-device-only -nocudainc -nocudalib -target i386-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/i386-device-defines-filtered
+// RUN:   | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/i386-device-defines-filtered
 // RUN: diff %t/i386-host-defines-filtered %t/i386-device-defines-filtered
 
 // RUN: %clang --cuda-host-only -nocudainc -target x86_64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/x86_64-host-defines-filtered
+// RUN:   | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/x86_64-host-defines-filtered
 // RUN: %clang --cuda-device-only -nocudainc -nocudalib -target x86_64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/x86_64-device-defines-filtered
+// RUN:   | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/x86_64-device-defines-filtered
 // RUN: diff %t/x86_64-host-defines-filtered %t/x86_64-device-defines-filtered
 
 // RUN: %clang --cuda-host-only -nocudainc -target powerpc64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/powerpc64-host-defines-filtered
+// RUN:   | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/powerpc64-host-defines-filtered
 // RUN: %clang --cuda-device-only -nocudainc -nocudalib -target powerpc64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/powerpc64-device-defines-filtered
+// RUN:   | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/powerpc64-device-defines-filtered
 // RUN: diff %t/powerpc64-host-defines-filtered %t/powerpc64-device-defines-filtered
 
 // RUN: %clang --cuda-host-only -nocudainc -target i386-windows-msvc -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/i386-msvc-host-defines-filtered
+// RUN:   | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/i386-msvc-host-defines-filtered
 // RUN: %clang --cuda-device-only -nocudainc -nocudalib -target i386-windows-msvc -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/i386-msvc-device-defines-filtered
+// RUN:   | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/i386-msvc-device-defines-filtered
 // RUN: diff %t/i386-msvc-host-defines-filtered %t/i386-msvc-device-defines-filtered
 
 // RUN: %clang --cuda-host-only -nocudainc -target x86_64-windows-msvc -x cuda -E -dM -o - /dev/null \

Re: [clang-tools-extra] r319557 - [clangd] Fuzzy match scorer

2017-12-01 Thread Galina Kistanova via cfe-commits
Hello Sam,

This commit broke one of our bots:
http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-test/builds/18908

. . .
FAILED:
tools/clang/tools/extra/clangd/CMakeFiles/clangDaemon.dir/FuzzyMatch.cpp.o
/usr/bin/c++   -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-Itools/clang/tools/extra/clangd
-I/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd
-I/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/include
-Itools/clang/include -Iinclude
-I/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/include
-fPIC -fvisibility-inlines-hidden -std=c++11 -Wall -W -Wno-unused-parameter
-Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic
-Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor
-Wno-comment -ffunction-sections -fdata-sections -fno-common
-Woverloaded-virtual -fno-strict-aliasing -O3-UNDEBUG  -fno-exceptions
-fno-rtti -MD -MT
tools/clang/tools/extra/clangd/CMakeFiles/clangDaemon.dir/FuzzyMatch.cpp.o
-MF
tools/clang/tools/extra/clangd/CMakeFiles/clangDaemon.dir/FuzzyMatch.cpp.o.d
-o
tools/clang/tools/extra/clangd/CMakeFiles/clangDaemon.dir/FuzzyMatch.cpp.o
-c
/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd/FuzzyMatch.cpp
/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd/FuzzyMatch.cpp:64:25:
error: redeclaration ‘clang::clangd::FuzzyMatcher::MaxPat’ differs in
‘constexpr’
 const int FuzzyMatcher::MaxPat;
 ^
In file included from
/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd/FuzzyMatch.cpp:57:0:
/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd/FuzzyMatch.h:45:24:
error: from previous declaration ‘clang::clangd::FuzzyMatcher::MaxPat’
   constexpr static int MaxPat = 63, MaxWord = 127;
^
/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd/FuzzyMatch.cpp:64:25:
error: declaration of ‘constexpr const int
clang::clangd::FuzzyMatcher::MaxPat’ outside of class is not definition
[-fpermissive]
 const int FuzzyMatcher::MaxPat;
 ^
/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd/FuzzyMatch.cpp:65:25:
error: redeclaration ‘clang::clangd::FuzzyMatcher::MaxWord’ differs in
‘constexpr’
 const int FuzzyMatcher::MaxWord;
 ^
In file included from
/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd/FuzzyMatch.cpp:57:0:
/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd/FuzzyMatch.h:45:37:
error: from previous declaration ‘clang::clangd::FuzzyMatcher::MaxWord’
   constexpr static int MaxPat = 63, MaxWord = 127;
 ^
/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd/FuzzyMatch.cpp:65:25:
error: declaration of ‘constexpr const int
clang::clangd::FuzzyMatcher::MaxWord’ outside of class is not definition
[-fpermissive]
 const int FuzzyMatcher::MaxWord;
 ^

Please have a look?

Thanks

Galina

On Fri, Dec 1, 2017 at 9:08 AM, Sam McCall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: sammccall
> Date: Fri Dec  1 09:08:02 2017
> New Revision: 319557
>
> URL: http://llvm.org/viewvc/llvm-project?rev=319557=rev
> Log:
> [clangd] Fuzzy match scorer
>
> Summary:
> This will be used for rescoring code completion results based on partial
> identifiers.
> Short-term use:
>   - we want to limit the number of code completion results returned to
>   improve performance of global completion. The scorer will be used to
>   rerank the results to return when the user has applied a filter.
> Long-term use case:
>   - ranking of completion results from in-memory index
>   - merging of completion results from multiple sources (merging usually
>   works best when done at the component-score level, rescoring the
>   fuzzy-match quality avoids different backends needing to have
>   comparable scores)
>
> Reviewers: ilya-biryukov
>
> Subscribers: cfe-commits, mgorny
>
> Differential Revision: https://reviews.llvm.org/D40060
>
> Added:
> clang-tools-extra/trunk/clangd/FuzzyMatch.cpp
> clang-tools-extra/trunk/clangd/FuzzyMatch.h
> clang-tools-extra/trunk/unittests/clangd/FuzzyMatchTests.cpp
> Modified:
> clang-tools-extra/trunk/clangd/CMakeLists.txt
> clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt
>
> Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clangd/CMakeLists.txt?rev=319557=319556=319557=diff
> 
> ==
> --- 

[PATCH] D35894: [clangd] Code hover for Clangd

2017-12-01 Thread William Enright via Phabricator via cfe-commits
Nebiroth marked 9 inline comments as done.
Nebiroth added inline comments.



Comment at: clangd/Protocol.h:26
 #include "llvm/ADT/Optional.h"
-#include 
+#include "llvm/Support/YAMLParser.h"
 #include 

malaperle wrote:
> revert this change?
#include  is not needed.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D35894



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


[PATCH] D40748: [ThinLTO] Enable importing of aliases as copy of aliasee

2017-12-01 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson created this revision.
Herald added a subscriber: inglorion.

Clang side changes to go with LLVM change to import aliases as
a copy of their aliasee. Simply refactor out some handling that
is moved to LLVM for use elsewhere.

Depends on https://reviews.llvm.org/D40747.


Repository:
  rC Clang

https://reviews.llvm.org/D40748

Files:
  lib/CodeGen/BackendUtil.cpp


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -1038,23 +1038,8 @@
   // we should only invoke this using the individual indexes written out
   // via a WriteIndexesThinBackend.
   FunctionImporter::ImportMapTy ImportList;
-  for (auto  : *CombinedIndex) {
-// Ignore entries for undefined references.
-if (GlobalList.second.SummaryList.empty())
-  continue;
-
-auto GUID = GlobalList.first;
-assert(GlobalList.second.SummaryList.size() == 1 &&
-   "Expected individual combined index to have one summary per GUID");
-auto  = GlobalList.second.SummaryList[0];
-// Skip the summaries for the importing module. These are included to
-// e.g. record required linkage changes.
-if (Summary->modulePath() == M->getModuleIdentifier())
-  continue;
-// Doesn't matter what value we plug in to the map, just needs an entry
-// to provoke importing by thinBackend.
-ImportList[Summary->modulePath()][GUID] = 1;
-  }
+  llvm::ComputeCrossModuleImportForModuleFromIndex(M->getModuleIdentifier(),
+   *CombinedIndex, ImportList);
 
   std::vector OwnedImports;
   MapVector ModuleMap;


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -1038,23 +1038,8 @@
   // we should only invoke this using the individual indexes written out
   // via a WriteIndexesThinBackend.
   FunctionImporter::ImportMapTy ImportList;
-  for (auto  : *CombinedIndex) {
-// Ignore entries for undefined references.
-if (GlobalList.second.SummaryList.empty())
-  continue;
-
-auto GUID = GlobalList.first;
-assert(GlobalList.second.SummaryList.size() == 1 &&
-   "Expected individual combined index to have one summary per GUID");
-auto  = GlobalList.second.SummaryList[0];
-// Skip the summaries for the importing module. These are included to
-// e.g. record required linkage changes.
-if (Summary->modulePath() == M->getModuleIdentifier())
-  continue;
-// Doesn't matter what value we plug in to the map, just needs an entry
-// to provoke importing by thinBackend.
-ImportList[Summary->modulePath()][GUID] = 1;
-  }
+  llvm::ComputeCrossModuleImportForModuleFromIndex(M->getModuleIdentifier(),
+   *CombinedIndex, ImportList);
 
   std::vector OwnedImports;
   MapVector ModuleMap;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40746: Correctly handle line directives without filenames that come first in the file

2017-12-01 Thread Hans Wennborg via Phabricator via cfe-commits
hans created this revision.

The comment in LineTableInfo::AddLineNote says "An unspecified
FilenameID means use the last filename if available, or the main source
file otherwise.", but the second part of that sentence was never
actually implemented. This lead to asserts when writing the line table
to a PCH file.

(Chromium runs into this when building with the latest MS SDK.)


https://reviews.llvm.org/D40746

Files:
  include/clang/Basic/SourceManagerInternals.h
  lib/Basic/SourceManager.cpp
  test/PCH/line-directive-nofilename.c
  test/PCH/line-directive-nofilename.h


Index: test/PCH/line-directive-nofilename.h
===
--- /dev/null
+++ test/PCH/line-directive-nofilename.h
@@ -0,0 +1,5 @@
+#line 42
+int foo; // This should appear as at line-directive-nofilename.h:42
+
+#line 100 "foobar.h"
+int bar; // This should appear as at foobar.h:100
Index: test/PCH/line-directive-nofilename.c
===
--- /dev/null
+++ test/PCH/line-directive-nofilename.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-pch -o %t %S/line-directive-nofilename.h
+// RUN: not %clang_cc1 -include-pch %t -fsyntax-only %s 2>&1 | FileCheck %s
+
+// This causes an "error: redefinition" diagnostic. The notes will have the
+// locations of the declarations from the PCH file.
+double foo, bar;
+
+// CHECK: line-directive-nofilename.h:42:5: note: previous definition is here
+// CHECK: foobar.h:100:5: note: previous definition is here
Index: lib/Basic/SourceManager.cpp
===
--- lib/Basic/SourceManager.cpp
+++ lib/Basic/SourceManager.cpp
@@ -207,13 +207,19 @@
 /// system header or extern C system header.
 void LineTableInfo::AddLineNote(FileID FID, unsigned Offset, unsigned LineNo,
 int FilenameID, unsigned EntryExit,
-SrcMgr::CharacteristicKind FileKind) {
+SrcMgr::CharacteristicKind FileKind,
+const SourceManager ) {
   std::vector  = LineEntries[FID];
 
   // An unspecified FilenameID means use the last filename if available, or the
   // main source file otherwise.
-  if (FilenameID == -1 && !Entries.empty())
-FilenameID = Entries.back().FilenameID;
+  if (FilenameID == -1) {
+if (!Entries.empty())
+  FilenameID = Entries.back().FilenameID;
+else
+  FilenameID = 
getLineTableFilenameID(SM.getFileEntryForID(FID)->getName());
+  }
+  assert(FilenameID != -1);
 
   assert((Entries.empty() || Entries.back().FileOffset < Offset) &&
  "Adding line entries out of order!");
@@ -297,7 +303,7 @@
 EntryExit = 2;
 
   LineTable->AddLineNote(LocInfo.first, LocInfo.second, LineNo, FilenameID,
- EntryExit, FileKind);
+ EntryExit, FileKind, *this);
 }
 
 LineTableInfo ::getLineTable() {
Index: include/clang/Basic/SourceManagerInternals.h
===
--- include/clang/Basic/SourceManagerInternals.h
+++ include/clang/Basic/SourceManagerInternals.h
@@ -108,10 +108,9 @@
 
   unsigned getNumFilenames() const { return FilenamesByID.size(); }
 
-  void AddLineNote(FileID FID, unsigned Offset,
-   unsigned LineNo, int FilenameID,
-   unsigned EntryExit, SrcMgr::CharacteristicKind FileKind);
-
+  void AddLineNote(FileID FID, unsigned Offset, unsigned LineNo, int 
FilenameID,
+   unsigned EntryExit, SrcMgr::CharacteristicKind FileKind,
+   const SourceManager );
 
   /// \brief Find the line entry nearest to FID that is before it.
   ///


Index: test/PCH/line-directive-nofilename.h
===
--- /dev/null
+++ test/PCH/line-directive-nofilename.h
@@ -0,0 +1,5 @@
+#line 42
+int foo; // This should appear as at line-directive-nofilename.h:42
+
+#line 100 "foobar.h"
+int bar; // This should appear as at foobar.h:100
Index: test/PCH/line-directive-nofilename.c
===
--- /dev/null
+++ test/PCH/line-directive-nofilename.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-pch -o %t %S/line-directive-nofilename.h
+// RUN: not %clang_cc1 -include-pch %t -fsyntax-only %s 2>&1 | FileCheck %s
+
+// This causes an "error: redefinition" diagnostic. The notes will have the
+// locations of the declarations from the PCH file.
+double foo, bar;
+
+// CHECK: line-directive-nofilename.h:42:5: note: previous definition is here
+// CHECK: foobar.h:100:5: note: previous definition is here
Index: lib/Basic/SourceManager.cpp
===
--- lib/Basic/SourceManager.cpp
+++ lib/Basic/SourceManager.cpp
@@ -207,13 +207,19 @@
 /// system header or extern C system header.
 void LineTableInfo::AddLineNote(FileID FID, unsigned Offset, 

[PATCH] D40044: [CodeGen] convert math libcalls/builtins to equivalent LLVM intrinsics

2017-12-01 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D40044



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


[PATCH] D40743: Make rehash(0) work with ubsan's unsigned-integer-overflow.

2017-12-01 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.

Repository:
  rCXX libc++

https://reviews.llvm.org/D40743

Files:
  include/__hash_table


Index: include/__hash_table
===
--- include/__hash_table
+++ include/__hash_table
@@ -2136,7 +2136,7 @@
 void
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n)
 {
-if (__n == 1)
+if (__n < 2)
 __n = 2;
 else if (__n & (__n - 1))
 __n = __next_prime(__n);


Index: include/__hash_table
===
--- include/__hash_table
+++ include/__hash_table
@@ -2136,7 +2136,7 @@
 void
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n)
 {
-if (__n == 1)
+if (__n < 2)
 __n = 2;
 else if (__n & (__n - 1))
 __n = __next_prime(__n);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40671: [clang-tidy] Support specific checks for NOLINT directive

2017-12-01 Thread Anton via Phabricator via cfe-commits
xgsa updated this revision to Diff 125190.
xgsa added a comment.

An item to release notes was added.

Also I have added a paragraph about NOLINT to the main documentation page, 
because I suppose it's useful information and it's related to the feature. 
Please, let me know if it should be added with a separate commit or shouldn't 
be added at all.


https://reviews.llvm.org/D40671

Files:
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/nolint.cpp
  test/clang-tidy/nolintnextline.cpp

Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -250,6 +250,27 @@
   value:   'some value'
   ...
 
+Generally, there is no need to suppress :program:`clang-tidy` diagnostics. If
+there are false positives, either a bug should be reported or the code should be
+updated to be clear for both tool and developer. However, if there is a need to
+silent some diagnostics for a line of code, the ``NOLINT`` or ``NOLINTNEXTLINE``
+comments can be used. For example:
+
+.. code-block:: c++
+
+  class Foo
+  {
+// Skip all the diagnostics for the line
+Foo(int param); // NOLINT
+
+// Skip only the specified checks for the line
+Foo(double param); // NOLINT(google-explicit-constructor, google-runtime-int)
+
+// Skip only the specified diagnostics for the next line
+// NOLINTNEXTLINE (google-explicit-constructor, google-runtime-int)
+Foo(bool param); 
+  };
+
 .. _LibTooling: http://clang.llvm.org/docs/LibTooling.html
 .. _How To Setup Tooling For LLVM: http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
 
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -256,6 +256,9 @@
   - `hicpp-use-nullptr `_
   - `hicpp-vararg `_
 
+- The ``NOLINT`` and ``NOLINTNEXTLINE`` suppression comments were extended to support the list of checks
+  to disable in parentheses.
+
 Improvements to include-fixer
 -
 
Index: test/clang-tidy/nolint.cpp
===
--- test/clang-tidy/nolint.cpp
+++ test/clang-tidy/nolint.cpp
@@ -13,7 +13,18 @@
 
 class B { B(int i); }; // NOLINT
 
-class C { C(int i); }; // NOLINT(we-dont-care-about-categories-yet)
+class C { C(int i); }; // NOLINT(for-some-other-check)
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+class C1 { C1(int i); }; // NOLINT(*)
+
+class C2 { C2(int i); }; // NOLINT(not-closed-bracket-is-treated-as-skip-all
+
+class C3 { C3(int i); }; // NOLINT(google-explicit-constructor)
+
+class C4 { C4(int i); }; // NOLINT(some-check, google-explicit-constructor)
+
+class C5 { C5(int i); }; // NOLINT without-brackets-skip-all, another-check
 
 void f() {
   int i;
@@ -35,4 +46,4 @@
 #define DOUBLE_MACRO MACRO(H) // NOLINT
 DOUBLE_MACRO
 
-// CHECK-MESSAGES: Suppressed 8 warnings (8 NOLINT)
+// CHECK-MESSAGES: Suppressed 12 warnings (12 NOLINT)
Index: test/clang-tidy/nolintnextline.cpp
===
--- test/clang-tidy/nolintnextline.cpp
+++ test/clang-tidy/nolintnextline.cpp
@@ -4,8 +4,24 @@
 // NOLINTNEXTLINE
 class B { B(int i); };
 
-// NOLINTNEXTLINE(we-dont-care-about-categories-yet)
+// NOLINTNEXTLINE(for-some-other-check)
 class C { C(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+// NOLINTNEXTLINE(*)
+class C1 { C1(int i); };
+
+// NOLINTNEXTLINE(not-closed-bracket-is-treated-as-skip-all
+class C2 { C2(int i); };
+
+// NOLINTNEXTLINE(google-explicit-constructor)
+class C3 { C3(int i); };
+
+// NOLINTNEXTLINE(some-check, google-explicit-constructor)
+class C4 { C4(int i); };
+
+// NOLINTNEXTLINE without-brackets-skip-all, another-check
+class C5 { C5(int i); };
 
 
 // NOLINTNEXTLINE
@@ -28,6 +44,6 @@
 // NOLINTNEXTLINE
 MACRO_NOARG
 
-// CHECK-MESSAGES: Suppressed 4 warnings (4 NOLINT)
+// CHECK-MESSAGES: Suppressed 8 warnings (8 NOLINT)
 
 // RUN: %check_clang_tidy %s google-explicit-constructor %t --
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -21,6 +21,7 @@
 #include "clang/AST/ASTDiagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Frontend/DiagnosticRenderer.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include 
 #include 
@@ -290,7 +291,38 @@
   LastErrorPassesLineFilter = false;
 }
 
-static bool LineIsMarkedWithNOLINT(SourceManager , SourceLocation Loc) {
+static bool 

[PATCH] D34082: [Frontend] 'Show hotness' can be used with a sampling profile

2017-12-01 Thread Adam Nemet via Phabricator via cfe-commits
anemet added a comment.

Sorted these out in https://reviews.llvm.org/rL319576, 
https://reviews.llvm.org/rL319577 and https://reviews.llvm.org/rL319578.


https://reviews.llvm.org/D34082



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


[clang-tools-extra] r319579 - [clangd] Define constants in the right namespace. NFC

2017-12-01 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Fri Dec  1 12:03:19 2017
New Revision: 319579

URL: http://llvm.org/viewvc/llvm-project?rev=319579=rev
Log:
[clangd] Define constants in the right namespace. NFC

Modified:
clang-tools-extra/trunk/clangd/FuzzyMatch.cpp

Modified: clang-tools-extra/trunk/clangd/FuzzyMatch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FuzzyMatch.cpp?rev=319579=319578=319579=diff
==
--- clang-tools-extra/trunk/clangd/FuzzyMatch.cpp (original)
+++ clang-tools-extra/trunk/clangd/FuzzyMatch.cpp Fri Dec  1 12:03:19 2017
@@ -58,8 +58,9 @@
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/Format.h"
 
+namespace clang {
+namespace clangd {
 using namespace llvm;
-using namespace clang::clangd;
 
 const int FuzzyMatcher::MaxPat;
 const int FuzzyMatcher::MaxWord;
@@ -371,3 +372,6 @@ llvm::SmallString<256> FuzzyMatcher::dum
 
   return Result;
 }
+
+} // namespace clangd
+} // namespace clang


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


r319578 - Fix the second part of the broken comment from r306079

2017-12-01 Thread Adam Nemet via cfe-commits
Author: anemet
Date: Fri Dec  1 11:59:45 2017
New Revision: 319578

URL: http://llvm.org/viewvc/llvm-project?rev=319578=rev
Log:
Fix the second part of the broken comment from r306079

The driver-based test is still not identical to the front-end line, remove the
hotness threshold from there and add a new front-end based test with
threshold.

Modified:
cfe/trunk/test/Frontend/optimization-remark-with-hotness.c

Modified: cfe/trunk/test/Frontend/optimization-remark-with-hotness.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/optimization-remark-with-hotness.c?rev=319578=319577=319578=diff
==
--- cfe/trunk/test/Frontend/optimization-remark-with-hotness.c (original)
+++ cfe/trunk/test/Frontend/optimization-remark-with-hotness.c Fri Dec  1 
11:59:45 2017
@@ -15,8 +15,7 @@
 // RUN: %clang -target x86_64-apple-macosx10.9 %s -c -emit-llvm -o /dev/null \
 // RUN: -fprofile-instr-use=%t.profdata -Rpass=inline \
 // RUN: -Rpass-analysis=inline -Rpass-missed=inline \
-// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 \
-// RUN: -Xclang -verify
+// RUN: -fdiagnostics-show-hotness -Xclang -verify
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
 // RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
 // RUN: -fprofile-sample-use=%t-sample.profdata -Rpass=inline \
@@ -26,6 +25,11 @@
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
 // RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
 // RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
+// RUN: -Rpass-analysis=inline -Rpass-missed=inline \
+// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 
-verify
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
+// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
+// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
 // RUN: -Rpass-analysis=inline 2>&1 | FileCheck -check-prefix=HOTNESS_OFF 
%s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
 // RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \


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


r319577 - Fix opt-remark with hotness testcase for sample-based PGO

2017-12-01 Thread Adam Nemet via cfe-commits
Author: anemet
Date: Fri Dec  1 11:59:42 2017
New Revision: 319577

URL: http://llvm.org/viewvc/llvm-project?rev=319577=rev
Log:
Fix opt-remark with hotness testcase for sample-based PGO

1. Require hotness on all remark lines with -verify.

3. Fix the samplePGO file to actually produce hotness on each line.

The second remark has hotness 60 rather 30 which I don't quite understand but
testing this is strictly better than before.  It also unblocks the commit of
D40678.

Modified:

cfe/trunk/test/Frontend/Inputs/optimization-remark-with-hotness-sample.proftext
cfe/trunk/test/Frontend/optimization-remark-with-hotness.c

Modified: 
cfe/trunk/test/Frontend/Inputs/optimization-remark-with-hotness-sample.proftext
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/Inputs/optimization-remark-with-hotness-sample.proftext?rev=319577=319576=319577=diff
==
--- 
cfe/trunk/test/Frontend/Inputs/optimization-remark-with-hotness-sample.proftext 
(original)
+++ 
cfe/trunk/test/Frontend/Inputs/optimization-remark-with-hotness-sample.proftext 
Fri Dec  1 11:59:42 2017
@@ -1,7 +1,7 @@
-foo:0:0
- 0: 0
+foo:29:29
+ 0: 29
 bar:29:29
- 9: foo:0
-main:0:0
- 0: 0 bar:0
+ 8: 29 foo:29
+main:29:1
+ 3: 29 bar:29
 

Modified: cfe/trunk/test/Frontend/optimization-remark-with-hotness.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/optimization-remark-with-hotness.c?rev=319577=319576=319577=diff
==
--- cfe/trunk/test/Frontend/optimization-remark-with-hotness.c (original)
+++ cfe/trunk/test/Frontend/optimization-remark-with-hotness.c Fri Dec  1 
11:59:42 2017
@@ -56,13 +56,13 @@ void bar(int x) {
   // THRESHOLD-NOT: hotness
   // NO_PGO: '-fdiagnostics-show-hotness' requires profile-guided optimization 
information
   // NO_PGO: '-fdiagnostics-hotness-threshold=' requires profile-guided 
optimization information
-  // expected-remark@+1 {{foo inlined into bar with cost=always}}
+  // expected-remark@+1 {{foo inlined into bar with cost=always (hotness:}}
   sum += foo(x, x - 2);
 }
 
 int main(int argc, const char *argv[]) {
   for (int i = 0; i < 30; i++)
-// expected-remark@+1 {{bar not inlined into main because it should never 
be inlined}}
+// expected-remark@+1 {{bar not inlined into main because it should never 
be inlined (cost=never) (hotness:}}
 bar(argc);
   return sum;
 }


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


r319576 - Partially fix comment in test broken in r306079 and r306948

2017-12-01 Thread Adam Nemet via cfe-commits
Author: anemet
Date: Fri Dec  1 11:59:37 2017
New Revision: 319576

URL: http://llvm.org/viewvc/llvm-project?rev=319576=rev
Log:
Partially fix comment in test broken in r306079 and r306948

A RUN line was referring to the previous RUN line but a new test was added in
between them.  Just reorder the lines.

Note this still does not completely fix this the brokenness of the comment as
the driver-based test gained a new hotness-threshold argument in r306948 but
I'll fix that is a separate commit.

Modified:
cfe/trunk/test/Frontend/optimization-remark-with-hotness.c

Modified: cfe/trunk/test/Frontend/optimization-remark-with-hotness.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/optimization-remark-with-hotness.c?rev=319576=319575=319576=diff
==
--- cfe/trunk/test/Frontend/optimization-remark-with-hotness.c (original)
+++ cfe/trunk/test/Frontend/optimization-remark-with-hotness.c Fri Dec  1 
11:59:37 2017
@@ -11,12 +11,6 @@
 // RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
 // RUN: -Rpass-analysis=inline -Rpass-missed=inline \
 // RUN: -fdiagnostics-show-hotness -verify
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
-// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
-// RUN: -fprofile-sample-use=%t-sample.profdata -Rpass=inline \
-// RUN: -Rpass-analysis=inline -Rpass-missed=inline \
-// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 \
-// RUN: -verify
 // The clang version of the previous test.
 // RUN: %clang -target x86_64-apple-macosx10.9 %s -c -emit-llvm -o /dev/null \
 // RUN: -fprofile-instr-use=%t.profdata -Rpass=inline \
@@ -25,6 +19,12 @@
 // RUN: -Xclang -verify
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
 // RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
+// RUN: -fprofile-sample-use=%t-sample.profdata -Rpass=inline \
+// RUN: -Rpass-analysis=inline -Rpass-missed=inline \
+// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 \
+// RUN: -verify
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
+// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
 // RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
 // RUN: -Rpass-analysis=inline 2>&1 | FileCheck -check-prefix=HOTNESS_OFF 
%s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \


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


[PATCH] D36357: Added a better diagnostic when using the delete operator with lambdas

2017-12-01 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete updated this revision to Diff 125189.
Rakete added a comment.

Updated error message, added a FixItHint + a rebase and friendly ping :)


https://reviews.llvm.org/D36357

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  lib/Parse/ParseExprCXX.cpp
  test/Parser/cxx0x-lambda-expressions.cpp
  test/SemaCXX/new-delete-0x.cpp

Index: test/SemaCXX/new-delete-0x.cpp
===
--- test/SemaCXX/new-delete-0x.cpp
+++ test/SemaCXX/new-delete-0x.cpp
@@ -34,6 +34,7 @@
 void bad_deletes()
 {
   // 'delete []' is always array delete, per [expr.delete]p1.
-  // FIXME: Give a better diagnostic.
-  delete []{ return (int*)0; }(); // expected-error {{expected expression}}
+  delete []{ return (int*)0; }(); // expected-error {{'[]' after delete interpreted as 'delete[]'}}
+  // expected-note@-1 {{add parentheses around the lambda}}
 }
+
Index: test/Parser/cxx0x-lambda-expressions.cpp
===
--- test/Parser/cxx0x-lambda-expressions.cpp
+++ test/Parser/cxx0x-lambda-expressions.cpp
@@ -53,7 +53,8 @@
   void delete_lambda(int *p) {
 delete [] p;
 delete [] (int*) { new int }; // ok, compound-literal, not lambda
-delete [] { return new int; } (); // expected-error{{expected expression}}
+delete [] { return new int; } (); // expected-error {{'[]' after delete interpreted as 'delete[]'}}
+// expected-note@-1 {{add parentheses around the lambda}}
 delete [&] { return new int; } (); // ok, lambda
   }
 
Index: lib/Parse/ParseExprCXX.cpp
===
--- lib/Parse/ParseExprCXX.cpp
+++ lib/Parse/ParseExprCXX.cpp
@@ -2896,15 +2896,45 @@
 //   [Footnote: A lambda expression with a lambda-introducer that consists
 //  of empty square brackets can follow the delete keyword if
 //  the lambda expression is enclosed in parentheses.]
-// FIXME: Produce a better diagnostic if the '[]' is unambiguously a
-//lambda-introducer.
-ArrayDelete = true;
-BalancedDelimiterTracker T(*this, tok::l_square);
+TentativeParsingAction TPA(*this);
 
-T.consumeOpen();
-T.consumeClose();
-if (T.getCloseLocation().isInvalid())
-  return ExprError();
+// Basic lookahead to check if we have a lambda expression. If we
+// encounter two braces with a semicolon, we can be pretty sure
+// that this is a lambda, not say a compound literal. 
+if (!SkipUntil(tok::l_brace, SkipUntilFlags::StopAtSemi) ||
+(NextToken().isNot(tok::r_brace) && !SkipUntil(tok::semi)) ||
+!SkipUntil(tok::r_brace, SkipUntilFlags::StopAtSemi)) {
+  TPA.Revert();
+  ArrayDelete = true;
+  BalancedDelimiterTracker T(*this, tok::l_square);
+
+  T.consumeOpen();
+  T.consumeClose();
+  if (T.getCloseLocation().isInvalid())
+return ExprError();
+} else {
+  TPA.Revert();
+
+  // Warn if the non-capturing lambda isn't surrounded by parenthesis
+  // to disambiguate it from 'delete[]'.
+  ExprResult Lambda = TryParseLambdaExpression();
+  if (!Lambda.isInvalid()) {
+SourceLocation StartLoc = Lambda.get()->getLocStart();
+Diag(Start, diag::err_lambda_after_delete)
+<< SourceRange(Start, StartLoc.getLocWithOffset(1));
+
+SourceLocation BeforeBracket = StartLoc.getLocWithOffset(-1);
+Diag(BeforeBracket, diag::note_lambda_after_delete)
+<< FixItHint::CreateInsertion(BeforeBracket, "(")
+<< FixItHint::CreateInsertion(
+   Lambda.get()->getLocEnd().getLocWithOffset(1), ")");
+
+// Evaluate any postfix expressions used on the lambda.
+Lambda = ParsePostfixExpressionSuffix(Lambda);
+return Actions.ActOnCXXDelete(Start, UseGlobal, /*ArrayForm=*/false,
+  Lambda.get());
+  }
+}
   }
 
   ExprResult Operand(ParseCastExpression(false));
Index: include/clang/Basic/DiagnosticParseKinds.td
===
--- include/clang/Basic/DiagnosticParseKinds.td
+++ include/clang/Basic/DiagnosticParseKinds.td
@@ -99,6 +99,10 @@
   InGroup, DefaultIgnore;
 def ext_alignof_expr : ExtWarn<
   "%0 applied to an expression is a GNU extension">, InGroup;
+def err_lambda_after_delete : Error<
+  "'[]' after delete interpreted as 'delete[]'">;
+def note_lambda_after_delete : Note<
+  "add parentheses around the lambda">;
 
 def warn_microsoft_dependent_exists : Warning<
   "dependent %select{__if_not_exists|__if_exists}0 declarations are ignored">, 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40731: Integrate CHash into CLang

2017-12-01 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

We already have mechanisms to hash the AST. I'm strongly opposed to adding 
another one (and requiring AST modifications to update yet more such 
mechanisms).

Please look at the work that Richard Trieu has been doing recently to create 
stable-across-TUs hashes of statements and declarations, start a conversation 
on cfe-dev about integrating your approach and the existing Profile approach, 
and try to reach consensus on a way forward that doesn't leave us with multiple 
different hashing mechanisms. Replacing the Profile mechanism with a 
tablegen-driven one such as the one in this patch (and then generating the 
various hashing functions with their distinct requirements from that shared 
description) does seem like it could be a reasonable approach to me, but it 
needs to be a replacement rather than keeping both mechanisms around.


Repository:
  rC Clang

https://reviews.llvm.org/D40731



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


[PATCH] D40739: Pass through --undefined to Wasm LLD

2017-12-01 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

By the way, thank you for all these wasm patches!


Repository:
  rC Clang

https://reviews.llvm.org/D40739



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


[PATCH] D40739: Pass through --undefined to Wasm LLD

2017-12-01 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

Oh I see.  lgtm.   Do we need to update any tests?   I see we won't have a 
wasm-ld.c test yet?   We should add one?


Repository:
  rC Clang

https://reviews.llvm.org/D40739



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


[PATCH] D40731: Integrate CHash into CLang

2017-12-01 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please run Clang-format and Clang-tidy modernize over newly added code.




Comment at: include/clang/AST/CHashVisitor.h:1
+#ifndef __CHASH_VISITOR
+#define __CHASH_VISITOR

Please loon onto other headers for inclusion guards style.



Comment at: include/clang/AST/CHashVisitor.h:9
+#include "llvm/Support/MD5.h"
+
+

No empty lines between header groups.



Comment at: include/clang/AST/CHashVisitor.h:14
+#include 
+
+

Unnecessary empty line.



Comment at: include/clang/AST/CHashVisitor.h:18
+
+namespace CHashConstants {
+enum  {

Please add empty line below.



Comment at: include/clang/AST/CHashVisitor.h:153
+};
+}
+

} // namespace CHashConstants

Please add empty line above.



Comment at: include/clang/AST/CHashVisitor.h:159
+
+typedef clang::RecursiveASTVisitor> Inherited;
+public:

Please use using instead of typedef same in other places.



Comment at: include/clang/AST/CHashVisitor.h:160
+typedef clang::RecursiveASTVisitor> Inherited;
+public:
+typedef H Hash;

Please add empty line above.



Comment at: include/clang/AST/CHashVisitor.h:446
+Hash () { return HashStack.back(); }
+
+

Unnecessary lines.



Comment at: include/clang/AST/CHashVisitor.h:450
+
+}
+#endif

} // namespace clang



Comment at: include/clang/AST/CHashVisitor.h:451
+}
+#endif

#endif // 


Repository:
  rC Clang

https://reviews.llvm.org/D40731



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


[PATCH] D40562: [Sema] Ignore decls in namespaces when global decls are not wanted.

2017-12-01 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D40562#941753, @ilya-biryukov wrote:

> In https://reviews.llvm.org/D40562#941570, @arphaman wrote:
>
> > I'm not actually 100% sure, but I would imagine that this one of the 
> > reasons, yes. It would be nice to improve the cache to have things like 
> > namespace-level `Decl`, although how will lookup work in that case? Btw, do 
> > you think the cache can be reused in clangd as well?
>
>
> As Eric mentioned, we are planning to have project-global completion for 
> namespace-level Decls (to have completion items not #included in the current 
> file and add the #include directive properly).  So the cache is probably not 
> that useful to clangd long-term.


Interesting, thanks! Will this be something that clients of clangd can opt-out 
from? Or at least configure certain aspects of the behaviour?

> For proper lookup in the cache that include all namespace-level Decls I'd go 
> with tweaking `LookupVisibleDecls` so that it does not deserialize everything 
> from the preamble, but rather provides a list of scopes that we need to get 
> completion items from. Though sounds simple, it may be a non-trivial change 
> and we shouldn't probably pursue it as part of this change.
>  (We'll probably need it for clangd too).
> 
> In https://reviews.llvm.org/D40562#941735, @ioeric wrote:
> 
>> I took a quick look at the completion cache and lookup code. I think the 
>> completion cache also assumes that top-level decls are only TU-level decls, 
>> and this assumption seems to be also built into the lookup code. At this 
>> point, I am inclined to add a separate completion option for what I want 
>> (`IgnoreDeclsInTUOrNamespaces`?). Regarding cache in clangd, I think it 
>> might be useful short-term, when we still use Sema's global code completion, 
>> but long term, we would use symbols from clangd's indexes, so the cache 
>> would not be useful anymore.
> 
> 
> +1 for having a separate flag. Maybe call it `IncludeNamespaceLevelDecls` 
> instead? (I'd say TU is also a (global) namespace from completion's point of 
> view).

I agree with the new flag as well. I would also like to see a followup patch 
where this change is used before this is committed.


https://reviews.llvm.org/D40562



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


[PATCH] D40739: Pass through --undefined to Wasm LLD

2017-12-01 Thread Nicholas Wilson via Phabricator via cfe-commits
ncw added a comment.

I didn't know it existed either, and you're right it's odd that it doesn't 
appear in the help text... However it duly exists and is implemented in 
clang/lib/Driver/ToolChains/Gnu.cpp, without any note that it's deprecated. 
`man gcc` documents it.


Repository:
  rC Clang

https://reviews.llvm.org/D40739



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


[PATCH] D34082: [Frontend] 'Show hotness' can be used with a sampling profile

2017-12-01 Thread Adam Nemet via Phabricator via cfe-commits
anemet added a comment.

Looks like it's a test problem.  When I tweak the sample profile file according 
to https://clang.llvm.org/docs/UsersManual.html#sample-profile-text-format, I 
do get hotness on the remarks.


https://reviews.llvm.org/D34082



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


[PATCH] D40740: [compiler-rt] Remove out of date comment

2017-12-01 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319570: [compiler-rt] Remove out of date comment (authored 
by smeenai).

Repository:
  rL LLVM

https://reviews.llvm.org/D40740

Files:
  compiler-rt/trunk/CMakeLists.txt


Index: compiler-rt/trunk/CMakeLists.txt
===
--- compiler-rt/trunk/CMakeLists.txt
+++ compiler-rt/trunk/CMakeLists.txt
@@ -1,9 +1,5 @@
 # CMake build for CompilerRT.
 #
-# This build assumes that CompilerRT is checked out into the
-# 'projects/compiler-rt' or 'runtimes/compiler-rt' inside of an LLVM tree.
-# Standalone build system for CompilerRT is not yet ready.
-#
 # An important constraint of the build is that it only produces libraries
 # based on the ability of the host toolchain to target various platforms.
 


Index: compiler-rt/trunk/CMakeLists.txt
===
--- compiler-rt/trunk/CMakeLists.txt
+++ compiler-rt/trunk/CMakeLists.txt
@@ -1,9 +1,5 @@
 # CMake build for CompilerRT.
 #
-# This build assumes that CompilerRT is checked out into the
-# 'projects/compiler-rt' or 'runtimes/compiler-rt' inside of an LLVM tree.
-# Standalone build system for CompilerRT is not yet ready.
-#
 # An important constraint of the build is that it only produces libraries
 # based on the ability of the host toolchain to target various platforms.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40687: [compiler-rt] Add install-*-stripped targets

2017-12-01 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319569: [compiler-rt] Add install-*-stripped targets 
(authored by smeenai).

Repository:
  rL LLVM

https://reviews.llvm.org/D40687

Files:
  compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
  compiler-rt/trunk/cmake/base-config-ix.cmake


Index: compiler-rt/trunk/cmake/base-config-ix.cmake
===
--- compiler-rt/trunk/cmake/base-config-ix.cmake
+++ compiler-rt/trunk/cmake/base-config-ix.cmake
@@ -11,6 +11,7 @@
 # Top level target used to build all compiler-rt libraries.
 add_custom_target(compiler-rt ALL)
 add_custom_target(install-compiler-rt)
+add_custom_target(install-compiler-rt-stripped)
 set_target_properties(compiler-rt PROPERTIES FOLDER "Compiler-RT Misc")
 
 # Setting these variables from an LLVM build is sufficient that compiler-rt can
Index: compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
===
--- compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
+++ compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
@@ -210,9 +210,18 @@
 COMMAND "${CMAKE_COMMAND}"
 -DCMAKE_INSTALL_COMPONENT=${LIB_PARENT_TARGET}
 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  add_custom_target(install-${LIB_PARENT_TARGET}-stripped
+DEPENDS ${LIB_PARENT_TARGET}
+COMMAND "${CMAKE_COMMAND}"
+-DCMAKE_INSTALL_COMPONENT=${LIB_PARENT_TARGET}
+-DCMAKE_INSTALL_DO_STRIP=1
+-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
   set_target_properties(install-${LIB_PARENT_TARGET} PROPERTIES
 FOLDER "Compiler-RT Misc")
+  set_target_properties(install-${LIB_PARENT_TARGET}-stripped PROPERTIES
+FOLDER "Compiler-RT Misc")
   add_dependencies(install-compiler-rt install-${LIB_PARENT_TARGET})
+  add_dependencies(install-compiler-rt-stripped 
install-${LIB_PARENT_TARGET}-stripped)
 endif()
   endif()
 
@@ -267,10 +276,17 @@
 COMMAND "${CMAKE_COMMAND}"
 -DCMAKE_INSTALL_COMPONENT=${libname}
 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  add_custom_target(install-${libname}-stripped
+DEPENDS ${libname}
+COMMAND "${CMAKE_COMMAND}"
+-DCMAKE_INSTALL_COMPONENT=${libname}
+-DCMAKE_INSTALL_DO_STRIP=1
+-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
   # If you have a parent target specified, we bind the new install target
   # to the parent install target.
   if(LIB_PARENT_TARGET)
 add_dependencies(install-${LIB_PARENT_TARGET} install-${libname})
+add_dependencies(install-${LIB_PARENT_TARGET}-stripped 
install-${libname}-stripped)
   endif()
 endif()
 if(APPLE)


Index: compiler-rt/trunk/cmake/base-config-ix.cmake
===
--- compiler-rt/trunk/cmake/base-config-ix.cmake
+++ compiler-rt/trunk/cmake/base-config-ix.cmake
@@ -11,6 +11,7 @@
 # Top level target used to build all compiler-rt libraries.
 add_custom_target(compiler-rt ALL)
 add_custom_target(install-compiler-rt)
+add_custom_target(install-compiler-rt-stripped)
 set_target_properties(compiler-rt PROPERTIES FOLDER "Compiler-RT Misc")
 
 # Setting these variables from an LLVM build is sufficient that compiler-rt can
Index: compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
===
--- compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
+++ compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
@@ -210,9 +210,18 @@
 COMMAND "${CMAKE_COMMAND}"
 -DCMAKE_INSTALL_COMPONENT=${LIB_PARENT_TARGET}
 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  add_custom_target(install-${LIB_PARENT_TARGET}-stripped
+DEPENDS ${LIB_PARENT_TARGET}
+COMMAND "${CMAKE_COMMAND}"
+-DCMAKE_INSTALL_COMPONENT=${LIB_PARENT_TARGET}
+-DCMAKE_INSTALL_DO_STRIP=1
+-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
   set_target_properties(install-${LIB_PARENT_TARGET} PROPERTIES
 FOLDER "Compiler-RT Misc")
+  set_target_properties(install-${LIB_PARENT_TARGET}-stripped PROPERTIES
+FOLDER "Compiler-RT Misc")
   add_dependencies(install-compiler-rt install-${LIB_PARENT_TARGET})
+  add_dependencies(install-compiler-rt-stripped 

[PATCH] D40740: [compiler-rt] Remove out of date comment

2017-12-01 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D40740



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


[PATCH] D40687: [compiler-rt] Add install-*-stripped targets

2017-12-01 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D40687



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


[PATCH] D40739: Pass through --undefined to Wasm LLD

2017-12-01 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

I'm a little confused by this.  I was assuming you would do "-Wl,-u,foo" or 
"-Xlinker".I wasn't aware -u was a valid compiler flag itself.  It doesn't 
show up in --help.


Repository:
  rC Clang

https://reviews.llvm.org/D40739



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


[PATCH] D40740: [compiler-rt] Remove out of date comment

2017-12-01 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
Herald added subscribers: mgorny, dberris.

Per beanz, building compiler-rt standalone is a pretty important use
case, so the comment is very out of date.


https://reviews.llvm.org/D40740

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -1,9 +1,5 @@
 # CMake build for CompilerRT.
 #
-# This build assumes that CompilerRT is checked out into the
-# 'projects/compiler-rt' or 'runtimes/compiler-rt' inside of an LLVM tree.
-# Standalone build system for CompilerRT is not yet ready.
-#
 # An important constraint of the build is that it only produces libraries
 # based on the ability of the host toolchain to target various platforms.
 


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -1,9 +1,5 @@
 # CMake build for CompilerRT.
 #
-# This build assumes that CompilerRT is checked out into the
-# 'projects/compiler-rt' or 'runtimes/compiler-rt' inside of an LLVM tree.
-# Standalone build system for CompilerRT is not yet ready.
-#
 # An important constraint of the build is that it only produces libraries
 # based on the ability of the host toolchain to target various platforms.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40687: [compiler-rt] Add install-*-stripped targets

2017-12-01 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai updated this revision to Diff 125180.
smeenai retitled this revision from "[compiler-rt] Switch to 
add_llvm_install_targets" to "[compiler-rt] Add install-*-stripped targets".
smeenai edited the summary of this revision.
smeenai added a comment.

Add targets manually


https://reviews.llvm.org/D40687

Files:
  cmake/Modules/AddCompilerRT.cmake
  cmake/base-config-ix.cmake


Index: cmake/base-config-ix.cmake
===
--- cmake/base-config-ix.cmake
+++ cmake/base-config-ix.cmake
@@ -11,6 +11,7 @@
 # Top level target used to build all compiler-rt libraries.
 add_custom_target(compiler-rt ALL)
 add_custom_target(install-compiler-rt)
+add_custom_target(install-compiler-rt-stripped)
 set_target_properties(compiler-rt PROPERTIES FOLDER "Compiler-RT Misc")
 
 # Setting these variables from an LLVM build is sufficient that compiler-rt can
Index: cmake/Modules/AddCompilerRT.cmake
===
--- cmake/Modules/AddCompilerRT.cmake
+++ cmake/Modules/AddCompilerRT.cmake
@@ -210,9 +210,18 @@
 COMMAND "${CMAKE_COMMAND}"
 -DCMAKE_INSTALL_COMPONENT=${LIB_PARENT_TARGET}
 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  add_custom_target(install-${LIB_PARENT_TARGET}-stripped
+DEPENDS ${LIB_PARENT_TARGET}
+COMMAND "${CMAKE_COMMAND}"
+-DCMAKE_INSTALL_COMPONENT=${LIB_PARENT_TARGET}
+-DCMAKE_INSTALL_DO_STRIP=1
+-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
   set_target_properties(install-${LIB_PARENT_TARGET} PROPERTIES
 FOLDER "Compiler-RT Misc")
+  set_target_properties(install-${LIB_PARENT_TARGET}-stripped PROPERTIES
+FOLDER "Compiler-RT Misc")
   add_dependencies(install-compiler-rt install-${LIB_PARENT_TARGET})
+  add_dependencies(install-compiler-rt-stripped 
install-${LIB_PARENT_TARGET}-stripped)
 endif()
   endif()
 
@@ -267,10 +276,17 @@
 COMMAND "${CMAKE_COMMAND}"
 -DCMAKE_INSTALL_COMPONENT=${libname}
 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  add_custom_target(install-${libname}-stripped
+DEPENDS ${libname}
+COMMAND "${CMAKE_COMMAND}"
+-DCMAKE_INSTALL_COMPONENT=${libname}
+-DCMAKE_INSTALL_DO_STRIP=1
+-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
   # If you have a parent target specified, we bind the new install target
   # to the parent install target.
   if(LIB_PARENT_TARGET)
 add_dependencies(install-${LIB_PARENT_TARGET} install-${libname})
+add_dependencies(install-${LIB_PARENT_TARGET}-stripped 
install-${libname}-stripped)
   endif()
 endif()
 if(APPLE)


Index: cmake/base-config-ix.cmake
===
--- cmake/base-config-ix.cmake
+++ cmake/base-config-ix.cmake
@@ -11,6 +11,7 @@
 # Top level target used to build all compiler-rt libraries.
 add_custom_target(compiler-rt ALL)
 add_custom_target(install-compiler-rt)
+add_custom_target(install-compiler-rt-stripped)
 set_target_properties(compiler-rt PROPERTIES FOLDER "Compiler-RT Misc")
 
 # Setting these variables from an LLVM build is sufficient that compiler-rt can
Index: cmake/Modules/AddCompilerRT.cmake
===
--- cmake/Modules/AddCompilerRT.cmake
+++ cmake/Modules/AddCompilerRT.cmake
@@ -210,9 +210,18 @@
 COMMAND "${CMAKE_COMMAND}"
 -DCMAKE_INSTALL_COMPONENT=${LIB_PARENT_TARGET}
 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  add_custom_target(install-${LIB_PARENT_TARGET}-stripped
+DEPENDS ${LIB_PARENT_TARGET}
+COMMAND "${CMAKE_COMMAND}"
+-DCMAKE_INSTALL_COMPONENT=${LIB_PARENT_TARGET}
+-DCMAKE_INSTALL_DO_STRIP=1
+-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
   set_target_properties(install-${LIB_PARENT_TARGET} PROPERTIES
 FOLDER "Compiler-RT Misc")
+  set_target_properties(install-${LIB_PARENT_TARGET}-stripped PROPERTIES
+FOLDER "Compiler-RT Misc")
   add_dependencies(install-compiler-rt install-${LIB_PARENT_TARGET})
+  add_dependencies(install-compiler-rt-stripped install-${LIB_PARENT_TARGET}-stripped)
 endif()
   endif()
 
@@ -267,10 +276,17 @@
 COMMAND "${CMAKE_COMMAND}"
 

[PATCH] D40738: Don't use Wasm function sections for more than one function

2017-12-01 Thread Dan Gohman via Phabricator via cfe-commits
sunfish accepted this revision.
sunfish added a comment.
This revision is now accepted and ready to land.

I think that was copied from LinuxTargetInfo before we figured out our current 
object file strategy. On native platforms, it's an icache optimization, because 
startup functions are all called around the same time, and then never used 
again. However, this doesn't really apply to WebAssembly. It is possible that 
WebAssembly may eventually want to put everything called during startup at the 
beginning, so that clever browser engines can start running code even before 
the whole module is downloaded, however the optimization here wouldn't be 
sufficient. So this change looks good.


Repository:
  rC Clang

https://reviews.llvm.org/D40738



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


[PATCH] D36836: [clang-tidy] Implement sonarsource-function-cognitive-complexity check

2017-12-01 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 125178.
lebedev.ri changed the repository for this revision from rL LLVM to rCTE Clang 
Tools Extra.
lebedev.ri added a comment.

Rebased.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D36836

Files:
  LICENSE.TXT
  clang-tidy/CMakeLists.txt
  clang-tidy/plugin/CMakeLists.txt
  clang-tidy/sonarsource/CMakeLists.txt
  clang-tidy/sonarsource/FunctionCognitiveComplexityCheck.cpp
  clang-tidy/sonarsource/FunctionCognitiveComplexityCheck.h
  clang-tidy/sonarsource/LICENSE.TXT
  clang-tidy/sonarsource/SONARSOURCETidyModule.cpp
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/sonarsource-function-cognitive-complexity.rst
  test/clang-tidy/sonarsource-function-cognitive-complexity.cpp

Index: test/clang-tidy/sonarsource-function-cognitive-complexity.cpp
===
--- /dev/null
+++ test/clang-tidy/sonarsource-function-cognitive-complexity.cpp
@@ -0,0 +1,954 @@
+// RUN: %check_clang_tidy %s sonarsource-function-cognitive-complexity %t -- -config='{CheckOptions: [{key: sonarsource-function-cognitive-complexity.Threshold, value: 0}]}' -- -std=c++11 -w
+
+// any function should be checked.
+
+extern int ext_func(int x = 0);
+
+int some_func(int x = 0);
+
+static int some_other_func(int x = 0) {}
+
+template void some_templ_func(T x = 0) {}
+
+class SomeClass {
+public:
+  int *begin(int x = 0);
+  int *end(int x = 0);
+  static int func(int x = 0);
+  template void some_templ_func(T x = 0) {}
+  SomeClass() = default;
+  SomeClass(SomeClass&) = delete;
+};
+
+// nothing ever decreases cognitive complexity, so we can check all the things
+// in one go. none of the following should increase cognitive complexity:
+void unittest_false() {
+  {};
+  ext_func();
+  some_func();
+  some_other_func();
+  some_templ_func();
+  some_templ_func();
+  SomeClass::func();
+  SomeClass C;
+  C.some_templ_func();
+  C.some_templ_func();
+  C.func();
+  C.end();
+  int i = some_func();
+  i = i;
+  i++;
+  --i;
+  i < 0;
+  int j = 0 ?: 1;
+  auto k = new int;
+  delete k;
+  throw i;
+  {
+throw i;
+  }
+end:
+  return;
+}
+
+#if 1
+#define CC100
+#else
+// this macro has cognitive complexity of 100.
+// it is needed to be able to compare the testcases with the
+// reference Sonar implementation. please place it right after the first
+// CHECK-NOTES in each function
+#define CC100 if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){}if(1){}
+#endif
+
+////
+//-- B1. Increments --//
+////
+// Check that every thing listed in B1 of the specification does indeed   //
+// recieve the base increment, and that not-body does not increase nesting//
+////
+
+// break does not increase cognitive complexity.
+// only  break LABEL  does, but it is unavaliable in C or C++
+
+// continue does not increase cognitive complexity.
+// only  continue LABEL  does, but it is unavaliable in C or C++
+
+void unittest_b1_00() {
+// CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'unittest_b1_00' has cognitive complexity of 33 (threshold 0) [sonarsource-function-cognitive-complexity]
+  CC100;
+
+  if (1 ? 1 : 0) {
+// CHECK-NOTES: :[[@LINE-1]]:3: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:9: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}}
+
+if (1 ? 1 : 0) {
+// CHECK-NOTES: :[[@LINE-1]]:5: note: +2, including nesting penalty of 1, nesting level increased to 2{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:11: note: +2, including nesting penalty of 1, nesting level increased to 2{{$}}
+} else if (1 ? 1 : 0) {
+// CHECK-NOTES: :[[@LINE-1]]:12: note: +1, nesting level increased to 2{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:18: note: +3, including nesting penalty of 2, nesting level increased to 3{{$}}
+} else {
+// CHECK-NOTES: :[[@LINE-1]]:7: note: +1, nesting level increased to 2{{$}}
+}
+  } else if (1 ? 1 : 0) {
+// CHECK-NOTES: :[[@LINE-1]]:10: note: +1, nesting level increased to 1{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:16: note: +2, including nesting penalty of 1, nesting level increased to 2{{$}}
+
+if (1 ? 1 : 0) {
+// CHECK-NOTES: :[[@LINE-1]]:5: note: +2, including nesting penalty of 1, nesting level increased to 2{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:11: note: +2, including nesting penalty of 1, nesting level increased to 2{{$}}
+} else if (1 ? 1 : 0) {
+// CHECK-NOTES: :[[@LINE-1]]:12: note: +1, nesting level increased to 2{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:18: note: +3, including nesting penalty of 2, nesting 

[PATCH] D40687: [compiler-rt] Switch to add_llvm_install_targets

2017-12-01 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

Yes, that comment is very out of date. The compiler-rt standalone build is 
essential to many of the users. It is quite common to build and use compiler-rt 
without LLVM (like sanitizer support in gcc).


https://reviews.llvm.org/D40687



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


[PATCH] D40687: [compiler-rt] Switch to add_llvm_install_targets

2017-12-01 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

Ah, that's a bummer.

compiler-rt's CMakeLists has this big shiny comment up top:

  # This build assumes that CompilerRT is checked out into the
  # 'projects/compiler-rt' or 'runtimes/compiler-rt' inside of an LLVM tree.
  # Standalone build system for CompilerRT is not yet ready.

I assume that's out of date then?


https://reviews.llvm.org/D40687



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


[PATCH] D40739: Pass through --undefined to Wasm LLD

2017-12-01 Thread Nicholas Wilson via Phabricator via cfe-commits
ncw updated this revision to Diff 125176.
ncw added a comment.

(D'oh, more trouble with arcane commands getting diffs into phabricator... 
sorry for the spam.)


Repository:
  rC Clang

https://reviews.llvm.org/D40739

Files:
  lib/Driver/ToolChains/WebAssembly.cpp


Index: lib/Driver/ToolChains/WebAssembly.cpp
===
--- lib/Driver/ToolChains/WebAssembly.cpp
+++ lib/Driver/ToolChains/WebAssembly.cpp
@@ -47,6 +47,7 @@
 CmdArgs.push_back("--strip-all");
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
+  Args.AddAllArgs(CmdArgs, options::OPT_u);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))


Index: lib/Driver/ToolChains/WebAssembly.cpp
===
--- lib/Driver/ToolChains/WebAssembly.cpp
+++ lib/Driver/ToolChains/WebAssembly.cpp
@@ -47,6 +47,7 @@
 CmdArgs.push_back("--strip-all");
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
+  Args.AddAllArgs(CmdArgs, options::OPT_u);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40739: Pass through --undefined to Wasm LLD

2017-12-01 Thread Nicholas Wilson via Phabricator via cfe-commits
ncw created this revision.
Herald added subscribers: cfe-commits, sunfish, aheejin, jgravelle-google, 
dschuff, jfb, klimek.

This is a follow-on to https://reviews.llvm.org/D40724 (Wasm entrypoint changes 
#1, add `--undefined` argument to LLD).


Repository:
  rC Clang

https://reviews.llvm.org/D40739

Files:
  lib/Driver/ToolChains/WebAssembly.cpp
  lib/Format/ContinuationIndenter.cpp
  lib/Format/ContinuationIndenter.h
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -9934,8 +9934,8 @@
   Style.PenaltyExcessCharacter = 90;
   verifyFormat("int a; // the comment", Style);
   EXPECT_EQ("int a; // the comment\n"
-"   // aa",
-format("int a; // the comment aa", Style));
+"   // aaa",
+format("int a; // the comment aaa", Style));
   EXPECT_EQ("int a; /* first line\n"
 "* second line\n"
 "* third line\n"
@@ -9963,14 +9963,14 @@
Style));
 
   EXPECT_EQ("// foo bar baz bazfoo\n"
-"// foo bar\n",
+"// foo bar foo bar\n",
 format("// foo bar baz bazfoo\n"
-   "// foobar\n",
+   "// foo bar foo   bar\n",
Style));
   EXPECT_EQ("// foo bar baz bazfoo\n"
-"// foo bar\n",
+"// foo bar foo bar\n",
 format("// foo bar baz  bazfoo\n"
-   "// foobar\n",
+   "// foobar foo bar\n",
Style));
 
   // FIXME: Optimally, we'd keep bazfoo on the first line and reflow bar to the
@@ -9996,6 +9996,20 @@
"// foo bar baz  bazfoo bar\n"
"// foo   bar\n",
Style));
+
+  // Make sure we do not keep protruding characters if strict mode reflow is
+  // cheaper than keeping protruding characters.
+  Style.ColumnLimit = 21;
+  EXPECT_EQ("// foo foo foo foo\n"
+"// foo foo foo foo\n"
+"// foo foo foo foo\n",
+format("// foo foo foo foo foo foo foo foo foo foo foo foo\n",
+   Style));
+
+  EXPECT_EQ("int a = /* long block\n"
+"   comment */\n"
+"42;",
+format("int a = /* long block comment */ 42;", Style));
 }
 
 #define EXPECT_ALL_STYLES_EQUAL(Styles)\
Index: lib/Format/ContinuationIndenter.h
===
--- lib/Format/ContinuationIndenter.h
+++ lib/Format/ContinuationIndenter.h
@@ -123,14 +123,25 @@
   /// \brief If the current token sticks out over the end of the line, break
   /// it if possible.
   ///
-  /// \returns An extra penalty if a token was broken, otherwise 0.
+  /// \returns A pair (penalty, exceeded), where penalty is the extra penalty
+  /// when tokens are broken or lines exceed the column limit, and exceeded
+  /// indicates whether the algorithm purposefully left lines exceeding the
+  /// column limit.
   ///
   /// The returned penalty will cover the cost of the additional line breaks
   /// and column limit violation in all lines except for the last one. The
   /// penalty for the column limit violation in the last line (and in single
   /// line tokens) is handled in \c addNextStateToQueue.
-  unsigned breakProtrudingToken(const FormatToken , LineState ,
-bool AllowBreak, bool DryRun);
+  ///
+  /// \p Strict indicates whether reflowing is allowed to leave characters
+  /// protruding the column limit; if true, lines will be split strictly within
+  /// the column limit where possible; if false, words are allowed to protrude
+  /// over the column limit as long as the penalty is less than the penalty
+  /// of a break.
+  std::pair breakProtrudingToken(const FormatToken ,
+ LineState ,
+ bool AllowBreak, bool DryRun,
+ bool Strict);
 
   /// \brief Returns the \c BreakableToken starting at \p Current, or nullptr
   /// if the current token cannot be broken.
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -1390,7 +1390,36 @@
 Penalty = addMultilineToken(Current, State);
   } else if (State.Line->Type != LT_ImportStatement) {
 // We generally don't break import statements.
-Penalty = breakProtrudingToken(Current, State, AllowBreak, DryRun);
+LineState OriginalState = State;
+
+// Whether we force the reflowing algorithm to stay strictly within the
+// column limit.
+bool Strict = false;
+

[PATCH] D34082: [Frontend] 'Show hotness' can be used with a sampling profile

2017-12-01 Thread Davide Italiano via Phabricator via cfe-commits
davide added a comment.

In https://reviews.llvm.org/D34082#942420, @anemet wrote:

> @modocache, @davide, are you guys sure this feature is working?  The test 
> does not actually check whether hotness is included in the remarks and when I 
> run it manually they are missing.  In https://reviews.llvm.org/D40678, I am 
> filtering out remarks with no hotness when any threshold is set all the 
> remarks are filtered out in this new test.
>
> So either the test is incorrect or somehow with sample-based profiling we 
> don't get hotness info.
>
> Any ideas?  I am inclined to just remove this test for now and file a bug to 
> fix this in order to unblock https://reviews.llvm.org/D40678.


I don't know, I haven't reviewed this feature, but I can take a look later 
today.


https://reviews.llvm.org/D34082



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


[PATCH] D40738: Don't use Wasm function sections for more than one function

2017-12-01 Thread Nicholas Wilson via Phabricator via cfe-commits
ncw created this revision.
Herald added subscribers: cfe-commits, aheejin, sbc100, dschuff, jfb.

Fixes Bugzilla https://bugs.llvm.org/show_bug.cgi?id=35467

If a Wasm function section is created with more than one symbol, 
WasmObjectWriter fails with the following message: "function sections must 
contain one function each".

Currently, if a C++ file contains multiple static initialisers, they'll all be 
put in the same function section, triggering the error.

I think this change here is safe - it seems to be a spurious optimisation. In 
fact, I'm not even sure how it's intended to optimise the output...?


Repository:
  rC Clang

https://reviews.llvm.org/D40738

Files:
  lib/Basic/Targets/OSTargets.h
  test/CodeGenCXX/static-init-wasm.cpp


Index: test/CodeGenCXX/static-init-wasm.cpp
===
--- test/CodeGenCXX/static-init-wasm.cpp
+++ test/CodeGenCXX/static-init-wasm.cpp
@@ -43,12 +43,12 @@
 
 A theA;
 
-// WEBASSEMBLY32: define internal void @__cxx_global_var_init() #3 section 
".text.__startup" {
+// WEBASSEMBLY32: define internal void @__cxx_global_var_init() #3 {
 // WEBASSEMBLY32: call %struct.A* @_ZN1AC1Ev(%struct.A* @theA)
-// WEBASSEMBLY32: define internal void @_GLOBAL__sub_I_static_init_wasm.cpp() 
#3 section ".text.__startup" {
+// WEBASSEMBLY32: define internal void @_GLOBAL__sub_I_static_init_wasm.cpp() 
#3 {
 // WEBASSEMBLY32: call void @__cxx_global_var_init()
 //
-// WEBASSEMBLY64: define internal void @__cxx_global_var_init() #3 section 
".text.__startup" {
+// WEBASSEMBLY64: define internal void @__cxx_global_var_init() #3 {
 // WEBASSEMBLY64: call %struct.A* @_ZN1AC1Ev(%struct.A* @theA)
-// WEBASSEMBLY64: define internal void @_GLOBAL__sub_I_static_init_wasm.cpp() 
#3 section ".text.__startup" {
+// WEBASSEMBLY64: define internal void @_GLOBAL__sub_I_static_init_wasm.cpp() 
#3 {
 // WEBASSEMBLY64: call void @__cxx_global_var_init()
Index: lib/Basic/Targets/OSTargets.h
===
--- lib/Basic/Targets/OSTargets.h
+++ lib/Basic/Targets/OSTargets.h
@@ -711,11 +711,6 @@
   Builder.defineMacro("_GNU_SOURCE");
   }
 
-  // As an optimization, group static init code together in a section.
-  const char *getStaticInitSectionSpecifier() const final {
-return ".text.__startup";
-  }
-
 public:
   explicit WebAssemblyOSTargetInfo(const llvm::Triple ,
const TargetOptions )


Index: test/CodeGenCXX/static-init-wasm.cpp
===
--- test/CodeGenCXX/static-init-wasm.cpp
+++ test/CodeGenCXX/static-init-wasm.cpp
@@ -43,12 +43,12 @@
 
 A theA;
 
-// WEBASSEMBLY32: define internal void @__cxx_global_var_init() #3 section ".text.__startup" {
+// WEBASSEMBLY32: define internal void @__cxx_global_var_init() #3 {
 // WEBASSEMBLY32: call %struct.A* @_ZN1AC1Ev(%struct.A* @theA)
-// WEBASSEMBLY32: define internal void @_GLOBAL__sub_I_static_init_wasm.cpp() #3 section ".text.__startup" {
+// WEBASSEMBLY32: define internal void @_GLOBAL__sub_I_static_init_wasm.cpp() #3 {
 // WEBASSEMBLY32: call void @__cxx_global_var_init()
 //
-// WEBASSEMBLY64: define internal void @__cxx_global_var_init() #3 section ".text.__startup" {
+// WEBASSEMBLY64: define internal void @__cxx_global_var_init() #3 {
 // WEBASSEMBLY64: call %struct.A* @_ZN1AC1Ev(%struct.A* @theA)
-// WEBASSEMBLY64: define internal void @_GLOBAL__sub_I_static_init_wasm.cpp() #3 section ".text.__startup" {
+// WEBASSEMBLY64: define internal void @_GLOBAL__sub_I_static_init_wasm.cpp() #3 {
 // WEBASSEMBLY64: call void @__cxx_global_var_init()
Index: lib/Basic/Targets/OSTargets.h
===
--- lib/Basic/Targets/OSTargets.h
+++ lib/Basic/Targets/OSTargets.h
@@ -711,11 +711,6 @@
   Builder.defineMacro("_GNU_SOURCE");
   }
 
-  // As an optimization, group static init code together in a section.
-  const char *getStaticInitSectionSpecifier() const final {
-return ".text.__startup";
-  }
-
 public:
   explicit WebAssemblyOSTargetInfo(const llvm::Triple ,
const TargetOptions )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40580: [clang-tidy] Adding Fuchsia checker for multiple inheritance

2017-12-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/fuchsia/MultipleInheritanceCheck.cpp:35
+  StringRef Name = Node->getIdentifier()->getName();
+  auto Pair = InterfaceMap.find(Name);
+  if (Pair == InterfaceMap.end())

Eugene.Zelenko wrote:
> aaron.ballman wrote:
> > Don't use `auto` as the type is not spelled out explicitly in the 
> > initialization.
> But such cases are included in modernize-use-auto.
Hmm, I suppose you could maybe make a case that `StringMap::iterator` is 
"complex enough" and that the returned type is sufficiently clear to warrant 
using `auto`...


https://reviews.llvm.org/D40580



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


[PATCH] D34082: [Frontend] 'Show hotness' can be used with a sampling profile

2017-12-01 Thread Adam Nemet via Phabricator via cfe-commits
anemet added a subscriber: davide.
anemet added a comment.

@modocache, @davide, are you guys sure this feature is working?  The test does 
not actually check whether hotness is included in the remarks and when I run it 
manually they are missing.  In https://reviews.llvm.org/D40678, I am filtering 
out remarks with no hotness when any threshold is set all the remarks are 
filtered out in this new test.

So either the test is incorrect or somehow with sample-based profiling we don't 
get hotness info.

Any ideas?  I am inclined to just remove this test for now and file a bug to 
fix this in order to unblock https://reviews.llvm.org/D40678.


https://reviews.llvm.org/D34082



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


[PATCH] D40580: [clang-tidy] Adding Fuchsia checker for multiple inheritance

2017-12-01 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tidy/fuchsia/MultipleInheritanceCheck.cpp:35
+  StringRef Name = Node->getIdentifier()->getName();
+  auto Pair = InterfaceMap.find(Name);
+  if (Pair == InterfaceMap.end())

aaron.ballman wrote:
> Don't use `auto` as the type is not spelled out explicitly in the 
> initialization.
But such cases are included in modernize-use-auto.


https://reviews.llvm.org/D40580



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


[PATCH] D40737: [clang-tidy] Resubmit hicpp-multiway-paths-covered without breaking test

2017-12-01 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth created this revision.
Herald added subscribers: cfe-commits, xazax.hun, mgorny.

The original check did break the green buildbot in the sanitizer build.
It took a while to redroduce and understand the issue.

There occured a stackoverflow while parsing the AST. The testcase with
256 case labels was the problem because each case label added another
stackframe. It seemed that the issue occured only in 'RelWithDebInfo' builds
and not in normal sanitizer builds.

To simplify the matchers the recognition for the different kinds of switch
statements has been moved into a seperate function and will not be done with
ASTMatchers. This is an attempt to reduce recursion and stacksize as well.

The new check removed this big testcase. Covering all possible values is still
implemented for bitfields and works there. The same logic on integer types
will lead to the issue.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40737

Files:
  clang-tidy/hicpp/CMakeLists.txt
  clang-tidy/hicpp/HICPPTidyModule.cpp
  clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
  clang-tidy/hicpp/MultiwayPathsCoveredCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/hicpp-multiway-paths-covered.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/hicpp-multiway-paths-covered-else.cpp
  test/clang-tidy/hicpp-multiway-paths-covered.cpp

Index: test/clang-tidy/hicpp-multiway-paths-covered.cpp
===
--- /dev/null
+++ test/clang-tidy/hicpp-multiway-paths-covered.cpp
@@ -0,0 +1,206 @@
+// RUN: %check_clang_tidy %s hicpp-multiway-paths-covered %t
+
+enum OS { Mac,
+  Windows,
+  Linux };
+
+struct Bitfields {
+  unsigned UInt : 3;
+  int SInt : 1;
+};
+
+int return_integer() { return 42; }
+
+void bad_switch(int i) {
+  switch (i) {
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: switch with only one case; use an if statement
+  case 0:
+break;
+  }
+  // No default in this switch
+  switch (i) {
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: potential uncovered code path; add a default label
+  case 0:
+break;
+  case 1:
+break;
+  case 2:
+break;
+  }
+
+  // degenerate, maybe even warning
+  switch (i) {
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: degenerated switch without labels
+  }
+
+  switch (int j = return_integer()) {
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: potential uncovered code path; add a default label
+  case 0:
+  case 1:
+  case 2:
+break;
+  }
+
+  // Degenerated, only default case.
+  switch (i) {
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: degenerated switch with default label only
+  default:
+break;
+  }
+
+  // Degenerated, only one case label and default case -> Better as if-stmt.
+  switch (i) {
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: switch could be better written as an if/else statement
+  case 0:
+break;
+  default:
+break;
+  }
+
+  unsigned long long BigNumber = 0;
+  switch (BigNumber) {
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: potential uncovered code path; add a default label
+  case 0:
+  case 1:
+break;
+  }
+
+  const int  = i;
+  switch (IntRef) {
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: potential uncovered code path; add a default label
+  case 0:
+  case 1:
+break;
+  }
+
+  char C = 'A';
+  switch (C) {
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: potential uncovered code path; add a default label
+  case 'A':
+break;
+  case 'B':
+break;
+  }
+
+  Bitfields Bf;
+  // UInt has 3 bits size.
+  switch (Bf.UInt) {
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: potential uncovered code path; add a default label
+  case 0:
+  case 1:
+break;
+  }
+  // All paths explicitly covered.
+  switch (Bf.UInt) {
+  case 0:
+  case 1:
+  case 2:
+  case 3:
+  case 4:
+  case 5:
+  case 6:
+  case 7:
+break;
+  }
+  // SInt has 1 bit size, so this is somewhat degenerated.
+  switch (Bf.SInt) {
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: switch with only one case; use an if statement
+  case 0:
+break;
+  }
+  // All paths explicitly covered.
+  switch (Bf.SInt) {
+  case 0:
+  case 1:
+break;
+  }
+
+  // Some paths are covered by the switch and a default case is present.
+  int c = 1;
+  switch (c) {
+  case 1:
+  case 2:
+  case 3:
+  default:
+break;
+  }
+
+  bool Flag = false;
+  switch (Flag) {
+// CHECK-MESSAGES:[[@LINE-1]]:3: warning: switch with only one case; use an if statement
+  case true:
+break;
+  }
+
+  switch (Flag) {
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: degenerated switch with default label only
+  default:
+break;
+  }
+
+  // This `switch` will create a frontend warning from '-Wswitch-bool' but is
+  // ok for this check.
+  switch (Flag) {
+  case true:
+break;
+  case false:
+break;
+  }
+}
+
+OS return_enumerator() {
+  return Linux;
+}
+
+// Enumpaths are already covered by a warning, this is just to ensure, that there is
+// no interference or false 

[PATCH] D40673: Add _Float128 as alias to __float128 to enable compilations on Fedora27/glibc2-26

2017-12-01 Thread Melanie Blower via Phabricator via cfe-commits
mibintc abandoned this revision.
mibintc added a comment.

Thanks for all your reviews


https://reviews.llvm.org/D40673



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


[PATCH] D40580: [clang-tidy] Adding Fuchsia checker for multiple inheritance

2017-12-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/fuchsia/MultipleInheritanceCheck.cpp:35
+  StringRef Name = Node->getIdentifier()->getName();
+  auto Pair = InterfaceMap.find(Name);
+  if (Pair == InterfaceMap.end())

Don't use `auto` as the type is not spelled out explicitly in the 
initialization.



Comment at: clang-tidy/fuchsia/MultipleInheritanceCheck.cpp:60
+  // To be an interface, all base classes must be interfaces as well.
+  for (const auto  : Node->bases()) {
+const auto *Ty = I.getType()->getAs();

What about virtual bases (`Node->vbases()`)? This would also be worth some test 
cases.



Comment at: clang-tidy/fuchsia/MultipleInheritanceCheck.cpp:77
+  // Match declarations which have definitions.
+  Finder->addMatcher(cxxRecordDecl(hasDefinition()).bind("decl"), this);
+}

It might be nice to not bother matching class definitions that have no bases or 
virtual bases rather than matching every class definition. However, this could 
be done in a follow-up patch (it likely requires adding an AST matcher).



Comment at: clang-tidy/fuchsia/MultipleInheritanceCheck.cpp:85
+unsigned NumConcrete = 0;
+for (const auto  : D->bases()) {
+  const auto *Ty = I.getType()->getAs();

And virtual bases?



Comment at: clang-tidy/fuchsia/MultipleInheritanceCheck.cpp:88
+  assert(Ty && "RecordType of base class is unknown");
+  const auto *Base = cast(Ty->getDecl()->getDefinition());
+  if (!isInterface(Base)) NumConcrete++;

It might make sense to add a degenerate case here to ensure a base class 
without a definition doesn't cause a null pointer dereference. e.g.,
```
struct B;

struct D : B {}; // compile error, B is not a complete type
```
I'm not certain whether Clang's AST will contain the base or not.



Comment at: clang-tidy/fuchsia/MultipleInheritanceCheck.h:34-36
+  bool getInterfaceStatus(const CXXRecordDecl *Node, bool );
+  bool isCurrentClassInterface(const CXXRecordDecl *Node);
+  bool isInterface(const CXXRecordDecl *Node);

I believe all these methods can be marked `const`.



Comment at: test/clang-tidy/fuchsia-multiple-inheritance.cpp:80
+};
+
+int main(void) {

Please add a test case consisting of only data members, e.g.,
```
struct B1 {
  int x;
};

struct B2 {
  int x;
};

struct D : B1, B2 {};
```


https://reviews.llvm.org/D40580



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


[PATCH] D40687: [compiler-rt] Switch to add_llvm_install_targets

2017-12-01 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

This change isn't safe. Compiler-RT is buildable without LLVM's modules as long 
as you disable the tests, so you can't use an AddLLVM function inside 
AddCompilerRT unless it is only used when tests are disabled.


https://reviews.llvm.org/D40687



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


r319560 - [OPENMP] Do not allow variables to be first|last-privates in

2017-12-01 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Dec  1 09:40:15 2017
New Revision: 319560

URL: http://llvm.org/viewvc/llvm-project?rev=319560=rev
Log:
[OPENMP] Do not allow variables to be first|last-privates in
distribute directives.

OpenMP standard does not allow to mark the variables as firstprivate and 
lastprivate at the same time in distribute-based directives. Patch fixes this 
problem.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_ast_print.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_lastprivate_messages.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_ast_print.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_lastprivate_messages.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_misc_messages.c
cfe/trunk/test/OpenMP/distribute_simd_ast_print.cpp
cfe/trunk/test/OpenMP/distribute_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/distribute_simd_lastprivate_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_lastprivate_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_loop_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_misc_messages.c

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_lastprivate_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_loop_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_misc_messages.c

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_lastprivate_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_loop_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_misc_messages.c
cfe/trunk/test/OpenMP/target_teams_distribute_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_lastprivate_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_misc_messages.c
cfe/trunk/test/OpenMP/teams_distribute_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_lastprivate_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_loop_messages.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_lastprivate_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_loop_messages.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_messages.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_lastprivate_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_lastprivate_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_loop_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=319560=319559=319560=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Dec  1 09:40:15 2017
@@ -9146,7 +9146,8 @@ OMPClause *Sema::ActOnOpenMPFirstprivate
   // A list item may appear in a firstprivate or lastprivate clause but not
   // both.
   if (DVar.CKind != OMPC_unknown && DVar.CKind != OMPC_firstprivate &&
-  (CurrDir == OMPD_distribute || DVar.CKind != OMPC_lastprivate) &&
+  (isOpenMPDistributeDirective(CurrDir) ||
+   DVar.CKind != OMPC_lastprivate) &&
   DVar.RefExpr) {
 Diag(ELoc, diag::err_omp_wrong_dsa)
 << getOpenMPClauseName(DVar.CKind)
@@ -9240,14 +9241,7 @@ OMPClause *Sema::ActOnOpenMPFirstprivate
   // OpenMP 4.5 [2.15.5.1, Restrictions, p.3]
   // A list item cannot appear in both a map clause and a data-sharing
   // attribute clause on the same construct
-  if (CurrDir == OMPD_target || CurrDir == OMPD_target_parallel ||
-  CurrDir == OMPD_target_teams || 
-  CurrDir == OMPD_target_teams_distribute ||
-  CurrDir == OMPD_target_teams_distribute_parallel_for ||
-  CurrDir == OMPD_target_teams_distribute_parallel_for_simd ||
-  CurrDir == OMPD_target_teams_distribute_simd ||
-  CurrDir == OMPD_target_parallel_for_simd ||
-  CurrDir == OMPD_target_parallel_for) {
+  if 

[PATCH] D40671: [clang-tidy] Support specific checks for NOLINT directive

2017-12-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

This feature should probably be mentioned in the release notes.


https://reviews.llvm.org/D40671



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


[PATCH] D38845: [ASTImporter] Support importing UnresolvedMemberExpr, DependentNameType, DependentScopeDeclRefExpr

2017-12-01 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Hello Peter. Please set the dependencies for the patch - it cannot be applied 
clearly and even if I add ImportTemplateArgumentListInfo, tests still fail - 
looks like FunctionTemplateDecl patch should be applied first.


https://reviews.llvm.org/D38845



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


[clang-tools-extra] r319557 - [clangd] Fuzzy match scorer

2017-12-01 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Fri Dec  1 09:08:02 2017
New Revision: 319557

URL: http://llvm.org/viewvc/llvm-project?rev=319557=rev
Log:
[clangd] Fuzzy match scorer

Summary:
This will be used for rescoring code completion results based on partial
identifiers.
Short-term use:
  - we want to limit the number of code completion results returned to
  improve performance of global completion. The scorer will be used to
  rerank the results to return when the user has applied a filter.
Long-term use case:
  - ranking of completion results from in-memory index
  - merging of completion results from multiple sources (merging usually
  works best when done at the component-score level, rescoring the
  fuzzy-match quality avoids different backends needing to have
  comparable scores)

Reviewers: ilya-biryukov

Subscribers: cfe-commits, mgorny

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

Added:
clang-tools-extra/trunk/clangd/FuzzyMatch.cpp
clang-tools-extra/trunk/clangd/FuzzyMatch.h
clang-tools-extra/trunk/unittests/clangd/FuzzyMatchTests.cpp
Modified:
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=319557=319556=319557=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Fri Dec  1 09:08:02 2017
@@ -8,6 +8,7 @@ add_clang_library(clangDaemon
   ClangdUnit.cpp
   ClangdUnitStore.cpp
   DraftStore.cpp
+  FuzzyMatch.cpp
   GlobalCompilationDatabase.cpp
   JSONExpr.cpp
   JSONRPCDispatcher.cpp

Added: clang-tools-extra/trunk/clangd/FuzzyMatch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FuzzyMatch.cpp?rev=319557=auto
==
--- clang-tools-extra/trunk/clangd/FuzzyMatch.cpp (added)
+++ clang-tools-extra/trunk/clangd/FuzzyMatch.cpp Fri Dec  1 09:08:02 2017
@@ -0,0 +1,373 @@
+//===--- FuzzyMatch.h - Approximate identifier matching  -*- 
C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// To check for a match between a Pattern ('u_p') and a Word ('unique_ptr'),
+// we consider the possible partial match states:
+//
+// u n i q u e _ p t r
+//   +-
+//   |A . . . . . . . . . .
+//  u|
+//   |. . . . . . . . . . .
+//  _|
+//   |. . . . . . . O . . .
+//  p|
+//   |. . . . . . . . . . B
+//
+// Each dot represents some prefix of the pattern being matched against some
+// prefix of the word.
+//   - A is the initial state: '' matched against ''
+//   - O is an intermediate state: 'u_' matched against 'unique_'
+//   - B is the target state: 'u_p' matched against 'unique_ptr'
+//
+// We aim to find the best path from A->B.
+//  - Moving right (consuming a word character)
+//Always legal: not all word characters must match.
+//  - Moving diagonally (consuming both a word and pattern character)
+//Legal if the characters match.
+//  - Moving down (consuming a pattern character) is never legal.
+//Never legal: all pattern characters must match something.
+//
+// The scoring is based on heuristics:
+//  - when matching a character, apply a bonus or penalty depending on the
+//match quality (does case match, do word segments align, etc)
+//  - when skipping a character, apply a penalty if it hurts the match
+//(it starts a word segment, or splits the matched region, etc)
+//
+// These heuristics require the ability to "look backward" one character, to
+// see whether it was matched or not. Therefore the dynamic-programming matrix
+// has an extra dimension (last character matched).
+// Each entry also has an additional flag indicating whether the last-but-one
+// character matched, which is needed to trace back through the scoring table
+// and reconstruct the match.
+//
+// We treat strings as byte-sequences, so only ASCII has first-class support.
+//
+// This algorithm was inspired by VS code's client-side filtering, and aims
+// to be mostly-compatible.
+//
+//===--===//
+
+#include "FuzzyMatch.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/Support/Format.h"
+
+using namespace llvm;
+using namespace clang::clangd;
+
+const int FuzzyMatcher::MaxPat;
+const int FuzzyMatcher::MaxWord;
+
+static char lower(char C) { return C >= 'A' && C <= 'Z' ? C + ('a' - 'A') : C; 
}
+// A "negative infinity" score that won't overflow.
+// We use this to mark unreachable states and forbidden solutions.
+// Score field is 15 bits 

[PATCH] D40625: Harmonizing attribute GNU/C++ spellings

2017-12-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/Attr.td:602
 def AnalyzerNoReturn : InheritableAttr {
-  let Spellings = [GNU<"analyzer_noreturn">];
+  let Spellings = [Clang<"analyzer_noreturn">];
   let Documentation = [Undocumented];

dcoughlin wrote:
> aaron.ballman wrote:
> > rsmith wrote:
> > > Hmm, should the clang static analyzer reuse the `clang::` namespace, or 
> > > should it get its own?
> > Good question, I don't have strong opinions on the answer here, but perhaps 
> > @dcoughlin does?
> > 
> > If we want to use a separate namespace for the analyzer, would we want to 
> > use that same namespace for any clang-tidy specific attributes? Or should 
> > clang-tidy get its own namespace? (Do we ever plan to execute clang-tidy 
> > through the clang driver? That might change our answer.)
> How would this look if we added a special namespace for the clang static 
> analyzer? Would this lead to duplication (say, 
> [[clang_analyzer::analyzer_noreturn]]) so that we keep the "analyzer_" prefix 
> for __attribute__((analyzer_noreturn))? Or could we have the "analyzer_" 
> prefix only for GNU-style attributes but not for C++ (for example, 
> [[clang_analyzer::noreturn]])?
> 
> As for clang-tidy, I think it probably makes sense for it to have its own 
> namespace, but we should ask @alexfh.
> How would this look if we added a special namespace for the clang static 
> analyzer? Would this lead to duplication (say, 
> [[clang_analyzer::analyzer_noreturn]]) so that we keep the "analyzer_" prefix 
> for attribute((analyzer_noreturn))? Or could we have the "analyzer_" prefix 
> only for GNU-style attributes but not for C++ (for example, 
> [[clang_analyzer::noreturn]])?

We have the ability to do whatever we'd like there. Given that the semantics 
are so similar to `[[noreturn]]`, I think it would be reasonable to use 
`[[clang_analyzer::noreturn]]` and `__attribute__((analyzer_noreturn))` if 
that's the direction you think is best.

> As for clang-tidy, I think it probably makes sense for it to have its own 
> namespace, but we should ask @alexfh.

I'm less enthusiastic about giving clang-tidy a vendor namespace that's 
separate from the static analyzer, should the need arise. My biggest concern 
there is that I would *really* like to see clang-tidy be more tightly 
integrated with the clang driver (so users don't have to manually execute a 
secondary tool). If that were to happen, then the user experience would be that 
there are two vendor namespaces both related to analyzer attributes.

That said, I would also not be opposed to putting all of these attributes under 
the `clang` vendor namespace and not having a separate vendor for the analyzer 
or clang-tidy.


https://reviews.llvm.org/D40625



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


r319555 - Disallow a cleanup attribute from appertaining to a parameter (the attribute only appertains to local variables and is silently a noop on parameters). This repurposes the unused (and syntact

2017-12-01 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Dec  1 08:53:49 2017
New Revision: 319555

URL: http://llvm.org/viewvc/llvm-project?rev=319555=rev
Log:
Disallow a cleanup attribute from appertaining to a parameter (the attribute 
only appertains to local variables and is silently a noop on parameters). This 
repurposes the unused (and syntactically incorrect) NormalVar attribute subject.

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/attr-cleanup.c

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=319555=319554=319555=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Fri Dec  1 08:53:49 2017
@@ -77,13 +77,8 @@ class SubsetSubjectgetStorageClass() != VarDecl::Register &&
-S->getKind() != Decl::ImplicitParam &&
-S->getKind() != Decl::ParmVar &&
-S->getKind() != Decl::NonTypeTemplateParm}],
+def LocalVar : SubsetSubjecthasLocalStorage() && !isa(S)}],
   "local variables">;
 def NonParmVar : SubsetSubjectgetKind() != Decl::ParmVar}],
@@ -533,7 +528,6 @@ def Alias : Attr {
 def Aligned : InheritableAttr {
   let Spellings = [GCC<"aligned">, Declspec<"align">, Keyword<"alignas">,
Keyword<"_Alignas">];
-//  let Subjects = SubjectList<[NonBitField, NormalVar, Tag]>;
   let Args = [AlignedArgument<"Alignment", 1>];
   let Accessors = [Accessor<"isGNU", [GCC<"aligned">]>,
Accessor<"isC11", [Keyword<"_Alignas">]>,
@@ -768,7 +762,7 @@ def CFConsumed : InheritableParamAttr {
 def Cleanup : InheritableAttr {
   let Spellings = [GCC<"cleanup">];
   let Args = [FunctionArgument<"FunctionDecl">];
-  let Subjects = SubjectList<[Var]>;
+  let Subjects = SubjectList<[LocalVar]>;
   let Documentation = [Undocumented];
 }
 

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=319555=319554=319555=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Dec  1 08:53:49 2017
@@ -3067,12 +3067,6 @@ static void handleTargetAttr(Sema , De
 }
 
 static void handleCleanupAttr(Sema , Decl *D, const AttributeList ) {
-  VarDecl *VD = cast(D);
-  if (!VD->hasLocalStorage()) {
-S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
-return;
-  }
-
   Expr *E = Attr.getArgAsExpr(0);
   SourceLocation Loc = E->getExprLoc();
   FunctionDecl *FD = nullptr;
@@ -3115,7 +3109,7 @@ static void handleCleanupAttr(Sema , D
 
   // We're currently more strict than GCC about what function types we accept.
   // If this ever proves to be a problem it should be easy to fix.
-  QualType Ty = S.Context.getPointerType(VD->getType());
+  QualType Ty = S.Context.getPointerType(cast(D)->getType());
   QualType ParamTy = FD->getParamDecl(0)->getType();
   if (S.CheckAssignmentConstraints(FD->getParamDecl(0)->getLocation(),
ParamTy, Ty) != Sema::Compatible) {

Modified: cfe/trunk/test/Sema/attr-cleanup.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-cleanup.c?rev=319555=319554=319555=diff
==
--- cfe/trunk/test/Sema/attr-cleanup.c (original)
+++ cfe/trunk/test/Sema/attr-cleanup.c Fri Dec  1 08:53:49 2017
@@ -2,16 +2,16 @@
 
 void c1(int *a);
 
-extern int g1 __attribute((cleanup(c1))); // expected-warning {{'cleanup' 
attribute ignored}}
-int g2 __attribute((cleanup(c1))); // expected-warning {{'cleanup' attribute 
ignored}}
-static int g3 __attribute((cleanup(c1))); // expected-warning {{'cleanup' 
attribute ignored}}
+extern int g1 __attribute((cleanup(c1))); // expected-warning {{'cleanup' 
attribute only applies to local variables}}
+int g2 __attribute((cleanup(c1))); // expected-warning {{'cleanup' attribute 
only applies to local variables}}
+static int g3 __attribute((cleanup(c1))); // expected-warning {{'cleanup' 
attribute only applies to local variables}}
 
 void t1()
 {
 int v1 __attribute((cleanup)); // expected-error {{'cleanup' attribute 
takes one argument}}
 int v2 __attribute((cleanup(1, 2))); // expected-error {{'cleanup' 
attribute takes one argument}}
 
-static int v3 __attribute((cleanup(c1))); // expected-warning {{'cleanup' 
attribute ignored}}
+static int v3 __attribute((cleanup(c1))); // expected-warning {{'cleanup' 
attribute only applies to local variables}}
 
 int v4 __attribute((cleanup(h))); // expected-error {{use of undeclared 
identifier 'h'}}
 
@@ -46,3 

[PATCH] D15406: Add warning for attribute-cleanup on function parameter.

2017-12-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

I committed a different fix for this in r319555.


https://reviews.llvm.org/D15406



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


[PATCH] D39279: Stringizing raw string literals containing newline

2017-12-01 Thread Jan Korous via Phabricator via cfe-commits
jkorous-apple added a comment.

Thank you for your patience @twoh and sorry for the delay.
I have few suggestions about doxygen annotations but otherwise LGTM.




Comment at: include/clang/Lex/Lexer.h:247
+  /// add surrounding ""'s to the string. If Charify is true, this escapes the
+  /// ' character instead of ".
   static std::string Stringify(StringRef Str, bool Charify = false);

Shouldn't we put all the details from implementation annotation here as well 
(since this is the public interface that people will actually use)?



Comment at: include/clang/Lex/Lexer.h:251
+  /// Stringify - Convert the specified string into a C string. This does not
+  /// add surrounding ""'s to the string.
   static void Stringify(SmallVectorImpl );

Shouldn't we put all the details from implementation annotation here as well 
(since this is the public interface that people will actually use)?



Comment at: lib/Lex/Lexer.cpp:214
+/// specified string into a C string by i) escaping '\' and " characters and
+/// ii) replacing newline character(s) with "\n".
+template 

I am not sure I understand this correctly but wouldn't it be more precise if 
these literals are escaped?
... escaping '\' ... -> ...escaping '\\' ... 
... with "\n" ... -> ... with "\\n"

Alternatively we could use R"(\)" and R"(\n)".


https://reviews.llvm.org/D39279



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


[PATCH] D40720: No -fsanitize=function warning when calling noexcept function through non-noexcept pointer in C++17

2017-12-01 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg updated this revision to Diff 125152.
sberg added a comment.

(Diff 125121 had accidentally contained a spurious "}". Fixed that now.)


https://reviews.llvm.org/D40720

Files:
  clang/lib/CodeGen/CGExpr.cpp
  compiler-rt/lib/ubsan/ubsan_handlers.cc
  compiler-rt/lib/ubsan/ubsan_handlers.h
  compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp

Index: compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp
===
--- compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp
+++ compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp
@@ -1,4 +1,4 @@
-// RUN: %clangxx -fsanitize=function %s -O3 -g -o %t
+// RUN: %clangxx -std=c++17 -fsanitize=function %s -O3 -g -o %t
 // RUN: %run %t 2>&1 | FileCheck %s
 // Verify that we can disable symbolization if needed:
 // RUN: %env_ubsan_opts=symbolize=0 %run %t 2>&1 | FileCheck %s --check-prefix=NOSYM
@@ -23,9 +23,47 @@
   reinterpret_cast(reinterpret_cast(f))(42);
 }
 
+void f1(int) {}
+void f2(unsigned int) {}
+void f3(int) noexcept {}
+void f4(unsigned int) noexcept {}
+
+void check_noexcept_calls() {
+  void (*p1)(int);
+  p1 = 
+  p1(0);
+  p1 = reinterpret_cast();
+  // CHECK: function.cpp:[[@LINE+2]]:3: runtime error: call to function f2(unsigned int) through pointer to incorrect function type 'void (*)(int)'
+  // NOSYM: function.cpp:[[@LINE+1]]:3: runtime error: call to function (unknown) through pointer to incorrect function type 'void (*)(int)'
+  p1(0);
+  p1 = 
+  p1(0);
+  p1 = reinterpret_cast();
+  // CHECK: function.cpp:[[@LINE+2]]:3: runtime error: call to function f4(unsigned int) through pointer to incorrect function type 'void (*)(int)'
+  // NOSYM: function.cpp:[[@LINE+1]]:3: runtime error: call to function (unknown) through pointer to incorrect function type 'void (*)(int)'
+  p1(0);
+
+  void (*p2)(int) noexcept;
+  p2 = reinterpret_cast();
+  // CHECK: function.cpp:[[@LINE+2]]:3: runtime error: call to function f1(int) through pointer to incorrect function type 'void (*)(int) noexcept'
+  // NOSYM: function.cpp:[[@LINE+1]]:3: runtime error: call to function (unknown) through pointer to incorrect function type 'void (*)(int) noexcept'
+  p2(0);
+  p2 = reinterpret_cast();
+  // CHECK: function.cpp:[[@LINE+2]]:3: runtime error: call to function f2(unsigned int) through pointer to incorrect function type 'void (*)(int) noexcept'
+  // NOSYM: function.cpp:[[@LINE+1]]:3: runtime error: call to function (unknown) through pointer to incorrect function type 'void (*)(int) noexcept'
+  p2(0);
+  p2 = 
+  p2(0);
+  p2 = reinterpret_cast();
+  // CHECK: function.cpp:[[@LINE+2]]:3: runtime error: call to function f4(unsigned int) through pointer to incorrect function type 'void (*)(int) noexcept'
+  // NOSYM: function.cpp:[[@LINE+1]]:3: runtime error: call to function (unknown) through pointer to incorrect function type 'void (*)(int) noexcept'
+  p2(0);
+}
+
 int main(void) {
   make_valid_call();
   make_invalid_call();
+  check_noexcept_calls();
   // Check that no more errors will be printed.
   // CHECK-NOT: runtime error: call to function
   // NOSYM-NOT: runtime error: call to function
Index: compiler-rt/lib/ubsan/ubsan_handlers.h
===
--- compiler-rt/lib/ubsan/ubsan_handlers.h
+++ compiler-rt/lib/ubsan/ubsan_handlers.h
@@ -140,11 +140,12 @@
 struct FunctionTypeMismatchData {
   SourceLocation Loc;
   const TypeDescriptor 
+  ValueHandle NonNoexceptRTTI;
 };
 
 RECOVERABLE(function_type_mismatch,
 FunctionTypeMismatchData *Data,
-ValueHandle Val)
+ValueHandle Val, ValueHandle RTTI)
 
 struct NonNullReturnData {
   SourceLocation AttrLoc;
Index: compiler-rt/lib/ubsan/ubsan_handlers.cc
===
--- compiler-rt/lib/ubsan/ubsan_handlers.cc
+++ compiler-rt/lib/ubsan/ubsan_handlers.cc
@@ -18,6 +18,9 @@
 
 #include "sanitizer_common/sanitizer_common.h"
 
+#include 
+#include 
+
 using namespace __sanitizer;
 using namespace __ubsan;
 
@@ -462,14 +465,50 @@
   Die();
 }
 
-static void handleFunctionTypeMismatch(FunctionTypeMismatchData *Data,
-   ValueHandle Function,
+// Check that TI2 represents the same function type as TI1, except that TI2 has
+// "noexcept" and TI1 does not.
+static bool checkForAddedNoexcept(const std::type_info *TI1,
+  const std::type_info *TI2) {
+  const char *Mangled1 = TI1->name();
+  const char *Mangled2 = TI2->name();
+
+  // Skip .
+  if (*Mangled1 == 'V') {
+if (*Mangled2 != 'V')
+  return false;
+++Mangled1;
+++Mangled2;
+  }
+  if (*Mangled1 == 'K') {
+if (*Mangled2 != 'K')
+  return false;
+++Mangled1;
+++Mangled2;
+  }
+
+  // Check for "Do" .
+  if (*Mangled2++ != 'D' || *Mangled2++ != 'o')
+return false;
+
+  // Check remainder is identical.
+  return 

[clang-tools-extra] r319552 - [clangd] Filter completion results by fuzzy-matching identifiers.

2017-12-01 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Fri Dec  1 08:35:50 2017
New Revision: 319552

URL: http://llvm.org/viewvc/llvm-project?rev=319552=rev
Log:
[clangd] Filter completion results by fuzzy-matching identifiers.

Summary:
This allows us to limit the number of results we return and still allow them
to be surfaced by refining a query (D39852).

The initial algorithm is very conservative - it accepts a completion if the
filter is any case-insensitive sub-sequence. It does not attempt to rank items
based on match quality.

Reviewers: ilya-biryukov

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
clang-tools-extra/trunk/test/clangd/completion-items-kinds.test
clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=319552=319551=319552=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Fri Dec  1 08:35:50 2017
@@ -446,6 +446,7 @@ public:
   void ProcessCodeCompleteResults(Sema , CodeCompletionContext Context,
   CodeCompletionResult *Results,
   unsigned NumResults) override final {
+StringRef Filter = S.getPreprocessor().getCodeCompletionFilter();
 std::priority_queue Candidates;
 for (unsigned I = 0; I < NumResults; ++I) {
   auto  = Results[I];
@@ -453,6 +454,8 @@ public:
   (Result.Availability == CXAvailability_NotAvailable ||
Result.Availability == CXAvailability_NotAccessible))
 continue;
+  if (!Filter.empty() && !fuzzyMatch(S, Context, Filter, Result))
+continue;
   Candidates.emplace(Result);
   if (ClangdOpts.Limit && Candidates.size() > ClangdOpts.Limit) {
 Candidates.pop();
@@ -476,6 +479,39 @@ public:
   CodeCompletionTUInfo () override { return CCTUInfo; }
 
 private:
+  bool fuzzyMatch(Sema , const CodeCompletionContext , StringRef 
Filter,
+  CodeCompletionResult Result) {
+switch (Result.Kind) {
+case CodeCompletionResult::RK_Declaration:
+  if (auto *ID = Result.Declaration->getIdentifier())
+return fuzzyMatch(Filter, ID->getName());
+  break;
+case CodeCompletionResult::RK_Keyword:
+  return fuzzyMatch(Filter, Result.Keyword);
+case CodeCompletionResult::RK_Macro:
+  return fuzzyMatch(Filter, Result.Macro->getName());
+case CodeCompletionResult::RK_Pattern:
+  return fuzzyMatch(Filter, Result.Pattern->getTypedText());
+}
+auto *CCS = Result.CreateCodeCompletionString(
+S, CCCtx, *Allocator, CCTUInfo, /*IncludeBriefComments=*/false);
+return fuzzyMatch(Filter, CCS->getTypedText());
+  }
+
+  // Checks whether Target matches the Filter.
+  // Currently just requires a case-insensitive subsequence match.
+  // FIXME: make stricter and word-based: 'unique_ptr' should not match 'que'.
+  // FIXME: return a score to be incorporated into ranking.
+  static bool fuzzyMatch(StringRef Filter, StringRef Target) {
+size_t TPos = 0;
+for (char C : Filter) {
+  TPos = Target.find_lower(C, TPos);
+  if (TPos == StringRef::npos)
+return false;
+}
+return true;
+  }
+
   CompletionItem
   ProcessCodeCompleteResult(const CompletionCandidate ,
 const CodeCompletionString ) const {

Modified: clang-tools-extra/trunk/test/clangd/completion-items-kinds.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/completion-items-kinds.test?rev=319552=319551=319552=diff
==
--- clang-tools-extra/trunk/test/clangd/completion-items-kinds.test (original)
+++ clang-tools-extra/trunk/test/clangd/completion-items-kinds.test Fri Dec  1 
08:35:50 2017
@@ -30,7 +30,7 @@ Content-Length: 148
 # CHECK-SAME: ]}}
 Content-Length: 146
 
-{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"whi"}}}
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"nam"}}}
 Content-Length: 148
 
 
{"jsonrpc":"2.0","id":2,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":1,"character":3}}}

Modified: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp?rev=319552=319551=319552=diff
==
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp (original)
+++ 

[PATCH] D39882: [clangd] Filter completion results by fuzzy-matching identifiers.

2017-12-01 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319552: [clangd] Filter completion results by fuzzy-matching 
identifiers. (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D39882?vs=125009=125155#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39882

Files:
  clang-tools-extra/trunk/clangd/ClangdUnit.cpp
  clang-tools-extra/trunk/test/clangd/completion-items-kinds.test
  clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp

Index: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
@@ -742,6 +742,61 @@
   EXPECT_FALSE(ContainsItem(Results, "CCC"));
 }
 
+TEST_F(ClangdCompletionTest, Filter) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
+  CDB.ExtraClangFlags.push_back("-xc++");
+  ErrorCheckingDiagConsumer DiagConsumer;
+  clangd::CodeCompleteOptions Opts;
+  ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+  /*StorePreamblesInMemory=*/true, Opts,
+  EmptyLogger::getInstance());
+
+  auto FooCpp = getVirtualTestFilePath("foo.cpp");
+  FS.Files[FooCpp] = "";
+  FS.ExpectedFile = FooCpp;
+  const char *Body = R"cpp(
+int Abracadabra;
+int Alakazam;
+struct S {
+  int FooBar;
+  int FooBaz;
+  int Qux;
+};
+  )cpp";
+  auto Complete = [&](StringRef Query) {
+StringWithPos Completion = parseTextMarker(
+formatv("{0} int main() { {1}{{complete}} }", Body, Query).str(),
+"complete");
+Server.addDocument(FooCpp, Completion.Text);
+return Server
+.codeComplete(FooCpp, Completion.MarkerPos, StringRef(Completion.Text))
+.get()
+.Value;
+  };
+
+  auto Foba = Complete("S().Foba");
+  EXPECT_TRUE(ContainsItem(Foba, "FooBar"));
+  EXPECT_TRUE(ContainsItem(Foba, "FooBaz"));
+  EXPECT_FALSE(ContainsItem(Foba, "Qux"));
+
+  auto FR = Complete("S().FR");
+  EXPECT_TRUE(ContainsItem(FR, "FooBar"));
+  EXPECT_FALSE(ContainsItem(FR, "FooBaz"));
+  EXPECT_FALSE(ContainsItem(FR, "Qux"));
+
+  auto Op = Complete("S().opr");
+  EXPECT_TRUE(ContainsItem(Op, "operator="));
+
+  auto Aaa = Complete("aaa");
+  EXPECT_TRUE(ContainsItem(Aaa, "Abracadabra"));
+  EXPECT_TRUE(ContainsItem(Aaa, "Alakazam"));
+
+  auto UA = Complete("_a");
+  EXPECT_TRUE(ContainsItem(UA, "static_cast"));
+  EXPECT_FALSE(ContainsItem(UA, "Abracadabra"));
+}
+
 TEST_F(ClangdCompletionTest, CompletionOptions) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp
@@ -446,13 +446,16 @@
   void ProcessCodeCompleteResults(Sema , CodeCompletionContext Context,
   CodeCompletionResult *Results,
   unsigned NumResults) override final {
+StringRef Filter = S.getPreprocessor().getCodeCompletionFilter();
 std::priority_queue Candidates;
 for (unsigned I = 0; I < NumResults; ++I) {
   auto  = Results[I];
   if (!ClangdOpts.IncludeIneligibleResults &&
   (Result.Availability == CXAvailability_NotAvailable ||
Result.Availability == CXAvailability_NotAccessible))
 continue;
+  if (!Filter.empty() && !fuzzyMatch(S, Context, Filter, Result))
+continue;
   Candidates.emplace(Result);
   if (ClangdOpts.Limit && Candidates.size() > ClangdOpts.Limit) {
 Candidates.pop();
@@ -476,6 +479,39 @@
   CodeCompletionTUInfo () override { return CCTUInfo; }
 
 private:
+  bool fuzzyMatch(Sema , const CodeCompletionContext , StringRef Filter,
+  CodeCompletionResult Result) {
+switch (Result.Kind) {
+case CodeCompletionResult::RK_Declaration:
+  if (auto *ID = Result.Declaration->getIdentifier())
+return fuzzyMatch(Filter, ID->getName());
+  break;
+case CodeCompletionResult::RK_Keyword:
+  return fuzzyMatch(Filter, Result.Keyword);
+case CodeCompletionResult::RK_Macro:
+  return fuzzyMatch(Filter, Result.Macro->getName());
+case CodeCompletionResult::RK_Pattern:
+  return fuzzyMatch(Filter, Result.Pattern->getTypedText());
+}
+auto *CCS = Result.CreateCodeCompletionString(
+S, CCCtx, *Allocator, CCTUInfo, /*IncludeBriefComments=*/false);
+return fuzzyMatch(Filter, CCS->getTypedText());
+  }
+
+  // Checks whether Target matches the Filter.
+  // Currently just requires a case-insensitive subsequence match.
+  // FIXME: make stricter and word-based: 'unique_ptr' should not match 'que'.
+  // FIXME: return a score to be incorporated into ranking.
+  static bool fuzzyMatch(StringRef 

[PATCH] D39882: [clangd] Filter completion results by fuzzy-matching identifiers.

2017-12-01 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE319552: [clangd] Filter completion results by 
fuzzy-matching identifiers. (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D39882?vs=125009=125154#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39882

Files:
  clangd/ClangdUnit.cpp
  test/clangd/completion-items-kinds.test
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -742,6 +742,61 @@
   EXPECT_FALSE(ContainsItem(Results, "CCC"));
 }
 
+TEST_F(ClangdCompletionTest, Filter) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
+  CDB.ExtraClangFlags.push_back("-xc++");
+  ErrorCheckingDiagConsumer DiagConsumer;
+  clangd::CodeCompleteOptions Opts;
+  ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+  /*StorePreamblesInMemory=*/true, Opts,
+  EmptyLogger::getInstance());
+
+  auto FooCpp = getVirtualTestFilePath("foo.cpp");
+  FS.Files[FooCpp] = "";
+  FS.ExpectedFile = FooCpp;
+  const char *Body = R"cpp(
+int Abracadabra;
+int Alakazam;
+struct S {
+  int FooBar;
+  int FooBaz;
+  int Qux;
+};
+  )cpp";
+  auto Complete = [&](StringRef Query) {
+StringWithPos Completion = parseTextMarker(
+formatv("{0} int main() { {1}{{complete}} }", Body, Query).str(),
+"complete");
+Server.addDocument(FooCpp, Completion.Text);
+return Server
+.codeComplete(FooCpp, Completion.MarkerPos, StringRef(Completion.Text))
+.get()
+.Value;
+  };
+
+  auto Foba = Complete("S().Foba");
+  EXPECT_TRUE(ContainsItem(Foba, "FooBar"));
+  EXPECT_TRUE(ContainsItem(Foba, "FooBaz"));
+  EXPECT_FALSE(ContainsItem(Foba, "Qux"));
+
+  auto FR = Complete("S().FR");
+  EXPECT_TRUE(ContainsItem(FR, "FooBar"));
+  EXPECT_FALSE(ContainsItem(FR, "FooBaz"));
+  EXPECT_FALSE(ContainsItem(FR, "Qux"));
+
+  auto Op = Complete("S().opr");
+  EXPECT_TRUE(ContainsItem(Op, "operator="));
+
+  auto Aaa = Complete("aaa");
+  EXPECT_TRUE(ContainsItem(Aaa, "Abracadabra"));
+  EXPECT_TRUE(ContainsItem(Aaa, "Alakazam"));
+
+  auto UA = Complete("_a");
+  EXPECT_TRUE(ContainsItem(UA, "static_cast"));
+  EXPECT_FALSE(ContainsItem(UA, "Abracadabra"));
+}
+
 TEST_F(ClangdCompletionTest, CompletionOptions) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -446,13 +446,16 @@
   void ProcessCodeCompleteResults(Sema , CodeCompletionContext Context,
   CodeCompletionResult *Results,
   unsigned NumResults) override final {
+StringRef Filter = S.getPreprocessor().getCodeCompletionFilter();
 std::priority_queue Candidates;
 for (unsigned I = 0; I < NumResults; ++I) {
   auto  = Results[I];
   if (!ClangdOpts.IncludeIneligibleResults &&
   (Result.Availability == CXAvailability_NotAvailable ||
Result.Availability == CXAvailability_NotAccessible))
 continue;
+  if (!Filter.empty() && !fuzzyMatch(S, Context, Filter, Result))
+continue;
   Candidates.emplace(Result);
   if (ClangdOpts.Limit && Candidates.size() > ClangdOpts.Limit) {
 Candidates.pop();
@@ -476,6 +479,39 @@
   CodeCompletionTUInfo () override { return CCTUInfo; }
 
 private:
+  bool fuzzyMatch(Sema , const CodeCompletionContext , StringRef Filter,
+  CodeCompletionResult Result) {
+switch (Result.Kind) {
+case CodeCompletionResult::RK_Declaration:
+  if (auto *ID = Result.Declaration->getIdentifier())
+return fuzzyMatch(Filter, ID->getName());
+  break;
+case CodeCompletionResult::RK_Keyword:
+  return fuzzyMatch(Filter, Result.Keyword);
+case CodeCompletionResult::RK_Macro:
+  return fuzzyMatch(Filter, Result.Macro->getName());
+case CodeCompletionResult::RK_Pattern:
+  return fuzzyMatch(Filter, Result.Pattern->getTypedText());
+}
+auto *CCS = Result.CreateCodeCompletionString(
+S, CCCtx, *Allocator, CCTUInfo, /*IncludeBriefComments=*/false);
+return fuzzyMatch(Filter, CCS->getTypedText());
+  }
+
+  // Checks whether Target matches the Filter.
+  // Currently just requires a case-insensitive subsequence match.
+  // FIXME: make stricter and word-based: 'unique_ptr' should not match 'que'.
+  // FIXME: return a score to be incorporated into ranking.
+  static bool fuzzyMatch(StringRef Filter, StringRef Target) {
+size_t TPos = 0;
+for (char C : Filter) {
+  TPos = Target.find_lower(C, TPos);
+  if (TPos == StringRef::npos)
+return false;
+}
+return true;
+  }
+
   

[PATCH] D40660: Enable auto-linking on Windows

2017-12-01 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai accepted this revision.
smeenai added a comment.
This revision is now accepted and ready to land.

I think it would make sense for this change to also have the conditional for 
the static C++ library selection. Basically something like

  #if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
  # if defined(_DLL)
  #  pragma comment(lib, "c++.lib")
  # else
  #  pragma comment(lib, "libc++.lib")
  # endif
  #endif

If you wanna be super consistent with `use_ansi.h`, change the second condition 
to

  # if defined(_DLL) && !defined(_STATIC_CPPLIB)

LGTM with that.

Also, the diff needs more context :)




Comment at: include/__config:1267
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)
+# pragma comment(lib, "c++d.lib")

compnerd wrote:
> smeenai wrote:
> > compnerd wrote:
> > > smeenai wrote:
> > > > I guess `_DLL` is appropriate here. Ideally though I think adding the 
> > > > pragma should be keyed on exactly the same conditional that determines 
> > > > whether we annotate with dllexport/dllimport, and right now that's only 
> > > > conditional on `_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS`.
> > > Its more complicated.  This is for the *user* not the library itself.  
> > > When building the shared library we need to ensure that it is not added 
> > > (`!defined(_LIBCPP_BUILDING_LIBRARY)`).  When using the headers as a 
> > > user, the `_DLL` tells you about the dynamic/static behavior.
> > I know, but the dllimport annotations are also for the *user*. If you're 
> > getting the dllimport annotations, you should also be getting the pragma, 
> > and vice-versa.
> Right, but `_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS` does not imply use of a 
> static libc++, but `!defined(_DLL)` does, unless Im missing something.  So 
> doesn't this do exactly what you were thinking of?
What I meant was, this is our current logic for determining whether dllimport 
annotations are used: 
https://reviews.llvm.org/diffusion/L/browse/libcxx/trunk/include/__config;319549$616-632.
 In other words, you get the dllimport annotations if 
`_LIBCPP_OBJECT_FORMAT_COFF && !_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS && 
!_LIBCPP_BUILDING_LIBRARY`.

I agree that semantically, `_DLL` is the right thing to key the pragma on. 
However, the condition for the pragma and the condition for dllimport 
annotations is now inconsistent, so we can end up in situations where we get 
the pragma but not the dllimport annotations, or vice versa, which seems wrong.

Making the conditionals consistent is hairy, however, because `_DLL` won't be 
defined for non-MSVC drivers, and the dllimport codepath is required for all of 
Windows. I'm fine with this as is, and we can think more about that consistency 
later.

Do you think you also wanna add a pragma for the non-DLL codepath 
(`libc++.lib`)? Could do that in a follow-up as well, but it seems natural to 
have that as part of this change, and it would be more consistent with how 
`use_ansi.h` does it.

Looks like msvcprt also has `_STATIC_CPPLIB` for forcing the use of the static 
C++ library even when `_DLL`. Idk if we care about supporting that.


Repository:
  rCXX libc++

https://reviews.llvm.org/D40660



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


[PATCH] D40733: [clangd] GlobalCompilationDatabase interface changes

2017-12-01 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
Herald added subscribers: cfe-commits, klimek.

- GlobalCompilationDatabase now returns a single command (that's all we use)
- fallback flags are now part of the GlobalCompilationDatabase. There's a 
default implementation that they can optionally customize.
- this allows us to avoid invoking the fallback logic on two separate codepaths
- race on extra flags fixed by locking the mutex
- made GCD const-correct (DBGCD does have mutating methods)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40733

Files:
  clangd/ClangdUnitStore.cpp
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -212,21 +212,17 @@
   ExtraClangFlags.push_back("-ffreestanding");
   }
 
-  std::vector
-  getCompileCommands(PathRef File) override {
+  llvm::Optional
+  getCompileCommand(PathRef File) const override {
 if (ExtraClangFlags.empty())
-  return {};
-
-std::vector CommandLine;
-CommandLine.reserve(3 + ExtraClangFlags.size());
-CommandLine.insert(CommandLine.end(), {"clang", "-fsyntax-only"});
-CommandLine.insert(CommandLine.end(), ExtraClangFlags.begin(),
-   ExtraClangFlags.end());
-CommandLine.push_back(File.str());
+  return llvm::None;
 
+auto CommandLine = ExtraClangFlags;
+CommandLine.insert(CommandLine.begin(), "clang");
+CommandLine.insert(CommandLine.end(), File.str());
 return {tooling::CompileCommand(llvm::sys::path::parent_path(File),
 llvm::sys::path::filename(File),
-CommandLine, "")};
+std::move(CommandLine), "")};
   }
 
   std::vector ExtraClangFlags;
Index: clangd/GlobalCompilationDatabase.h
===
--- clangd/GlobalCompilationDatabase.h
+++ clangd/GlobalCompilationDatabase.h
@@ -27,16 +27,19 @@
 
 class Logger;
 
-/// Returns a default compile command to use for \p File.
-tooling::CompileCommand getDefaultCompileCommand(PathRef File);
-
 /// Provides compilation arguments used for parsing C and C++ files.
 class GlobalCompilationDatabase {
 public:
   virtual ~GlobalCompilationDatabase() = default;
 
-  virtual std::vector
-  getCompileCommands(PathRef File) = 0;
+  /// If there are any known-good commands for building this file, returns one.
+  virtual llvm::Optional
+  getCompileCommand(PathRef File) const = 0;
+
+  /// Makes a guess at how to build a file.
+  /// The default implementation just runs clang on the file.
+  /// Clangd should treat the results as unreliable.
+  virtual tooling::CompileCommand getFallbackCommand(PathRef File) const;
 
   /// FIXME(ibiryukov): add facilities to track changes to compilation flags of
   /// existing targets.
@@ -50,19 +53,26 @@
   DirectoryBasedGlobalCompilationDatabase(
   clangd::Logger , llvm::Optional CompileCommandsDir);
 
-  std::vector
-  getCompileCommands(PathRef File) override;
+  /// Scans File's parents looking for compilation databases.
+  /// Any extra flags will be added.
+  llvm::Optional
+  getCompileCommand(PathRef File) const override;
+
+  /// Uses the default fallback command, adding any extra flags.
+  tooling::CompileCommand getFallbackCommand(PathRef File) const override;
 
+  /// Sets the extra flags that should be added to a file.
   void setExtraFlagsForFile(PathRef File, std::vector ExtraFlags);
 
 private:
-  tooling::CompilationDatabase *getCompilationDatabase(PathRef File);
-  tooling::CompilationDatabase *tryLoadDatabaseFromPath(PathRef File);
+  tooling::CompilationDatabase *getCompilationDatabase(PathRef File) const;
+  tooling::CompilationDatabase *tryLoadDatabaseFromPath(PathRef File) const;
+  void addExtraFlags(PathRef File, tooling::CompileCommand ) const;
 
-  std::mutex Mutex;
+  mutable std::mutex Mutex;
   /// Caches compilation databases loaded from directories(keys are
   /// directories).
-  llvm::StringMap
+  mutable llvm::StringMap
   CompilationDatabases;
 
   /// Stores extra flags per file.
Index: clangd/GlobalCompilationDatabase.cpp
===
--- clangd/GlobalCompilationDatabase.cpp
+++ clangd/GlobalCompilationDatabase.cpp
@@ -16,59 +16,63 @@
 namespace clang {
 namespace clangd {
 
-static void addExtraFlags(tooling::CompileCommand ,
-  const std::vector ) {
-  if (ExtraFlags.empty())
-return;
-  assert(Command.CommandLine.size() >= 2 &&
- "Expected a command line containing at least 2 arguments, the "
- "compiler binary and the output file");
-  // The last argument of CommandLine is the name of the input file.
-  // Add ExtraFlags before it.

[PATCH] D39882: [clangd] Filter completion results by fuzzy-matching identifiers.

2017-12-01 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D39882



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


[PATCH] D40625: Harmonizing attribute GNU/C++ spellings

2017-12-01 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a subscriber: alexfh.
dcoughlin added inline comments.



Comment at: include/clang/Basic/Attr.td:602
 def AnalyzerNoReturn : InheritableAttr {
-  let Spellings = [GNU<"analyzer_noreturn">];
+  let Spellings = [Clang<"analyzer_noreturn">];
   let Documentation = [Undocumented];

aaron.ballman wrote:
> rsmith wrote:
> > Hmm, should the clang static analyzer reuse the `clang::` namespace, or 
> > should it get its own?
> Good question, I don't have strong opinions on the answer here, but perhaps 
> @dcoughlin does?
> 
> If we want to use a separate namespace for the analyzer, would we want to use 
> that same namespace for any clang-tidy specific attributes? Or should 
> clang-tidy get its own namespace? (Do we ever plan to execute clang-tidy 
> through the clang driver? That might change our answer.)
How would this look if we added a special namespace for the clang static 
analyzer? Would this lead to duplication (say, 
[[clang_analyzer::analyzer_noreturn]]) so that we keep the "analyzer_" prefix 
for __attribute__((analyzer_noreturn))? Or could we have the "analyzer_" prefix 
only for GNU-style attributes but not for C++ (for example, 
[[clang_analyzer::noreturn]])?

As for clang-tidy, I think it probably makes sense for it to have its own 
namespace, but we should ask @alexfh.


https://reviews.llvm.org/D40625



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


[PATCH] D40731: Integrate CHash into CLang

2017-12-01 Thread Christian Dietrich via Phabricator via cfe-commits
stettberger created this revision.
Herald added subscribers: cfe-commits, aprantl, mgorny.

The CHashVisitor can be used to determine a unique hash for a translation unit. 
The hash is stable across compiler invocations and if two translation units 
have the same hash, the resulting object file is semantically equal (code, 
data, etc. are equal; debug information may be different).


Repository:
  rC Clang

https://reviews.llvm.org/D40731

Files:
  include/clang/AST/AttrDataCollectors.td
  include/clang/AST/CHashVisitor.h
  include/clang/AST/CMakeLists.txt
  include/clang/AST/DeclDataCollectors.td
  include/clang/AST/StmtDataCollectors.td
  include/clang/AST/TypeDataCollectors.td
  unittests/AST/CHashTest.cpp
  unittests/AST/CMakeLists.txt

Index: unittests/AST/CMakeLists.txt
===
--- unittests/AST/CMakeLists.txt
+++ unittests/AST/CMakeLists.txt
@@ -18,6 +18,7 @@
   PostOrderASTVisitor.cpp
   SourceLocationTest.cpp
   StmtPrinterTest.cpp
+  CHashTest.cpp
   )
 
 target_link_libraries(ASTTests
Index: unittests/AST/CHashTest.cpp
===
--- /dev/null
+++ unittests/AST/CHashTest.cpp
@@ -0,0 +1,91 @@
+//===- unittests/AST/DataCollectionTest.cpp ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file contains tests for the DataCollection module.
+//
+// They work by hashing the collected data of two nodes and asserting that the
+// hash values are equal iff the nodes are considered equal.
+//
+//===--===//
+
+#include "clang/AST/CHashVisitor.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace clang;
+using namespace tooling;
+
+
+class CHashConsumer : public ASTConsumer {
+CompilerInstance 
+llvm::MD5::MD5Result *ASTHash;
+
+public:
+CHashConsumer(CompilerInstance , llvm::MD5::MD5Result *ASTHash)
+: CI(CI), ASTHash(ASTHash){}
+
+virtual void HandleTranslationUnit(clang::ASTContext ) override {
+TranslationUnitDecl *TU = Context.getTranslationUnitDecl();
+
+// Traversing the translation unit decl via a RecursiveASTVisitor
+// will visit all nodes in the AST.
+CHashVisitor<> Visitor(Context);
+Visitor.TraverseDecl(TU);
+// Copy Away the resulting hash
+*ASTHash = *Visitor.getHash(TU);
+
+}
+~CHashConsumer() override {}
+
+};
+
+class CHashAction : public ASTFrontendAction {
+public: // We are all friends
+llvm::MD5::MD5Result *Hash;
+
+CHashAction(llvm::MD5::MD5Result *Hash) : Hash(Hash) {}
+
+std::unique_ptr CreateASTConsumer(CompilerInstance ,
+   StringRef) override {
+return std::unique_ptr(new CHashConsumer(CI, Hash));
+}
+};
+
+static testing::AssertionResult
+isASTHashEqual(StringRef Code1, StringRef Code2) {
+llvm::MD5::MD5Result Hash1, Hash2;
+if (!runToolOnCode(new CHashAction(), Code1)) {
+return testing::AssertionFailure()
+<< "Parsing error in (A)\"" << Code1.str() << "\"";
+}
+if (!runToolOnCode(new CHashAction(), Code2)) {
+return testing::AssertionFailure()
+<< "Parsing error in (B) \"" << Code2.str() << "\"";
+}
+return testing::AssertionResult(Hash1 == Hash2);
+}
+
+TEST(CHashVisitor, TestRecordTypes) {
+ASSERT_TRUE(isASTHashEqual( // Unused struct
+ "struct foobar { int a0; char a1; unsigned long a2; };",
+ "struct foobar { int a0; char a1;};"
+ ));
+
+}
+
+TEST(CHashVisitor, TestSourceStructure) {
+ASSERT_FALSE(isASTHashEqual(
+ "void foo() { int c; if (0) { c = 1; } }",
+ "void foo() { int c; if (0) { } c = 1; }"));
+
+ASSERT_FALSE(isASTHashEqual(
+ "void f1() {} void f2() {   }",
+ "void f1() {} void f2() { f1(); }"));
+}
Index: include/clang/AST/TypeDataCollectors.td
===
--- include/clang/AST/TypeDataCollectors.td
+++ include/clang/AST/TypeDataCollectors.td
@@ -0,0 +1,66 @@
+//--- Types ---//
+class Type {
+  code Code = [{
+ addData(S->getTypeClass());
+  }];
+}
+
+class BuiltinType {
+   code Code = [{
+  addData(S->getKind());
+   }];
+}
+
+class ArrayType  {
+   code Code = [{
+  addData(S->getSizeModifier());
+  addData(S->getIndexTypeCVRQualifiers());
+   }];
+}
+
+class ConstantArrayType {
+   code Code = [{
+  addData(S->getSize().getZExtValue());
+   }];
+}
+
+class VectorType 

[clang-tools-extra] r319460 - add new check to find NSError init invocation

2017-12-01 Thread Yan Zhang via cfe-commits
Author: wizard
Date: Thu Nov 30 11:05:09 2017
New Revision: 319460

URL: http://llvm.org/viewvc/llvm-project?rev=319460=rev
Log:
add new check to find NSError init invocation

Subscribers: klimek, mgorny, cfe-commits

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

Added:
clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp
  - copied, changed from r319459, 
clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.cpp
clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.h
  - copied, changed from r319459, 
clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.h
Removed:
clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.cpp
clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.h
Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst

Copied: clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp (from 
r319459, clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.cpp)
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp?p2=clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp=clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.cpp=319459=319460=319460=diff
==
(empty)

Copied: clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.h (from 
r319459, clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.h)
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.h?p2=clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.h=clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.h=319459=319460=319460=diff
==
(empty)

Removed: clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.cpp?rev=319459=auto
==
--- clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.cpp (removed)
@@ -1,37 +0,0 @@
-//===--- AvoidNSErrorInitCheck.cpp - 
clang-tidy===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#include "AvoidNSErrorInitCheck.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-
-using namespace clang::ast_matchers;
-
-namespace clang {
-namespace tidy {
-namespace objc {
-
-void AvoidNSErrorInitCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(objcMessageExpr(hasSelector("init"),
- hasReceiverType(asString("NSError *")))
- .bind("nserrorInit"),
- this);
-}
-
-void AvoidNSErrorInitCheck::check(const MatchFinder::MatchResult ) {
-  const auto *MatchedExpr =
-  Result.Nodes.getNodeAs("nserrorInit");
-  diag(MatchedExpr->getLocStart(),
-   "use errorWithDomain:code:userInfo: or initWithDomain:code:userInfo: to 
"
-   "create a new NSError");
-}
-
-}  // namespace objc
-}  // namespace tidy
-}  // namespace clang

Removed: clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.h?rev=319459=auto
==
--- clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.h (removed)
@@ -1,36 +0,0 @@
-//===--- AvoidNSErrorInitCheck.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_OBJC_AVOIDNSERRORINITCHECK_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOIDNSERRORINITCHECK_H
-
-#include "../ClangTidy.h"
-
-namespace clang {
-namespace tidy {
-namespace objc {
-
-/// Finds usages of [NSSError init]. It is not the proper way of creating
-/// NSError. errorWithDomain:code:userInfo: should be used instead.
-///
-/// For the user-facing documentation see:
-/// http://clang.llvm.org/extra/clang-tidy/checks/objc-avoid-nserror-init.html
-class AvoidNSErrorInitCheck : public ClangTidyCheck {
- public:
-  AvoidNSErrorInitCheck(StringRef Name, ClangTidyContext *Context)
-  : 

  1   2   >