r319746 - Add __WINT_MAX__.

2017-12-05 Thread Ed Schouten via cfe-commits
Author: ed
Date: Tue Dec  5 01:13:18 2017
New Revision: 319746

URL: http://llvm.org/viewvc/llvm-project?rev=319746&view=rev
Log:
Add __WINT_MAX__.

This definition is similar to __WCHAR_MAX__, except that it applies to
wint_t. It's also documented as being supported by GCC 4.5 and later.

Modified:
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=319746&r1=319745&r2=319746&view=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Tue Dec  5 01:13:18 2017
@@ -751,6 +751,7 @@ static void InitializePredefinedMacros(c
   DefineTypeSize("__LONG_MAX__", TargetInfo::SignedLong, TI, Builder);
   DefineTypeSize("__LONG_LONG_MAX__", TargetInfo::SignedLongLong, TI, Builder);
   DefineTypeSize("__WCHAR_MAX__", TI.getWCharType(), TI, Builder);
+  DefineTypeSize("__WINT_MAX__", TI.getWIntType(), TI, Builder);
   DefineTypeSize("__INTMAX_MAX__", TI.getIntMaxType(), TI, Builder);
   DefineTypeSize("__SIZE_MAX__", TI.getSizeType(), TI, Builder);
 

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=319746&r1=319745&r2=319746&view=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Tue Dec  5 01:13:18 2017
@@ -1243,6 +1243,7 @@
 // AARCH64-FREEBSD:#define __WCHAR_TYPE__ unsigned int
 // AARCH64-FREEBSD:#define __WCHAR_UNSIGNED__ 1
 // AARCH64-FREEBSD:#define __WCHAR_WIDTH__ 32
+// AARCH64-FREEBSD:#define __WINT_MAX__ 2147483647
 // AARCH64-FREEBSD:#define __WINT_TYPE__ int
 // AARCH64-FREEBSD:#define __WINT_WIDTH__ 32
 // AARCH64-FREEBSD:#define __aarch64__ 1
@@ -8440,6 +8441,7 @@
 // X86_64-CLOUDABI:#define __WCHAR_MAX__ 2147483647
 // X86_64-CLOUDABI:#define __WCHAR_TYPE__ int
 // X86_64-CLOUDABI:#define __WCHAR_WIDTH__ 32
+// X86_64-CLOUDABI:#define __WINT_MAX__ 2147483647
 // X86_64-CLOUDABI:#define __WINT_TYPE__ int
 // X86_64-CLOUDABI:#define __WINT_WIDTH__ 32
 // X86_64-CLOUDABI:#define __amd64 1
@@ -9364,6 +9366,7 @@
 // WEBASSEMBLY32-NEXT:#define __WCHAR_TYPE__ int
 // WEBASSEMBLY32-NOT:#define __WCHAR_UNSIGNED__
 // WEBASSEMBLY32-NEXT:#define __WCHAR_WIDTH__ 32
+// WEBASSEMBLY32-NEXT:#define __WINT_MAX__ 2147483647
 // WEBASSEMBLY32-NEXT:#define __WINT_TYPE__ int
 // WEBASSEMBLY32-NOT:#define __WINT_UNSIGNED__
 // WEBASSEMBLY32-NEXT:#define __WINT_WIDTH__ 32
@@ -9695,6 +9698,7 @@
 // WEBASSEMBLY64-NEXT:#define __WCHAR_TYPE__ int
 // WEBASSEMBLY64-NOT:#define __WCHAR_UNSIGNED__
 // WEBASSEMBLY64-NEXT:#define __WCHAR_WIDTH__ 32
+// WEBASSEMBLY64-NEXT:#define __WINT_MAX__ 2147483647
 // WEBASSEMBLY64-NEXT:#define __WINT_TYPE__ int
 // WEBASSEMBLY64-NOT:#define __WINT_UNSIGNED__
 // WEBASSEMBLY64-NEXT:#define __WINT_WIDTH__ 32


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


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

2017-12-05 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

Ping


https://reviews.llvm.org/D40415



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


r319748 - [clang-format] Releasenotes for rL319024 : Add option to group multiple #include blocks when sorting includes

2017-12-05 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Tue Dec  5 01:23:47 2017
New Revision: 319748

URL: http://llvm.org/viewvc/llvm-project?rev=319748&view=rev
Log:
[clang-format] Releasenotes for rL319024 : Add option to group multiple 
#include blocks when sorting includes

Summary:
This change adds missing releasenotes for commit rL319024
https://reviews.llvm.org/rL319024

Patch by Krzysztof Kapusta

Reviewers: sylvestre.ledru

Reviewed By: sylvestre.ledru

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

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=319748&r1=319747&r2=319748&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Tue Dec  5 01:23:47 2017
@@ -248,6 +248,19 @@ clang-format
 * Option -verbose added to the command line.
   Shows the list of processed files.
 
+* Option *IncludeBlocks* added to merge and regroup multiple ``#include`` 
blocks during sorting.
+
+  
+-+-+-+
+  | Before (Preserve)   | Merge   | Regroup
 |
+  
+=+=+=+
+  |  .. code-block:: c++| .. code-block:: c++ | .. code-block:: c++
 |
+  | | |
 |
+  |   #include "b.h"|   #include "a.h"|   #include "a.h"   
 |
+  | |   #include "b.h"|   #include "b.h"   
 |
+  |   #include "a.b"|   #include  |
 |
+  |   #include  | |   #include 
 |
+  
+-+-+-+
+
 libclang
 
 


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


[PATCH] D36672: [clang-tidy] readability-non-const-parameter: fixit on all function declarations

2017-12-05 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

Fixed by https://reviews.llvm.org/rL319021?


Repository:
  rL LLVM

https://reviews.llvm.org/D36672



___
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-05 Thread silviu.bara...@arm.com via Phabricator via cfe-commits
sbaranga added inline comments.



Comment at: include/clang/Basic/Attr.td:1218-1228
 def NeonPolyVectorType : TypeAttr {
-  let Spellings = [GNU<"neon_polyvector_type">];
+  let Spellings = [Clang<"neon_polyvector_type">];
   let Args = [IntArgument<"NumElements">];
   let Documentation = [Undocumented];
 }
 
 def NeonVectorType : TypeAttr {

aaron.ballman wrote:
> aaron.ballman wrote:
> > rsmith wrote:
> > > I *think* these are a Clang invention rather than part of the ARM NEON 
> > > intrinsics specification, but perhaps you could ask someone from ARM to 
> > > confirm that.
> > @sbaranga or @jmolloy -- do you happen to know the answer to this, or know 
> > someone who does?
> Pinging this comment.
Yes, these should be internal to clang and used to implement the ACLE 
specification (which defines the NEON intrinsics). The ACLE doesn't define 
these.

Here is a link to the latest spec: 
https://developer.arm.com/products/software-development-tools/compilers/arm-compiler-5/docs/101028/latest/1-preface


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] D36390: Fix overloaded static functions in SemaCodeComplete

2017-12-05 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added inline comments.



Comment at: cfe/trunk/lib/Sema/SemaOverload.cpp:6365
cast(FD)->getParent(), ObjectType,
-   ObjectClassification, Args.slice(1), CandidateSet,
+   ObjectClassification, FunctionArgs, CandidateSet,
SuppressUserConversions, PartialOverloading);

cameron314 wrote:
> yvvan wrote:
> > cameron314 wrote:
> > > This breaks normal (non-static) method overload resolution, since the 
> > > `this` argument is now passed to `AddMethodCandidate` which is not 
> > > expecting it. It always thinks too many arguments are passed to methods 
> > > with no parameters; most other calls to `AddMethodCandidate` in 
> > > SemaOverload.cpp don't pass the implicit `this`.
> > This code is correct. It is sliced at line 6361 - only in the case when the 
> > args size is greater than 0.
> Hmm, you're right, I didn't see that. That line was missing after a rebase on 
> our side, my fault for not properly cross-referencing the diffs. Sorry for 
> the false alarm.
> 
> But shouldn't the slice only be done now when `Args.size() > 0 && (!Args[0] 
> || (FirstArgumentIsBase && isa(FD) && 
> !isa(FD)))`?
there's already a check for this case that it's a CXXMethodDecl, it's not 
static. That means that we always need to slice (except those rare cases when 
we don't have any args, and in fact I don't know why these cases exist)


Repository:
  rL LLVM

https://reviews.llvm.org/D36390



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


[PATCH] D40780: [clangd] Incorporate fuzzy-match into result rankings.

2017-12-05 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/ClangdUnit.cpp:377
+  : Result(&Result), SymbolScore(score(Result)), FilterScore(FilterScore),
+Score(FilterScore * SymbolScore) {}
 

It might worth mentioning how well `FilterScore * SymbolScore` performs. I 
think it could be affected by the distribution of the filtering score and 
symbol scores. We might want to do some tweaks on the numbers depending on the 
distributions...



Comment at: clangd/ClangdUnit.cpp:380
   CodeCompletionResult *Result;
-  float Score; // 0 to 1, higher is better.
+  float SymbolScore; // higher is better
+  float FilterScore; // 0 to 1, higher is better.

Any reason not to use `CompletionItemScores` here? Maybe copy over some 
comments?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40780



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


[PATCH] D40829: [clang-tidy] adjust cppcoreguidelines-owning-memory documentation

2017-12-05 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth created this revision.
Herald added subscribers: cfe-commits, kbarton, xazax.hun, nemanjai, klimek.

A user of the check opened a bugreport and reported that `std::exchange`
triggers a false positive. I adjusted the doc to include a list of known
(std) constructs that do trigger the issue with templates forgetting the
type alias.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40829

Files:
  docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst


Index: docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
===
--- docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
+++ docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
@@ -111,7 +111,11 @@
 In template functions and classes, like in the example below, the information
 of the type aliases gets lost. Therefore using ``gsl::owner`` in a heavy 
templated
 code base might lead to false positives. 
-This limitation results in ``std::vector>`` not being diagnosed 
correctly.
+
+Known code constructs that do not get diagnosed correctly are
+
+- ``std::exchange``
+- ``std::vector>``
 
 .. code-block:: c++
 


Index: docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
===
--- docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
+++ docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
@@ -111,7 +111,11 @@
 In template functions and classes, like in the example below, the information
 of the type aliases gets lost. Therefore using ``gsl::owner`` in a heavy templated
 code base might lead to false positives. 
-This limitation results in ``std::vector>`` not being diagnosed correctly.
+
+Known code constructs that do not get diagnosed correctly are
+
+- ``std::exchange``
+- ``std::vector>``
 
 .. code-block:: c++
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40654: [clangd] Set completion options per-request.

2017-12-05 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319753: [clangd] Set completion options per-request. 
(authored by ibiryukov).

Changed prior to commit:
  https://reviews.llvm.org/D40654?vs=124944&id=125487#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40654

Files:
  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
  clang-tools-extra/trunk/clangd/ClangdLSPServer.h
  clang-tools-extra/trunk/clangd/ClangdServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.h
  clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
  clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp

Index: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
@@ -75,7 +75,6 @@
 
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
   /*StorePreamblesInMemory=*/true,
-  clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
@@ -88,6 +87,9 @@
 int cbc;
 int b =   ;
 )cpp";
+
+  // Use default options.
+  CodeCompleteOptions CCOpts;
   // Complete after '=' sign. We need to be careful to keep the SourceContents'
   // size the same.
   // We complete on the 3rd line (2nd in zero-based numbering), because raw
@@ -103,15 +105,15 @@
 
   {
 auto CodeCompletionResults1 =
-Server.codeComplete(FooCpp, CompletePos, None).get().Value;
+Server.codeComplete(FooCpp, CompletePos, CCOpts, None).get().Value;
 EXPECT_TRUE(ContainsItem(CodeCompletionResults1, "aba"));
 EXPECT_FALSE(ContainsItem(CodeCompletionResults1, "cbc"));
   }
 
   {
 auto CodeCompletionResultsOverriden =
 Server
-.codeComplete(FooCpp, CompletePos,
+.codeComplete(FooCpp, CompletePos, CCOpts,
   StringRef(OverridenSourceContents))
 .get()
 .Value;
@@ -121,7 +123,7 @@
 
   {
 auto CodeCompletionResults2 =
-Server.codeComplete(FooCpp, CompletePos, None).get().Value;
+Server.codeComplete(FooCpp, CompletePos, CCOpts, None).get().Value;
 EXPECT_TRUE(ContainsItem(CodeCompletionResults2, "aba"));
 EXPECT_FALSE(ContainsItem(CodeCompletionResults2, "cbc"));
   }
@@ -132,10 +134,8 @@
   MockCompilationDatabase CDB;
   CDB.ExtraClangFlags.push_back("-xc++");
   IgnoreDiagnostics DiagConsumer;
-  clangd::CodeCompleteOptions Opts;
-  Opts.Limit = 2;
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-  /*StorePreamblesInMemory=*/true, Opts,
+  /*StorePreamblesInMemory=*/true,
   EmptyLogger::getInstance());
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
@@ -152,9 +152,12 @@
  "complete");
   Server.addDocument(FooCpp, Completion.Text);
 
+  clangd::CodeCompleteOptions Opts;
+  Opts.Limit = 2;
+
   /// For after-dot completion we must always get consistent results.
   auto Results = Server
- .codeComplete(FooCpp, Completion.MarkerPos,
+ .codeComplete(FooCpp, Completion.MarkerPos, Opts,
StringRef(Completion.Text))
  .get()
  .Value;
@@ -171,9 +174,8 @@
   MockCompilationDatabase CDB;
   CDB.ExtraClangFlags.push_back("-xc++");
   IgnoreDiagnostics DiagConsumer;
-  clangd::CodeCompleteOptions Opts;
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-  /*StorePreamblesInMemory=*/true, Opts,
+  /*StorePreamblesInMemory=*/true,
   EmptyLogger::getInstance());
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
@@ -194,7 +196,8 @@
 "complete");
 Server.addDocument(FooCpp, Completion.Text);
 return Server
-.codeComplete(FooCpp, Completion.MarkerPos, StringRef(Completion.Text))
+.codeComplete(FooCpp, Completion.MarkerPos,
+  clangd::CodeCompleteOptions(), StringRef(Completion.Text))
 .get()
 .Value;
   };
@@ -288,7 +291,7 @@
 
   auto TestWithOpts = [&](clangd::CodeCompleteOptions Opts) {
 ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-/*StorePreamblesInMemory=*/true, Opts,
+/*StorePreamblesInMemory=*/true,
 EmptyLogger::getInstance());
 // No need to sync reparses here as there are no asserts on diagnostics (or
 // other async operations).
@@ -301,7 +304,7 @@
 /// For after-dot completion we must always get consistent results.
 {
   auto Results = Server
- .codeComplete(FooCpp, MemberCompletion.MarkerPo

[clang-tools-extra] r319753 - [clangd] Set completion options per-request.

2017-12-05 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Tue Dec  5 02:42:57 2017
New Revision: 319753

URL: http://llvm.org/viewvc/llvm-project?rev=319753&view=rev
Log:
[clangd] Set completion options per-request.

Summary:
Previously, completion options were set per ClangdServer instance.
It will allow to change completion preferences during the lifetime
of a single ClangdServer instance.

Also rewrote ClangdCompletionTest.CompletionOptions to reuse single
ClangdServer instance, the test now runs 2x faster on my machine.

Reviewers: sammccall, ioeric, hokein

Reviewed By: sammccall, ioeric

Subscribers: klimek, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdLSPServer.h
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=319753&r1=319752&r2=319753&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Tue Dec  5 02:42:57 2017
@@ -194,14 +194,15 @@ void ClangdLSPServer::onCodeAction(Ctx C
 }
 
 void ClangdLSPServer::onCompletion(Ctx C, TextDocumentPositionParams &Params) {
-  auto List = Server
-  .codeComplete(
-  Params.textDocument.uri.file,
-  Position{Params.position.line, 
Params.position.character})
-  .get() // FIXME(ibiryukov): This could be made async if we
- // had an API that would allow to attach callbacks to
- // futures returned by ClangdServer.
-  .Value;
+  auto List =
+  Server
+  .codeComplete(
+  Params.textDocument.uri.file,
+  Position{Params.position.line, Params.position.character}, 
CCOpts)
+  .get() // FIXME(ibiryukov): This could be made async if we
+ // had an API that would allow to attach callbacks to
+ // futures returned by ClangdServer.
+  .Value;
   C.reply(List);
 }
 
@@ -240,9 +241,9 @@ ClangdLSPServer::ClangdLSPServer(JSONOut
  llvm::Optional ResourceDir,
  llvm::Optional CompileCommandsDir)
 : Out(Out), CDB(/*Logger=*/Out, std::move(CompileCommandsDir)),
-  Server(CDB, /*DiagConsumer=*/*this, FSProvider, AsyncThreadsCount,
- StorePreamblesInMemory, CCOpts,
- /*Logger=*/Out, ResourceDir) {}
+  CCOpts(CCOpts), Server(CDB, /*DiagConsumer=*/*this, FSProvider,
+ AsyncThreadsCount, StorePreamblesInMemory,
+ /*Logger=*/Out, ResourceDir) {}
 
 bool ClangdLSPServer::run(std::istream &In) {
   assert(!IsDone && "Run was called before");

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.h?rev=319753&r1=319752&r2=319753&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.h Tue Dec  5 02:42:57 2017
@@ -96,7 +96,8 @@ private:
   // before ClangdServer.
   DirectoryBasedGlobalCompilationDatabase CDB;
   RealFileSystemProvider FSProvider;
-
+  /// Options used for code completion
+  clangd::CodeCompleteOptions CCOpts;
   // Server must be the last member of the class to allow its destructor to 
exit
   // the worker thread that may otherwise run an async callback on partially
   // destructed instance of ClangdLSPServer.

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=319753&r1=319752&r2=319753&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Tue Dec  5 02:42:57 2017
@@ -173,16 +173,14 @@ ClangdServer::ClangdServer(GlobalCompila
DiagnosticsConsumer &DiagConsumer,
FileSystemProvider &FSProvider,
unsigned AsyncThreadsCount,
-   bool StorePreamblesInMemory,
-   const clangd::CodeCompleteOptions &CodeCompleteOpts,
-   clangd::Logger &Logger,
+   bool StorePreamblesInMemory, clangd::Logger &Logger,
llvm::Optional ResourceDir)
 : Logger(

[PATCH] D28820: Warn when calling a non interrupt function from an interrupt on ARM

2017-12-05 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

In https://reviews.llvm.org/D28820#944365, @efriedma wrote:

> > What is the best way to modify the code for this compiler change ?
>
> Currently, the "interrupt" attribute only has an effect on functions, not 
> function pointers, so your code won't work the way you want.  It's a bug that 
> we don't emit a warning for this.


https://bugs.llvm.org/show_bug.cgi?id=35527

> Currently, this warning doesn't have its own warning flag, instead being 
> lumped under -Wextra.  This is also a bug.

https://bugs.llvm.org/show_bug.cgi?id=35528

> We don't emit the warning if your code is compiled for a target which doesn't 
> support floating-point (-mfpu=none or -msoft-float); see 
> https://reviews.llvm.org/D32918. But otherwise, if you're sure your code is 
> actually correct, you can turn off the warning with -Wno-extra or something 
> like that.  (The whole thing is kind of awkward because the implementation of 
> the interrupt attribute in clang is buggy: the frontend lies to the backend 
> about the calling convention, so the backend can't save/restore VFP registers 
> correctly.)

https://i.imgur.com/BFRoEUO.gif

In https://reviews.llvm.org/D28820#944706, @kc.austin2017 wrote:

> so is there any plan to make the "interrupt" attribute not just support on 
> functions?


I'll fix these. Give me a few weeks though.


https://reviews.llvm.org/D28820



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


[PATCH] D39719: [X86][AVX512] lowering kunpack intrinsic - clang part

2017-12-05 Thread jina via Phabricator via cfe-commits
jina.nahias added a comment.

ping


https://reviews.llvm.org/D39719



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


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

2017-12-05 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

@aaron.ballman I further investigated and the issue does not come directly from 
my code (at least thats what i believe) :)

If i change the matcher simply to

  Finder->addMatcher(switchStmt().bind("switch"), this);

The overflow still occurs! I assume that the recursive natur of ASTVisitor 
causes that issue. How should we go further? Maybe ask klimek for some advice?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40737



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

BTW, how will this feature interact with cpplint.py's way of handling specific 
NOLINT directives that use different lint rule names, which sometimes refer to 
the same rule (e.g. `// NOLINT(runtime/explicit)` suppresses the 
`runtime/explicit` cpplint rule that enforces the same style rule as the 
google-runtime-explicit check)?


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] D39279: Stringizing raw string literals containing newline

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

I see your concern. Would you just consider moving the annotation to header 
file then? It looks more like documentation of public interface than 
implementation details to me. I imagine any programmer interested in these 
methods needs to know these details so they would probably appreciate not 
having to search for it.

Anyway, I don't want to dwell on minor details and it's probably a matter of 
opinion as well. If you prefer to leave it as it is feel free to commit your 
patch.

Good job!

LGTM.


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] D39430: [clangd] various fixes

2017-12-05 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D39430#943387, @malaperle wrote:

> I'd rather keep one commit per fix or feature. I would think the clang-format 
> part should be one commit/review on its own. But I'm not very familiar with 
> the practices here so I'll let others comment.


+1, please create a separate review per fix or feature.




Comment at: clangd/ClangdServer.h:288
+  /// Get "FixIt" replacements for the given diagnostic.
+  llvm::SmallVector getFixIts(StringRef File,
+   const clangd::Diagnostic &D);

There are two ways to return fixits from `ClangdServer` now, one is 
`DiagnosticsConsumer`, the other is the new `getFixIts` method.

I'd also argue the fact that we can't attach fixits to diagnostics is 
LSP-specific and therefore it should be handled by `ClangdLSPServer`.
If the problem is that the cache is never cleaned up, we could simply remove 
the fixits when handling `textDocument/didClose`.

I think we should not put this method into `ClangdServer`.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D39430



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


[PATCH] D40832: [clang-format] Adds canonical raw string delimiters support

2017-12-05 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
Herald added subscribers: cfe-commits, klimek.

A canonical raw string delimiter for a given language is the preferred raw 
string
delimiter to use for that language. For example, both 'pb' and 'proto' could
serve to indentify a raw string literal as a proto string, but 'proto' is the
preferred one.
This patch adds support for canonical raw string delimiters to clang-format,
effectively updating the delimiters to the canonical one.


Repository:
  rC Clang

https://reviews.llvm.org/D40832

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  unittests/Format/FormatTestRawStrings.cpp

Index: unittests/Format/FormatTestRawStrings.cpp
===
--- unittests/Format/FormatTestRawStrings.cpp
+++ unittests/Format/FormatTestRawStrings.cpp
@@ -67,21 +67,24 @@
 Style.ColumnLimit = ColumnLimit;
 Style.RawStringFormats = {{/*Delimiter=*/"pb",
/*Kind=*/FormatStyle::LK_TextProto,
-   /*BasedOnStyle=*/"google"}};
+   /*BasedOnStyle=*/"google",
+   /*Canonical=*/false}};
 return Style;
   }
 
   FormatStyle getRawStringLLVMCppStyleBasedOn(std::string BasedOnStyle) {
 FormatStyle Style = getLLVMStyle();
 Style.RawStringFormats = {{/*Delimiter=*/"cpp",
-   /*Kind=*/FormatStyle::LK_Cpp, BasedOnStyle}};
+   /*Kind=*/FormatStyle::LK_Cpp, BasedOnStyle,
+   /*Canonical=*/false}};
 return Style;
   }
 
   FormatStyle getRawStringGoogleCppStyleBasedOn(std::string BasedOnStyle) {
 FormatStyle Style = getGoogleStyle(FormatStyle::LK_Cpp);
 Style.RawStringFormats = {{/*Delimiter=*/"cpp",
-   /*Kind=*/FormatStyle::LK_Cpp, BasedOnStyle}};
+   /*Kind=*/FormatStyle::LK_Cpp, BasedOnStyle,
+   /*Canonical=*/false}};
 return Style;
   }
 
@@ -125,9 +128,9 @@
   FormatStyle MixedStyle = getLLVMStyle();
   MixedStyle.RawStringFormats = {
   {/*Delimiter=*/"cpp", /*Kind=*/FormatStyle::LK_Cpp,
-   /*BasedOnStyle=*/"llvm"},
+   /*BasedOnStyle=*/"llvm", /*Canonical=*/false},
   {/*Delimiter=*/"CPP", /*Kind=*/FormatStyle::LK_Cpp,
-   /*BasedOnStyle=*/"google"}};
+   /*BasedOnStyle=*/"google", /*Canonical=*/false}};
 
   // Format the 'cpp' raw string with '*' on the right.
   // Format the 'CPP' raw string with '*' on the left.
@@ -210,9 +213,9 @@
 P p = TP(R"pb(item_1 <1>
   item_2: <2>
   item_3 {})pb");)test",
-  format(R"test(
+format(R"test(
 P p = TP(R"pb(item_1<1> item_2:<2> item_3{ })pb");)test",
-  getRawStringPbStyleWithColumns(40)));
+   getRawStringPbStyleWithColumns(40)));
 
   expect_eq(
   R"test(
@@ -515,7 +518,6 @@
 format(R"test(
 ASSERT_TRUE(ParseFromString(R"pb(item_1: 1 item_2: 2)pb"), ptr);)test",
getRawStringPbStyleWithColumns(40)));
-
 }
 
 TEST_F(FormatTestRawStrings, RawStringsInOperands) {
@@ -642,7 +644,6 @@
 auto S=(count<3)?R"pb(item_1:1)pb":R"pb(item_2:2,item_3:3)pb";
 )test",
getRawStringPbStyleWithColumns(40)));
-
 }
 
 TEST_F(FormatTestRawStrings, PrefixAndSuffixAlignment) {
@@ -728,6 +729,54 @@
getRawStringPbStyleWithColumns(20)));
 }
 
+TEST_F(FormatTestRawStrings, UpdatesToCanonicalDelimiters) {
+  FormatStyle Style = getRawStringPbStyleWithColumns(25);
+  Style.RawStringFormats.push_back({/*Delimiter=*/"proto",
+/*Kind=*/FormatStyle::LK_TextProto,
+/*BasedOnStyle=*/"google",
+/*Canonical=*/true});
+  expect_eq(R"test(a = R"proto(key: value)proto";)test",
+format(R"test(a = R"pb(key:value)pb";)test", Style));
+  expect_eq(R"test(a = R"proto(key: value)proto";)test",
+format(R"test(a = R"proto(key:value)proto";)test", Style));
+  expect_eq(R"test(
+f(a,
+  R"proto(item {
+key: value
+key: value
+  })proto");
+)test",
+format(R"test(
+f(a,
+  R"pb(item {
+ key: value
+ key: value
+   })pb");
+)test",
+   Style));
+  // The last canonical delimiter for a language is the canonical delimiter for
+  // that language.
+  Style.RawStringFormats.push_back({/*Delimiter=*/"cproto",
+/*Kind=*/FormatStyle::LK_TextProto,
+/*BasedOnStyle=*/"google",
+/*Canonical=*/true});
+  expect_eq(R"test(
+f(a,
+  R"cproto(item {
+ key: value
+ key: value
+   })cproto");
+)test",
+format(R"test(
+f(a,
+  R"proto(item {
+ key: v

[PATCH] D40832: [clang-format] Adds canonical raw string delimiters support

2017-12-05 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 125501.
krasimir added a comment.

- Update documentation


Repository:
  rC Clang

https://reviews.llvm.org/D40832

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  unittests/Format/FormatTestRawStrings.cpp

Index: unittests/Format/FormatTestRawStrings.cpp
===
--- unittests/Format/FormatTestRawStrings.cpp
+++ unittests/Format/FormatTestRawStrings.cpp
@@ -67,21 +67,24 @@
 Style.ColumnLimit = ColumnLimit;
 Style.RawStringFormats = {{/*Delimiter=*/"pb",
/*Kind=*/FormatStyle::LK_TextProto,
-   /*BasedOnStyle=*/"google"}};
+   /*BasedOnStyle=*/"google",
+   /*Canonical=*/false}};
 return Style;
   }
 
   FormatStyle getRawStringLLVMCppStyleBasedOn(std::string BasedOnStyle) {
 FormatStyle Style = getLLVMStyle();
 Style.RawStringFormats = {{/*Delimiter=*/"cpp",
-   /*Kind=*/FormatStyle::LK_Cpp, BasedOnStyle}};
+   /*Kind=*/FormatStyle::LK_Cpp, BasedOnStyle,
+   /*Canonical=*/false}};
 return Style;
   }
 
   FormatStyle getRawStringGoogleCppStyleBasedOn(std::string BasedOnStyle) {
 FormatStyle Style = getGoogleStyle(FormatStyle::LK_Cpp);
 Style.RawStringFormats = {{/*Delimiter=*/"cpp",
-   /*Kind=*/FormatStyle::LK_Cpp, BasedOnStyle}};
+   /*Kind=*/FormatStyle::LK_Cpp, BasedOnStyle,
+   /*Canonical=*/false}};
 return Style;
   }
 
@@ -125,9 +128,9 @@
   FormatStyle MixedStyle = getLLVMStyle();
   MixedStyle.RawStringFormats = {
   {/*Delimiter=*/"cpp", /*Kind=*/FormatStyle::LK_Cpp,
-   /*BasedOnStyle=*/"llvm"},
+   /*BasedOnStyle=*/"llvm", /*Canonical=*/false},
   {/*Delimiter=*/"CPP", /*Kind=*/FormatStyle::LK_Cpp,
-   /*BasedOnStyle=*/"google"}};
+   /*BasedOnStyle=*/"google", /*Canonical=*/false}};
 
   // Format the 'cpp' raw string with '*' on the right.
   // Format the 'CPP' raw string with '*' on the left.
@@ -210,9 +213,9 @@
 P p = TP(R"pb(item_1 <1>
   item_2: <2>
   item_3 {})pb");)test",
-  format(R"test(
+format(R"test(
 P p = TP(R"pb(item_1<1> item_2:<2> item_3{ })pb");)test",
-  getRawStringPbStyleWithColumns(40)));
+   getRawStringPbStyleWithColumns(40)));
 
   expect_eq(
   R"test(
@@ -515,7 +518,6 @@
 format(R"test(
 ASSERT_TRUE(ParseFromString(R"pb(item_1: 1 item_2: 2)pb"), ptr);)test",
getRawStringPbStyleWithColumns(40)));
-
 }
 
 TEST_F(FormatTestRawStrings, RawStringsInOperands) {
@@ -642,7 +644,6 @@
 auto S=(count<3)?R"pb(item_1:1)pb":R"pb(item_2:2,item_3:3)pb";
 )test",
getRawStringPbStyleWithColumns(40)));
-
 }
 
 TEST_F(FormatTestRawStrings, PrefixAndSuffixAlignment) {
@@ -728,6 +729,54 @@
getRawStringPbStyleWithColumns(20)));
 }
 
+TEST_F(FormatTestRawStrings, UpdatesToCanonicalDelimiters) {
+  FormatStyle Style = getRawStringPbStyleWithColumns(25);
+  Style.RawStringFormats.push_back({/*Delimiter=*/"proto",
+/*Kind=*/FormatStyle::LK_TextProto,
+/*BasedOnStyle=*/"google",
+/*Canonical=*/true});
+  expect_eq(R"test(a = R"proto(key: value)proto";)test",
+format(R"test(a = R"pb(key:value)pb";)test", Style));
+  expect_eq(R"test(a = R"proto(key: value)proto";)test",
+format(R"test(a = R"proto(key:value)proto";)test", Style));
+  expect_eq(R"test(
+f(a,
+  R"proto(item {
+key: value
+key: value
+  })proto");
+)test",
+format(R"test(
+f(a,
+  R"pb(item {
+ key: value
+ key: value
+   })pb");
+)test",
+   Style));
+  // The last canonical delimiter for a language is the canonical delimiter for
+  // that language.
+  Style.RawStringFormats.push_back({/*Delimiter=*/"cproto",
+/*Kind=*/FormatStyle::LK_TextProto,
+/*BasedOnStyle=*/"google",
+/*Canonical=*/true});
+  expect_eq(R"test(
+f(a,
+  R"cproto(item {
+ key: value
+ key: value
+   })cproto");
+)test",
+format(R"test(
+f(a,
+  R"proto(item {
+ key: value
+ key: value
+   })proto");
+)test",
+   Style));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -641,7 +641,8 @@
   LLVMStyle.SpacesBeforeTrailingComments

[PATCH] D40834: [libc++] std::map: use throw_out_of_range()

2017-12-05 Thread Petteri Aimonen via Phabricator via cfe-commits
PetteriAimonen created this revision.
Herald added a reviewer: EricWF.

Previously std::map ignored out-of-bounds access when exceptions were
disabled. Other containers such as std::vector use throw_out_of_range()
which will terminate the program if exceptions are disabled.


https://reviews.llvm.org/D40834

Files:
  include/map


Index: include/map
===
--- include/map
+++ include/map
@@ -1371,10 +1371,8 @@
 {
 __parent_pointer __parent;
 __node_base_pointer& __child = __tree_.__find_equal(__parent, __k);
-#ifndef _LIBCPP_NO_EXCEPTIONS
 if (__child == nullptr)
-throw out_of_range("map::at:  key not found");
-#endif  // _LIBCPP_NO_EXCEPTIONS
+_VSTD::__throw_out_of_range("map::at:  key not found");
 return static_cast<__node_pointer>(__child)->__value_.__cc.second;
 }
 
@@ -1384,10 +1382,8 @@
 {
 __parent_pointer __parent;
 __node_base_pointer __child = __tree_.__find_equal(__parent, __k);
-#ifndef _LIBCPP_NO_EXCEPTIONS
 if (__child == nullptr)
-throw out_of_range("map::at:  key not found");
-#endif  // _LIBCPP_NO_EXCEPTIONS
+_VSTD::__throw_out_of_range("map::at:  key not found");
 return static_cast<__node_pointer>(__child)->__value_.__cc.second;
 }
 


Index: include/map
===
--- include/map
+++ include/map
@@ -1371,10 +1371,8 @@
 {
 __parent_pointer __parent;
 __node_base_pointer& __child = __tree_.__find_equal(__parent, __k);
-#ifndef _LIBCPP_NO_EXCEPTIONS
 if (__child == nullptr)
-throw out_of_range("map::at:  key not found");
-#endif  // _LIBCPP_NO_EXCEPTIONS
+_VSTD::__throw_out_of_range("map::at:  key not found");
 return static_cast<__node_pointer>(__child)->__value_.__cc.second;
 }
 
@@ -1384,10 +1382,8 @@
 {
 __parent_pointer __parent;
 __node_base_pointer __child = __tree_.__find_equal(__parent, __k);
-#ifndef _LIBCPP_NO_EXCEPTIONS
 if (__child == nullptr)
-throw out_of_range("map::at:  key not found");
-#endif  // _LIBCPP_NO_EXCEPTIONS
+_VSTD::__throw_out_of_range("map::at:  key not found");
 return static_cast<__node_pointer>(__child)->__value_.__cc.second;
 }
 
___
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-05 Thread Anton via Phabricator via cfe-commits
xgsa marked 2 inline comments as done.
xgsa added inline comments.



Comment at: docs/clang-tidy/index.rst:254-255
+While :program:`clang-tidy` diagnostics are intended to call out code that does
+not adhere to a coding standard, or is otherwise problematic in some way, there
+are times when it is more appropriate to silence the diagnostic instead of 
+changing the semantics of the code. The preferable way of doing this is using

aaron.ballman wrote:
> I would reword this somewhat now. I would put a period before ", there are 
> times" and then move that whole "there are times" clause below.
I tried to move the "there are times"-clause below, but in this case "The 
preferable way of doing this is using..." becomes unclear, because it tries to 
explain the way of doing something without naming the purpose that is expected 
to achieve. So I suppose, it is necessary to place "However, there are times 
when it is more appropriate to silence the diagnostic instead of changing the 
semantics of the code" here. Am I missing something?


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] D40671: [clang-tidy] Support specific checks for NOLINT directive

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

Updated documentation


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,56 @@
   value:   'some value'
   ...
 
+:program:`clang-tidy` diagnostics are intended to call out code that does
+not adhere to a coding standard, or is otherwise problematic in some way.
+However, there are times, when it is more appropriate to silence the diagnostic
+instead of changing the semantics of the code. The preferred way of doing this
+is using the check-specific ways, if they are available (e.g. 
+bugprone-use-after-move can be silenced by re-initializing the variable after 
+it has been moved out, misc-string-integer-assignment can be suppressed by 
+explicitly casting the integer to char, readability-implicit-bool-conversion
+can also be suppressed by using explicit casts, etc.). Otherwise, 
+the ``NOLINT`` or ``NOLINTNEXTLINE`` comments can be used. For example:
+
+.. code-block:: c++
+
+  class Foo
+  {
+// Silent all the diagnostics for the line
+Foo(int param); // NOLINT
+
+// Silent only the specified checks for the line
+Foo(double param); // NOLINT(google-explicit-constructor, google-runtime-int)
+
+// Silent only the specified diagnostics for the next line
+// NOLINTNEXTLINE(google-explicit-constructor, google-runtime-int)
+Foo(bool param); 
+  };
+
+The formal syntax of ``NOLINT``/``NOLINTNEXTLINE`` is the following:
+
+.. parsed-literal::
+
+  lint-comment:
+lint-command
+lint-command lint-args
+
+  lint-args:
+**(** check-name-list **)**
+
+  check-name-list:
+*check-name*
+check-name-list **,** *check-name*
+
+  lint-command:
+**NOLINT**
+**NOLINTNEXTLINE**
+
+Note that whitespaces between ``NOLINT``/``NOLINTNEXTLINE`` and the opening
+parenthesis are not allowed (in this case the comment will be treated just as
+``NOLINT``/``NOLINTNEXTLINE``), whereas in check names list (inside
+the parenthesis) whitespaces can be used and will be ignored.
+
 .. _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,8 @@
   - `hicpp-use-nullptr `_
   - `hicpp-vararg `_
 
+- Added the ability to suppress specific checks (or all checks) in a ``NOLINT`` or ``NOLINTNEXTLINE`` comment.
+
 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

[PATCH] D40838: [OpenCL] Fix layering violation by getOpenCLTypeAddrSpace

2017-12-05 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
Herald added a subscriber: nhaehnle.

Commit 7ac28eb0a5 / r310911 ("[OpenCL] Allow targets to select address
space per type", 2017-08-15) made Basic depend on AST, introducing a
circular dependency.  Break this dependency by adding the
OpenCLTypeKind enum in Basic and map from AST types to this enum in
ASTContext.


https://reviews.llvm.org/D40838

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/TargetInfo.h
  lib/AST/ASTContext.cpp
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets/AMDGPU.h
  lib/CodeGen/CGOpenCLRuntime.cpp

Index: lib/CodeGen/CGOpenCLRuntime.cpp
===
--- lib/CodeGen/CGOpenCLRuntime.cpp
+++ lib/CodeGen/CGOpenCLRuntime.cpp
@@ -36,8 +36,9 @@
  "Not an OpenCL specific type!");
 
   llvm::LLVMContext& Ctx = CGM.getLLVMContext();
+  TargetInfo::OpenCLTypeKind TK = CGM.getContext().getOpenCLTypeKind(T);
   uint32_t AddrSpc = CGM.getContext().getTargetAddressSpace(
-  CGM.getTarget().getOpenCLTypeAddrSpace(T));
+  CGM.getTarget().getOpenCLTypeAddrSpace(TK));
   switch (cast(T)->getKind()) {
   default:
 llvm_unreachable("Unexpected opencl builtin type!");
@@ -67,21 +68,24 @@
 
 llvm::Type *CGOpenCLRuntime::getPipeType(const PipeType *T) {
   if (!PipeTy){
+TargetInfo::OpenCLTypeKind TK = CGM.getContext().getOpenCLTypeKind(T);
 uint32_t PipeAddrSpc = CGM.getContext().getTargetAddressSpace(
-CGM.getTarget().getOpenCLTypeAddrSpace(T));
+CGM.getTarget().getOpenCLTypeAddrSpace(TK));
 PipeTy = llvm::PointerType::get(llvm::StructType::create(
   CGM.getLLVMContext(), "opencl.pipe_t"), PipeAddrSpc);
   }
 
   return PipeTy;
 }
 
 llvm::PointerType *CGOpenCLRuntime::getSamplerType(const Type *T) {
-  if (!SamplerTy)
+  if (!SamplerTy) {
+TargetInfo::OpenCLTypeKind TK = CGM.getContext().getOpenCLTypeKind(T);
 SamplerTy = llvm::PointerType::get(llvm::StructType::create(
   CGM.getLLVMContext(), "opencl.sampler_t"),
   CGM.getContext().getTargetAddressSpace(
-  CGM.getTarget().getOpenCLTypeAddrSpace(T)));
+  CGM.getTarget().getOpenCLTypeAddrSpace(TK)));
+  }
   return SamplerTy;
 }
 
Index: lib/Basic/Targets/AMDGPU.h
===
--- lib/Basic/Targets/AMDGPU.h
+++ lib/Basic/Targets/AMDGPU.h
@@ -14,7 +14,6 @@
 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_AMDGPU_H
 #define LLVM_CLANG_LIB_BASIC_TARGETS_AMDGPU_H
 
-#include "clang/AST/Type.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetOptions.h"
 #include "llvm/ADT/StringSet.h"
@@ -258,24 +257,18 @@
 }
   }
 
-  LangAS getOpenCLTypeAddrSpace(const Type *T) const override {
-auto BT = dyn_cast(T);
+  LangAS getOpenCLTypeAddrSpace(OpenCLTypeKind TK) const override {
+switch (TK) {
+case OCLTK_Image:
+  return LangAS::opencl_constant;
 
-if (!BT)
-  return TargetInfo::getOpenCLTypeAddrSpace(T);
-
-switch (BT->getKind()) {
-#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix)   \
-  case BuiltinType::Id:\
-return LangAS::opencl_constant;
-#include "clang/Basic/OpenCLImageTypes.def"
-case BuiltinType::OCLClkEvent:
-case BuiltinType::OCLQueue:
-case BuiltinType::OCLReserveID:
+case OCLTK_ClkEvent:
+case OCLTK_Queue:
+case OCLTK_ReserveID:
   return LangAS::opencl_global;
 
 default:
-  return TargetInfo::getOpenCLTypeAddrSpace(T);
+  return TargetInfo::getOpenCLTypeAddrSpace(TK);
 }
   }
 
Index: lib/Basic/TargetInfo.cpp
===
--- lib/Basic/TargetInfo.cpp
+++ lib/Basic/TargetInfo.cpp
@@ -12,7 +12,6 @@
 //===--===//
 
 #include "clang/Basic/TargetInfo.h"
-#include "clang/AST/Type.h"
 #include "clang/Basic/AddressSpaces.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/LangOptions.h"
@@ -357,23 +356,13 @@
   return true;
 }
 
-LangAS TargetInfo::getOpenCLTypeAddrSpace(const Type *T) const {
-  auto BT = dyn_cast(T);
-
-  if (!BT) {
-if (isa(T))
-  return LangAS::opencl_global;
-
-return LangAS::Default;
-  }
-
-  switch (BT->getKind()) {
-#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix)   \
-  case BuiltinType::Id:\
+LangAS TargetInfo::getOpenCLTypeAddrSpace(OpenCLTypeKind TK) const {
+  switch (TK) {
+  case OCLTK_Image:
+  case OCLTK_Pipe:
 return LangAS::opencl_global;
-#include "clang/Basic/OpenCLImageTypes.def"
 
-  case BuiltinType::OCLSampler:
+  case OCLTK_Sampler:
 return LangAS::opencl_constant;
 
   default:
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1826,7 +1826,8 @@
 #define IMAGE_TYPE(ImgType, I

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

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

Added error returns in findDocumentHighlights
Ran clang-format on ClangdUnit.h, .cpp and ClangdServer.cpp


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/ProtocolHand

[PATCH] D33989: [OpenCL] Allow targets to select address space per type

2017-12-05 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added a comment.

Following up on the layering violation in https://reviews.llvm.org/D40838


Repository:
  rL LLVM

https://reviews.llvm.org/D33989



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


Re: r319715 - Fix record-parsing-invocation.c test on Windows

2017-12-05 Thread Sean Eveson via cfe-commits
Hi,

It looks like the test is still failing on one of the Windows build bots:
http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015

>From looking at the test locally it seems the problem is when you do `//
RUN: not env...`. The env command doesn't get handled by llvm-lit.py,
because it gets passed through to `not.exe`.

In terms of fixing this test, changing from `not env X=Y COMMAND` to `env
X=Y not COMMAND` works on my machine. Otherwise maybe llvm-lit could be
changed to make the handling of env (and other utilities) consistent when
used after a not?

Thanks,

Sean Eveson
SN Systems - Sony Interactive Entertainment

On Mon, Dec 4, 2017 at 11:21 PM, Alex Lorenz via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: arphaman
> Date: Mon Dec  4 15:21:07 2017
> New Revision: 319715
>
> URL: http://llvm.org/viewvc/llvm-project?rev=319715&view=rev
> Log:
> Fix record-parsing-invocation.c test on Windows
>
> We should not check for the forward slash '/'
>
> Modified:
> cfe/trunk/test/Index/record-parsing-invocation.c
>
> Modified: cfe/trunk/test/Index/record-parsing-invocation.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/
> record-parsing-invocation.c?rev=319715&r1=319714&r2=319715&view=diff
> 
> ==
> --- cfe/trunk/test/Index/record-parsing-invocation.c (original)
> +++ cfe/trunk/test/Index/record-parsing-invocation.c Mon Dec  4 15:21:07
> 2017
> @@ -18,4 +18,4 @@
>  #  pragma clang __debug parser_crash
>  #endif
>
> -// CHECK: {"toolchain":"{{.*}}","libclang.operation":"parse","
> libclang.opts":1,"args":["clang","-fno-spell-checking","
> {{.*}}/record-parsing-invocation.c","-Xclang","-
> detailed-preprocessing-record","-fallow-editor-placeholders"]}
> +// CHECK: {"toolchain":"{{.*}}","libclang.operation":"parse","
> libclang.opts":1,"args":["clang","-fno-spell-checking","
> {{.*}}record-parsing-invocation.c","-Xclang","-
> detailed-preprocessing-record","-fallow-editor-placeholders"]}
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r319774 - [OPENMP] Fix assert fail after target implicit map checks.

2017-12-05 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Dec  5 07:22:49 2017
New Revision: 319774

URL: http://llvm.org/viewvc/llvm-project?rev=319774&view=rev
Log:
[OPENMP] Fix assert fail after target implicit map checks.

If the error is generated during analysis of implicitly or explicitly
mapped variables, it may cause compiler crash because of incorrect
analysis.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/target_map_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=319774&r1=319773&r2=319774&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Dec  5 07:22:49 2017
@@ -1996,7 +1996,8 @@ public:
 }
 if (isOpenMPTargetExecutionDirective(DKind) && !FD->isBitField()) {
   OMPClauseMappableExprCommon::MappableExprComponentList CurComponents;
-  CheckMapClauseExpressionBase(SemaRef, E, CurComponents, OMPC_map);
+  if (!CheckMapClauseExpressionBase(SemaRef, E, CurComponents, OMPC_map))
+return;
   auto *VD = cast(
   CurComponents.back().getAssociatedDeclaration()->getCanonicalDecl());
   if (!Stack->checkMappableExprComponentListsForDecl(
@@ -11467,7 +11468,7 @@ static Expr *CheckMapClauseExpressionBas
 
 if (auto *CurE = dyn_cast(E)) {
   if (!isa(CurE->getDecl()))
-break;
+return nullptr;
 
   RelevantExpr = CurE;
 
@@ -11477,12 +11478,8 @@ static Expr *CheckMapClauseExpressionBas
   AllowWholeSizeArraySection = false;
 
   // Record the component.
-  CurComponents.push_back(OMPClauseMappableExprCommon::MappableComponent(
-  CurE, CurE->getDecl()));
-  continue;
-}
-
-if (auto *CurE = dyn_cast(E)) {
+  CurComponents.emplace_back(CurE, CurE->getDecl());
+} else if (auto *CurE = dyn_cast(E)) {
   auto *BaseE = CurE->getBase()->IgnoreParenImpCasts();
 
   if (isa(BaseE))
@@ -11494,7 +11491,7 @@ static Expr *CheckMapClauseExpressionBas
   if (!isa(CurE->getMemberDecl())) {
 SemaRef.Diag(ELoc, diag::err_omp_expected_access_to_data_field)
 << CurE->getSourceRange();
-break;
+return nullptr;
   }
 
   auto *FD = cast(CurE->getMemberDecl());
@@ -11505,7 +11502,7 @@ static Expr *CheckMapClauseExpressionBas
   if (FD->isBitField()) {
 SemaRef.Diag(ELoc, diag::err_omp_bit_fields_forbidden_in_clause)
 << CurE->getSourceRange() << getOpenMPClauseName(CKind);
-break;
+return nullptr;
   }
 
   // OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, C++, p.1]
@@ -11521,7 +11518,7 @@ static Expr *CheckMapClauseExpressionBas
 if (RT->isUnionType()) {
   SemaRef.Diag(ELoc, diag::err_omp_union_type_not_allowed)
   << CurE->getSourceRange();
-  break;
+  return nullptr;
 }
 
   // If we got a member expression, we should not expect any array section
@@ -11535,18 +11532,14 @@ static Expr *CheckMapClauseExpressionBas
   AllowWholeSizeArraySection = false;
 
   // Record the component.
-  CurComponents.push_back(
-  OMPClauseMappableExprCommon::MappableComponent(CurE, FD));
-  continue;
-}
-
-if (auto *CurE = dyn_cast(E)) {
+  CurComponents.emplace_back(CurE, FD);
+} else if (auto *CurE = dyn_cast(E)) {
   E = CurE->getBase()->IgnoreParenImpCasts();
 
   if (!E->getType()->isAnyPointerType() && !E->getType()->isArrayType()) {
 SemaRef.Diag(ELoc, diag::err_omp_expected_base_var_name)
 << 0 << CurE->getSourceRange();
-break;
+return nullptr;
   }
 
   // If we got an array subscript that express the whole dimension we
@@ -11557,15 +11550,11 @@ static Expr *CheckMapClauseExpressionBas
 AllowWholeSizeArraySection = false;
 
   // Record the component - we don't have any declaration associated.
-  CurComponents.push_back(
-  OMPClauseMappableExprCommon::MappableComponent(CurE, nullptr));
-  continue;
-}
-
-if (auto *CurE = dyn_cast(E)) {
+  CurComponents.emplace_back(CurE, nullptr);
+} else if (auto *CurE = dyn_cast(E)) {
   E = CurE->getBase()->IgnoreParenImpCasts();
 
-  auto CurType =
+  QualType CurType =
   OMPArraySectionExpr::getBaseOriginalType(E).getCanonicalType();
 
   // OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, C++, p.1]
@@ -11579,7 +11568,7 @@ static Expr *CheckMapClauseExpressionBas
   if (!IsPointer && !CurType->isArrayType()) {
 SemaRef.Diag(ELoc, diag::err_omp_expected_base_var_name)
 << 0 << CurE->getSourceRange();
-break;
+return nullptr;
   }
 
   bool NotWhole =
@@ -11602,20 +11591,18 @@ static Expr *CheckMapClauseExpressionBas
 SemaRef.Diag(
 ELoc, diag::err_array_section_does_not_specify_contiguous_storag

[PATCH] D40752: [OpenMP] Fix assert fail after target implicit map checks

2017-12-05 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Fixed in a bit different way in r319774


https://reviews.llvm.org/D40752



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


r319777 - [x86][AVX512] Lowering kunpack intrinsics to LLVM IR

2017-12-05 Thread Jina Nahias via cfe-commits
Author: jina.nahias
Date: Tue Dec  5 07:42:47 2017
New Revision: 319777

URL: http://llvm.org/viewvc/llvm-project?rev=319777&view=rev
Log:
[x86][AVX512] Lowering kunpack intrinsics to LLVM IR

This patch, together with a matching llvm patch 
(https://reviews.llvm.org/D39720), implements the lowering of X86 kunpack 
intrinsics to IR.

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

Change-Id: Id5d3cb394ad33b98be79a6783d1d15569e2b798d

Modified:
cfe/trunk/lib/Headers/avx512bwintrin.h
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512bw-builtins.c
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/lib/Headers/avx512bwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bwintrin.h?rev=319777&r1=319776&r2=319777&view=diff
==
--- cfe/trunk/lib/Headers/avx512bwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512bwintrin.h Tue Dec  5 07:42:47 2017
@@ -1854,15 +1854,13 @@ _mm512_maskz_set1_epi8 (__mmask64 __M, c
 static __inline__ __mmask64 __DEFAULT_FN_ATTRS
 _mm512_kunpackd (__mmask64 __A, __mmask64 __B)
 {
-  return (__mmask64) __builtin_ia32_kunpckdi ((__mmask64) __A,
-(__mmask64) __B);
+  return (__mmask64)  (( __A  & 0x) | ( __B << 32));
 }
 
 static __inline__ __mmask32 __DEFAULT_FN_ATTRS
 _mm512_kunpackw (__mmask32 __A, __mmask32 __B)
 {
-  return (__mmask32) __builtin_ia32_kunpcksi ((__mmask32) __A,
-(__mmask32) __B);
+return (__mmask32)  (( __A  & 0x) | ( __B << 16));
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=319777&r1=319776&r2=319777&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Tue Dec  5 07:42:47 2017
@@ -8787,7 +8787,7 @@ _mm512_kortestz (__mmask16 __A, __mmask1
 static __inline__ __mmask16 __DEFAULT_FN_ATTRS
 _mm512_kunpackb (__mmask16 __A, __mmask16 __B)
 {
-  return (__mmask16) __builtin_ia32_kunpckhi ((__mmask16) __A, (__mmask16) 
__B);
+  return (__mmask16)  (( __A  & 0xFF) | ( __B << 8));
 }
 
 static __inline__ __mmask16 __DEFAULT_FN_ATTRS

Modified: cfe/trunk/test/CodeGen/avx512bw-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512bw-builtins.c?rev=319777&r1=319776&r2=319777&view=diff
==
--- cfe/trunk/test/CodeGen/avx512bw-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512bw-builtins.c Tue Dec  5 07:42:47 2017
@@ -1626,16 +1626,26 @@ __m512i test_mm512_maskz_set1_epi8(__mma
   return _mm512_maskz_set1_epi8(__M, __A); 
 }
 
-__mmask64 test_mm512_kunpackd(__mmask64 __A, __mmask64 __B) {
+__mmask64 test_mm512_kunpackd(__m512i __A, __m512i __B, __m512i __C, __m512i 
__D, __m512i __E, __m512i __F) {
   // CHECK-LABEL: @test_mm512_kunpackd
-  // CHECK: @llvm.x86.avx512.kunpck.dq
-  return _mm512_kunpackd(__A, __B); 
+  // CHECK: bitcast <64 x i1> %{{.*}} to i64
+  // CHECK: bitcast <64 x i1> %{{.*}} to i64
+  // CHECK: and i64 %{{.*}}, 4294967295
+  // CHECK: shl i64 %{{.*}}, 32
+  // CHECK: or i64 %{{.*}}, %{{.*}}
+  // CHECK: bitcast i64 %{{.*}} to <64 x i1>
+  return 
_mm512_mask_cmpneq_epu8_mask(_mm512_kunpackd(_mm512_cmpneq_epu8_mask(__B, 
__A),_mm512_cmpneq_epu8_mask(__C, __D)), __E, __F); 
 }
 
-__mmask32 test_mm512_kunpackw(__mmask32 __A, __mmask32 __B) {
+__mmask32 test_mm512_kunpackw(__m512i __A, __m512i __B, __m512i __C, __m512i 
__D, __m512i __E, __m512i __F) {
   // CHECK-LABEL: @test_mm512_kunpackw
-  // CHECK: @llvm.x86.avx512.kunpck.wd
-  return _mm512_kunpackw(__A, __B); 
+  // CHECK: bitcast <32 x i1> %{{.*}} to i32
+  // CHECK: bitcast <32 x i1> %{{.*}} to i32
+  // CHECK: and i32 %{{.*}}, 65535
+  // CHECK: shl i32 %{{.*}}, 16
+  // CHECK: or i32 %{{.*}}, %{{.*}}
+  // CHECK: bitcast i32 %{{.*}} to <32 x i1>
+  return 
_mm512_mask_cmpneq_epu16_mask(_mm512_kunpackw(_mm512_cmpneq_epu16_mask(__B, 
__A),_mm512_cmpneq_epu16_mask(__C, __D)), __E, __F); 
 }
 
 __m512i test_mm512_mask_loadu_epi16(__m512i __W, __mmask32 __U, void const 
*__P) {

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=319777&r1=319776&r2=319777&view=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Tue Dec  5 07:42:47 2017
@@ -6241,10 +6241,17 @@ int test_mm512_kortestz(__mmask16 __A, _
   return _mm512_kortestz(__A, __B); 
 }
 
-__mmask16 test_mm512_kunpackb(__mmask16 __A, __mmask16 __B) {
+__mmask16 test_mm512_kunpackb(__m512i __A, __m512i __B, __m512i __C, __m512i 
__D, __m512i __E, __m512i __F) {
   // CH

[PATCH] D39719: [X86][AVX512] lowering kunpack intrinsic - clang part

2017-12-05 Thread jina via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319777: [x86][AVX512] Lowering kunpack intrinsics to LLVM IR 
(authored by jina.nahias).

Changed prior to commit:
  https://reviews.llvm.org/D39719?vs=122617&id=125525#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39719

Files:
  cfe/trunk/lib/Headers/avx512bwintrin.h
  cfe/trunk/lib/Headers/avx512fintrin.h
  cfe/trunk/test/CodeGen/avx512bw-builtins.c
  cfe/trunk/test/CodeGen/avx512f-builtins.c


Index: cfe/trunk/lib/Headers/avx512fintrin.h
===
--- cfe/trunk/lib/Headers/avx512fintrin.h
+++ cfe/trunk/lib/Headers/avx512fintrin.h
@@ -8787,7 +8787,7 @@
 static __inline__ __mmask16 __DEFAULT_FN_ATTRS
 _mm512_kunpackb (__mmask16 __A, __mmask16 __B)
 {
-  return (__mmask16) __builtin_ia32_kunpckhi ((__mmask16) __A, (__mmask16) 
__B);
+  return (__mmask16)  (( __A  & 0xFF) | ( __B << 8));
 }
 
 static __inline__ __mmask16 __DEFAULT_FN_ATTRS
Index: cfe/trunk/lib/Headers/avx512bwintrin.h
===
--- cfe/trunk/lib/Headers/avx512bwintrin.h
+++ cfe/trunk/lib/Headers/avx512bwintrin.h
@@ -1854,15 +1854,13 @@
 static __inline__ __mmask64 __DEFAULT_FN_ATTRS
 _mm512_kunpackd (__mmask64 __A, __mmask64 __B)
 {
-  return (__mmask64) __builtin_ia32_kunpckdi ((__mmask64) __A,
-(__mmask64) __B);
+  return (__mmask64)  (( __A  & 0x) | ( __B << 32));
 }
 
 static __inline__ __mmask32 __DEFAULT_FN_ATTRS
 _mm512_kunpackw (__mmask32 __A, __mmask32 __B)
 {
-  return (__mmask32) __builtin_ia32_kunpcksi ((__mmask32) __A,
-(__mmask32) __B);
+return (__mmask32)  (( __A  & 0x) | ( __B << 16));
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
Index: cfe/trunk/test/CodeGen/avx512bw-builtins.c
===
--- cfe/trunk/test/CodeGen/avx512bw-builtins.c
+++ cfe/trunk/test/CodeGen/avx512bw-builtins.c
@@ -1626,16 +1626,26 @@
   return _mm512_maskz_set1_epi8(__M, __A); 
 }
 
-__mmask64 test_mm512_kunpackd(__mmask64 __A, __mmask64 __B) {
+__mmask64 test_mm512_kunpackd(__m512i __A, __m512i __B, __m512i __C, __m512i 
__D, __m512i __E, __m512i __F) {
   // CHECK-LABEL: @test_mm512_kunpackd
-  // CHECK: @llvm.x86.avx512.kunpck.dq
-  return _mm512_kunpackd(__A, __B); 
+  // CHECK: bitcast <64 x i1> %{{.*}} to i64
+  // CHECK: bitcast <64 x i1> %{{.*}} to i64
+  // CHECK: and i64 %{{.*}}, 4294967295
+  // CHECK: shl i64 %{{.*}}, 32
+  // CHECK: or i64 %{{.*}}, %{{.*}}
+  // CHECK: bitcast i64 %{{.*}} to <64 x i1>
+  return 
_mm512_mask_cmpneq_epu8_mask(_mm512_kunpackd(_mm512_cmpneq_epu8_mask(__B, 
__A),_mm512_cmpneq_epu8_mask(__C, __D)), __E, __F); 
 }
 
-__mmask32 test_mm512_kunpackw(__mmask32 __A, __mmask32 __B) {
+__mmask32 test_mm512_kunpackw(__m512i __A, __m512i __B, __m512i __C, __m512i 
__D, __m512i __E, __m512i __F) {
   // CHECK-LABEL: @test_mm512_kunpackw
-  // CHECK: @llvm.x86.avx512.kunpck.wd
-  return _mm512_kunpackw(__A, __B); 
+  // CHECK: bitcast <32 x i1> %{{.*}} to i32
+  // CHECK: bitcast <32 x i1> %{{.*}} to i32
+  // CHECK: and i32 %{{.*}}, 65535
+  // CHECK: shl i32 %{{.*}}, 16
+  // CHECK: or i32 %{{.*}}, %{{.*}}
+  // CHECK: bitcast i32 %{{.*}} to <32 x i1>
+  return 
_mm512_mask_cmpneq_epu16_mask(_mm512_kunpackw(_mm512_cmpneq_epu16_mask(__B, 
__A),_mm512_cmpneq_epu16_mask(__C, __D)), __E, __F); 
 }
 
 __m512i test_mm512_mask_loadu_epi16(__m512i __W, __mmask32 __U, void const 
*__P) {
Index: cfe/trunk/test/CodeGen/avx512f-builtins.c
===
--- cfe/trunk/test/CodeGen/avx512f-builtins.c
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c
@@ -6241,10 +6241,17 @@
   return _mm512_kortestz(__A, __B); 
 }
 
-__mmask16 test_mm512_kunpackb(__mmask16 __A, __mmask16 __B) {
+__mmask16 test_mm512_kunpackb(__m512i __A, __m512i __B, __m512i __C, __m512i 
__D, __m512i __E, __m512i __F) {
   // CHECK-LABEL: @test_mm512_kunpackb
-  // CHECK: @llvm.x86.avx512.kunpck.bw
-  return _mm512_kunpackb(__A, __B); 
+  // CHECK: bitcast <16 x i1> %{{.*}} to i16
+  // CHECK: bitcast <16 x i1> %{{.*}} to i16
+  // CHECK: and i32 %{{.*}}, 255
+  // CHECK: shl i32 %{{.*}}, 8
+  // CHECK: or i32 %{{.*}}, %{{.*}}
+  // CHECK: bitcast i16 %{{.*}} to <16 x i1>
+  return 
_mm512_mask_cmpneq_epu32_mask(_mm512_kunpackb(_mm512_cmpneq_epu32_mask(__A, 
__B),
+   
_mm512_cmpneq_epu32_mask(__C, __D)),
+   __E, __F);
 }
 
 __mmask16 test_mm512_kxnor(__mmask16 __A, __mmask16 __B) {


Index: cfe/trunk/lib/Headers/avx512fintrin.h
===
--- cfe/trunk/lib/Headers/avx512fintrin.h
+++ cfe/trunk/lib/Headers/avx512fintrin.h
@@ -8787,7 +8787,7 @@
 static __inline__ __mmask16 __DEFAULT_FN_ATTRS
 _mm512_kunpackb (__mmask16 __A, __mmask16 __B)
 {
-  

[PATCH] D39719: [X86][AVX512] lowering kunpack intrinsic - clang part

2017-12-05 Thread jina via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC319777: [x86][AVX512] Lowering kunpack intrinsics to LLVM IR 
(authored by jina.nahias).

Repository:
  rC Clang

https://reviews.llvm.org/D39719

Files:
  lib/Headers/avx512bwintrin.h
  lib/Headers/avx512fintrin.h
  test/CodeGen/avx512bw-builtins.c
  test/CodeGen/avx512f-builtins.c


Index: lib/Headers/avx512bwintrin.h
===
--- lib/Headers/avx512bwintrin.h
+++ lib/Headers/avx512bwintrin.h
@@ -1854,15 +1854,13 @@
 static __inline__ __mmask64 __DEFAULT_FN_ATTRS
 _mm512_kunpackd (__mmask64 __A, __mmask64 __B)
 {
-  return (__mmask64) __builtin_ia32_kunpckdi ((__mmask64) __A,
-(__mmask64) __B);
+  return (__mmask64)  (( __A  & 0x) | ( __B << 32));
 }
 
 static __inline__ __mmask32 __DEFAULT_FN_ATTRS
 _mm512_kunpackw (__mmask32 __A, __mmask32 __B)
 {
-  return (__mmask32) __builtin_ia32_kunpcksi ((__mmask32) __A,
-(__mmask32) __B);
+return (__mmask32)  (( __A  & 0x) | ( __B << 16));
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
Index: lib/Headers/avx512fintrin.h
===
--- lib/Headers/avx512fintrin.h
+++ lib/Headers/avx512fintrin.h
@@ -8787,7 +8787,7 @@
 static __inline__ __mmask16 __DEFAULT_FN_ATTRS
 _mm512_kunpackb (__mmask16 __A, __mmask16 __B)
 {
-  return (__mmask16) __builtin_ia32_kunpckhi ((__mmask16) __A, (__mmask16) 
__B);
+  return (__mmask16)  (( __A  & 0xFF) | ( __B << 8));
 }
 
 static __inline__ __mmask16 __DEFAULT_FN_ATTRS
Index: test/CodeGen/avx512f-builtins.c
===
--- test/CodeGen/avx512f-builtins.c
+++ test/CodeGen/avx512f-builtins.c
@@ -6241,10 +6241,17 @@
   return _mm512_kortestz(__A, __B); 
 }
 
-__mmask16 test_mm512_kunpackb(__mmask16 __A, __mmask16 __B) {
+__mmask16 test_mm512_kunpackb(__m512i __A, __m512i __B, __m512i __C, __m512i 
__D, __m512i __E, __m512i __F) {
   // CHECK-LABEL: @test_mm512_kunpackb
-  // CHECK: @llvm.x86.avx512.kunpck.bw
-  return _mm512_kunpackb(__A, __B); 
+  // CHECK: bitcast <16 x i1> %{{.*}} to i16
+  // CHECK: bitcast <16 x i1> %{{.*}} to i16
+  // CHECK: and i32 %{{.*}}, 255
+  // CHECK: shl i32 %{{.*}}, 8
+  // CHECK: or i32 %{{.*}}, %{{.*}}
+  // CHECK: bitcast i16 %{{.*}} to <16 x i1>
+  return 
_mm512_mask_cmpneq_epu32_mask(_mm512_kunpackb(_mm512_cmpneq_epu32_mask(__A, 
__B),
+   
_mm512_cmpneq_epu32_mask(__C, __D)),
+   __E, __F);
 }
 
 __mmask16 test_mm512_kxnor(__mmask16 __A, __mmask16 __B) {
Index: test/CodeGen/avx512bw-builtins.c
===
--- test/CodeGen/avx512bw-builtins.c
+++ test/CodeGen/avx512bw-builtins.c
@@ -1626,16 +1626,26 @@
   return _mm512_maskz_set1_epi8(__M, __A); 
 }
 
-__mmask64 test_mm512_kunpackd(__mmask64 __A, __mmask64 __B) {
+__mmask64 test_mm512_kunpackd(__m512i __A, __m512i __B, __m512i __C, __m512i 
__D, __m512i __E, __m512i __F) {
   // CHECK-LABEL: @test_mm512_kunpackd
-  // CHECK: @llvm.x86.avx512.kunpck.dq
-  return _mm512_kunpackd(__A, __B); 
+  // CHECK: bitcast <64 x i1> %{{.*}} to i64
+  // CHECK: bitcast <64 x i1> %{{.*}} to i64
+  // CHECK: and i64 %{{.*}}, 4294967295
+  // CHECK: shl i64 %{{.*}}, 32
+  // CHECK: or i64 %{{.*}}, %{{.*}}
+  // CHECK: bitcast i64 %{{.*}} to <64 x i1>
+  return 
_mm512_mask_cmpneq_epu8_mask(_mm512_kunpackd(_mm512_cmpneq_epu8_mask(__B, 
__A),_mm512_cmpneq_epu8_mask(__C, __D)), __E, __F); 
 }
 
-__mmask32 test_mm512_kunpackw(__mmask32 __A, __mmask32 __B) {
+__mmask32 test_mm512_kunpackw(__m512i __A, __m512i __B, __m512i __C, __m512i 
__D, __m512i __E, __m512i __F) {
   // CHECK-LABEL: @test_mm512_kunpackw
-  // CHECK: @llvm.x86.avx512.kunpck.wd
-  return _mm512_kunpackw(__A, __B); 
+  // CHECK: bitcast <32 x i1> %{{.*}} to i32
+  // CHECK: bitcast <32 x i1> %{{.*}} to i32
+  // CHECK: and i32 %{{.*}}, 65535
+  // CHECK: shl i32 %{{.*}}, 16
+  // CHECK: or i32 %{{.*}}, %{{.*}}
+  // CHECK: bitcast i32 %{{.*}} to <32 x i1>
+  return 
_mm512_mask_cmpneq_epu16_mask(_mm512_kunpackw(_mm512_cmpneq_epu16_mask(__B, 
__A),_mm512_cmpneq_epu16_mask(__C, __D)), __E, __F); 
 }
 
 __m512i test_mm512_mask_loadu_epi16(__m512i __W, __mmask32 __U, void const 
*__P) {


Index: lib/Headers/avx512bwintrin.h
===
--- lib/Headers/avx512bwintrin.h
+++ lib/Headers/avx512bwintrin.h
@@ -1854,15 +1854,13 @@
 static __inline__ __mmask64 __DEFAULT_FN_ATTRS
 _mm512_kunpackd (__mmask64 __A, __mmask64 __B)
 {
-  return (__mmask64) __builtin_ia32_kunpckdi ((__mmask64) __A,
-(__mmask64) __B);
+  return (__mmask64)  (( __A  & 0x) | ( __B << 32));
 }
 
 static __inline__ __mmask32 __DEFAULT_FN_ATTRS
 _mm512_kunpackw (__mmask32 __A, __mmask32 __B)
 {
-  ret

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

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



Comment at: test/clang-tidy/fuchsia-multiple-inheritance.cpp:48
+};
+
+// Inherits from multiple concrete classes.

juliehockett wrote:
> aaron.ballman wrote:
> > The virtual base test cases I was thinking of were:
> > ```
> > struct Base { virtual void foo() = 0; };
> > struct V1 : virtual Base {};
> > struct V2 : virtual Base {};
> > struct D : V1, V2 {}; // Should be fine
> > ---
> > struct Base { virtual void foo(); };
> > struct V1 : virtual Base {};
> > struct V2 : virtual Base {};
> > struct D : V1, V2 {}; // Should be fine (there's only one concrete base)?
> > ---
> > struct Base {};
> > struct V1 : virtual Base { virtual void f(); }
> > struct V2 : virtual Base { virtual void g(); }
> > struct D : V1, V2 {}; // Not okay
> > ---
> > struct Base {};
> > struct V1 : virtual Base { virtual void f() = 0; }
> > struct V2 : virtual Base { virtual void g() = 0; }
> > struct D : V1, V2 {}; // Okay
> > ---
> > struct Base { virtual void f(); };
> > struct V1 : virtual Base { virtual void f(); }
> > struct V2 : virtual base { virtual void g() = 0; }
> > struct D : V1, V2 {}; // Should be okay (V1::f() overrides Base::f() which 
> > is only inherited once)?
> > ```
> Ah okay I see what you mean. We're actually following the Google style guide 
> (see [[ https://google.github.io/styleguide/cppguide.html#Inheritance | here 
> ]]), so virtual inheritance is disallowed. There's another check that covers 
> these cases (see [[ https://reviews.llvm.org/D40813 | D40813 ]]).
What about users who disable that check but leave this one enabled? I think the 
crux of the rule is that multiple inheritance of interface features is bad, and 
so I think there's a sensible answer here for virtual bases as well.


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] D40813: [clang-tidy] Adding Fuchsia checker for virtual inheritance

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



Comment at: clang-tidy/fuchsia/FuchsiaTidyModule.cpp:28-29
 "fuchsia-default-arguments");
+CheckFactories.registerCheck(
+"fuchsia-virtual-inheritance");
   }

Formatting looks off here.



Comment at: clang-tidy/fuchsia/VirtualInheritanceCheck.cpp:21
+AST_MATCHER(CXXRecordDecl, hasVirtualBaseClass) {
+  return Node.hasDefinition() && (Node.getNumVBases() != 0);
+}

Elide spurious parens.



Comment at: clang-tidy/fuchsia/VirtualInheritanceCheck.cpp:44
+  else if (const auto *S = Result.Nodes.getNodeAs("stmt"))
+diag(S->getLocStart(), "constructing a class which inherits a virtual base 
"
+   "class is disallowed");

s/which/that



Comment at: docs/clang-tidy/checks/fuchsia-virtual-inheritance.rst:12
+
+  class B : public virtual A {}   // warning
+

Missing a semicolon on the class declaration.


https://reviews.llvm.org/D40813



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


[libcxx] r319779 - Mark a couple of internal routines as 'noexcept'

2017-12-05 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Dec  5 07:56:26 2017
New Revision: 319779

URL: http://llvm.org/viewvc/llvm-project?rev=319779&view=rev
Log:
Mark a couple of internal routines as 'noexcept'

Modified:
libcxx/trunk/include/memory

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=319779&r1=319778&r2=319779&view=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Tue Dec  5 07:56:26 2017
@@ -1730,10 +1730,10 @@ private:
 }
 
 _LIBCPP_INLINE_VISIBILITY
-static size_type __max_size(true_type, const allocator_type& __a)
+static size_type __max_size(true_type, const allocator_type& __a) _NOEXCEPT
 {return __a.max_size();}
 _LIBCPP_INLINE_VISIBILITY
-static size_type __max_size(false_type, const allocator_type&)
+static size_type __max_size(false_type, const allocator_type&) _NOEXCEPT
 {return numeric_limits::max() / sizeof(value_type);}
 
 _LIBCPP_INLINE_VISIBILITY


___
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-05 Thread Nicholas Wilson via Phabricator via cfe-commits
ncw added a comment.

Thanks for the review @sunfish (and for the other input you've given). Could 
you land this for me Dan, as I don't have commit access? Thanks.


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] D40829: [clang-tidy] adjust cppcoreguidelines-owning-memory documentation

2017-12-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

This is reasonable, though if the list starts getting longer, we should 
consider trying to fix the bug rather than enumerate them.




Comment at: docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst:115
+
+Known code constructs that do not get diagnosed correctly are
+

Add a colon after `are`.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40829



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


[PATCH] D28820: Warn when calling a non interrupt function from an interrupt on ARM

2017-12-05 Thread KCG via Phabricator via cfe-commits
kc.austin2017 added a comment.

In https://reviews.llvm.org/D28820#944865, @jroelofs wrote:

> In https://reviews.llvm.org/D28820#944365, @efriedma wrote:
>
> > > What is the best way to modify the code for this compiler change ?
> >
> > Currently, the "interrupt" attribute only has an effect on functions, not 
> > function pointers, so your code won't work the way you want.  It's a bug 
> > that we don't emit a warning for this.
>
>
> https://bugs.llvm.org/show_bug.cgi?id=35527
>
> > Currently, this warning doesn't have its own warning flag, instead being 
> > lumped under -Wextra.  This is also a bug.
>
> https://bugs.llvm.org/show_bug.cgi?id=35528
>
> > We don't emit the warning if your code is compiled for a target which 
> > doesn't support floating-point (-mfpu=none or -msoft-float); see 
> > https://reviews.llvm.org/D32918. But otherwise, if you're sure your code is 
> > actually correct, you can turn off the warning with -Wno-extra or something 
> > like that.  (The whole thing is kind of awkward because the implementation 
> > of the interrupt attribute in clang is buggy: the frontend lies to the 
> > backend about the calling convention, so the backend can't save/restore VFP 
> > registers correctly.)
>
> https://i.imgur.com/BFRoEUO.gif
>
> In https://reviews.llvm.org/D28820#944706, @kc.austin2017 wrote:
>
> > so is there any plan to make the "interrupt" attribute not just support on 
> > functions?
>
>
> I'll fix these. Give me a few weeks though.


Thank you very much for recording the bug.


https://reviews.llvm.org/D28820



___
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-05 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

In https://reviews.llvm.org/D39694#944642, @hfinkel wrote:

> I think this is a good idea.


Thanks for the review.  I've replied to each comment and will make revisions 
after we agree on the behavioral issue you raised.




Comment at: include/clang/Driver/CC1Options.td:407
 def verify : Flag<["-"], "verify">,
-  HelpText<"Verify diagnostic output using comment directives">;
+  HelpText<"Similar to -verify=expected">;
 def verify_ignore_unexpected : Flag<["-"], "verify-ignore-unexpected">,

hfinkel wrote:
> "Similar to" seems unfortunately vague. Can it say, "Equivalent to ..."?
I agree I should have made it clearer.

"Equivalent to -verify=expected"  works if we decide that duplicate explicit 
prefixes are permitted, as you've suggested in a later comment.

With the current implementation, it should be "All occurrences together are 
equivalent to one occurrence of -verify=expected".  That is, I chose to permit 
multiple occurrences of -verify without explicit prefixes for backward 
compatibility, but I chose not to permit duplicate explicit prefixes for 
reasons I'll discuss in the other comment.

I'll clean up the documentation once we agree on the right behavior.





Comment at: lib/Frontend/CompilerInvocation.cpp:1081
+[](char C){return !isAlphanumeric(C)
+  && C!='-' && C!='_';});
+if (BadChar != Prefix.end() || !isLetter(Prefix[0])) {

hfinkel wrote:
> I'd prefer to have spaces around the != operators.
Will change.



Comment at: lib/Frontend/CompilerInvocation.cpp:1095
+  if (Diags) {
+Diags->Report(diag::err_drv_invalid_value) << "-verify=" << Prefix;
+Diags->Report(diag::note_drv_verify_prefix_unique);

hfinkel wrote:
> If this were going to be an error, then it should have error message that 
> explains the problem (e.g., duplicate --verify prefix). I don't believe that 
> we should make this an error (i.e., I think that we should allow duplicate 
> --verify options with the same prefixes).
> If this were going to be an error, then it should have error message that 
> explains the problem (e.g., duplicate --verify prefix).

Are you saying you prefer that to be in the error instead of the note (where it 
is now)?

> I don't believe that we should make this an error (i.e., I think that we 
> should allow duplicate --verify options with the same prefixes).

I see two reasons to permit duplicate explicit prefixes:

1. It simplifies the documentation some (see previous comment).

2. Typically, it's convenient to permit command-line options to be repeated so 
that groups of options can be collected in shell or make variables without 
having to worry about conflicts between groups.  On the other hand, I'm having 
trouble imagining that use case for -verify options, which I believe would 
normally appear directly in command lines in test source files.  Have you seen 
use cases (perhaps with FileCheck) where it would be useful?

I see three reasons not to permit duplicate explicit prefixes:

1. Not permitting duplicates is consistent with FileCheck's --check-prefix[es].

2. If we change our mind, we can later relax the restriction without breaking 
backward compatibility, but we cannot go the other direction.

3. Suppose a developer wants to extend an existing test case by adding new 
-verify prefixes to existing clang command lines that already uses many -verify 
prefixes.  If the developer accidentally duplicates an existing prefix, the 
test case surely will not behave as expected, but it should be easier to 
understand what has gone wrong if the compiler complains about duplicate 
prefixes.

I'm not adamant about the current behavior, but I think we should consider 
these points before deciding.



Comment at: lib/Frontend/VerifyDiagnosticConsumer.cpp:233
   // Return true if string literal is found.
   // When true, P marks begin-position of S in content.
+  bool Search(StringRef S, bool EnsureStartOfWord = false,

hfinkel wrote:
> Please document here what FinishDirectiveWord means (and, while you're at it, 
> documenting what EnsureStartOfWord means would be nice too).
Sure, I'll work on it.



Comment at: lib/Frontend/VerifyDiagnosticConsumer.cpp:370
+bool NoDiag = false;
+{
+  StringRef DType;

hfinkel wrote:
> This block is to limit the scope of the DType StringRef? That doesn't seem 
> worthwhile.
Will change.


https://reviews.llvm.org/D39694



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


[PATCH] D37813: clang-format: better handle namespace macros

2017-12-05 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

I don't think this is really relevant for this tool: if someone changes the 
implementation of the macro, then *they* must indeed if it should not be 
formatted like a namespace (and keep the clang-format configuration unchanged), 
or if it should now be formatted like a class (and thus make changes to 
clang-format configuration). Here we are not defining what the macro does, but 
how clang-format should indent it : in most case I don't think the indentation 
format should actually depend on the way it is implemented...


https://reviews.llvm.org/D37813



___
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-05 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle requested changes to this revision.
malaperle added a comment.
This revision now requires changes to proceed.

Sorry I forgot to submit this additional comment in my last review pass :(




Comment at: clangd/Protocol.cpp:365
+  {"range", toJSON(DH.range)},
+  {"kind", (int)DH.kind},
+  };

static_cast(DH.kind)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38425



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


[PATCH] D40829: [clang-tidy] adjust cppcoreguidelines-owning-memory documentation

2017-12-05 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

I agree.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40829



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


[PATCH] D40829: [clang-tidy] adjust cppcoreguidelines-owning-memory documentation

2017-12-05 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 125536.
JonasToth added a comment.

- [Fix] typo


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40829

Files:
  docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst


Index: docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
===
--- docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
+++ docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
@@ -111,7 +111,11 @@
 In template functions and classes, like in the example below, the information
 of the type aliases gets lost. Therefore using ``gsl::owner`` in a heavy 
templated
 code base might lead to false positives. 
-This limitation results in ``std::vector>`` not being diagnosed 
correctly.
+
+Known code constructs that do not get diagnosed correctly are:
+
+- ``std::exchange``
+- ``std::vector>``
 
 .. code-block:: c++
 


Index: docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
===
--- docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
+++ docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
@@ -111,7 +111,11 @@
 In template functions and classes, like in the example below, the information
 of the type aliases gets lost. Therefore using ``gsl::owner`` in a heavy templated
 code base might lead to false positives. 
-This limitation results in ``std::vector>`` not being diagnosed correctly.
+
+Known code constructs that do not get diagnosed correctly are:
+
+- ``std::exchange``
+- ``std::vector>``
 
 .. code-block:: c++
 
___
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-05 Thread Anton via Phabricator via cfe-commits
xgsa added a comment.

In https://reviews.llvm.org/D40671#944906, @alexfh wrote:

> BTW, how will this feature interact with cpplint.py's way of handling 
> specific NOLINT directives that use different lint rule names, which 
> sometimes refer to the same rule (e.g. `// NOLINT(runtime/explicit)` 
> suppresses the `runtime/explicit` cpplint rule that enforces the same style 
> rule as the google-runtime-explicit check)?


This feature accepts only full check names.


https://reviews.llvm.org/D40671



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


[clang-tools-extra] r319785 - [clang-tidy] adjust cppcoreguidelines-owning-memory documentation

2017-12-05 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Tue Dec  5 08:37:49 2017
New Revision: 319785

URL: http://llvm.org/viewvc/llvm-project?rev=319785&view=rev
Log:
[clang-tidy] adjust cppcoreguidelines-owning-memory documentation

Summary:
A user of the check opened a bugreport and reported that `std::exchange`
triggers a false positive. I adjusted the doc to include a list of known
(std) constructs that do trigger the issue with templates forgetting the
type alias.

Reviewers: aaron.ballman, alexfh, hokein

Reviewed By: aaron.ballman

Subscribers: klimek, nemanjai, xazax.hun, kbarton, cfe-commits

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

Modified:

clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst?rev=319785&r1=319784&r2=319785&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
 Tue Dec  5 08:37:49 2017
@@ -111,7 +111,11 @@ The ``gsl::owner`` is declared as a
 In template functions and classes, like in the example below, the information
 of the type aliases gets lost. Therefore using ``gsl::owner`` in a heavy 
templated
 code base might lead to false positives. 
-This limitation results in ``std::vector>`` not being diagnosed 
correctly.
+
+Known code constructs that do not get diagnosed correctly are:
+
+- ``std::exchange``
+- ``std::vector>``
 
 .. code-block:: c++
 


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


[PATCH] D40829: [clang-tidy] adjust cppcoreguidelines-owning-memory documentation

2017-12-05 Thread Jonas Toth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319785: [clang-tidy] adjust cppcoreguidelines-owning-memory 
documentation (authored by JonasToth).

Repository:
  rL LLVM

https://reviews.llvm.org/D40829

Files:
  
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst


Index: 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
===
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
@@ -111,7 +111,11 @@
 In template functions and classes, like in the example below, the information
 of the type aliases gets lost. Therefore using ``gsl::owner`` in a heavy 
templated
 code base might lead to false positives. 
-This limitation results in ``std::vector>`` not being diagnosed 
correctly.
+
+Known code constructs that do not get diagnosed correctly are:
+
+- ``std::exchange``
+- ``std::vector>``
 
 .. code-block:: c++
 


Index: clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
@@ -111,7 +111,11 @@
 In template functions and classes, like in the example below, the information
 of the type aliases gets lost. Therefore using ``gsl::owner`` in a heavy templated
 code base might lead to false positives. 
-This limitation results in ``std::vector>`` not being diagnosed correctly.
+
+Known code constructs that do not get diagnosed correctly are:
+
+- ``std::exchange``
+- ``std::vector>``
 
 .. code-block:: c++
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40485: [clangd] Introduced a Context that stores implicit data

2017-12-05 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 125539.
ilya-biryukov added a comment.
Herald added a subscriber: klimek.

Addressed some review comments.

- Removed global context.
- Context now stores a shared_ptr to ContextData to handle lifetimes properly.
- Added helper getters for some commonly used types to Context.
- Removed PtrKey, this simplified code a bit.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40485

Files:
  clangd/CMakeLists.txt
  clangd/Context.cpp
  clangd/Context.h
  clangd/TypedValueMap.h
  unittests/clangd/CMakeLists.txt
  unittests/clangd/ContextTests.cpp

Index: unittests/clangd/ContextTests.cpp
===
--- /dev/null
+++ unittests/clangd/ContextTests.cpp
@@ -0,0 +1,71 @@
+//===-- ContextTests.cpp - Context tests *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "Context.h"
+
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+
+TEST(TypedValueMapTests, Simple) {
+  Key IntParam;
+  Key ExtraIntParam;
+
+  clangd::TypedValueMap Ctx;
+
+  ASSERT_TRUE(Ctx.emplace(IntParam, 10));
+  ASSERT_TRUE(Ctx.emplace(ExtraIntParam, 20));
+
+  EXPECT_EQ(*Ctx.get(IntParam), 10);
+  EXPECT_EQ(*Ctx.get(ExtraIntParam), 20);
+
+  ASSERT_FALSE(Ctx.emplace(IntParam, 30));
+
+  ASSERT_TRUE(Ctx.remove(IntParam));
+  EXPECT_EQ(Ctx.get(IntParam), nullptr);
+  EXPECT_EQ(*Ctx.get(ExtraIntParam), 20);
+
+  ASSERT_TRUE(Ctx.emplace(IntParam, 30));
+  EXPECT_EQ(*Ctx.get(IntParam), 30);
+  EXPECT_EQ(*Ctx.get(ExtraIntParam), 20);
+}
+
+TEST(TypedValueMapTests, MoveOps) {
+  Key> Param;
+
+  clangd::TypedValueMap Ctx;
+  Ctx.emplace(Param, llvm::make_unique(10));
+  EXPECT_EQ(**Ctx.get(Param), 10);
+
+  clangd::TypedValueMap NewCtx = std::move(Ctx);
+  EXPECT_EQ(**NewCtx.get(Param), 10);
+}
+
+TEST(ContextTests, Builders) {
+  Key ParentParam;
+  Key ParentAndChildParam;
+  Key ChildParam;
+
+  Context ParentCtx =
+  buildCtx().add(ParentParam, 10).add(ParentAndChildParam, 20);
+  Context ChildCtx =
+  ParentCtx.derive().add(ParentAndChildParam, 30).add(ChildParam, 40);
+
+  EXPECT_EQ(*ParentCtx->get(ParentParam), 10);
+  EXPECT_EQ(*ParentCtx->get(ParentAndChildParam), 20);
+  EXPECT_EQ(ParentCtx->get(ChildParam), nullptr);
+
+  EXPECT_EQ(*ChildCtx->get(ParentParam), 10);
+  EXPECT_EQ(*ChildCtx->get(ParentAndChildParam), 30);
+  EXPECT_EQ(*ChildCtx->get(ChildParam), 40);
+}
+
+} // namespace clangd
+} // namespace clang
Index: unittests/clangd/CMakeLists.txt
===
--- unittests/clangd/CMakeLists.txt
+++ unittests/clangd/CMakeLists.txt
@@ -11,6 +11,7 @@
 add_extra_unittest(ClangdTests
   ClangdTests.cpp
   CodeCompleteTests.cpp
+  ContextTests.cpp
   FuzzyMatchTests.cpp
   JSONExprTests.cpp
   TestFS.cpp
Index: clangd/TypedValueMap.h
===
--- /dev/null
+++ clangd/TypedValueMap.h
@@ -0,0 +1,95 @@
+//===--- TypedValueMap.h - Type-safe heterogenous key-value map -*- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Type-safe heterogenous map.
+//
+//===--===//
+
+#include "llvm/ADT/DenseMap.h"
+#include 
+
+namespace clang {
+namespace clangd {
+
+/// Used as identity for map values. Non-movable and non-copyable. Address of
+/// this object is used internally to as keys in a map.
+template  class Key {
+public:
+  static_assert(!std::is_reference::value,
+"Reference arguments to Key<> are not allowed");
+
+  Key() = default;
+
+  Key(Key const &) = delete;
+  Key &operator=(Key const &) = delete;
+  Key(Key &&) = delete;
+  Key &operator=(Key &&) = delete;
+};
+
+/// A type-safe map from Key to T.
+class TypedValueMap {
+public:
+  TypedValueMap() = default;
+  TypedValueMap(const TypedValueMap &) = delete;
+  TypedValueMap(TypedValueMap &&) = default;
+
+  template  Type *get(Key &Key) const {
+auto It = Map.find(&Key);
+if (It == Map.end())
+  return nullptr;
+return static_cast(It->second->getValuePtr());
+  }
+
+  template 
+  bool emplace(Key &Key, Args &&... As) {
+bool Added =
+Map.try_emplace(&Key,
+llvm::make_unique<
+TypedAnyStorage::type>>(
+std::forward(As)...))
+.second;
+return Added;
+  }
+
+  template  bool remove(Key &Key) {
+auto It = Map.find(&Key);
+if (It == Map.end()

[PATCH] D40838: [OpenCL] Fix layering violation by getOpenCLTypeAddrSpace

2017-12-05 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/CodeGen/CGOpenCLRuntime.cpp:41
   uint32_t AddrSpc = CGM.getContext().getTargetAddressSpace(
-  CGM.getTarget().getOpenCLTypeAddrSpace(T));
+  CGM.getTarget().getOpenCLTypeAddrSpace(TK));
   switch (cast(T)->getKind()) {

Maybe also introduce ASTContext::getOpenCLTypeAddrSpace(const Type *T) for 
convenience. It has TargetInfo member.


https://reviews.llvm.org/D40838



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


[PATCH] D40485: [clangd] Introduced a Context that stores implicit data

2017-12-05 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov marked 6 inline comments as done.
ilya-biryukov added a comment.

A second attempt at implementing the `Context`s. Still missing a few comments, 
but hopefully ready for review.




Comment at: clangd/Context.h:71
+/// before any clangd functions are called.
+class GlobalSession {
+public:

sammccall wrote:
> Maybe `WithGlobalContext` is a good name for this scoped object?
> 
> This comment doesn't give a clear idea why someone would want to call this.
> Maybe `All contexts used by clangd inherit from this global context 
> (including contexts created internally)`
Remove the global context altogether.



Comment at: clangd/Context.h:79
+/// Otherwise returns an empty Context.
+Context &globalCtx();
+

ilya-biryukov wrote:
> sammccall wrote:
> > ilya-biryukov wrote:
> > > bkramer wrote:
> > > > This is a giant code smell. If we want the context route, please pass 
> > > > contexts everywhere. I really don't want this kind of technical debt in 
> > > > clangd now.
> > > I'm with you on this one, but I think @sammccall was keen on having the 
> > > global context. The main reason was to always have access to **some** 
> > > loggers and tracers, even when it's hard to pass the Context into the 
> > > function.
> > > It's perfectly easy to remove all usages of `globalCtx()`, currently only 
> > > 8 usages to get rid of. However, I'd wait for Sam's comment before doing 
> > > that.
> > It's important to be able to call functions that require a context if you 
> > don't have one - adding a log statement/trace for debugging shouldn't 
> > require changing plumbing/interfaces. (It's fine if we want to avoid 
> > checking in such code...)
> > Having an "empty" global context allows this.
> > 
> > At the same time, we want the ability to set the sink for logs/traces etc 
> > globally.
> > 
> > A couple of options:
> >  - the sink (e.g. Logger) is part of the context, we need to allow 
> > embedders to set/augment the global context
> >  - the sink is not stored in the context, instead it is some other 
> > singleton the embedder can set up
> > 
> > I don't have a strong opinion which is better. It's nice to reuse 
> > mechanisms, on the other hand loggers vs request IDs are pretty different 
> > types of data.
> I'd still get rid of it. The less implicit behavior we have, the better.
> It does not seem hard to plumb the `Context` all the way through clangd 
> currently. And it should not be too hard in the future.
> 
> I was asking myself multiple times whether we needed the global context in 
> the first place while implementing it.
> I think we should aim for avoiding global state altogether. That includes 
> singletons, etc. 
Removed the global context.



Comment at: clangd/Context.h:116
+/// Creates a new ContextBuilder, using globalCtx() as a parent.
+ContextBuilder buildCtx();
+/// Creates a new ContextBuilder with explicit \p Parent.

ilya-biryukov wrote:
> sammccall wrote:
> > This seems more naturally a method on Context, e.g.
> > 
> > Context C = globalCtx().derive(key, value);
> > 
> > The relationship between global and C is clear.
> > 
> > (You can allow chaining+mapping by having Context::derive and 
> > ContextBuilder::derive both return ContextBuilder&&, but as noted below I'm 
> > not sure it's worth the complexity over Context::derive ->Context)
> I think the current interface is simple enough and allows for both storage 
> implementations. I'd really avoid providing an interface that ties us into a 
> single storage implementation.
Added a `derive()` method to the `Context`.  It currently returns 
`ContextBuilder`, I still think it's nice to have the `ContextBuilder` and a 
separation between an immutable `Context` and a mutable `ContextBuilder`. Happy 
to chat on whether we want to remove it.



Comment at: clangd/TypedValueMap.h:1
+//===--- TypedValueMap.h - Type-safe heterogenous key-value map -*- C++-*-===//
+//

ilya-biryukov wrote:
> sammccall wrote:
> > This might be doing a little more than it needs to.
> > 
> > Do we need the ability to have multiple values of the same type?
> > If request ID is an int, needing to do `struct RequestID { ID int };` 
> > doesn't seem like much of a burden, and simplifies the semantics here.
> > 
> > And for cases like Logger where the type carries the semantics, keying by 
> > type is clearer.
> Are `Key<>` types confusing? I really like the fact that I don't have to 
> specify type information and it is carried in the `Key` to the 
> `get`/`emplace` methods, i.e. I don't have to specify template arguments 
> there.
> I don't see how `struct RequestId { ID int };` is clearer or shorter than 
> `Key RequestID;`. Again, are `Key` a confusing concept in the 
> first place?
Unfortunately, `typeid` does not with `-fno-rtti`, so there does not seem to be 
a way to significantly simplify the implementation (i.e. we'll ne

[PATCH] D40486: [clangd] Implemented logging using Context

2017-12-05 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 125545.
ilya-biryukov added a comment.
Herald added a subscriber: klimek.

- Updated to match the new Context implementation.
- Logger is now stored in a global variable instead of the global Context.
- Removed json-specific RequestContext, now storing all required information in 
Context.
- `reply`,`replyError` and `call` are freestanding functions now.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40486

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/ClangdUnitStore.cpp
  clangd/ClangdUnitStore.h
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/JSONRPCDispatcher.cpp
  clangd/JSONRPCDispatcher.h
  clangd/Logger.cpp
  clangd/Logger.h
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  clangd/tool/ClangdMain.cpp
  unittests/clangd/ClangdTests.cpp
  unittests/clangd/CodeCompleteTests.cpp

Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -8,6 +8,7 @@
 //===--===//
 #include "ClangdServer.h"
 #include "Compiler.h"
+#include "Context.h"
 #include "Protocol.h"
 #include "TestFS.h"
 #include "gtest/gtest.h"
@@ -74,8 +75,7 @@
   MockCompilationDatabase CDB;
 
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-  /*StorePreamblesInMemory=*/true,
-  EmptyLogger::getInstance());
+  /*StorePreamblesInMemory=*/true);
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
   const auto SourceContents = R"cpp(
@@ -101,29 +101,33 @@
 
   // No need to sync reparses here as there are no asserts on diagnostics (or
   // other async operations).
-  Server.addDocument(FooCpp, SourceContents);
+  Server.addDocument(FooCpp, SourceContents, buildCtx());
 
   {
 auto CodeCompletionResults1 =
-Server.codeComplete(FooCpp, CompletePos, CCOpts, None).get().Value;
+Server.codeComplete(FooCpp, CompletePos, CCOpts, buildCtx(), None)
+.get()
+.first.Value;
 EXPECT_TRUE(ContainsItem(CodeCompletionResults1, "aba"));
 EXPECT_FALSE(ContainsItem(CodeCompletionResults1, "cbc"));
   }
 
   {
 auto CodeCompletionResultsOverriden =
 Server
-.codeComplete(FooCpp, CompletePos, CCOpts,
+.codeComplete(FooCpp, CompletePos, CCOpts, buildCtx(),
   StringRef(OverridenSourceContents))
 .get()
-.Value;
+.first.Value;
 EXPECT_TRUE(ContainsItem(CodeCompletionResultsOverriden, "cbc"));
 EXPECT_FALSE(ContainsItem(CodeCompletionResultsOverriden, "aba"));
   }
 
   {
 auto CodeCompletionResults2 =
-Server.codeComplete(FooCpp, CompletePos, CCOpts, None).get().Value;
+Server.codeComplete(FooCpp, CompletePos, CCOpts, buildCtx(), None)
+.get()
+.first.Value;
 EXPECT_TRUE(ContainsItem(CodeCompletionResults2, "aba"));
 EXPECT_FALSE(ContainsItem(CodeCompletionResults2, "cbc"));
   }
@@ -135,8 +139,7 @@
   CDB.ExtraClangFlags.push_back("-xc++");
   IgnoreDiagnostics DiagConsumer;
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-  /*StorePreamblesInMemory=*/true,
-  EmptyLogger::getInstance());
+  /*StorePreamblesInMemory=*/true);
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
   FS.Files[FooCpp] = "";
@@ -150,17 +153,17 @@
 int main() { ClassWithMembers().{complete} }
   )cpp",
  "complete");
-  Server.addDocument(FooCpp, Completion.Text);
+  Server.addDocument(FooCpp, Completion.Text, buildCtx());
 
   clangd::CodeCompleteOptions Opts;
   Opts.Limit = 2;
 
   /// For after-dot completion we must always get consistent results.
   auto Results = Server
  .codeComplete(FooCpp, Completion.MarkerPos, Opts,
-   StringRef(Completion.Text))
+   buildCtx(), StringRef(Completion.Text))
  .get()
- .Value;
+ .first.Value;
 
   EXPECT_TRUE(Results.isIncomplete);
   EXPECT_EQ(Opts.Limit, Results.items.size());
@@ -175,8 +178,7 @@
   CDB.ExtraClangFlags.push_back("-xc++");
   IgnoreDiagnostics DiagConsumer;
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-  /*StorePreamblesInMemory=*/true,
-  EmptyLogger::getInstance());
+  /*StorePreamblesInMemory=*/true);
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
   FS.Files[FooCpp] = "";
@@ -19

[PATCH] D40489: [clangd] Changed tracing interfaces

2017-12-05 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov planned changes to this revision.
ilya-biryukov added a comment.

Have to update to match the new `Context` implementation.


https://reviews.llvm.org/D40489



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


[PATCH] D40486: [clangd] Implemented logging using Context

2017-12-05 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Additionally:

- All async methods now take `Context` by-value and pass it to their 
`Callback`s or return them in `future`s.
- All sync methods take `Context` by-ref



In https://reviews.llvm.org/D40486#941210, @sammccall wrote:

> This is pretty bikesheddy, but I wonder what you think about passing Ctx as 
> the first vs last parameter.
>  First has some advantages (maybe I just read too much Go though):
>
> - it's a short expr, and F(short, long) tends to format better than F(long, 
> short). Particularly with lambdas but also long strings.
> - it doesn't interfere with default args
>
>   It would be nice if we could be completely uniform here.


To be fair it was just a random thought and I totally agree with your points. 
I'll update the implementation and place the `Context` as the first parameter 
everywhere instead.
Could you take a look at other changes in the patch while I'm at it?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40486



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


[PATCH] D40841: [analyzer] Fix a crash on C++17 AST for non-trivial construction into a trivial brace initializer.

2017-12-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
Herald added subscribers: cfe-commits, rnkovacs.

Yet another situation where we cannot easily guess, by looking at the CFG, the 
target region for C++ constructor call.

Consider the following brace initialization:

  struct A {
A();
   };
  
  struct B : public A {
int x;
  };

void foo() {

  B b = {};

}

AST in C++14:

  `-VarDecl 0x7ff07884eab8  col:5 b 'struct B' cinit
`-CXXConstructExpr 0x7ff07887a940  'struct B' 'void (void) 
noexcept(false)' list zeroing

AST in C++17:

  `-VarDecl 0x7fb1cf012b18  col:5 b 'struct B' cinit
`-InitListExpr 0x7fb1cf012f38  'struct B'
  |-CXXConstructExpr 0x7fb1cf012fd0  'struct A' 'void (void)' list
  `-ImplicitValueInitExpr 0x7fb1cf013000 <> 'int'

CFG in C++14:

  [B1]
1: {} (CXXConstructExpr, struct B)
2: B b = {};

CFG in C++17:

  [B1]
1: {} (CXXConstructExpr, struct A)
2: /*implicit*/(int)0
3: {}
4: B b = {};

So, essentially, in C++17 we don't have the trivial constructor call for `B` 
present anywhere at all, neither in AST, nor in CFG.

This causes a crash in the analyzer because he tries to find the target region 
for `CK_NonVirtualBase` constructor of `A` by looking at the parent stack 
frame, expecting to find the derived class constructor (for `B`) here, and then 
taking a base region within its this-object.

This fix is a quick-and-dirty suppression for the crash. It follows the 
tradition of "when unsure, make up a temporary and construct into that, then 
discard the result" - which is wrong, but at least it gets some invalidation 
done.

In our example it would be correct to construct into `base{A, b}`. There can 
also be situations when such initializer-list is instead lifetime-extended by a 
`const&` or `&&` reference (see the tests), so in this case we'd need to 
construct into a respective sub-region of the temporary (but not into the 
temporary itself, of course).

Finally, from the perspective of checker development, i believe it would be 
useful to actually revive the constructor call, so that PreCall/PostCall event 
occured.


Repository:
  rC Clang

https://reviews.llvm.org/D40841

Files:
  lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  test/Analysis/initializer.cpp

Index: test/Analysis/initializer.cpp
===
--- test/Analysis/initializer.cpp
+++ test/Analysis/initializer.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks,debug.ExprInspection -analyzer-config c++-inlining=constructors -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks,debug.ExprInspection -analyzer-config c++-inlining=constructors -std=c++17 -DCPLUSPLUS17 -verify %s
 
 void clang_analyzer_eval(bool);
 
@@ -220,3 +221,40 @@
   C c{x}; // no-warning
 }
 }
+
+namespace CXX17_default_brace_syntax {
+struct A {
+  A();
+};
+
+struct B: public A {
+};
+
+struct C: public B {
+};
+
+struct D: public virtual A {
+};
+
+void foo() {
+  B b = {}; // no-crash
+  const B &bl = {}; // no-crash
+  B &&br = {}; // no-crash
+
+  C c = {}; // no-crash
+  const C &cl = {}; // no-crash
+  C &&cr = {}; // no-crash
+
+  D d = {};
+
+#ifdef CPLUSPLUS17
+  C cd = {{}}; // no-crash
+  const C &cdl = {{}}; // no-crash
+  C &&cdr = {{}}; // no-crash
+
+  const B &bll = {{}}; // no-crash
+  const B &bcl = C({{}}); // no-crash
+  B &&bcr = C({{}}); // no-crash
+#endif
+}
+}
Index: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -14,6 +14,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/StmtCXX.h"
+#include "clang/AST/ParentMap.h"
 #include "clang/Basic/PrettyStackTrace.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
@@ -277,6 +278,19 @@
 }
 // FALLTHROUGH
   case CXXConstructExpr::CK_NonVirtualBase:
+// FIXME: support C++17 construction into initializer lists. Instead of the
+// incorrect temporary region we use as a placeholder here, we should figure
+// out what region is being initialized by the surrounding InitListExpr and
+// construct into the relevant part of it. We might as well model the
+// trivial constructor call that's missing in the AST and CFG in this case
+// (which is why we cannot simply get the target region by sub-regioning the
+// this-region of the parent stack frame).
+if (dyn_cast_or_null(LCtx->getParentMap().getParent(CE))) {
+  MemRegionManager &MRMgr = getSValBuilder().getRegionManager();
+  Target = MRMgr.getCXXTempObjectRegion(CE, LCtx);
+  break;
+}
+// FALLTHROUGH
   case CXXConstructExpr::CK_Delegating: {
 

[PATCH] D40841: [analyzer] Fix a crash on C++17 AST for non-trivial construction into a trivial brace initializer.

2017-12-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 125547.
NoQ added a comment.

Add a forgotten //no-warning.


https://reviews.llvm.org/D40841

Files:
  lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  test/Analysis/initializer.cpp

Index: test/Analysis/initializer.cpp
===
--- test/Analysis/initializer.cpp
+++ test/Analysis/initializer.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks,debug.ExprInspection -analyzer-config c++-inlining=constructors -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks,debug.ExprInspection -analyzer-config c++-inlining=constructors -std=c++17 -DCPLUSPLUS17 -verify %s
 
 void clang_analyzer_eval(bool);
 
@@ -220,3 +221,40 @@
   C c{x}; // no-warning
 }
 }
+
+namespace CXX17_default_brace_syntax {
+struct A {
+  A();
+};
+
+struct B: public A {
+};
+
+struct C: public B {
+};
+
+struct D: public virtual A {
+};
+
+void foo() {
+  B b = {}; // no-crash
+  const B &bl = {}; // no-crash
+  B &&br = {}; // no-crash
+
+  C c = {}; // no-crash
+  const C &cl = {}; // no-crash
+  C &&cr = {}; // no-crash
+
+  D d = {}; // no-crash
+
+#ifdef CPLUSPLUS17
+  C cd = {{}}; // no-crash
+  const C &cdl = {{}}; // no-crash
+  C &&cdr = {{}}; // no-crash
+
+  const B &bll = {{}}; // no-crash
+  const B &bcl = C({{}}); // no-crash
+  B &&bcr = C({{}}); // no-crash
+#endif
+}
+}
Index: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -14,6 +14,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/StmtCXX.h"
+#include "clang/AST/ParentMap.h"
 #include "clang/Basic/PrettyStackTrace.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
@@ -277,6 +278,19 @@
 }
 // FALLTHROUGH
   case CXXConstructExpr::CK_NonVirtualBase:
+// FIXME: support C++17 construction into initializer lists. Instead of the
+// incorrect temporary region we use as a placeholder here, we should figure
+// out what region is being initialized by the surrounding InitListExpr and
+// construct into the relevant part of it. We might as well model the
+// trivial constructor call that's missing in the AST and CFG in this case
+// (which is why we cannot simply get the target region by sub-regioning the
+// this-region of the parent stack frame).
+if (dyn_cast_or_null(LCtx->getParentMap().getParent(CE))) {
+  MemRegionManager &MRMgr = getSValBuilder().getRegionManager();
+  Target = MRMgr.getCXXTempObjectRegion(CE, LCtx);
+  break;
+}
+// FALLTHROUGH
   case CXXConstructExpr::CK_Delegating: {
 const CXXMethodDecl *CurCtor = cast(LCtx->getDecl());
 Loc ThisPtr = getSValBuilder().getCXXThis(CurCtor,
Index: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
===
--- lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
+++ lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
@@ -22,6 +22,7 @@
 //===--===//
 
 #include "ClangSACheckers.h"
+#include "clang/AST/ParentMap.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
@@ -262,8 +263,14 @@
   if (const MemRegion *Target = Ctor->getCXXThisVal().getAsRegion()) {
 // We just finished a base constructor. Now we can use the subclass's
 // type when resolving virtual calls.
-const Decl *D = C.getLocationContext()->getDecl();
-recordFixedType(Target, cast(D), C);
+const LocationContext *LCtx = C.getLocationContext();
+
+// FIXME: Support C++17 constructors into initializer lists.
+if (dyn_cast_or_null(
+LCtx->getParentMap().getParent(Ctor->getOriginExpr(
+  return;
+
+recordFixedType(Target, cast(LCtx->getDecl()), C);
   }
   return;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r319793 - [analyzer] Mark heap-based symbolic regions in debug dumps.

2017-12-05 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Tue Dec  5 09:14:39 2017
New Revision: 319793

URL: http://llvm.org/viewvc/llvm-project?rev=319793&view=rev
Log:
[analyzer] Mark heap-based symbolic regions in debug dumps.

They are now printed as HeapSymRegion{$x} in order to discriminate between that
and regular SymRegion{$x}, which are two different regions, having different
parent reginos (memory spaces) - HeapSpaceRegion and UnknownSpaceRegion
respectively.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp?rev=319793&r1=319792&r2=319793&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp Tue Dec  5 09:14:39 2017
@@ -472,6 +472,8 @@ void ObjCStringRegion::dumpToStream(raw_
 }
 
 void SymbolicRegion::dumpToStream(raw_ostream &os) const {
+  if (isa(getSuperRegion()))
+os << "Heap";
   os << "SymRegion{" << sym << '}';
 }
 


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


[PATCH] D40793: [analyzer] Improve SymbolicRegion::dump() for heap pointers.

2017-12-05 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC319793: [analyzer] Mark heap-based symbolic regions in debug 
dumps. (authored by dergachev).

Repository:
  rC Clang

https://reviews.llvm.org/D40793

Files:
  lib/StaticAnalyzer/Core/MemRegion.cpp


Index: lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- lib/StaticAnalyzer/Core/MemRegion.cpp
+++ lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -472,6 +472,8 @@
 }
 
 void SymbolicRegion::dumpToStream(raw_ostream &os) const {
+  if (isa(getSuperRegion()))
+os << "Heap";
   os << "SymRegion{" << sym << '}';
 }
 


Index: lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- lib/StaticAnalyzer/Core/MemRegion.cpp
+++ lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -472,6 +472,8 @@
 }
 
 void SymbolicRegion::dumpToStream(raw_ostream &os) const {
+  if (isa(getSuperRegion()))
+os << "Heap";
   os << "SymRegion{" << sym << '}';
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40838: [OpenCL] Fix layering violation by getOpenCLTypeAddrSpace

2017-12-05 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh updated this revision to Diff 125554.
svenvh added a comment.

Introducing ASTContext::getOpenCLTypeAddrSpace(const Type *T) as suggested.


https://reviews.llvm.org/D40838

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/TargetInfo.h
  lib/AST/ASTContext.cpp
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets/AMDGPU.h
  lib/CodeGen/CGOpenCLRuntime.cpp

Index: lib/CodeGen/CGOpenCLRuntime.cpp
===
--- lib/CodeGen/CGOpenCLRuntime.cpp
+++ lib/CodeGen/CGOpenCLRuntime.cpp
@@ -37,7 +37,7 @@
 
   llvm::LLVMContext& Ctx = CGM.getLLVMContext();
   uint32_t AddrSpc = CGM.getContext().getTargetAddressSpace(
-  CGM.getTarget().getOpenCLTypeAddrSpace(T));
+  CGM.getContext().getOpenCLTypeAddrSpace(T));
   switch (cast(T)->getKind()) {
   default:
 llvm_unreachable("Unexpected opencl builtin type!");
@@ -68,7 +68,7 @@
 llvm::Type *CGOpenCLRuntime::getPipeType(const PipeType *T) {
   if (!PipeTy){
 uint32_t PipeAddrSpc = CGM.getContext().getTargetAddressSpace(
-CGM.getTarget().getOpenCLTypeAddrSpace(T));
+CGM.getContext().getOpenCLTypeAddrSpace(T));
 PipeTy = llvm::PointerType::get(llvm::StructType::create(
   CGM.getLLVMContext(), "opencl.pipe_t"), PipeAddrSpc);
   }
@@ -81,7 +81,7 @@
 SamplerTy = llvm::PointerType::get(llvm::StructType::create(
   CGM.getLLVMContext(), "opencl.sampler_t"),
   CGM.getContext().getTargetAddressSpace(
-  CGM.getTarget().getOpenCLTypeAddrSpace(T)));
+  CGM.getContext().getOpenCLTypeAddrSpace(T)));
   return SamplerTy;
 }
 
Index: lib/Basic/Targets/AMDGPU.h
===
--- lib/Basic/Targets/AMDGPU.h
+++ lib/Basic/Targets/AMDGPU.h
@@ -14,7 +14,6 @@
 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_AMDGPU_H
 #define LLVM_CLANG_LIB_BASIC_TARGETS_AMDGPU_H
 
-#include "clang/AST/Type.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetOptions.h"
 #include "llvm/ADT/StringSet.h"
@@ -258,24 +257,18 @@
 }
   }
 
-  LangAS getOpenCLTypeAddrSpace(const Type *T) const override {
-auto BT = dyn_cast(T);
+  LangAS getOpenCLTypeAddrSpace(OpenCLTypeKind TK) const override {
+switch (TK) {
+case OCLTK_Image:
+  return LangAS::opencl_constant;
 
-if (!BT)
-  return TargetInfo::getOpenCLTypeAddrSpace(T);
-
-switch (BT->getKind()) {
-#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix)   \
-  case BuiltinType::Id:\
-return LangAS::opencl_constant;
-#include "clang/Basic/OpenCLImageTypes.def"
-case BuiltinType::OCLClkEvent:
-case BuiltinType::OCLQueue:
-case BuiltinType::OCLReserveID:
+case OCLTK_ClkEvent:
+case OCLTK_Queue:
+case OCLTK_ReserveID:
   return LangAS::opencl_global;
 
 default:
-  return TargetInfo::getOpenCLTypeAddrSpace(T);
+  return TargetInfo::getOpenCLTypeAddrSpace(TK);
 }
   }
 
Index: lib/Basic/TargetInfo.cpp
===
--- lib/Basic/TargetInfo.cpp
+++ lib/Basic/TargetInfo.cpp
@@ -12,7 +12,6 @@
 //===--===//
 
 #include "clang/Basic/TargetInfo.h"
-#include "clang/AST/Type.h"
 #include "clang/Basic/AddressSpaces.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/LangOptions.h"
@@ -357,23 +356,13 @@
   return true;
 }
 
-LangAS TargetInfo::getOpenCLTypeAddrSpace(const Type *T) const {
-  auto BT = dyn_cast(T);
-
-  if (!BT) {
-if (isa(T))
-  return LangAS::opencl_global;
-
-return LangAS::Default;
-  }
-
-  switch (BT->getKind()) {
-#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix)   \
-  case BuiltinType::Id:\
+LangAS TargetInfo::getOpenCLTypeAddrSpace(OpenCLTypeKind TK) const {
+  switch (TK) {
+  case OCLTK_Image:
+  case OCLTK_Pipe:
 return LangAS::opencl_global;
-#include "clang/Basic/OpenCLImageTypes.def"
 
-  case BuiltinType::OCLSampler:
+  case OCLTK_Sampler:
 return LangAS::opencl_constant;
 
   default:
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1826,7 +1826,8 @@
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
 case BuiltinType::Id:
 #include "clang/Basic/OpenCLImageTypes.def"
-  AS = getTargetAddressSpace(Target->getOpenCLTypeAddrSpace(T));
+  AS = getTargetAddressSpace(
+  Target->getOpenCLTypeAddrSpace(getOpenCLTypeKind(T)));
   Width = Target->getPointerWidth(AS);
   Align = Target->getPointerAlign(AS);
   break;
@@ -5720,6 +5721,46 @@
   return getTagDeclType(BlockDescriptorExtendedType);
 }
 
+TargetInfo::OpenCLTypeKind ASTContext::getOpenCLTypeKind(const Type *T) const {
+  auto BT = dyn_cast(T);
+
+  if (!BT) {
+if (

[PATCH] D40752: [OpenMP] Fix assert fail after target implicit map checks

2017-12-05 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

r319774 works for my current use cases.  Thanks.

While we're on this topic, do you happen to know the rationale behind the 
OpenMP restriction for which err_omp_union_type_not_allowed diagnoses 
violations?  I googled but couldn't find the rationale.  If you would prefer 
that I ask this in a different forum, would you please suggest one?  Thanks.


https://reviews.llvm.org/D40752



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


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

2017-12-05 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 125556.
JonasToth retitled this revision from "[clang-tidy] WIP Resubmit 
hicpp-multiway-paths-covered without breaking test  " to "[clang-tidy] WIP 
Resubmit hicpp-multiway-paths-covered without breaking test".
JonasToth added a comment.
Herald added a subscriber: klimek.

- [Misc] comment out matcher, make compile and runnable


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,472 @@
+// 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 &IntRef = 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;
+  }
+
+  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;
+  }
+}
+
+void unproblematic_switch(unsigned char c) {
+  //
+  switch (c) {
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: potential uncovered code path; add a default label
+  case 0:
+  case 1:
+  case 2:
+  case 3:
+  case 4:
+  case 5:
+  case 6:
+  case 7:
+  case 8:
+  case 9:
+  case 10:
+  case 11:
+  case 12:
+  case 13:
+  case 14:
+  case 15:
+  case 16:
+  case 17:
+  case 18:
+  case 19:
+  case 20:
+  case 21:
+  case 22:
+  case 23:
+  case 24:
+  case 25:
+  case 26:
+  case 27:
+  case 28:
+  case 29:
+  case 30:
+  case 31:
+  case 32:
+  case 33:
+  case 34:
+  case 35:
+  case 36:
+  case 37:
+  case 38:
+  case 39:
+  case 40:
+  case 41:
+  case 42:
+  case 43:
+  case 44:
+  case 45:
+  case 46:
+  case 47:
+  case 48:
+  case 49:
+  case 50:
+  case 51:
+  case 52:
+  case 53:
+  case 54:
+  case 55:
+  cas

[PATCH] D40832: [clang-format] Adds canonical raw string delimiters support

2017-12-05 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 125557.
krasimir added a comment.

- Make 'textproto' the canonical text proto delimiter for google style


Repository:
  rC Clang

https://reviews.llvm.org/D40832

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  unittests/Format/FormatTestRawStrings.cpp

Index: unittests/Format/FormatTestRawStrings.cpp
===
--- unittests/Format/FormatTestRawStrings.cpp
+++ unittests/Format/FormatTestRawStrings.cpp
@@ -67,21 +67,24 @@
 Style.ColumnLimit = ColumnLimit;
 Style.RawStringFormats = {{/*Delimiter=*/"pb",
/*Kind=*/FormatStyle::LK_TextProto,
-   /*BasedOnStyle=*/"google"}};
+   /*BasedOnStyle=*/"google",
+   /*Canonical=*/false}};
 return Style;
   }
 
   FormatStyle getRawStringLLVMCppStyleBasedOn(std::string BasedOnStyle) {
 FormatStyle Style = getLLVMStyle();
 Style.RawStringFormats = {{/*Delimiter=*/"cpp",
-   /*Kind=*/FormatStyle::LK_Cpp, BasedOnStyle}};
+   /*Kind=*/FormatStyle::LK_Cpp, BasedOnStyle,
+   /*Canonical=*/false}};
 return Style;
   }
 
   FormatStyle getRawStringGoogleCppStyleBasedOn(std::string BasedOnStyle) {
 FormatStyle Style = getGoogleStyle(FormatStyle::LK_Cpp);
 Style.RawStringFormats = {{/*Delimiter=*/"cpp",
-   /*Kind=*/FormatStyle::LK_Cpp, BasedOnStyle}};
+   /*Kind=*/FormatStyle::LK_Cpp, BasedOnStyle,
+   /*Canonical=*/false}};
 return Style;
   }
 
@@ -125,9 +128,9 @@
   FormatStyle MixedStyle = getLLVMStyle();
   MixedStyle.RawStringFormats = {
   {/*Delimiter=*/"cpp", /*Kind=*/FormatStyle::LK_Cpp,
-   /*BasedOnStyle=*/"llvm"},
+   /*BasedOnStyle=*/"llvm", /*Canonical=*/false},
   {/*Delimiter=*/"CPP", /*Kind=*/FormatStyle::LK_Cpp,
-   /*BasedOnStyle=*/"google"}};
+   /*BasedOnStyle=*/"google", /*Canonical=*/false}};
 
   // Format the 'cpp' raw string with '*' on the right.
   // Format the 'CPP' raw string with '*' on the left.
@@ -210,9 +213,9 @@
 P p = TP(R"pb(item_1 <1>
   item_2: <2>
   item_3 {})pb");)test",
-  format(R"test(
+format(R"test(
 P p = TP(R"pb(item_1<1> item_2:<2> item_3{ })pb");)test",
-  getRawStringPbStyleWithColumns(40)));
+   getRawStringPbStyleWithColumns(40)));
 
   expect_eq(
   R"test(
@@ -515,7 +518,6 @@
 format(R"test(
 ASSERT_TRUE(ParseFromString(R"pb(item_1: 1 item_2: 2)pb"), ptr);)test",
getRawStringPbStyleWithColumns(40)));
-
 }
 
 TEST_F(FormatTestRawStrings, RawStringsInOperands) {
@@ -642,7 +644,6 @@
 auto S=(count<3)?R"pb(item_1:1)pb":R"pb(item_2:2,item_3:3)pb";
 )test",
getRawStringPbStyleWithColumns(40)));
-
 }
 
 TEST_F(FormatTestRawStrings, PrefixAndSuffixAlignment) {
@@ -728,6 +729,54 @@
getRawStringPbStyleWithColumns(20)));
 }
 
+TEST_F(FormatTestRawStrings, UpdatesToCanonicalDelimiters) {
+  FormatStyle Style = getRawStringPbStyleWithColumns(25);
+  Style.RawStringFormats.push_back({/*Delimiter=*/"proto",
+/*Kind=*/FormatStyle::LK_TextProto,
+/*BasedOnStyle=*/"google",
+/*Canonical=*/true});
+  expect_eq(R"test(a = R"proto(key: value)proto";)test",
+format(R"test(a = R"pb(key:value)pb";)test", Style));
+  expect_eq(R"test(a = R"proto(key: value)proto";)test",
+format(R"test(a = R"proto(key:value)proto";)test", Style));
+  expect_eq(R"test(
+f(a,
+  R"proto(item {
+key: value
+key: value
+  })proto");
+)test",
+format(R"test(
+f(a,
+  R"pb(item {
+ key: value
+ key: value
+   })pb");
+)test",
+   Style));
+  // The last canonical delimiter for a language is the canonical delimiter for
+  // that language.
+  Style.RawStringFormats.push_back({/*Delimiter=*/"cproto",
+/*Kind=*/FormatStyle::LK_TextProto,
+/*BasedOnStyle=*/"google",
+/*Canonical=*/true});
+  expect_eq(R"test(
+f(a,
+  R"cproto(item {
+ key: value
+ key: value
+   })cproto");
+)test",
+format(R"test(
+f(a,
+  R"proto(item {
+ key: value
+ key: value
+   })proto");
+)test",
+   Style));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -641,7 +64

[PATCH] D38801: [analyzer] In getSVal() API, disable auto-detection of void type as char type.

2017-12-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 12.
NoQ added a comment.
Herald added a subscriber: rnkovacs.

Rebase on top of https://reviews.llvm.org/D39862 (attn. George!~).


https://reviews.llvm.org/D38801

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
  lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  lib/StaticAnalyzer/Core/RegionStore.cpp


Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -1405,10 +1405,7 @@
 T = Ctx.VoidTy;
 }
 assert(!T.isNull() && "Unable to auto-detect binding type!");
-if (T->isVoidType()) {
-  // When trying to dereference a void pointer, read the first byte.
-  T = Ctx.CharTy;
-}
+assert(!T->isVoidType() && "Attempting to dereference a void pointer!");
 MR = GetElementZeroRegion(cast(MR), T);
   }
 
Index: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
+++ lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
@@ -466,7 +466,7 @@
 }
 
 Optional GenericTaintChecker::getPointedToSVal(CheckerContext &C,
-const Expr* Arg) {
+ const Expr *Arg) {
   ProgramStateRef State = C.getState();
   SVal AddrVal = State->getSVal(Arg->IgnoreParens(), C.getLocationContext());
   if (AddrVal.isUnknownOrUndef())
@@ -476,9 +476,18 @@
   if (!AddrLoc)
 return None;
 
-  const PointerType *ArgTy =
-dyn_cast(Arg->getType().getCanonicalType().getTypePtr());
-  return State->getSVal(*AddrLoc, ArgTy ? ArgTy->getPointeeType(): QualType());
+  QualType ArgTy = Arg->getType().getCanonicalType();
+  if (!ArgTy->isPointerType())
+return None;
+
+  QualType ValTy = ArgTy->getPointeeType();
+
+  // Do not dereference void pointers. Treat them as byte pointers instead.
+  // FIXME: we might want to consider more than just the first byte.
+  if (ValTy->isVoidType())
+ValTy = C.getASTContext().CharTy;
+
+  return State->getSVal(*AddrLoc, ValTy);
 }
 
 ProgramStateRef
Index: lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
@@ -179,7 +179,7 @@
 
   if (const MemRegion *SValMemRegion = V.getAsRegion()) {
 const ProgramStateRef State = C.getState();
-const SVal PSV = State->getSVal(SValMemRegion);
+const SVal PSV = State->getSVal(SValMemRegion, C.getASTContext().CharTy);
 if (PSV.isUndef()) {
   if (ExplodedNode *N = C.generateErrorNode()) {
 LazyInit_BT(BD, BT);
Index: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -308,8 +308,12 @@
 
   /// \brief Return the value bound to the specified location.
   /// Returns UnknownVal() if none found.
-  SVal getSVal(const MemRegion* R) const;
+  SVal getSVal(const MemRegion* R, QualType T = QualType()) const;
 
+  /// \brief Return the value bound to the specified location, assuming
+  /// that the value is a scalar integer or an enumeration or a pointer.
+  /// Returns UnknownVal() if none found or the region is not known to hold
+  /// a value of such type.
   SVal getSValAsScalarOrLoc(const MemRegion *R) const;
 
   /// \brief Visits the symbols reachable from the given SVal using the 
provided
@@ -758,9 +762,10 @@
   return getStateManager().StoreMgr->getBinding(getStore(), LV, T);
 }
 
-inline SVal ProgramState::getSVal(const MemRegion* R) const {
+inline SVal ProgramState::getSVal(const MemRegion* R, QualType T) const {
   return getStateManager().StoreMgr->getBinding(getStore(),
-loc::MemRegionVal(R));
+loc::MemRegionVal(R),
+T);
 }
 
 inline BasicValueFactory &ProgramState::getBasicVals() const {


Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -1405,10 +1405,7 @@
 T = Ctx.VoidTy;
 }
 assert(!T.isNull() && "Unable to auto-detect binding type!");
-if (T->isVoidType()) {
-  // When trying to dereference a void pointer, read the first byte.
-  T = Ctx.CharTy;
-}
+assert(!T->isVoidType() && "Attempting to dereference a void pointer!");
 MR = GetElementZeroRegion(cast(MR), T);
   }
 
Index: lib/StaticAn

[PATCH] D40838: [OpenCL] Fix layering violation by getOpenCLTypeAddrSpace

2017-12-05 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


https://reviews.llvm.org/D40838



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


[PATCH] D40774: [libcxx] Fix intrinsics for MSVC

2017-12-05 Thread Andrey Khalyavin via Phabricator via cfe-commits
halyavin added a comment.

In https://reviews.llvm.org/D40774#944751, @smeenai wrote:

> In https://reviews.llvm.org/D40774#944749, @halyavin wrote:
>
> > In https://reviews.llvm.org/D40774#943993, @smeenai wrote:
> >
> > > Are you actually using libc++ with cl? :)
> >
> >
> > People mostly use it to compile on Windows but I heard someone launches the 
> > result too. Since no one complains and it passed most of the testing, I 
> > guess the result doesn't explode. It is also part of catboost but I haven't 
> > tried how well it works there myself yet.
>
>
> Hmm how is `#include_next` handled?


About the same way as this proposed change: https://reviews.llvm.org/D32411 .

PS Could you please commit this (https://reviews.llvm.org/D40774) change? I 
don't have commit rights.


https://reviews.llvm.org/D40774



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


[PATCH] D40752: [OpenMP] Fix assert fail after target implicit map checks

2017-12-05 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In https://reviews.llvm.org/D40752#945234, @jdenny wrote:

> r319774 works for my current use cases.  Thanks.
>
> While we're on this topic, do you happen to know the rationale behind the 
> OpenMP restriction for which err_omp_union_type_not_allowed diagnoses 
> violations?  I googled but couldn't find the rationale.  If you would prefer 
> that I ask this in a different forum, would you please suggest one?  Thanks.


You cannot map the member of the union, but you can map the whole union. 
Mapping of separate members is not allowed because you will definitely have 
troubles with overlapping memory for union members.


https://reviews.llvm.org/D40752



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


[PATCH] D40841: [analyzer] Fix a crash on C++17 AST for non-trivial construction into a trivial brace initializer.

2017-12-05 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added inline comments.



Comment at: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:288
+// this-region of the parent stack frame).
+if (dyn_cast_or_null(LCtx->getParentMap().getParent(CE))) {
+  MemRegionManager &MRMgr = getSValBuilder().getRegionManager();

Could we try to make another lookup to see if we're initializing a variable of 
non-reference type? If so, we can make MemRegionManager use the region of the 
variable; otherwise, we can always fallback to temporary (it seems like 
sometimes this situation can happen out of DeclStmts). Or am I missing 
something?


https://reviews.llvm.org/D40841



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


r319800 - [OPENMP] Remove non-required parameters for distribute simd outlined

2017-12-05 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Dec  5 09:41:34 2017
New Revision: 319800

URL: http://llvm.org/viewvc/llvm-project?rev=319800&view=rev
Log:
[OPENMP] Remove non-required parameters for distribute simd outlined
region, NFC.

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

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=319800&r1=319799&r2=319800&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Dec  5 09:41:34 2017
@@ -2125,6 +2125,7 @@ void Sema::ActOnOpenMPRegionStart(OpenMP
   case OMPD_critical:
   case OMPD_taskgroup:
   case OMPD_distribute:
+  case OMPD_distribute_simd:
   case OMPD_ordered:
   case OMPD_atomic:
   case OMPD_target_data:
@@ -2199,7 +2200,6 @@ void Sema::ActOnOpenMPRegionStart(OpenMP
 break;
   }
   case OMPD_distribute_parallel_for_simd:
-  case OMPD_distribute_simd:
   case OMPD_distribute_parallel_for:
   case OMPD_teams_distribute_simd:
   case OMPD_target_teams_distribute:
@@ -2220,7 +2220,7 @@ void Sema::ActOnOpenMPRegionStart(OpenMP
  Params);
 break;
   }
-  case OMPD_teams_distribute_parallel_for: 
+  case OMPD_teams_distribute_parallel_for:
   case OMPD_teams_distribute_parallel_for_simd: {
 QualType KmpInt32Ty = Context.getIntTypeForBitwidth(32, 1);
 QualType KmpInt32PtrTy =


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


[PATCH] D40813: [clang-tidy] Adding Fuchsia checker for virtual inheritance

2017-12-05 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 125560.
juliehockett marked 5 inline comments as done.

https://reviews.llvm.org/D40813

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

Index: test/clang-tidy/fuchsia-virtual-inheritance.cpp
===
--- /dev/null
+++ test/clang-tidy/fuchsia-virtual-inheritance.cpp
@@ -0,0 +1,54 @@
+// RUN: %check_clang_tidy %s fuchsia-virtual-inheritance %t
+
+class A {
+public:
+  A(int value) : val(value) {}
+
+  int do_A() { return val; }
+
+private:
+  int val;
+};
+
+class B : public virtual A {
+  // CHECK-MESSAGES: [[@LINE-1]]:1: warning: virtual inheritance is disallowed [fuchsia-virtual-inheritance]
+  // CHECK-NEXT: class B : public virtual A {
+public:
+  B() : A(0) {}
+  int do_B() { return 1 + do_A(); }
+};
+
+class C : public virtual A {
+  // CHECK-MESSAGES: [[@LINE-1]]:1: warning: virtual inheritance is disallowed [fuchsia-virtual-inheritance]
+  // CHECK-NEXT: class C : public virtual A {
+public:
+  C() : A(0) {}
+  int do_C() { return 2 + do_A(); }
+};
+
+class D : public B, public C {
+  // CHECK-MESSAGES: [[@LINE-1]]:1: warning: virtual inheritance is disallowed [fuchsia-virtual-inheritance]
+  // CHECK-NEXT: class C : public B, public C {
+public:
+  D(int value) : A(value), B(), C() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: constructing a class that inherits a virtual base class is disallowed [fuchsia-virtual-inheritance]
+  // CHECK-NEXT:  D(int value) : A(value), B(), C() {}
+  // CHECK-MESSAGES: [[@LINE-3]]:33: warning: constructing a class that inherits a virtual base class is disallowed [fuchsia-virtual-inheritance]
+  // CHECK-NEXT:  D(int value) : A(value), B(), C() {}
+
+  int do_D() { return do_A() + do_B() + do_C(); }
+};
+
+int main() {
+  A *a = new A(0);
+  B *b = new B();
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: constructing a class that inherits a virtual base class is disallowed [fuchsia-virtual-inheritance]
+  // CHECK-NEXT:  B *b = new B();
+  C *c = new C();
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: constructing a class that inherits a virtual base class is disallowed [fuchsia-virtual-inheritance]
+  // CHECK-NEXT:  C *c = new C();
+  D *d = new D(0);
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: constructing a class that inherits a virtual base class is disallowed [fuchsia-virtual-inheritance]
+  // CHECK-NEXT:  D *d = new D(0);
+  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-virtual-inheritance
google-build-explicit-make-pair
google-build-namespaces
google-build-using-namespace
Index: docs/clang-tidy/checks/fuchsia-virtual-inheritance.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/fuchsia-virtual-inheritance.rst
@@ -0,0 +1,20 @@
+.. title:: clang-tidy - fuchsia-virtual-inheritance
+
+fuchsia-virtual-inheritance
+===
+
+Warns if classes are defined or created with virtual inheritance.
+
+For example, classes should not be defined with virtual inheritance:
+
+.. code-block:: c++
+
+  class B : public virtual A {};   // warning
+
+Classes with virtual inheritance should not be created:
+
+.. code-block:: c++
+
+  B *b = new B();   // warning
+
+See the features disallowed in Fuchsia at https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -134,7 +134,12 @@
   `_ check
 
   Warns if a function or method is declared or called with default arguments.
+  
+- New `fuchsia-virtual-inheritance
+  `_ check
 
+  Warns if classes are defined or created with virtual inheritance.
+
 - New `google-objc-avoid-throwing-exception
   `_ check
 
Index: clang-tidy/fuchsia/VirtualInheritanceCheck.h
===
--- /dev/null
+++ clang-tidy/fuchsia/VirtualInheritanceCheck.h
@@ -0,0 +1,35 @@
+//===--- VirtualInheritanceCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is d

[PATCH] D40752: [OpenMP] Fix assert fail after target implicit map checks

2017-12-05 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In https://reviews.llvm.org/D40752#945234, @jdenny wrote:

> r319774 works for my current use cases.  Thanks.
>
> While we're on this topic, do you happen to know the rationale behind the 
> OpenMP restriction for which err_omp_union_type_not_allowed diagnoses 
> violations?  I googled but couldn't find the rationale.  If you would prefer 
> that I ask this in a different forum, would you please suggest one?  Thanks.


Ahh, and in your example, there is a problem in the compiler. We should map the 
whole union implicitly. I'll fix this


https://reviews.llvm.org/D40752



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


[PATCH] D40774: [libcxx] Fix intrinsics for MSVC

2017-12-05 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a subscriber: bcraig.
smeenai added a comment.

In https://reviews.llvm.org/D40774#945254, @halyavin wrote:

> In https://reviews.llvm.org/D40774#944751, @smeenai wrote:
>
> > In https://reviews.llvm.org/D40774#944749, @halyavin wrote:
> >
> > > In https://reviews.llvm.org/D40774#943993, @smeenai wrote:
> > >
> > > > Are you actually using libc++ with cl? :)
> > >
> > >
> > > People mostly use it to compile on Windows but I heard someone launches 
> > > the result too. Since no one complains and it passed most of the testing, 
> > > I guess the result doesn't explode. It is also part of catboost but I 
> > > haven't tried how well it works there myself yet.
> >
> >
> > Hmm how is `#include_next` handled?
>
>
> About the same way as this proposed change: https://reviews.llvm.org/D32411 .
>
> PS Could you please commit this (https://reviews.llvm.org/D40774) change? I 
> don't have commit rights.


Ah, that's good to know. CC @bcraig

Sorry, didn't know you didn't have commit access. I'll commit it for you.


https://reviews.llvm.org/D40774



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


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

2017-12-05 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

@sbenza and @klimek the issue that occurs here is probably ASTMatchers related, 
thats why I added you.

The problem:

This patch introduces a stack overflow when building with `RelWithDebInfo` that 
is caught by the sanitizers. I isolated the issue in the big switch statements 
that has 256 case labels. On label 200 the overflow occurs, that is noted with 
a comment.
What I found while debugging is, that no matter which matcher I use the 
overflow occurs. The toplevel function is `parseAST` and then executing the 
frontend actions.

I think the problem is that every case label adds multiple recursive function 
calls coming from the nature of how case labels are stored in the AST. That 
produces the massive stack. Is there a way I could work around this Issue in 
the check?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40737



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


r319801 - [WebAssembly] Don't use Wasm function sections for more than one function

2017-12-05 Thread Dan Gohman via cfe-commits
Author: djg
Date: Tue Dec  5 09:46:17 2017
New Revision: 319801

URL: http://llvm.org/viewvc/llvm-project?rev=319801&view=rev
Log:
[WebAssembly] Don't use Wasm function sections for more than one function

Patch by Nicholas Wilson!

Fixes PR35467.

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

Modified:
cfe/trunk/lib/Basic/Targets/OSTargets.h
cfe/trunk/test/CodeGenCXX/static-init-wasm.cpp

Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.h?rev=319801&r1=319800&r2=319801&view=diff
==
--- cfe/trunk/lib/Basic/Targets/OSTargets.h (original)
+++ cfe/trunk/lib/Basic/Targets/OSTargets.h Tue Dec  5 09:46:17 2017
@@ -711,11 +711,6 @@ class LLVM_LIBRARY_VISIBILITY WebAssembl
   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 &Triple,
const TargetOptions &Opts)

Modified: cfe/trunk/test/CodeGenCXX/static-init-wasm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/static-init-wasm.cpp?rev=319801&r1=319800&r2=319801&view=diff
==
--- cfe/trunk/test/CodeGenCXX/static-init-wasm.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/static-init-wasm.cpp Tue Dec  5 09:46:17 2017
@@ -43,12 +43,12 @@ struct A {
 
 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()


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


[libcxx] r319802 - [libcxx] Fix intrinsics for MSVC

2017-12-05 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Tue Dec  5 09:46:23 2017
New Revision: 319802

URL: http://llvm.org/viewvc/llvm-project?rev=319802&view=rev
Log:
[libcxx] Fix intrinsics for MSVC

The parameter was previously renamed but MSVC path was not updated.

Patch by Andrey Khalyavin.

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

Modified:
libcxx/trunk/include/algorithm

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=319802&r1=319801&r2=319802&view=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Tue Dec  5 09:46:23 2017
@@ -797,7 +797,7 @@ unsigned __ctz(unsigned __x) {
   unsigned long where;
   // Search from LSB to MSB for first set bit.
   // Returns zero if no set bit is found.
-  if (_BitScanForward(&where, mask))
+  if (_BitScanForward(&where, __x))
 return where;
   return 32;
 #endif
@@ -823,15 +823,15 @@ unsigned long long __ctz(unsigned long l
 // Returns zero if no set bit is found.
 #if defined(_LIBCPP_HAS_BITSCAN64)
 (defined(_M_AMD64) || defined(__x86_64__))
-  if (_BitScanForward64(&where, mask))
+  if (_BitScanForward64(&where, __x))
 return static_cast(where);
 #else
   // Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit calls.
   // Scan the Low Word.
-  if (_BitScanForward(&where, static_cast(mask)))
+  if (_BitScanForward(&where, static_cast(__x)))
 return where;
   // Scan the High Word.
-  if (_BitScanForward(&where, static_cast(mask >> 32)))
+  if (_BitScanForward(&where, static_cast(__x >> 32)))
 return where + 32; // Create a bit offset from the LSB.
 #endif
   return 64;
@@ -849,7 +849,7 @@ unsigned __clz(unsigned __x) {
   unsigned long where;
   // Search from LSB to MSB for first set bit.
   // Returns zero if no set bit is found.
-  if (_BitScanReverse(&where, mask))
+  if (_BitScanReverse(&where, __x))
 return 31 - where;
   return 32; // Undefined Behavior.
 #endif
@@ -874,14 +874,14 @@ unsigned long long __clz(unsigned long l
 // BitScanReverse scans from MSB to LSB for first set bit.
 // Returns 0 if no set bit is found.
 #if defined(_LIBCPP_HAS_BITSCAN64)
-  if (_BitScanReverse64(&where, mask))
+  if (_BitScanReverse64(&where, __x))
 return static_cast(63 - where);
 #else
   // Scan the high 32 bits.
-  if (_BitScanReverse(&where, static_cast(mask >> 32)))
+  if (_BitScanReverse(&where, static_cast(__x >> 32)))
 return 63 - (where + 32); // Create a bit offset from the MSB.
   // Scan the low 32 bits.
-  if (_BitScanReverse(&where, static_cast(mask)))
+  if (_BitScanReverse(&where, static_cast(__x)))
 return 63 - where;
 #endif
   return 64; // Undefined Behavior.


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


[PATCH] D40774: [libcxx] Fix intrinsics for MSVC

2017-12-05 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCXX319802: [libcxx] Fix intrinsics for MSVC (authored by 
smeenai).

Repository:
  rCXX libc++

https://reviews.llvm.org/D40774

Files:
  include/algorithm


Index: include/algorithm
===
--- include/algorithm
+++ include/algorithm
@@ -797,7 +797,7 @@
   unsigned long where;
   // Search from LSB to MSB for first set bit.
   // Returns zero if no set bit is found.
-  if (_BitScanForward(&where, mask))
+  if (_BitScanForward(&where, __x))
 return where;
   return 32;
 #endif
@@ -823,15 +823,15 @@
 // Returns zero if no set bit is found.
 #if defined(_LIBCPP_HAS_BITSCAN64)
 (defined(_M_AMD64) || defined(__x86_64__))
-  if (_BitScanForward64(&where, mask))
+  if (_BitScanForward64(&where, __x))
 return static_cast(where);
 #else
   // Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit calls.
   // Scan the Low Word.
-  if (_BitScanForward(&where, static_cast(mask)))
+  if (_BitScanForward(&where, static_cast(__x)))
 return where;
   // Scan the High Word.
-  if (_BitScanForward(&where, static_cast(mask >> 32)))
+  if (_BitScanForward(&where, static_cast(__x >> 32)))
 return where + 32; // Create a bit offset from the LSB.
 #endif
   return 64;
@@ -849,7 +849,7 @@
   unsigned long where;
   // Search from LSB to MSB for first set bit.
   // Returns zero if no set bit is found.
-  if (_BitScanReverse(&where, mask))
+  if (_BitScanReverse(&where, __x))
 return 31 - where;
   return 32; // Undefined Behavior.
 #endif
@@ -874,14 +874,14 @@
 // BitScanReverse scans from MSB to LSB for first set bit.
 // Returns 0 if no set bit is found.
 #if defined(_LIBCPP_HAS_BITSCAN64)
-  if (_BitScanReverse64(&where, mask))
+  if (_BitScanReverse64(&where, __x))
 return static_cast(63 - where);
 #else
   // Scan the high 32 bits.
-  if (_BitScanReverse(&where, static_cast(mask >> 32)))
+  if (_BitScanReverse(&where, static_cast(__x >> 32)))
 return 63 - (where + 32); // Create a bit offset from the MSB.
   // Scan the low 32 bits.
-  if (_BitScanReverse(&where, static_cast(mask)))
+  if (_BitScanReverse(&where, static_cast(__x)))
 return 63 - where;
 #endif
   return 64; // Undefined Behavior.


Index: include/algorithm
===
--- include/algorithm
+++ include/algorithm
@@ -797,7 +797,7 @@
   unsigned long where;
   // Search from LSB to MSB for first set bit.
   // Returns zero if no set bit is found.
-  if (_BitScanForward(&where, mask))
+  if (_BitScanForward(&where, __x))
 return where;
   return 32;
 #endif
@@ -823,15 +823,15 @@
 // Returns zero if no set bit is found.
 #if defined(_LIBCPP_HAS_BITSCAN64)
 (defined(_M_AMD64) || defined(__x86_64__))
-  if (_BitScanForward64(&where, mask))
+  if (_BitScanForward64(&where, __x))
 return static_cast(where);
 #else
   // Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit calls.
   // Scan the Low Word.
-  if (_BitScanForward(&where, static_cast(mask)))
+  if (_BitScanForward(&where, static_cast(__x)))
 return where;
   // Scan the High Word.
-  if (_BitScanForward(&where, static_cast(mask >> 32)))
+  if (_BitScanForward(&where, static_cast(__x >> 32)))
 return where + 32; // Create a bit offset from the LSB.
 #endif
   return 64;
@@ -849,7 +849,7 @@
   unsigned long where;
   // Search from LSB to MSB for first set bit.
   // Returns zero if no set bit is found.
-  if (_BitScanReverse(&where, mask))
+  if (_BitScanReverse(&where, __x))
 return 31 - where;
   return 32; // Undefined Behavior.
 #endif
@@ -874,14 +874,14 @@
 // BitScanReverse scans from MSB to LSB for first set bit.
 // Returns 0 if no set bit is found.
 #if defined(_LIBCPP_HAS_BITSCAN64)
-  if (_BitScanReverse64(&where, mask))
+  if (_BitScanReverse64(&where, __x))
 return static_cast(63 - where);
 #else
   // Scan the high 32 bits.
-  if (_BitScanReverse(&where, static_cast(mask >> 32)))
+  if (_BitScanReverse(&where, static_cast(__x >> 32)))
 return 63 - (where + 32); // Create a bit offset from the MSB.
   // Scan the low 32 bits.
-  if (_BitScanReverse(&where, static_cast(mask)))
+  if (_BitScanReverse(&where, static_cast(__x)))
 return 63 - where;
 #endif
   return 64; // Undefined Behavior.
___
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-05 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC319801: [WebAssembly] Don't use Wasm function sections for 
more than one function (authored by djg).

Repository:
  rC Clang

https://reviews.llvm.org/D40738

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


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 &Triple,
const TargetOptions &Opts)
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 &Triple,
const TargetOptions &Opts)
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()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32411: [libcxx] Provide #include_next alternative for MSVC

2017-12-05 Thread Ben Craig via Phabricator via cfe-commits
bcraig added a comment.

Talked with mclow and some Microsoft devs in Albuquerque.  I'm not expecting 
include_next to show up in MSVC.  Sometime in the next month I hope to rebase 
this change.


https://reviews.llvm.org/D32411



___
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-05 Thread Taewook Oh via Phabricator via cfe-commits
twoh updated this revision to Diff 125563.
twoh added a comment.

@jkorous-apple Got it. I agree that it would be better to move the comments to 
the header. Will land it soon. Thanks!


https://reviews.llvm.org/D39279

Files:
  include/clang/Lex/Lexer.h
  lib/Lex/Lexer.cpp
  test/Preprocessor/macro_raw_string.cpp
  unittests/Lex/LexerTest.cpp

Index: unittests/Lex/LexerTest.cpp
===
--- unittests/Lex/LexerTest.cpp
+++ unittests/Lex/LexerTest.cpp
@@ -37,7 +37,7 @@
   DiagID(new DiagnosticIDs()),
   Diags(DiagID, new DiagnosticOptions, new IgnoringDiagConsumer()),
   SourceMgr(Diags, FileMgr),
-  TargetOpts(new TargetOptions) 
+  TargetOpts(new TargetOptions)
   {
 TargetOpts->Triple = "x86_64-apple-darwin11.1.0";
 Target = TargetInfo::CreateTargetInfo(Diags, TargetOpts);
@@ -478,4 +478,42 @@
   EXPECT_TRUE(LexedTokens.empty());
 }
 
+TEST_F(LexerTest, StringizingRasString) {
+  // For "std::string Lexer::Stringify(StringRef Str, bool Charify)".
+  std::string String1 = R"(foo
+{"bar":[]}
+baz)";
+  // For "void Lexer::Stringify(SmallVectorImpl &Str)".
+  SmallString<128> String2;
+  String2 += String1.c_str();
+
+  // Corner cases.
+  std::string String3 = R"(\
+\n
+\\n
+\\)";
+  SmallString<128> String4;
+  String4 += String3.c_str();
+  std::string String5 = R"(a\
+
+
+\\b)";
+  SmallString<128> String6;
+  String6 += String5.c_str();
+
+  String1 = Lexer::Stringify(StringRef(String1));
+  Lexer::Stringify(String2);
+  String3 = Lexer::Stringify(StringRef(String3));
+  Lexer::Stringify(String4);
+  String5 = Lexer::Stringify(StringRef(String5));
+  Lexer::Stringify(String6);
+
+  EXPECT_EQ(String1, R"(foo\n{\"bar\":[]}\nbaz)");
+  EXPECT_EQ(String2, R"(foo\n{\"bar\":[]}\nbaz)");
+  EXPECT_EQ(String3, R"(\\\n\\n\nn\n)");
+  EXPECT_EQ(String4, R"(\\\n\\n\nn\n)");
+  EXPECT_EQ(String5, R"(a\\\n\n\nb)");
+  EXPECT_EQ(String6, R"(a\\\n\n\nb)");
+}
+
 } // anonymous namespace
Index: test/Preprocessor/macro_raw_string.cpp
===
--- /dev/null
+++ test/Preprocessor/macro_raw_string.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -E -std=c++11 %s -o %t
+// RUN: %clang_cc1 %t
+
+#define FOO(str) foo(#str)
+
+extern void foo(const char *str);
+
+void bar() {
+  FOO(R"(foo
+bar)");
+}
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -209,29 +209,41 @@
   return L;
 }
 
-/// Stringify - Convert the specified string into a C string, with surrounding
-/// ""'s, and with escaped \ and " characters.
+template 
+void StringifyImpl(T& Str, char Quote) {
+  typename T::size_type i = 0, e = Str.size();
+  while (i < e) {
+if (Str[i] == '\\' || Str[i] == Quote) {
+  Str.insert(Str.begin() + i, '\\');
+  i += 2;
+  ++e;
+} else if (Str[i] == '\n' || Str[i] == '\r') {
+  // Replace '\r\n' and '\n\r' to '\\' followed by 'n'.
+  if ((i < e - 1) && (Str[i + 1] == '\n' || Str[i + 1] == '\r') &&
+  Str[i] != Str[i + 1]) {
+Str[i] = '\\';
+Str[i+1] = 'n';
+  } else {
+// Replace '\n' and '\r' to '\\' followed by 'n'.
+Str[i] = '\\';
+Str.insert(Str.begin() + i + 1, 'n');
+++e;
+  }
+  i += 2;
+} else
+  ++i;
+  }
+}
+
 std::string Lexer::Stringify(StringRef Str, bool Charify) {
   std::string Result = Str;
   char Quote = Charify ? '\'' : '"';
-  for (unsigned i = 0, e = Result.size(); i != e; ++i) {
-if (Result[i] == '\\' || Result[i] == Quote) {
-  Result.insert(Result.begin()+i, '\\');
-  ++i; ++e;
-}
-  }
+  StringifyImpl(Result, Quote);
   return Result;
 }
 
-/// Stringify - Convert the specified string into a C string by escaping '\'
-/// and " characters.  This does not add surrounding ""'s to the string.
 void Lexer::Stringify(SmallVectorImpl &Str) {
-  for (unsigned i = 0, e = Str.size(); i != e; ++i) {
-if (Str[i] == '\\' || Str[i] == '"') {
-  Str.insert(Str.begin()+i, '\\');
-  ++i; ++e;
-}
-  }
+  StringifyImpl(Str, '"');
 }
 
 //===--===//
@@ -367,7 +379,7 @@
 /// to point to a constant buffer with the data already in it (avoiding a
 /// copy).  The caller is not allowed to modify the returned buffer pointer
 /// if an internal buffer is returned.
-unsigned Lexer::getSpelling(const Token &Tok, const char *&Buffer, 
+unsigned Lexer::getSpelling(const Token &Tok, const char *&Buffer,
 const SourceManager &SourceMgr,
 const LangOptions &LangOpts, bool *Invalid) {
   assert((int)Tok.getLength() >= 0 && "Token character range is bogus!");
@@ -592,17 +604,17 @@
   if (TheTok.getKind() == tok::eof) {
 break;
   }
-  
+
  

[PATCH] D39279: Stringizing raw string literals containing newline

2017-12-05 Thread Taewook Oh via Phabricator via cfe-commits
twoh updated this revision to Diff 125564.
twoh added a comment.

clang-format


https://reviews.llvm.org/D39279

Files:
  include/clang/Lex/Lexer.h
  lib/Lex/Lexer.cpp
  test/Preprocessor/macro_raw_string.cpp
  unittests/Lex/LexerTest.cpp

Index: unittests/Lex/LexerTest.cpp
===
--- unittests/Lex/LexerTest.cpp
+++ unittests/Lex/LexerTest.cpp
@@ -37,7 +37,7 @@
   DiagID(new DiagnosticIDs()),
   Diags(DiagID, new DiagnosticOptions, new IgnoringDiagConsumer()),
   SourceMgr(Diags, FileMgr),
-  TargetOpts(new TargetOptions) 
+  TargetOpts(new TargetOptions)
   {
 TargetOpts->Triple = "x86_64-apple-darwin11.1.0";
 Target = TargetInfo::CreateTargetInfo(Diags, TargetOpts);
@@ -478,4 +478,42 @@
   EXPECT_TRUE(LexedTokens.empty());
 }
 
+TEST_F(LexerTest, StringizingRasString) {
+  // For "std::string Lexer::Stringify(StringRef Str, bool Charify)".
+  std::string String1 = R"(foo
+{"bar":[]}
+baz)";
+  // For "void Lexer::Stringify(SmallVectorImpl &Str)".
+  SmallString<128> String2;
+  String2 += String1.c_str();
+
+  // Corner cases.
+  std::string String3 = R"(\
+\n
+\\n
+\\)";
+  SmallString<128> String4;
+  String4 += String3.c_str();
+  std::string String5 = R"(a\
+
+
+\\b)";
+  SmallString<128> String6;
+  String6 += String5.c_str();
+
+  String1 = Lexer::Stringify(StringRef(String1));
+  Lexer::Stringify(String2);
+  String3 = Lexer::Stringify(StringRef(String3));
+  Lexer::Stringify(String4);
+  String5 = Lexer::Stringify(StringRef(String5));
+  Lexer::Stringify(String6);
+
+  EXPECT_EQ(String1, R"(foo\n{\"bar\":[]}\nbaz)");
+  EXPECT_EQ(String2, R"(foo\n{\"bar\":[]}\nbaz)");
+  EXPECT_EQ(String3, R"(\\\n\\n\nn\n)");
+  EXPECT_EQ(String4, R"(\\\n\\n\nn\n)");
+  EXPECT_EQ(String5, R"(a\\\n\n\nb)");
+  EXPECT_EQ(String6, R"(a\\\n\n\nb)");
+}
+
 } // anonymous namespace
Index: test/Preprocessor/macro_raw_string.cpp
===
--- /dev/null
+++ test/Preprocessor/macro_raw_string.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -E -std=c++11 %s -o %t
+// RUN: %clang_cc1 %t
+
+#define FOO(str) foo(#str)
+
+extern void foo(const char *str);
+
+void bar() {
+  FOO(R"(foo
+bar)");
+}
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -209,30 +209,39 @@
   return L;
 }
 
-/// Stringify - Convert the specified string into a C string, with surrounding
-/// ""'s, and with escaped \ and " characters.
+template  void StringifyImpl(T &Str, char Quote) {
+  typename T::size_type i = 0, e = Str.size();
+  while (i < e) {
+if (Str[i] == '\\' || Str[i] == Quote) {
+  Str.insert(Str.begin() + i, '\\');
+  i += 2;
+  ++e;
+} else if (Str[i] == '\n' || Str[i] == '\r') {
+  // Replace '\r\n' and '\n\r' to '\\' followed by 'n'.
+  if ((i < e - 1) && (Str[i + 1] == '\n' || Str[i + 1] == '\r') &&
+  Str[i] != Str[i + 1]) {
+Str[i] = '\\';
+Str[i + 1] = 'n';
+  } else {
+// Replace '\n' and '\r' to '\\' followed by 'n'.
+Str[i] = '\\';
+Str.insert(Str.begin() + i + 1, 'n');
+++e;
+  }
+  i += 2;
+} else
+  ++i;
+  }
+}
+
 std::string Lexer::Stringify(StringRef Str, bool Charify) {
   std::string Result = Str;
   char Quote = Charify ? '\'' : '"';
-  for (unsigned i = 0, e = Result.size(); i != e; ++i) {
-if (Result[i] == '\\' || Result[i] == Quote) {
-  Result.insert(Result.begin()+i, '\\');
-  ++i; ++e;
-}
-  }
+  StringifyImpl(Result, Quote);
   return Result;
 }
 
-/// Stringify - Convert the specified string into a C string by escaping '\'
-/// and " characters.  This does not add surrounding ""'s to the string.
-void Lexer::Stringify(SmallVectorImpl &Str) {
-  for (unsigned i = 0, e = Str.size(); i != e; ++i) {
-if (Str[i] == '\\' || Str[i] == '"') {
-  Str.insert(Str.begin()+i, '\\');
-  ++i; ++e;
-}
-  }
-}
+void Lexer::Stringify(SmallVectorImpl &Str) { StringifyImpl(Str, '"'); }
 
 //===--===//
 // Token Spelling
@@ -367,7 +376,7 @@
 /// to point to a constant buffer with the data already in it (avoiding a
 /// copy).  The caller is not allowed to modify the returned buffer pointer
 /// if an internal buffer is returned.
-unsigned Lexer::getSpelling(const Token &Tok, const char *&Buffer, 
+unsigned Lexer::getSpelling(const Token &Tok, const char *&Buffer,
 const SourceManager &SourceMgr,
 const LangOptions &LangOpts, bool *Invalid) {
   assert((int)Tok.getLength() >= 0 && "Token character range is bogus!");
@@ -592,17 +601,17 @@
   if (TheTok.getKind() == tok::eof) {
 break;
   }
-  
+
   // If we haven't hit the end of the

[PATCH] D39739: [HCC] Add flag to Import Weak Functions in Function Importer

2017-12-05 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/Transforms/IPO/FunctionImport.cpp:107
+static cl::opt
+ForceImportWeak("force-import-weak", cl::Hidden,
+cl::desc("Allow weak functions to be imported"),

AlexVlx wrote:
> yaxunl wrote:
> > Is it possible not to expose this option through extern? Generally these 
> > options should be kept static.
> This seems to suggest that it is not utterly unacceptable: 
> http://llvm.org/docs/CommandLine.html#internal-vs-external-storage, and the 
> use case described there maps pretty closely to this, since the flag itself 
> must be accessible from two different TUs. Am I missing something?
OK. I did not notice that it is also used byFunctionImportUtils.cpp.



Comment at: lib/Transforms/Utils/FunctionImportUtils.cpp:153
 // definition and importing would change the order they are seen by the
 // linker. The module linking caller needs to enforce this.
+if(!ForceImportWeakFlag)

If we link three modules, A, B, and C.

A calls function sin, B and C both contains function sin with weak linkage.

Which sin function will be linked?


Repository:
  rL LLVM

https://reviews.llvm.org/D39739



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


Re: [PATCH] D40841: [analyzer] Fix a crash on C++17 AST for non-trivial construction into a trivial brace initializer.

2017-12-05 Thread Richard Smith via cfe-commits
On 5 December 2017 at 09:08, Artem Dergachev via Phabricator via
cfe-commits  wrote:

> NoQ created this revision.
> Herald added subscribers: cfe-commits, rnkovacs.
>
> Yet another situation where we cannot easily guess, by looking at the CFG,
> the target region for C++ constructor call.
>
> Consider the following brace initialization:
>
>   struct A {
> A();
>};
>
>   struct B : public A {
> int x;
>   };
>
> void foo() {
>
>   B b = {};
>
> }
>
> AST in C++14:
>
>   `-VarDecl 0x7ff07884eab8  col:5 b 'struct B' cinit
> `-CXXConstructExpr 0x7ff07887a940  'struct B' 'void
> (void) noexcept(false)' list zeroing
>
> AST in C++17:
>
>   `-VarDecl 0x7fb1cf012b18  col:5 b 'struct B' cinit
> `-InitListExpr 0x7fb1cf012f38  'struct B'
>   |-CXXConstructExpr 0x7fb1cf012fd0  'struct A' 'void (void)'
> list
>   `-ImplicitValueInitExpr 0x7fb1cf013000 <> 'int'
>
> CFG in C++14:
>
>   [B1]
> 1: {} (CXXConstructExpr, struct B)
> 2: B b = {};
>
> CFG in C++17:
>
>   [B1]
> 1: {} (CXXConstructExpr, struct A)
> 2: /*implicit*/(int)0
> 3: {}
> 4: B b = {};
>
> So, essentially, in C++17 we don't have the trivial constructor call for
> `B` present anywhere at all, neither in AST, nor in CFG.
>
> This causes a crash in the analyzer because he tries to find the target
> region for `CK_NonVirtualBase` constructor of `A` by looking at the parent
> stack frame, expecting to find the derived class constructor (for `B`)
> here, and then taking a base region within its this-object.
>
> This fix is a quick-and-dirty suppression for the crash. It follows the
> tradition of "when unsure, make up a temporary and construct into that,
> then discard the result" - which is wrong, but at least it gets some
> invalidation done.
>
> In our example it would be correct to construct into `base{A, b}`. There
> can also be situations when such initializer-list is instead
> lifetime-extended by a `const&` or `&&` reference (see the tests), so in
> this case we'd need to construct into a respective sub-region of the
> temporary (but not into the temporary itself, of course).
>
> Finally, from the perspective of checker development, i believe it would
> be useful to actually revive the constructor call, so that PreCall/PostCall
> event occured.


Note that there is no constructor call here. This is aggregate
initialization. And there's not really any part of this that's new, except
that a class with base classes is now an a aggregate. You'll see the same
kind of AST formed in all C++ language modes with a slightly modified
example:

```
struct A {
  A();
};

struct B {
  A a;
  int x;
};

void foo() {
  B b = {};
}
```

The analyzer should presumably treat the new example the exact same way it
treats that case.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39739: [HCC] Add flag to Import Weak Functions in Function Importer

2017-12-05 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added a comment.

The usual rule is to take the first weak definition encountered.


Repository:
  rL LLVM

https://reviews.llvm.org/D39739



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


Re: r319727 - Generalize "static data member instantiated" notification to cover variable templates too.

2017-12-05 Thread Galina Kistanova via cfe-commits
Hello Richard,

This commit broke tests on one of our bots:

http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/6568

Failing Tests (3):
. . .
Clang :: Modules/var-templates.cpp
. . .

Please have a look?

Thanks

Galina

On Mon, Dec 4, 2017 at 5:31 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Mon Dec  4 17:31:47 2017
> New Revision: 319727
>
> URL: http://llvm.org/viewvc/llvm-project?rev=319727&view=rev
> Log:
> Generalize "static data member instantiated" notification to cover
> variable templates too.
>
> While here, split the "point of instantiation changed" notification out
> from
> it; these two really are orthogonal changes.
>
> Added:
> cfe/trunk/test/Modules/var-templates.cpp
> Modified:
> cfe/trunk/include/clang/AST/ASTMutationListener.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/include/clang/Serialization/ASTWriter.h
> cfe/trunk/lib/AST/Decl.cpp
> cfe/trunk/lib/Frontend/MultiplexConsumer.cpp
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/lib/Sema/SemaTemplate.cpp
> cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
> cfe/trunk/lib/Sema/SemaType.cpp
> cfe/trunk/lib/Serialization/ASTCommon.h
> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
>
> Modified: cfe/trunk/include/clang/AST/ASTMutationListener.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/ASTMutationListener.h?rev=319727&r1=319726&r2=319727&view=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/ASTMutationListener.h (original)
> +++ cfe/trunk/include/clang/AST/ASTMutationListener.h Mon Dec  4 17:31:47
> 2017
> @@ -36,6 +36,7 @@ namespace clang {
>class QualType;
>class RecordDecl;
>class TagDecl;
> +  class ValueDecl;
>class VarDecl;
>class VarTemplateDecl;
>class VarTemplateSpecializationDecl;
> @@ -87,8 +88,13 @@ public:
>/// \brief An implicit member got a definition.
>virtual void CompletedImplicitDefinition(const FunctionDecl *D) {}
>
> -  /// \brief A static data member was implicitly instantiated.
> -  virtual void StaticDataMemberInstantiated(const VarDecl *D) {}
> +  /// \brief The instantiation of a templated function or variable was
> +  /// requested. In particular, the point of instantiation and template
> +  /// specialization kind of \p D may have changed.
> +  virtual void InstantiationRequested(const ValueDecl *D) {}
> +
> +  /// \brief A templated variable's definition was implicitly
> instantiated.
> +  virtual void VariableDefinitionInstantiated(const VarDecl *D) {}
>
>/// \brief A function template's definition was instantiated.
>virtual void FunctionDefinitionInstantiated(const FunctionDecl *D) {}
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Sema/Sema.h?rev=319727&r1=319726&r2=319727&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Mon Dec  4 17:31:47 2017
> @@ -7790,11 +7790,6 @@ public:
>   VarDecl *Var, bool Recursive = false,
>   bool DefinitionRequired = false,
>   bool AtEndOfTU = false);
> -  void InstantiateStaticDataMemberDefinition(
> - SourceLocation PointOfInstantiation,
> - VarDecl *Var,
> - bool Recursive = false,
> - bool DefinitionRequired = false);
>
>void InstantiateMemInitializers(CXXConstructorDecl *New,
>const CXXConstructorDecl *Tmpl,
>
> Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Serialization/ASTWriter.h?rev=319727&r1=319726&r2=319727&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
> +++ cfe/trunk/include/clang/Serialization/ASTWriter.h Mon Dec  4 17:31:47
> 2017
> @@ -727,10 +727,11 @@ private:
>const FunctionDecl *Delete,
>Expr *ThisArg) override;
>void CompletedImplicitDefinition(const FunctionDecl *D) override;
> -  void StaticDataMemberInstantiated(const VarDecl *D) override;
> +  void InstantiationRequested(const ValueDecl *D) override;
> +  void VariableDefinitionInstantiated(const VarDecl *D) override;
> +  void FunctionDefinitionInstantiated(const FunctionDecl *D) override;
>void DefaultArgumentInstantiated(const ParmVarDecl *D) override;
>voi

[clang-tools-extra] r319812 - Commit access test.

2017-12-05 Thread Julie Hockett via cfe-commits
Author: juliehockett
Date: Tue Dec  5 10:50:49 2017
New Revision: 319812

URL: http://llvm.org/viewvc/llvm-project?rev=319812&view=rev
Log:
Commit access test.

Modified:
clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp

Modified: clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp?rev=319812&r1=319811&r2=319812&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp Tue Dec  5 
10:50:49 2017
@@ -18,7 +18,7 @@ namespace clang {
 namespace tidy {
 namespace fuchsia {
 
-/// This module is for Fuchsia specific checks.
+/// This module is for Fuchsia-specific checks.
 class FuchsiaModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {


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


[PATCH] D39739: [HCC] Add flag to Import Weak Functions in Function Importer

2017-12-05 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D39739#945318, @b-sumner wrote:

> The usual rule is to take the first weak definition encountered.


Will this work for us? Usually we would like the last one to be linked.


Repository:
  rL LLVM

https://reviews.llvm.org/D39739



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


[PATCH] D39284: Allow conditions to be decomposed with structured bindings

2017-12-05 Thread Zhihao Yuan via Phabricator via cfe-commits
lichray updated this revision to Diff 125581.
lichray added a comment.

Rebased.


Repository:
  rC Clang

https://reviews.llvm.org/D39284

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/DeclSpec.h
  lib/Parse/ParseExprCXX.cpp
  lib/Sema/SemaDeclCXX.cpp
  test/Misc/warning-flags.c
  test/Parser/cxx1z-decomposition.cpp
  test/Parser/decomposed-condition.cpp
  test/SemaCXX/decomposed-condition.cpp

Index: test/SemaCXX/decomposed-condition.cpp
===
--- /dev/null
+++ test/SemaCXX/decomposed-condition.cpp
@@ -0,0 +1,99 @@
+// RUN: %clang_cc1 -std=c++1z -w -verify %s
+
+struct X {
+  bool flag;
+  int data;
+  constexpr explicit operator bool() const {
+return flag;
+  }
+  constexpr operator int() const {
+return data;
+  }
+};
+
+namespace CondInIf {
+constexpr int f(X x) {
+  if (auto [ok, d] = x)
+return d + int(ok);
+  else
+return d * int(ok);
+  ok = {}; // expected-error {{use of undeclared identifier 'ok'}}
+  d = {};  // expected-error {{use of undeclared identifier 'd'}}
+}
+
+static_assert(f({true, 2}) == 3);
+static_assert(f({false, 2}) == 0);
+
+constexpr char g(char const (&x)[2]) {
+  if (auto &[a, b] = x)
+return a;
+  else
+return b;
+
+  if (auto [a, b] = x) // expected-error {{an array type is not allowed here}}
+;
+}
+
+static_assert(g("x") == 'x');
+} // namespace CondInIf
+
+namespace CondInSwitch {
+constexpr int f(int n) {
+  switch (X s = {true, n}; auto [ok, d] = s) {
+s = {};
+  case 0:
+return int(ok);
+  case 1:
+return d * 10;
+  case 2:
+return d * 40;
+  default:
+return 0;
+  }
+  ok = {}; // expected-error {{use of undeclared identifier 'ok'}}
+  d = {};  // expected-error {{use of undeclared identifier 'd'}}
+  s = {};  // expected-error {{use of undeclared identifier 's'}}
+}
+
+static_assert(f(0) == 1);
+static_assert(f(1) == 10);
+static_assert(f(2) == 80);
+} // namespace CondInSwitch
+
+namespace CondInWhile {
+constexpr int f(int n) {
+  int m = 1;
+  while (auto [ok, d] = X{n > 1, n}) {
+m *= d;
+--n;
+  }
+  return m;
+  return ok; // expected-error {{use of undeclared identifier 'ok'}}
+}
+
+static_assert(f(0) == 1);
+static_assert(f(1) == 1);
+static_assert(f(4) == 24);
+} // namespace CondInWhile
+
+namespace CondInFor {
+constexpr int f(int n) {
+  int a = 1, b = 1;
+  for (X x = {true, n}; auto &[ok, d] = x; --d) {
+if (d < 2)
+  ok = false;
+else {
+  int x = b;
+  b += a;
+  a = x;
+}
+  }
+  return b;
+  return d; // expected-error {{use of undeclared identifier 'd'}}
+}
+
+static_assert(f(0) == 1);
+static_assert(f(1) == 1);
+static_assert(f(2) == 2);
+static_assert(f(5) == 8);
+} // namespace CondInFor
Index: test/Parser/decomposed-condition.cpp
===
--- /dev/null
+++ test/Parser/decomposed-condition.cpp
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -std=c++1z %s -verify
+
+struct Na {
+  bool flag;
+  float data;
+};
+
+struct Rst {
+  bool flag;
+  float data;
+  explicit operator bool() const {
+return flag;
+  }
+};
+
+Rst f();
+Na g();
+
+namespace CondInIf {
+void h() {
+  if (auto [ok, d] = f()) // expected-warning {{ISO C++17 does not permit structured binding declaration in a condition}}
+;
+  if (auto [ok, d] = g()) // expected-warning {{ISO C++17 does not permit structured binding declaration in a condition}} expected-error {{value of type 'Na' is not contextually convertible to 'bool'}}
+;
+}
+} // namespace CondInIf
+
+namespace CondInWhile {
+void h() {
+  while (auto [ok, d] = f()) // expected-warning {{ISO C++17 does not permit structured binding declaration in a condition}}
+;
+  while (auto [ok, d] = g()) // expected-warning {{ISO C++17 does not permit structured binding declaration in a condition}} expected-error {{value of type 'Na' is not contextually convertible to 'bool'}}
+;
+}
+} // namespace CondInWhile
+
+namespace CondInFor {
+void h() {
+  for (; auto [ok, d] = f();) // expected-warning {{ISO C++17 does not permit structured binding declaration in a condition}}
+;
+  for (; auto [ok, d] = g();) // expected-warning {{ISO C++17 does not permit structured binding declaration in a condition}} expected-error {{value of type 'Na' is not contextually convertible to 'bool'}}
+;
+}
+} // namespace CondInFor
+
+struct IntegerLike {
+  bool flag;
+  float data;
+  operator int() const {
+return int(data);
+  }
+};
+
+namespace CondInSwitch {
+void h(IntegerLike x) {
+  switch (auto [ok, d] = x) // expected-warning {{ISO C++17 does not permit structured binding declaration in a condition}}
+;
+  switch (auto [ok, d] = g()) // expected-warning {{ISO C++17 does not permit structured binding declaration in a condition}} expected-error {{statement requires expression of integer type ('Na' invalid)}}
+;
+}
+} // namespace CondInSwitch
Index: test/Parser/cxx1z-decomposition.cpp

[PATCH] D39430: [clangd] various fixes

2017-12-05 Thread Raoul Wols via Phabricator via cfe-commits
rwols added a comment.

I will split this diff up into separate parts.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D39430



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


r319814 - [OPENMP] Fix implicit mapping analysis.

2017-12-05 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Dec  5 11:20:09 2017
New Revision: 319814

URL: http://llvm.org/viewvc/llvm-project?rev=319814&view=rev
Log:
[OPENMP] Fix implicit mapping analysis.

Fixed processing of implicitly mapped objects in target-based executable
directives.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/target_map_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=319814&r1=319813&r2=319814&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Dec  5 11:20:09 2017
@@ -38,7 +38,7 @@ using namespace clang;
 static Expr *CheckMapClauseExpressionBase(
 Sema &SemaRef, Expr *E,
 OMPClauseMappableExprCommon::MappableExprComponentList &CurComponents,
-OpenMPClauseKind CKind);
+OpenMPClauseKind CKind, bool NoDiagnose);
 
 namespace {
 /// \brief Default data sharing attributes, which can be applied to directive.
@@ -1932,10 +1932,10 @@ public:
 E->containsUnexpandedParameterPack() || E->isInstantiationDependent())
   return;
 auto *FD = dyn_cast(E->getMemberDecl());
-if (!FD)
-  return;
 OpenMPDirectiveKind DKind = Stack->getCurrentDirective();
 if (isa(E->getBase()->IgnoreParens())) {
+  if (!FD)
+return;
   auto DVar = Stack->getTopDSA(FD, false);
   // Check if the variable has explicit DSA set and stop analysis if it
   // so.
@@ -1958,12 +1958,8 @@ public:
 // OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, C/C++, p.3]
 //  A bit-field cannot appear in a map clause.
 //
-if (FD->isBitField()) {
-  SemaRef.Diag(E->getMemberLoc(),
-   diag::err_omp_bit_fields_forbidden_in_clause)
-  << E->getSourceRange() << getOpenMPClauseName(OMPC_map);
+if (FD->isBitField())
   return;
-}
 ImplicitMap.emplace_back(E);
 return;
   }
@@ -1994,9 +1990,10 @@ public:
 ImplicitFirstprivate.push_back(E);
   return;
 }
-if (isOpenMPTargetExecutionDirective(DKind) && !FD->isBitField()) {
+if (isOpenMPTargetExecutionDirective(DKind)) {
   OMPClauseMappableExprCommon::MappableExprComponentList CurComponents;
-  if (!CheckMapClauseExpressionBase(SemaRef, E, CurComponents, OMPC_map))
+  if (!CheckMapClauseExpressionBase(SemaRef, E, CurComponents, OMPC_map,
+/*NoDiagnose=*/true))
 return;
   auto *VD = cast(
   CurComponents.back().getAssociatedDeclaration()->getCanonicalDecl());
@@ -11418,7 +11415,7 @@ static bool CheckArrayExpressionDoesNotR
 static Expr *CheckMapClauseExpressionBase(
 Sema &SemaRef, Expr *E,
 OMPClauseMappableExprCommon::MappableExprComponentList &CurComponents,
-OpenMPClauseKind CKind) {
+OpenMPClauseKind CKind, bool NoDiagnose) {
   SourceLocation ELoc = E->getExprLoc();
   SourceRange ERange = E->getSourceRange();
 
@@ -11489,9 +11486,14 @@ static Expr *CheckMapClauseExpressionBas
 E = BaseE;
 
   if (!isa(CurE->getMemberDecl())) {
-SemaRef.Diag(ELoc, diag::err_omp_expected_access_to_data_field)
-<< CurE->getSourceRange();
-return nullptr;
+if (!NoDiagnose) {
+  SemaRef.Diag(ELoc, diag::err_omp_expected_access_to_data_field)
+  << CurE->getSourceRange();
+  return nullptr;
+}
+if (RelevantExpr)
+  return nullptr;
+continue;
   }
 
   auto *FD = cast(CurE->getMemberDecl());
@@ -11500,9 +11502,14 @@ static Expr *CheckMapClauseExpressionBas
   //  A bit-field cannot appear in a map clause.
   //
   if (FD->isBitField()) {
-SemaRef.Diag(ELoc, diag::err_omp_bit_fields_forbidden_in_clause)
-<< CurE->getSourceRange() << getOpenMPClauseName(CKind);
-return nullptr;
+if (!NoDiagnose) {
+  SemaRef.Diag(ELoc, diag::err_omp_bit_fields_forbidden_in_clause)
+  << CurE->getSourceRange() << getOpenMPClauseName(CKind);
+  return nullptr;
+}
+if (RelevantExpr)
+  return nullptr;
+continue;
   }
 
   // OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, C++, p.1]
@@ -11514,12 +11521,16 @@ static Expr *CheckMapClauseExpressionBas
   //  A list item cannot be a variable that is a member of a structure with
   //  a union type.
   //
-  if (auto *RT = CurType->getAs())
+  if (auto *RT = CurType->getAs()) {
 if (RT->isUnionType()) {
-  SemaRef.Diag(ELoc, diag::err_omp_union_type_not_allowed)
-  << CurE->getSourceRange();
-  return nullptr;
+  if (!NoDiagnose) {
+SemaRef.Diag(ELoc, diag::err_omp_union_type_not_allowed)
+<< CurE->getSourceRange();
+return nullptr;
+  }
+   

[PATCH] D40752: [OpenMP] Fix assert fail after target implicit map checks

2017-12-05 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In https://reviews.llvm.org/D40752#945234, @jdenny wrote:

> r319774 works for my current use cases.  Thanks.
>
> While we're on this topic, do you happen to know the rationale behind the 
> OpenMP restriction for which err_omp_union_type_not_allowed diagnoses 
> violations?  I googled but couldn't find the rationale.  If you would prefer 
> that I ask this in a different forum, would you please suggest one?  Thanks.


You can try it now, there should no more error messages


https://reviews.llvm.org/D40752



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


[PATCH] D40816: [libunwind] Use the correct variable name for target triple in lit

2017-12-05 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd accepted this revision.
compnerd added a comment.
This revision is now accepted and ready to land.

I'm okay with this change in principle, but Im worried that this may break the 
buildbots.  Please ensure that they remain green after this change.


Repository:
  rL LLVM

https://reviews.llvm.org/D40816



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


[libcxx] r319816 - Enable auto-linking on Windows

2017-12-05 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Tue Dec  5 11:32:49 2017
New Revision: 319816

URL: http://llvm.org/viewvc/llvm-project?rev=319816&view=rev
Log:
Enable auto-linking on Windows

The MSVC driver and clang do not link against the C++ runtime
explicitly.  Instead, they rely on the auto-linking via the pragma
(through `use_ansi.h`) to link against the correct version of the C++
runtime.  Attempt to do something similar here so that linking real C++
code on Windows does not require the user to explicitly specify
`c++.lib` when using libc++ as a C++ runtime on windows.

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=319816&r1=319815&r2=319816&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Tue Dec  5 11:32:49 2017
@@ -1265,6 +1265,13 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 # endif
 #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
 
+#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
+# if defined(_DLL)
+#   pragma(lib, "c++.lib")
+# else
+#   pragma(lib, "libc++.lib")
+# endif
+#endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
 
 #endif // __cplusplus
 


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


[PATCH] D40816: [libunwind] Use the correct variable name for target triple in lit

2017-12-05 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

After some more digging through libc++ test suite, I think I understand now why 
these are different variables. It may be possible to remove these and just rely 
on plain CMake variables but this is likely going to require some more CMake 
and lit surgery, so for now I'm going to land https://reviews.llvm.org/D40820 
which is an alternative solution and revisit this later after I cleanup libc++ 
test suite.


Repository:
  rL LLVM

https://reviews.llvm.org/D40816



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


[PATCH] D40660: Enable auto-linking on Windows

2017-12-05 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd closed this revision.
compnerd added a comment.

SVN r319816


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] D39694: [VerifyDiagnosticConsumer] support -verify=

2017-12-05 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added inline comments.



Comment at: lib/Frontend/CompilerInvocation.cpp:1095
+  if (Diags) {
+Diags->Report(diag::err_drv_invalid_value) << "-verify=" << Prefix;
+Diags->Report(diag::note_drv_verify_prefix_unique);

jdenny wrote:
> hfinkel wrote:
> > If this were going to be an error, then it should have error message that 
> > explains the problem (e.g., duplicate --verify prefix). I don't believe 
> > that we should make this an error (i.e., I think that we should allow 
> > duplicate --verify options with the same prefixes).
> > If this were going to be an error, then it should have error message that 
> > explains the problem (e.g., duplicate --verify prefix).
> 
> Are you saying you prefer that to be in the error instead of the note (where 
> it is now)?
> 
> > I don't believe that we should make this an error (i.e., I think that we 
> > should allow duplicate --verify options with the same prefixes).
> 
> I see two reasons to permit duplicate explicit prefixes:
> 
> 1. It simplifies the documentation some (see previous comment).
> 
> 2. Typically, it's convenient to permit command-line options to be repeated 
> so that groups of options can be collected in shell or make variables without 
> having to worry about conflicts between groups.  On the other hand, I'm 
> having trouble imagining that use case for -verify options, which I believe 
> would normally appear directly in command lines in test source files.  Have 
> you seen use cases (perhaps with FileCheck) where it would be useful?
> 
> I see three reasons not to permit duplicate explicit prefixes:
> 
> 1. Not permitting duplicates is consistent with FileCheck's 
> --check-prefix[es].
> 
> 2. If we change our mind, we can later relax the restriction without breaking 
> backward compatibility, but we cannot go the other direction.
> 
> 3. Suppose a developer wants to extend an existing test case by adding new 
> -verify prefixes to existing clang command lines that already uses many 
> -verify prefixes.  If the developer accidentally duplicates an existing 
> prefix, the test case surely will not behave as expected, but it should be 
> easier to understand what has gone wrong if the compiler complains about 
> duplicate prefixes.
> 
> I'm not adamant about the current behavior, but I think we should consider 
> these points before deciding.
>> If this were going to be an error, then it should have error message that 
>> explains the problem (e.g., duplicate --verify prefix).
> Are you saying you prefer that to be in the error instead of the note (where 
> it is now)?

No, I'm saying that if we retain this as an error at all, then it needs better 
text. I'd prefer it not be an error.

> I see three reasons not to permit duplicate explicit prefixes:

I don't have a strong opinion, but in general, prohibiting duplicating 
command-line options hurts composability of command lines and makes scripting 
more difficult. That's a general statement (i.e., not tied to this use case), 
but as a result, I feel that should be the default unless a good reason 
(technical or otherwise) is presented.

In this case, checking for duplicates adds complexity to the implementation, 
and as far as I can tell, adds little value. Obviously, when writing checks, 
the author should check that they work. Moreover, the implementation will 
already complain if there are unmatched diagnostics, or if nothing matches, so 
the chance of accidentally mistyping the verify prefix seems low. 

> 1. Not permitting duplicates is consistent with FileCheck's 
> --check-prefix[es].

I don't find this compelling. In part, this is because FileCheck can't complain 
about unmatched output (that wouldn't make sense), and so the chance of error 
with FileCheck is much higher.

> 2. If we change our mind, we can later relax the restriction without breaking 
> backward compatibility, but we cannot go the other direction.

Not for this kind of option, really. This is a tool for Clang developers. If we 
found in the future that allowing duplicates where a large source of errors, 
we'd just change it.

> 3. Suppose a developer wants to extend an existing test case by adding new 
> -verify prefixes to existing clang command lines that already uses many 
> -verify prefixes. If the developer accidentally duplicates an existing 
> prefix, the test case surely will not behave as expected, but it should be 
> easier to understand what has gone wrong if the compiler complains about 
> duplicate prefixes.

If someone else feels strongly about this, please speak up. I don't see this as 
worth the implementation complexity nor sufficient justification to override 
what I see as the best practice of allowing duplicate options.

> 
> I'm not adamant about the current behavior, but I think we should consider 
> these points before deciding.

Sure.


https://reviews.llvm.org/D39694



___
cfe-commits mailing

r319817 - Give this test a triple to avoid failures on MS bots.

2017-12-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Dec  5 11:39:37 2017
New Revision: 319817

URL: http://llvm.org/viewvc/llvm-project?rev=319817&view=rev
Log:
Give this test a triple to avoid failures on MS bots.

Modified:
cfe/trunk/test/Modules/var-templates.cpp

Modified: cfe/trunk/test/Modules/var-templates.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/var-templates.cpp?rev=319817&r1=319816&r2=319817&view=diff
==
--- cfe/trunk/test/Modules/var-templates.cpp (original)
+++ cfe/trunk/test/Modules/var-templates.cpp Tue Dec  5 11:39:37 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fmodules -std=c++14 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fmodules -std=c++14 -emit-llvm %s -o - -triple 
%itanium_abi_triple | FileCheck %s
 
 #pragma clang module build A
 module A {}


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


Re: r319727 - Generalize "static data member instantiated" notification to cover variable templates too.

2017-12-05 Thread Richard Smith via cfe-commits
Sorry about that, fixed in r319817.

On 5 December 2017 at 10:38, Galina Kistanova via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hello Richard,
>
> This commit broke tests on one of our bots:
>
> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-
> expensive-checks-win/builds/6568
>
> Failing Tests (3):
> . . .
> Clang :: Modules/var-templates.cpp
> . . .
>
> Please have a look?
>
> Thanks
>
> Galina
>
> On Mon, Dec 4, 2017 at 5:31 PM, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Mon Dec  4 17:31:47 2017
>> New Revision: 319727
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=319727&view=rev
>> Log:
>> Generalize "static data member instantiated" notification to cover
>> variable templates too.
>>
>> While here, split the "point of instantiation changed" notification out
>> from
>> it; these two really are orthogonal changes.
>>
>> Added:
>> cfe/trunk/test/Modules/var-templates.cpp
>> Modified:
>> cfe/trunk/include/clang/AST/ASTMutationListener.h
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/include/clang/Serialization/ASTWriter.h
>> cfe/trunk/lib/AST/Decl.cpp
>> cfe/trunk/lib/Frontend/MultiplexConsumer.cpp
>> cfe/trunk/lib/Sema/SemaExpr.cpp
>> cfe/trunk/lib/Sema/SemaTemplate.cpp
>> cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
>> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
>> cfe/trunk/lib/Sema/SemaType.cpp
>> cfe/trunk/lib/Serialization/ASTCommon.h
>> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>> cfe/trunk/lib/Serialization/ASTWriter.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/ASTMutationListener.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> AST/ASTMutationListener.h?rev=319727&r1=319726&r2=319727&view=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/AST/ASTMutationListener.h (original)
>> +++ cfe/trunk/include/clang/AST/ASTMutationListener.h Mon Dec  4
>> 17:31:47 2017
>> @@ -36,6 +36,7 @@ namespace clang {
>>class QualType;
>>class RecordDecl;
>>class TagDecl;
>> +  class ValueDecl;
>>class VarDecl;
>>class VarTemplateDecl;
>>class VarTemplateSpecializationDecl;
>> @@ -87,8 +88,13 @@ public:
>>/// \brief An implicit member got a definition.
>>virtual void CompletedImplicitDefinition(const FunctionDecl *D) {}
>>
>> -  /// \brief A static data member was implicitly instantiated.
>> -  virtual void StaticDataMemberInstantiated(const VarDecl *D) {}
>> +  /// \brief The instantiation of a templated function or variable was
>> +  /// requested. In particular, the point of instantiation and template
>> +  /// specialization kind of \p D may have changed.
>> +  virtual void InstantiationRequested(const ValueDecl *D) {}
>> +
>> +  /// \brief A templated variable's definition was implicitly
>> instantiated.
>> +  virtual void VariableDefinitionInstantiated(const VarDecl *D) {}
>>
>>/// \brief A function template's definition was instantiated.
>>virtual void FunctionDefinitionInstantiated(const FunctionDecl *D) {}
>>
>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Sema/Sema.h?rev=319727&r1=319726&r2=319727&view=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>> +++ cfe/trunk/include/clang/Sema/Sema.h Mon Dec  4 17:31:47 2017
>> @@ -7790,11 +7790,6 @@ public:
>>   VarDecl *Var, bool Recursive =
>> false,
>>   bool DefinitionRequired = false,
>>   bool AtEndOfTU = false);
>> -  void InstantiateStaticDataMemberDefinition(
>> - SourceLocation PointOfInstantiation,
>> - VarDecl *Var,
>> - bool Recursive = false,
>> - bool DefinitionRequired = false);
>>
>>void InstantiateMemInitializers(CXXConstructorDecl *New,
>>const CXXConstructorDecl *Tmpl,
>>
>> Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Serialization/ASTWriter.h?rev=319727&r1=319726&r2=319727&view=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
>> +++ cfe/trunk/include/clang/Serialization/ASTWriter.h Mon Dec  4
>> 17:31:47 2017
>> @@ -727,10 +727,11 @@ private:
>>const FunctionDecl *Delete,
>>Expr *ThisArg) override;
>>void CompletedImplicitDefinition(const FunctionDecl *D) override;
>> -  void StaticDataMemberInstantiated(const VarDecl *D) override;
>> +  void I

[PATCH] D39284: Allow conditions to be decomposed with structured bindings

2017-12-05 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: test/Misc/warning-flags.c:19
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 

lichray wrote:
> rsmith wrote:
> > Please read and respect this rule :)
> Do you know of some categories which can cover this kind of extensions?
Add a new warning flag for it. Maybe `-Wbinding-in-condition`?


Repository:
  rC Clang

https://reviews.llvm.org/D39284



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


[clang-tools-extra] r319820 - [clangd] Clean up code complete unit tests. NFC

2017-12-05 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Tue Dec  5 12:11:29 2017
New Revision: 319820

URL: http://llvm.org/viewvc/llvm-project?rev=319820&view=rev
Log:
[clangd] Clean up code complete unit tests. NFC

Modified:
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp

Modified: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp?rev=319820&r1=319819&r2=319820&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Tue Dec  5 
12:11:29 2017
@@ -10,12 +10,24 @@
 #include "Compiler.h"
 #include "Protocol.h"
 #include "TestFS.h"
+#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
 namespace clang {
 namespace clangd {
+// Let GMock print completion items.
+void PrintTo(const CompletionItem &I, std::ostream *O) {
+  llvm::raw_os_ostream OS(*O);
+  OS << toJSON(I);
+}
+
 namespace {
 using namespace llvm;
+using ::testing::AllOf;
+using ::testing::Contains;
+using ::testing::ElementsAre;
+using ::testing::Matcher;
+using ::testing::Not;
 
 class IgnoreDiagnostics : public DiagnosticsConsumer {
   void onDiagnosticsReady(
@@ -27,161 +39,74 @@ struct StringWithPos {
   clangd::Position MarkerPos;
 };
 
-/// Returns location of "{mark}" substring in \p Text and removes it from \p
-/// Text. Note that \p Text must contain exactly one occurence of "{mark}".
-///
-/// Marker name can be configured using \p MarkerName parameter.
-StringWithPos parseTextMarker(StringRef Text, StringRef MarkerName = "mark") {
-  SmallString<16> Marker;
-  Twine("{" + MarkerName + "}").toVector(/*ref*/ Marker);
-
-  std::size_t MarkerOffset = Text.find(Marker);
-  assert(MarkerOffset != StringRef::npos && "{mark} wasn't found in Text.");
+/// Accepts a source file with a cursor marker ^.
+/// Returns the source file with the marker removed, and the marker position.
+StringWithPos parseTextMarker(StringRef Text) {
+  std::size_t MarkerOffset = Text.find('^');
+  assert(MarkerOffset != StringRef::npos && "^ wasn't found in Text.");
 
   std::string WithoutMarker;
   WithoutMarker += Text.take_front(MarkerOffset);
-  WithoutMarker += Text.drop_front(MarkerOffset + Marker.size());
-  assert(StringRef(WithoutMarker).find(Marker) == StringRef::npos &&
- "There were multiple occurences of {mark} inside Text");
+  WithoutMarker += Text.drop_front(MarkerOffset + 1);
+  assert(StringRef(WithoutMarker).find('^') == StringRef::npos &&
+ "There were multiple occurences of ^ inside Text");
 
-  clangd::Position MarkerPos =
-  clangd::offsetToPosition(WithoutMarker, MarkerOffset);
+  auto MarkerPos = offsetToPosition(WithoutMarker, MarkerOffset);
   return {std::move(WithoutMarker), MarkerPos};
 }
 
-class ClangdCompletionTest : public ::testing::Test {
-protected:
-  template 
-  bool ContainsItemPred(CompletionList const &Items, Predicate Pred) {
-for (const auto &Item : Items.items) {
-  if (Pred(Item))
-return true;
-}
-return false;
-  }
-
-  bool ContainsItem(CompletionList const &Items, StringRef Name) {
-return ContainsItemPred(Items, [Name](clangd::CompletionItem Item) {
-  return Item.insertText == Name;
-});
-return false;
-  }
-};
-
-TEST_F(ClangdCompletionTest, CheckContentsOverride) {
-  MockFSProvider FS;
-  IgnoreDiagnostics DiagConsumer;
-  MockCompilationDatabase CDB;
-
-  ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-  /*StorePreamblesInMemory=*/true,
-  EmptyLogger::getInstance());
-
-  auto FooCpp = getVirtualTestFilePath("foo.cpp");
-  const auto SourceContents = R"cpp(
-int aba;
-int b =   ;
-)cpp";
-
-  const auto OverridenSourceContents = R"cpp(
-int cbc;
-int b =   ;
-)cpp";
-
-  // Use default options.
-  CodeCompleteOptions CCOpts;
-  // Complete after '=' sign. We need to be careful to keep the SourceContents'
-  // size the same.
-  // We complete on the 3rd line (2nd in zero-based numbering), because raw
-  // string literal of the SourceContents starts with a newline(it's easy to
-  // miss).
-  Position CompletePos = {2, 8};
-  FS.Files[FooCpp] = SourceContents;
-  FS.ExpectedFile = FooCpp;
-
-  // No need to sync reparses here as there are no asserts on diagnostics (or
-  // other async operations).
-  Server.addDocument(FooCpp, SourceContents);
-
-  {
-auto CodeCompletionResults1 =
-Server.codeComplete(FooCpp, CompletePos, CCOpts, None).get().Value;
-EXPECT_TRUE(ContainsItem(CodeCompletionResults1, "aba"));
-EXPECT_FALSE(ContainsItem(CodeCompletionResults1, "cbc"));
-  }
-
-  {
-auto CodeCompletionResultsOverriden =
-Server
-.codeComplete(FooCpp, CompletePos, CCOpts,
-  StringRef(OverridenSourceContents))
-.get()
-.V

[libunwind] r319823 - [libunwind] Pass LIBUNWIND_SYSROOT and LIBUNWIND_GCC_TOOLCHAIN to lit

2017-12-05 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Dec  5 12:22:10 2017
New Revision: 319823

URL: http://llvm.org/viewvc/llvm-project?rev=319823&view=rev
Log:
[libunwind] Pass LIBUNWIND_SYSROOT and LIBUNWIND_GCC_TOOLCHAIN to lit

These are expected to be set by the shared lit scripts used from
libc++.

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

Modified:
libunwind/trunk/test/lit.site.cfg.in

Modified: libunwind/trunk/test/lit.site.cfg.in
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/test/lit.site.cfg.in?rev=319823&r1=319822&r2=319823&view=diff
==
--- libunwind/trunk/test/lit.site.cfg.in (original)
+++ libunwind/trunk/test/lit.site.cfg.in Tue Dec  5 12:22:10 2017
@@ -19,6 +19,8 @@ config.enable_exceptions= "@LIBU
 config.host_triple  = "@LLVM_HOST_TRIPLE@"
 config.target_triple= "@TARGET_TRIPLE@"
 config.use_target   = len("@LIBUNWIND_TARGET_TRIPLE@") > 0
+config.sysroot  = "@LIBUNWIND_SYSROOT@"
+config.gcc_toolchain= "@LIBUNWIND_GCC_TOOLCHAIN@"
 config.cxx_ext_threads  = "@LIBUNWIND_BUILD_EXTERNAL_THREAD_LIBRARY@"
 
 # Let the main config do the real work.


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


[PATCH] D40817: [libunwind] Pass LIBUNWIND_SYSROOT and LIBUNWIND_GCC_TOOLCHAIN to lit

2017-12-05 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319823: [libunwind] Pass LIBUNWIND_SYSROOT and 
LIBUNWIND_GCC_TOOLCHAIN to lit (authored by phosek).

Changed prior to commit:
  https://reviews.llvm.org/D40817?vs=125455&id=125590#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40817

Files:
  libunwind/trunk/test/lit.site.cfg.in


Index: libunwind/trunk/test/lit.site.cfg.in
===
--- libunwind/trunk/test/lit.site.cfg.in
+++ libunwind/trunk/test/lit.site.cfg.in
@@ -19,6 +19,8 @@
 config.host_triple  = "@LLVM_HOST_TRIPLE@"
 config.target_triple= "@TARGET_TRIPLE@"
 config.use_target   = len("@LIBUNWIND_TARGET_TRIPLE@") > 0
+config.sysroot  = "@LIBUNWIND_SYSROOT@"
+config.gcc_toolchain= "@LIBUNWIND_GCC_TOOLCHAIN@"
 config.cxx_ext_threads  = "@LIBUNWIND_BUILD_EXTERNAL_THREAD_LIBRARY@"
 
 # Let the main config do the real work.


Index: libunwind/trunk/test/lit.site.cfg.in
===
--- libunwind/trunk/test/lit.site.cfg.in
+++ libunwind/trunk/test/lit.site.cfg.in
@@ -19,6 +19,8 @@
 config.host_triple  = "@LLVM_HOST_TRIPLE@"
 config.target_triple= "@TARGET_TRIPLE@"
 config.use_target   = len("@LIBUNWIND_TARGET_TRIPLE@") > 0
+config.sysroot  = "@LIBUNWIND_SYSROOT@"
+config.gcc_toolchain= "@LIBUNWIND_GCC_TOOLCHAIN@"
 config.cxx_ext_threads  = "@LIBUNWIND_BUILD_EXTERNAL_THREAD_LIBRARY@"
 
 # Let the main config do the real work.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40850: suppress undefined-template warnings when the pattern is declared in a system header

2017-12-05 Thread Nick Lewycky via Phabricator via cfe-commits
nlewycky created this revision.

The way to fix an undefined-template warning is to add lines to the header file 
that defines the template pattern. We should suppress the warnings when the 
template pattern is in a system header because we don't expect users to edit 
those.


https://reviews.llvm.org/D40850

Files:
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/SemaTemplate/undefined-template.cpp


Index: test/SemaTemplate/undefined-template.cpp
===
--- test/SemaTemplate/undefined-template.cpp
+++ test/SemaTemplate/undefined-template.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 -Wundefined-func-template 
%s
 
+#if !defined(INCLUDE)
 template  struct C1 {
   static char s_var_1;   // expected-note{{forward declaration of template 
entity is here}}
   static char s_var_2;   // expected-note{{forward declaration of template 
entity is here}}
@@ -142,6 +143,16 @@
   void h(X x) { g(x); } // no warning for use of 'g' despite the 
declaration having been instantiated from a template
 }
 
+#define INCLUDE
+#include "undefined-template.cpp"
+void func_25(SystemHeader *x) {
+  x->meth();
+}
+
 int main() {
   return 0;
 }
+#else
+#pragma clang system_header
+template  struct SystemHeader { T meth(); };
+#endif
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3808,7 +3808,8 @@
   PendingInstantiations.push_back(
 std::make_pair(Function, PointOfInstantiation));
 } else if (TSK == TSK_ImplicitInstantiation) {
-  if (AtEndOfTU && !getDiagnostics().hasErrorOccurred()) {
+  if (AtEndOfTU && !getDiagnostics().hasErrorOccurred() &&
+  !getSourceManager().isInSystemHeader(PatternDecl->getLocStart())) {
 Diag(PointOfInstantiation, diag::warn_func_template_missing)
   << Function;
 Diag(PatternDecl->getLocation(), diag::note_forward_template_decl);
@@ -4338,7 +4339,8 @@
 std::make_pair(Var, PointOfInstantiation));
 } else if (TSK == TSK_ImplicitInstantiation) {
   // Warn about missing definition at the end of translation unit.
-  if (AtEndOfTU && !getDiagnostics().hasErrorOccurred()) {
+  if (AtEndOfTU && !getDiagnostics().hasErrorOccurred() &&
+  !getSourceManager().isInSystemHeader(PatternDecl->getLocStart())) {
 Diag(PointOfInstantiation, diag::warn_var_template_missing)
   << Var;
 Diag(PatternDecl->getLocation(), diag::note_forward_template_decl);


Index: test/SemaTemplate/undefined-template.cpp
===
--- test/SemaTemplate/undefined-template.cpp
+++ test/SemaTemplate/undefined-template.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 -Wundefined-func-template %s
 
+#if !defined(INCLUDE)
 template  struct C1 {
   static char s_var_1;   // expected-note{{forward declaration of template entity is here}}
   static char s_var_2;   // expected-note{{forward declaration of template entity is here}}
@@ -142,6 +143,16 @@
   void h(X x) { g(x); } // no warning for use of 'g' despite the declaration having been instantiated from a template
 }
 
+#define INCLUDE
+#include "undefined-template.cpp"
+void func_25(SystemHeader *x) {
+  x->meth();
+}
+
 int main() {
   return 0;
 }
+#else
+#pragma clang system_header
+template  struct SystemHeader { T meth(); };
+#endif
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3808,7 +3808,8 @@
   PendingInstantiations.push_back(
 std::make_pair(Function, PointOfInstantiation));
 } else if (TSK == TSK_ImplicitInstantiation) {
-  if (AtEndOfTU && !getDiagnostics().hasErrorOccurred()) {
+  if (AtEndOfTU && !getDiagnostics().hasErrorOccurred() &&
+  !getSourceManager().isInSystemHeader(PatternDecl->getLocStart())) {
 Diag(PointOfInstantiation, diag::warn_func_template_missing)
   << Function;
 Diag(PatternDecl->getLocation(), diag::note_forward_template_decl);
@@ -4338,7 +4339,8 @@
 std::make_pair(Var, PointOfInstantiation));
 } else if (TSK == TSK_ImplicitInstantiation) {
   // Warn about missing definition at the end of translation unit.
-  if (AtEndOfTU && !getDiagnostics().hasErrorOccurred()) {
+  if (AtEndOfTU && !getDiagnostics().hasErrorOccurred() &&
+  !getSourceManager().isInSystemHeader(PatternDecl->getLocStart())) {
 Diag(PointOfInstantiation, diag::warn_var_template_missing)
   << Var;
 Diag(PatternDecl->getLocation(), diag::note_forward_template_decl);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
htt

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

2017-12-05 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.






Comment at: lib/Frontend/CompilerInvocation.cpp:1095
+  if (Diags) {
+Diags->Report(diag::err_drv_invalid_value) << "-verify=" << Prefix;
+Diags->Report(diag::note_drv_verify_prefix_unique);

hfinkel wrote:
> jdenny wrote:
> > hfinkel wrote:
> > > If this were going to be an error, then it should have error message that 
> > > explains the problem (e.g., duplicate --verify prefix). I don't believe 
> > > that we should make this an error (i.e., I think that we should allow 
> > > duplicate --verify options with the same prefixes).
> > > If this were going to be an error, then it should have error message that 
> > > explains the problem (e.g., duplicate --verify prefix).
> > 
> > Are you saying you prefer that to be in the error instead of the note 
> > (where it is now)?
> > 
> > > I don't believe that we should make this an error (i.e., I think that we 
> > > should allow duplicate --verify options with the same prefixes).
> > 
> > I see two reasons to permit duplicate explicit prefixes:
> > 
> > 1. It simplifies the documentation some (see previous comment).
> > 
> > 2. Typically, it's convenient to permit command-line options to be repeated 
> > so that groups of options can be collected in shell or make variables 
> > without having to worry about conflicts between groups.  On the other hand, 
> > I'm having trouble imagining that use case for -verify options, which I 
> > believe would normally appear directly in command lines in test source 
> > files.  Have you seen use cases (perhaps with FileCheck) where it would be 
> > useful?
> > 
> > I see three reasons not to permit duplicate explicit prefixes:
> > 
> > 1. Not permitting duplicates is consistent with FileCheck's 
> > --check-prefix[es].
> > 
> > 2. If we change our mind, we can later relax the restriction without 
> > breaking backward compatibility, but we cannot go the other direction.
> > 
> > 3. Suppose a developer wants to extend an existing test case by adding new 
> > -verify prefixes to existing clang command lines that already uses many 
> > -verify prefixes.  If the developer accidentally duplicates an existing 
> > prefix, the test case surely will not behave as expected, but it should be 
> > easier to understand what has gone wrong if the compiler complains about 
> > duplicate prefixes.
> > 
> > I'm not adamant about the current behavior, but I think we should consider 
> > these points before deciding.
> >> If this were going to be an error, then it should have error message that 
> >> explains the problem (e.g., duplicate --verify prefix).
> > Are you saying you prefer that to be in the error instead of the note 
> > (where it is now)?
> 
> No, I'm saying that if we retain this as an error at all, then it needs 
> better text. I'd prefer it not be an error.
> 
> > I see three reasons not to permit duplicate explicit prefixes:
> 
> I don't have a strong opinion, but in general, prohibiting duplicating 
> command-line options hurts composability of command lines and makes scripting 
> more difficult. That's a general statement (i.e., not tied to this use case), 
> but as a result, I feel that should be the default unless a good reason 
> (technical or otherwise) is presented.
> 
> In this case, checking for duplicates adds complexity to the implementation, 
> and as far as I can tell, adds little value. Obviously, when writing checks, 
> the author should check that they work. Moreover, the implementation will 
> already complain if there are unmatched diagnostics, or if nothing matches, 
> so the chance of accidentally mistyping the verify prefix seems low. 
> 
> > 1. Not permitting duplicates is consistent with FileCheck's 
> > --check-prefix[es].
> 
> I don't find this compelling. In part, this is because FileCheck can't 
> complain about unmatched output (that wouldn't make sense), and so the chance 
> of error with FileCheck is much higher.
> 
> > 2. If we change our mind, we can later relax the restriction without 
> > breaking backward compatibility, but we cannot go the other direction.
> 
> Not for this kind of option, really. This is a tool for Clang developers. If 
> we found in the future that allowing duplicates where a large source of 
> errors, we'd just change it.
> 
> > 3. Suppose a developer wants to extend an existing test case by adding new 
> > -verify prefixes to existing clang command lines that already uses many 
> > -verify prefixes. If the developer accidentally duplicates an existing 
> > prefix, the test case surely will not behave as expected, but it should be 
> > easier to understand what has gone wrong if the compiler complains about 
> > duplicate prefixes.
> 
> If someone else feels strongly about this, please speak up. I don't see this 
> as worth the implementation complexity nor sufficient justification to 
> override what I see as the best practice of allowing duplicate options.
> 
> > 
> > I'm not adamant abo

[libunwind] r319830 - [libunwind][CMake] Set TARGET_TRIPLE if LIBUNWND_TARGET_TRIPLE is set

2017-12-05 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Dec  5 12:48:05 2017
New Revision: 319830

URL: http://llvm.org/viewvc/llvm-project?rev=319830&view=rev
Log:
[libunwind][CMake] Set TARGET_TRIPLE if LIBUNWND_TARGET_TRIPLE is set

This follows the setup used by other runtimes and is expected by
the lit configuration.

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

Modified:
libunwind/trunk/CMakeLists.txt

Modified: libunwind/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=319830&r1=319829&r2=319830&view=diff
==
--- libunwind/trunk/CMakeLists.txt (original)
+++ libunwind/trunk/CMakeLists.txt Tue Dec  5 12:48:05 2017
@@ -211,6 +211,10 @@ add_target_flags_if(LIBUNWIND_GCC_TOOLCH
 add_target_flags_if(LIBUNWIND_SYSROOT
   "--sysroot=${LIBUNWIND_SYSROOT}")
 
+if (LIBUNWIND_TARGET_TRIPLE)
+  set(TARGET_TRIPLE "${LIBUNWIND_TARGET_TRIPLE}")
+endif()
+
 # Configure compiler.
 include(config-ix)
 


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


Re: r319715 - Fix record-parsing-invocation.c test on Windows

2017-12-05 Thread Alex L via cfe-commits
Thanks, I will take a look at it right now. I believe your solution is the
right fix.

On 5 December 2017 at 07:09, Sean Eveson  wrote:

> Hi,
>
> It looks like the test is still failing on one of the Windows build bots:
> http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015
>
> From looking at the test locally it seems the problem is when you do `//
> RUN: not env...`. The env command doesn't get handled by llvm-lit.py,
> because it gets passed through to `not.exe`.
>
> In terms of fixing this test, changing from `not env X=Y COMMAND` to `env
> X=Y not COMMAND` works on my machine. Otherwise maybe llvm-lit could be
> changed to make the handling of env (and other utilities) consistent when
> used after a not?
>
> Thanks,
>
> Sean Eveson
> SN Systems - Sony Interactive Entertainment
>
> On Mon, Dec 4, 2017 at 11:21 PM, Alex Lorenz via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: arphaman
>> Date: Mon Dec  4 15:21:07 2017
>> New Revision: 319715
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=319715&view=rev
>> Log:
>> Fix record-parsing-invocation.c test on Windows
>>
>> We should not check for the forward slash '/'
>>
>> Modified:
>> cfe/trunk/test/Index/record-parsing-invocation.c
>>
>> Modified: cfe/trunk/test/Index/record-parsing-invocation.c
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/rec
>> ord-parsing-invocation.c?rev=319715&r1=319714&r2=319715&view=diff
>> 
>> ==
>> --- cfe/trunk/test/Index/record-parsing-invocation.c (original)
>> +++ cfe/trunk/test/Index/record-parsing-invocation.c Mon Dec  4 15:21:07
>> 2017
>> @@ -18,4 +18,4 @@
>>  #  pragma clang __debug parser_crash
>>  #endif
>>
>> -// CHECK: {"toolchain":"{{.*}}","libclang.operation":"parse","libclang
>> .opts":1,"args":["clang","-fno-spell-checking","{{.*}}/
>> record-parsing-invocation.c","-Xclang","-detailed-
>> preprocessing-record","-fallow-editor-placeholders"]}
>> +// CHECK: {"toolchain":"{{.*}}","libclang.operation":"parse","libclang
>> .opts":1,"args":["clang","-fno-spell-checking","{{.*}}
>> record-parsing-invocation.c","-Xclang","-detailed-
>> preprocessing-record","-fallow-editor-placeholders"]}
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >