[PATCH] D57910: [ASTImporter] Find previous friend function template

2019-02-15 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Ping


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57910/new/

https://reviews.llvm.org/D57910



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


[PATCH] D57590: [ASTImporter] Improve import of FileID.

2019-02-15 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.
Herald added a subscriber: cfe-commits.

Ping


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57590/new/

https://reviews.llvm.org/D57590



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


r354109 - Revert "[Analysis] -Wunreachable-code shouldn't fire on the increment of a foreach loop"

2019-02-15 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Fri Feb 15 01:18:49 2019
New Revision: 354109

URL: http://llvm.org/viewvc/llvm-project?rev=354109&view=rev
Log:
Revert "[Analysis] -Wunreachable-code shouldn't fire on the increment of a 
foreach loop"

This reverts commit r354102.

Modified:
cfe/trunk/lib/Analysis/ReachableCode.cpp
cfe/trunk/test/SemaCXX/unreachable-code.cpp

Modified: cfe/trunk/lib/Analysis/ReachableCode.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ReachableCode.cpp?rev=354109&r1=354108&r2=354109&view=diff
==
--- cfe/trunk/lib/Analysis/ReachableCode.cpp (original)
+++ cfe/trunk/lib/Analysis/ReachableCode.cpp Fri Feb 15 01:18:49 2019
@@ -631,10 +631,6 @@ void DeadCodeScan::reportDeadCode(const
 // a for/for-range loop.  This is the block that contains
 // the increment code.
 if (const Stmt *LoopTarget = B->getLoopTarget()) {
-  // The increment on a foreach statement is not written.
-  if (isa(LoopTarget))
-return;
-
   SourceLocation Loc = LoopTarget->getBeginLoc();
   SourceRange R1(Loc, Loc), R2;
 

Modified: cfe/trunk/test/SemaCXX/unreachable-code.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/unreachable-code.cpp?rev=354109&r1=354108&r2=354109&view=diff
==
--- cfe/trunk/test/SemaCXX/unreachable-code.cpp (original)
+++ cfe/trunk/test/SemaCXX/unreachable-code.cpp Fri Feb 15 01:18:49 2019
@@ -52,11 +52,6 @@ void test3() {
   }
 }
 
-void test4() {
-  for (char c : "abc") // no-warning
-break;
-}
-
 // PR 6130 - Don't warn about bogus unreachable code with throw's and
 // temporary objects.
 class PR6130 {


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


[PATCH] D58275: [clangd] Support utf-8 offsets (rather than utf-16) as a protocol extension

2019-02-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added subscribers: cfe-commits, jdoerfert, kadircet, arphaman, jkorous, 
MaskRay, ioeric, ilya-biryukov.
Herald added a project: clang.

Still some pieces to go here: unit tests for new SourceCode functionality and
a command-line flag to force utf-8 mode. But wanted to get early feedback.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D58275

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  test/clangd/utf8.test

Index: test/clangd/utf8.test
===
--- /dev/null
+++ test/clangd/utf8.test
@@ -0,0 +1,32 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+# This test verifies that we can negotiate UTF-8 offsets via protocol extension.
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{"offsetEncoding":["utf-8","utf-16"]},"trace":"off"}}
+# CHECK: "offsetEncoding": "utf-8"
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"/*ö*/int x;\nint y=x;"}}}
+---
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":1,"character":6}}}
+# /*ö*/int x;
+# 01234567890
+# x is character (and utf-16) range [9,10) but byte range [10,11).
+#  CHECK:  "id": 1,
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": [
+# CHECK-NEXT:{
+# CHECK-NEXT:  "range": {
+# CHECK-NEXT:"end": {
+# CHECK-NEXT:  "character": 11,
+# CHECK-NEXT:  "line": 0
+# CHECK-NEXT:},
+# CHECK-NEXT:"start": {
+# CHECK-NEXT:  "character": 10,
+# CHECK-NEXT:  "line": 0
+# CHECK-NEXT:}
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "uri": "file://{{.*}}/main.cpp"
+# CHECK-NEXT:}
+# CHECK-NEXT:  ]
+---
+{"jsonrpc":"2.0","id":1,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}
Index: clangd/SourceCode.h
===
--- clangd/SourceCode.h
+++ clangd/SourceCode.h
@@ -12,6 +12,7 @@
 //===--===//
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_SOURCECODE_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SOURCECODE_H
+#include "Context.h"
 #include "Protocol.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/LangOptions.h"
@@ -34,8 +35,14 @@
 FileDigest digest(StringRef Content);
 Optional digestFile(const SourceManager &SM, FileID FID);
 
+// This context variable controls the behavior of functions in this file
+// that convert between LSP offsets and native clang byte offsets.
+// If not set, defaults to UTF-16 for backwards-compatibility.
+extern Key kCurrentOffsetEncoding;
+
 // Counts the number of UTF-16 code units needed to represent a string (LSP
 // specifies string lengths in UTF-16 code units).
+// Use of UTF-16 may be overridden by kCurrentOffsetEncoding.
 size_t lspLength(StringRef Code);
 
 /// Turn a [line, column] pair into an offset in Code.
Index: clangd/SourceCode.cpp
===
--- clangd/SourceCode.cpp
+++ clangd/SourceCode.cpp
@@ -7,6 +7,7 @@
 //===--===//
 #include "SourceCode.h"
 
+#include "Context.h"
 #include "Logger.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/Basic/SourceManager.h"
@@ -20,6 +21,8 @@
 namespace clang {
 namespace clangd {
 
+Key kCurrentOffsetEncoding;
+
 // Here be dragons. LSP positions use columns measured in *UTF-16 code units*!
 // Clangd uses UTF-8 and byte-offsets internally, so conversion is nontrivial.
 
@@ -67,8 +70,17 @@
   return std::min(Result, U8.size());
 }
 
+static bool useUTF8ForLSP() {
+  if (auto *Enc = Context::current().get(kCurrentOffsetEncoding))
+if (*Enc == OffsetEncoding::UTF8)
+  return true;
+  return false;
+}
+
 // Like most strings in clangd, the input is UTF-8 encoded.
 size_t lspLength(llvm::StringRef Code) {
+  if (useUTF8ForLSP())
+return Code.size();
   // A codepoint takes two UTF-16 code unit if it's astral (outside BMP).
   // Astral codepoints are encoded as 4 bytes in UTF-8, starting with 0xxx.
   size_t Count = 0;
@@ -98,14 +110,25 @@
   llvm::errc::invalid_argument);
 StartOfLine = NextNL + 1;
   }
-
-  size_t NextNL = Code.find('\n', StartOfLine);
-  if (NextNL == llvm::StringRef::npos)
-NextNL = Code.size();
-
+  StringRef Line =
+  Code.substr(StartOfLine).take_until([](char C) { return C == '\n'; });
+
+  // If the encoding is UTF-8, we do bounds-checking only.
+  if (useUTF8ForLSP()) {
+if (P.character > int(Line.size())) {
+  if (AllowColumnsBeyondLineLength)
+return StartOfLine + Line

[PATCH] D53928: Enable builtins necessary for SLEEF [AArch64] vectorized trigonometry libm functions

2019-02-15 Thread Renato Golin via Phabricator via cfe-commits
rengolin accepted this revision.
rengolin added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM!


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53928/new/

https://reviews.llvm.org/D53928



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


[PATCH] D53633: [AArch64] Implement FP16FML intrinsics

2019-02-15 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: cfe/trunk/test/CodeGen/aarch64-neon-fp16fml.c:12
+
+float32x2_t test_vfmlal_low_u32(float32x2_t a, float16x4_t b, float16x4_t c) {
+// CHECK-LABEL: define <2 x float> @test_vfmlal_low_u32(<2 x float> %a, <4 x 
half> %b, <4 x half> %c)

ab wrote:
> Hey folks, I'm curious: where does the "_u32" suffix come from? Should it be 
> _f16?
> 
> Also, are there any new ACLE/intrinsic list documents? As far as I can tell 
> there hasn't been any release since IHI0073B/IHI0053D.
> Also, are there any new ACLE/intrinsic list documents? As far as I can tell 
> there hasn't been any release since IHI0073B/IHI0053D.

I've checked, and an updated ACLE that includes these FP16FML intrinsics is 
coming soon.

> where does the "_u32" suffix come from? Should it be _f16?

Good question. It could probably be _f32 or _f16, but _u32 doesn't seem to make 
much sense. Looks like the spec says _u32, and that's also what GCC has 
implemented. I think we want to update the spec and fix the name before the 
updated spec is available. Will chase this, and let you know once I know more.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53633/new/

https://reviews.llvm.org/D53633



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


[clang-tools-extra] r354116 - [clangd] Unlink VFS working dir from OS working dir. Reland of r351051

2019-02-15 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Fri Feb 15 03:04:25 2019
New Revision: 354116

URL: http://llvm.org/viewvc/llvm-project?rev=354116&view=rev
Log:
[clangd] Unlink VFS working dir from OS working dir. Reland of r351051

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

Modified: clang-tools-extra/trunk/clangd/FSProvider.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FSProvider.cpp?rev=354116&r1=354115&r2=354116&view=diff
==
--- clang-tools-extra/trunk/clangd/FSProvider.cpp (original)
+++ clang-tools-extra/trunk/clangd/FSProvider.cpp Fri Feb 15 03:04:25 2019
@@ -74,9 +74,10 @@ clang::clangd::RealFileSystemProvider::g
 // FIXME: Try to use a similar approach in Sema instead of relying on
 //propagation of the 'isVolatile' flag through all layers.
 #ifdef _WIN32
-  return new VolatileFileSystem(llvm::vfs::getRealFileSystem());
+  return new VolatileFileSystem(
+  llvm::vfs::createPhysicalFileSystem().release());
 #else
-  return llvm::vfs::getRealFileSystem();
+  return llvm::vfs::createPhysicalFileSystem().release();
 #endif
 }
 } // namespace clangd


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


[PATCH] D58179: [OpenCL][PR40707] Allow OpenCL C types in C++ mode

2019-02-15 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh accepted this revision.
svenvh added a comment.
This revision is now accepted and ready to land.

LGTM!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58179/new/

https://reviews.llvm.org/D58179



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


[PATCH] D58275: [clangd] Support utf-8 offsets (rather than utf-16) as a protocol extension

2019-02-15 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

The code looks good. For this protocol extension, we need supports from other 
LSP clients, I think we may want to propose this extension to the LSP 
specification, so that all LSP servers/clients respect it.




Comment at: clangd/Protocol.h:377
+
+  /// Supported encodings for LSP character offsets. (clangd extension).
+  llvm::Optional> offsetEncoding;

nit: also mention this is in preferred order.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58275/new/

https://reviews.llvm.org/D58275



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


[PATCH] D58277: [OpenCL] Change type of block pointer for OpenCL

2019-02-15 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin created this revision.
AlexeySotkin added reviewers: Anastasia, yaxunl, svenvh.
Herald added a project: clang.

For some reason OpenCL blocks in LLVM IR are represented as function pointers.
These pointers do not point to any real function and never get called. Actually
they point to some structure, which in turn contains pointer to the real block
invoke function.
This patch changes represntation of OpenCL blocks in LLVM IR from function
pointers to pointers to `%struct.__block_literal_generic`.
Such representation allows to avoid unnecessary bitcasts and simplifies
further processing (e.g. translation to SPIR-V ) of the module for targets
which do not support function pointers.


Repository:
  rC Clang

https://reviews.llvm.org/D58277

Files:
  lib/CodeGen/CodeGenTypes.cpp
  test/CodeGenOpenCL/blocks.cl
  test/CodeGenOpenCL/cl20-device-side-enqueue.cl

Index: test/CodeGenOpenCL/cl20-device-side-enqueue.cl
===
--- test/CodeGenOpenCL/cl20-device-side-enqueue.cl
+++ test/CodeGenOpenCL/cl20-device-side-enqueue.cl
@@ -11,7 +11,7 @@
 
 // For a block global variable, first emit the block literal as a global variable, then emit the block variable itself.
 // COMMON: [[BL_GLOBAL:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* [[INV_G:@[^ ]+]] to i8*) to i8 addrspace(4)*) }
-// COMMON: @block_G =  addrspace(1) constant void (i8 addrspace(3)*) addrspace(4)* addrspacecast (void (i8 addrspace(3)*) addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BL_GLOBAL]] to void (i8 addrspace(3)*) addrspace(1)*) to void (i8 addrspace(3)*) addrspace(4)*)
+// COMMON: @block_G = addrspace(1) constant %struct.__opencl_block_literal_generic addrspace(4)* addrspacecast (%struct.__opencl_block_literal_generic addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BL_GLOBAL]] to %struct.__opencl_block_literal_generic addrspace(1)*) to %struct.__opencl_block_literal_generic addrspace(4)*)
 
 // For anonymous blocks without captures, emit block literals as global variable.
 // COMMON: [[BLG1:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* {{@[^ ]+}} to i8*) to i8 addrspace(4)*) }
@@ -77,9 +77,9 @@
   // COMMON: [[DEF_Q:%[0-9]+]] = load %opencl.queue_t{{.*}}*, %opencl.queue_t{{.*}}** %default_queue
   // COMMON: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
   // COMMON: store i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*)* [[INVL1:@__device_side_enqueue_block_invoke[^ ]*]] to i8*) to i8 addrspace(4)*), i8 addrspace(4)** %block.invoke
-  // B32: [[BL:%[0-9]+]] = bitcast <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>* %block to void ()*
-  // B64: [[BL:%[0-9]+]] = bitcast <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32 addrspace(1)*, i32 }>* %block to void ()*
-  // COMMON: [[BL_I8:%[0-9]+]] = addrspacecast void ()* [[BL]] to i8 addrspace(4)*
+  // B32: [[BL:%[0-9]+]] = bitcast <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>* %block to %struct.__opencl_block_literal_generic*
+  // B64: [[BL:%[0-9]+]] = bitcast <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32 addrspace(1)*, i32 }>* %block to %struct.__opencl_block_literal_generic*
+  // COMMON: [[BL_I8:%[0-9]+]] = addrspacecast %struct.__opencl_block_literal_generic* [[BL]] to i8 addrspace(4)*
   // COMMON-LABEL: call i32 @__enqueue_kernel_basic(
   // COMMON-SAME: %opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* byval [[NDR]]{{([0-9]+)?}},
   // COMMON-SAME: i8 addrspace(4)* addrspacecast (i8* bitcast ({{.*}} [[INVLK1:[^ ]+_kernel]] to i8*) to i8 addrspace(4)*),
@@ -95,8 +95,8 @@
   // COMMON: [[WAIT_EVNT:%[0-9]+]] = addrspacecast %opencl.clk_event_t{{.*}}** %event_wait_list to %opencl.clk_event_t{{.*}}* addrspace(4)*
   // COMMON: [[EVNT:%[0-9]+]] = addrspacecast %opencl.clk_event_t{{.*}}** %clk_event to %opencl.clk_event_t{{.*}}* addrspace(4)*
   // COMMON: store i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*)* [[INVL2:@__device_side_enqueue_block_invoke[^ ]*]] to i8*) to i8 addrspace(4)*), i8 addrspace(4)** %block.invoke
-  // COMMON: [[BL:%[0-9]+]] = bitcast <{ i32, i32, i8 addrspace(4)*, i32{{.*}}, i32{{.*}}, i32{{.*}} }>* %block3 to void ()*
-  // COMMON: [[BL_I8:%[0-9]+]] = addrspacecast void ()* [[BL]] to i8 addrspace(4)*
+  // COMMON: [[BL:%[0-9]+]] = bitcast <{ i32, i32, i8 addrspace(4)*, i32{{.*}}, i32{{.*}}, i32{{.*}} }>* %block3 to %struct.__opencl_block_literal_generic*
+  // COMMON: [[BL_I8:%[0-9]+]] = addrspacecast %struct.__opencl_block_literal_generic* [[BL]] to i8 addrspace(4)*
   // COMMON-LABEL: call i32 @

r354120 - [ASTImporter] Import every Decl in lambda record

2019-02-15 Thread Gabor Marton via cfe-commits
Author: martong
Date: Fri Feb 15 04:04:05 2019
New Revision: 354120

URL: http://llvm.org/viewvc/llvm-project?rev=354120&view=rev
Log:
[ASTImporter] Import every Decl in lambda record

Summary:
Previously only the fields were imported. Now every Decl is imported.
This way the destructor decl is not missing after import.

Patch by balazske (Balázs Kéri)

Reviewers: a.sidorin, shafik

Reviewed By: shafik

Subscribers: balazske, cfe-commits, Szelethus, martong, dkrupp

Tags: #clang

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

Modified:
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=354120&r1=354119&r2=354120&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Fri Feb 15 04:04:05 2019
@@ -7393,13 +7393,9 @@ ExpectedStmt ASTNodeImporter::VisitLambd
   // NOTE: lambda classes are created with BeingDefined flag set up.
   // It means that ImportDefinition doesn't work for them and we should fill it
   // manually.
-  if (ToClass->isBeingDefined()) {
-for (auto FromField : FromClass->fields()) {
-  auto ToFieldOrErr = import(FromField);
-  if (!ToFieldOrErr)
-return ToFieldOrErr.takeError();
-}
-  }
+  if (ToClass->isBeingDefined())
+if (Error Err = ImportDeclContext(FromClass, /*ForceImport = */ true))
+  return std::move(Err);
 
   auto ToCallOpOrErr = import(E->getCallOperator());
   if (!ToCallOpOrErr)

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=354120&r1=354119&r2=354120&view=diff
==
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Fri Feb 15 04:04:05 2019
@@ -2709,6 +2709,26 @@ TEST_P(ImportFunctions, ImportFunctionFr
 2u);
 }
 
+TEST_P(ImportFunctions, ImportImplicitFunctionsInLambda) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  void foo() {
+(void)[]() { ; };
+  }
+  )",
+  Lang_CXX11);
+  auto *FromD = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("foo")));
+  auto *ToD = Import(FromD, Lang_CXX);
+  EXPECT_TRUE(ToD);
+  CXXRecordDecl *LambdaRec =
+  cast(cast(
+   *cast(ToD->getBody())->body_begin())
+   ->getSubExpr())
+  ->getLambdaClass();
+  EXPECT_TRUE(LambdaRec->getDestructor());
+}
+
 struct ImportFriendFunctions : ImportFunctions {};
 
 TEST_P(ImportFriendFunctions, ImportFriendFunctionRedeclChainProto) {


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


[PATCH] D57740: [ASTImporter] Import every Decl in lambda record

2019-02-15 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354120: [ASTImporter] Import every Decl in lambda record 
(authored by martong, committed by ).
Herald added subscribers: llvm-commits, jdoerfert.
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D57740?vs=185509&id=186991#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57740/new/

https://reviews.llvm.org/D57740

Files:
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/unittests/AST/ASTImporterTest.cpp


Index: cfe/trunk/lib/AST/ASTImporter.cpp
===
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -7393,13 +7393,9 @@
   // NOTE: lambda classes are created with BeingDefined flag set up.
   // It means that ImportDefinition doesn't work for them and we should fill it
   // manually.
-  if (ToClass->isBeingDefined()) {
-for (auto FromField : FromClass->fields()) {
-  auto ToFieldOrErr = import(FromField);
-  if (!ToFieldOrErr)
-return ToFieldOrErr.takeError();
-}
-  }
+  if (ToClass->isBeingDefined())
+if (Error Err = ImportDeclContext(FromClass, /*ForceImport = */ true))
+  return std::move(Err);
 
   auto ToCallOpOrErr = import(E->getCallOperator());
   if (!ToCallOpOrErr)
Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp
===
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp
@@ -2709,6 +2709,26 @@
 2u);
 }
 
+TEST_P(ImportFunctions, ImportImplicitFunctionsInLambda) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  void foo() {
+(void)[]() { ; };
+  }
+  )",
+  Lang_CXX11);
+  auto *FromD = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("foo")));
+  auto *ToD = Import(FromD, Lang_CXX);
+  EXPECT_TRUE(ToD);
+  CXXRecordDecl *LambdaRec =
+  cast(cast(
+   *cast(ToD->getBody())->body_begin())
+   ->getSubExpr())
+  ->getLambdaClass();
+  EXPECT_TRUE(LambdaRec->getDestructor());
+}
+
 struct ImportFriendFunctions : ImportFunctions {};
 
 TEST_P(ImportFriendFunctions, ImportFriendFunctionRedeclChainProto) {


Index: cfe/trunk/lib/AST/ASTImporter.cpp
===
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -7393,13 +7393,9 @@
   // NOTE: lambda classes are created with BeingDefined flag set up.
   // It means that ImportDefinition doesn't work for them and we should fill it
   // manually.
-  if (ToClass->isBeingDefined()) {
-for (auto FromField : FromClass->fields()) {
-  auto ToFieldOrErr = import(FromField);
-  if (!ToFieldOrErr)
-return ToFieldOrErr.takeError();
-}
-  }
+  if (ToClass->isBeingDefined())
+if (Error Err = ImportDeclContext(FromClass, /*ForceImport = */ true))
+  return std::move(Err);
 
   auto ToCallOpOrErr = import(E->getCallOperator());
   if (!ToCallOpOrErr)
Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp
===
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp
@@ -2709,6 +2709,26 @@
 2u);
 }
 
+TEST_P(ImportFunctions, ImportImplicitFunctionsInLambda) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  void foo() {
+(void)[]() { ; };
+  }
+  )",
+  Lang_CXX11);
+  auto *FromD = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("foo")));
+  auto *ToD = Import(FromD, Lang_CXX);
+  EXPECT_TRUE(ToD);
+  CXXRecordDecl *LambdaRec =
+  cast(cast(
+   *cast(ToD->getBody())->body_begin())
+   ->getSubExpr())
+  ->getLambdaClass();
+  EXPECT_TRUE(LambdaRec->getDestructor());
+}
+
 struct ImportFriendFunctions : ImportFunctions {};
 
 TEST_P(ImportFriendFunctions, ImportFriendFunctionRedeclChainProto) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58278: Prepare ground for re-lexing modular headers.

2019-02-15 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh created this revision.
alexfh added reviewers: bkramer, klimek, rsmith.
Herald added subscribers: jdoerfert, jsji, kbarton, nemanjai.
Herald added a project: clang.

When a clang tool runs on a translation unit that uses modular headers, no
PPCallbacks will be invoked for the code in the modular headers (since they are
not parsed, but loaded as AST). Since some tools depend on PPCallbacks for all
transitively included headers, a solution is to re-lex the modular headers
from the sources stored along with AST inside module files. This patch makes it
possible to re-attach PPCallbacks from the compiler's Preprocessor to a custom
one that will be used to re-lex all transitively included headers. It also
updates clang-tidy checks to be compatible with this mode of operation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58278

Files:
  clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.cpp
  clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/readability/RedundantPreprocessorCheck.cpp
  clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp
  clang/include/clang/Lex/PPCallbacks.h
  clang/include/clang/Lex/Preprocessor.h

Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -908,11 +908,19 @@
   /// it.
   PPCallbacks *getPPCallbacks() const { return Callbacks.get(); }
   void addPPCallbacks(std::unique_ptr C) {
+assert(C && "Callback cannot be null.");
 if (Callbacks)
   C = llvm::make_unique(std::move(C),
 std::move(Callbacks));
+C->setPreprocessor(this);
 Callbacks = std::move(C);
   }
+
+  std::unique_ptr takePPCallbacks() {
+if (Callbacks)
+  Callbacks->setPreprocessor(nullptr);
+return std::move(Callbacks);
+  }
   /// \}
 
   bool isMacroDefined(StringRef Id) {
Index: clang/include/clang/Lex/PPCallbacks.h
===
--- clang/include/clang/Lex/PPCallbacks.h
+++ clang/include/clang/Lex/PPCallbacks.h
@@ -27,6 +27,7 @@
   class MacroDefinition;
   class MacroDirective;
   class MacroArgs;
+  class Preprocessor;
 
 /// This interface provides a way to observe the actions of the
 /// preprocessor as it does its thing.
@@ -341,6 +342,16 @@
   /// \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive.
   virtual void Endif(SourceLocation Loc, SourceLocation IfLoc) {
   }
+
+  virtual void setPreprocessor(Preprocessor *preprocessor) {
+preprocessor_ = preprocessor;
+  }
+
+protected:
+  Preprocessor *getPreprocessor() const { return preprocessor_; }
+
+private:
+  Preprocessor *preprocessor_;
 };
 
 /// Simple wrapper class for chaining callbacks.
@@ -556,6 +567,12 @@
 First->Endif(Loc, IfLoc);
 Second->Endif(Loc, IfLoc);
   }
+
+  void setPreprocessor(Preprocessor *preprocessor) override {
+PPCallbacks::setPreprocessor(preprocessor);
+First->setPreprocessor(preprocessor);
+Second->setPreprocessor(preprocessor);
+  }
 };
 
 }  // end namespace clang
Index: clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp
===
--- clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp
+++ clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp
@@ -27,15 +27,14 @@
 namespace {
 class HeaderGuardPPCallbacks : public PPCallbacks {
 public:
-  HeaderGuardPPCallbacks(Preprocessor *PP, HeaderGuardCheck *Check)
-  : PP(PP), Check(Check) {}
+  HeaderGuardPPCallbacks(HeaderGuardCheck *Check) : Check(Check) {}
 
   void FileChanged(SourceLocation Loc, FileChangeReason Reason,
SrcMgr::CharacteristicKind FileType,
FileID PrevFID) override {
 // Record all files we enter. We'll need them to diagnose headers without
 // guards.
-SourceManager &SM = PP->getSourceManager();
+SourceManager &SM = getPreprocessor()->getSourceManager();
 if (Reason == EnterFile && FileType == SrcMgr::C_User) {
   if (const FileEntry *FE = SM.getFileEntryForID(SM.getFileID(Loc))) {
 std::string FileName = cleanPath(FE->getName());
@@ -68,7 +67,7 @@
 
   void EndOfMainFile() override {
 // Now that we have all this information from the preprocessor, use it!
-SourceManager &SM = PP->getSourceManager();
+SourceManager &SM = getPreprocessor()->getSourceManager();
 
 for (const auto &MacroEntry : Macros) {
   const MacroInfo *MI = MacroEntry.second;
@@ -136,7 +135,8 @@
 size_t *EndIfLenPtr = nullptr) {
 if (!EndIf.isValid())
   return false;
-const char *EndIfData = PP->getSourceManager().getCharacterData(EndIf);
+const char *EndI

r354121 - [OpenCL][PR40707] Allow OpenCL C types in C++ mode.

2019-02-15 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Fri Feb 15 04:07:57 2019
New Revision: 354121

URL: http://llvm.org/viewvc/llvm-project?rev=354121&view=rev
Log:
[OpenCL][PR40707] Allow OpenCL C types in C++ mode.

Allow all OpenCL types to be parsed in C++ mode.


Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Parse/ParseTentative.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/CodeGenOpenCL/images.cl
cfe/trunk/test/SemaOpenCL/invalid-image.cl
cfe/trunk/test/SemaOpenCLCXX/restricted.cl

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=354121&r1=354120&r2=354121&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri Feb 15 04:07:57 
2019
@@ -1133,8 +1133,6 @@ def err_opencl_logical_exclusive_or : Er
 // OpenCL C++.
 def err_openclcxx_virtual_function : Error<
   "virtual functions are not supported in OpenCL C++">;
-def err_openclcxx_reserved : Error<
-  "'%0' is a reserved keyword in OpenCL C++">;
 
 // OpenMP support.
 def warn_pragma_omp_ignored : Warning<

Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=354121&r1=354120&r2=354121&view=diff
==
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Fri Feb 15 04:07:57 2019
@@ -550,9 +550,9 @@ ALIAS("read_only", __read_only  , KE
 ALIAS("write_only", __write_only, KEYOPENCLC | KEYOPENCLCXX)
 ALIAS("read_write", __read_write, KEYOPENCLC | KEYOPENCLCXX)
 // OpenCL builtins
-KEYWORD(__builtin_astype, KEYOPENCLC)
+KEYWORD(__builtin_astype, KEYOPENCLC | KEYOPENCLCXX)
 KEYWORD(vec_step, KEYOPENCLC | KEYALTIVEC | KEYZVECTOR)
-#define GENERIC_IMAGE_TYPE(ImgType, Id) KEYWORD(ImgType##_t, KEYOPENCLC)
+#define GENERIC_IMAGE_TYPE(ImgType, Id) KEYWORD(ImgType##_t, KEYOPENCLC | 
KEYOPENCLCXX)
 #include "clang/Basic/OpenCLImageTypes.def"
 
 // OpenMP Type Traits

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=354121&r1=354120&r2=354121&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Fri Feb 15 04:07:57 2019
@@ -3809,19 +3809,6 @@ void Parser::ParseDeclarationSpecifiers(
  getLangOpts());
   break;
 
-// OpenCL access qualifiers:
-case tok::kw___read_only:
-case tok::kw___write_only:
-case tok::kw___read_write:
-  // OpenCL C++ 1.0 s2.2: access qualifiers are reserved keywords.
-  if (Actions.getLangOpts().OpenCLCPlusPlus) {
-DiagID = diag::err_openclcxx_reserved;
-PrevSpec = Tok.getIdentifierInfo()->getNameStart();
-isInvalid = true;
-  }
-  ParseOpenCLQualifiers(DS.getAttributes());
-  break;
-
 // OpenCL address space qualifiers:
 case tok::kw___generic:
   // generic address space is introduced only in OpenCL v2.0
@@ -3838,6 +3825,10 @@ void Parser::ParseDeclarationSpecifiers(
 case tok::kw___global:
 case tok::kw___local:
 case tok::kw___constant:
+// OpenCL access qualifiers:
+case tok::kw___read_only:
+case tok::kw___write_only:
+case tok::kw___read_write:
   ParseOpenCLQualifiers(DS.getAttributes());
   break;
 

Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=354121&r1=354120&r2=354121&view=diff
==
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Fri Feb 15 04:07:57 2019
@@ -1998,6 +1998,13 @@ void Parser::ParseCXXSimpleTypeSpecifier
   case tok::kw_bool:
 DS.SetTypeSpecType(DeclSpec::TST_bool, Loc, PrevSpec, DiagID, Policy);
 break;
+#define GENERIC_IMAGE_TYPE(ImgType, Id)
\
+  case tok::kw_##ImgType##_t:  
\
+DS.SetTypeSpecType(DeclSpec::TST_##ImgType##_t, Loc, PrevSpec, DiagID, 
\
+   Policy);
\
+break;
+#include "clang/Basic/OpenCLImageTypes.def"
+
   case tok::annot_decltype:
   case tok::kw_decltype:
 DS.SetRangeEnd(ParseDecltypeSpecifier(DS));

Modified: cfe/trunk/lib/Parse/ParseTentative.cpp
URL: 
http://llvm.org/viewvc/llvm

[PATCH] D57956: [www] Add ASTImporter fuzzer project.

2019-02-15 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor closed this revision.
teemperor added a comment.

landed in llvm-svn: 354043


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57956/new/

https://reviews.llvm.org/D57956



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


r354127 - [Analyzer] Fix for test file of bug 40625

2019-02-15 Thread Adam Balogh via cfe-commits
Author: baloghadamsoftware
Date: Fri Feb 15 04:33:42 2019
New Revision: 354127

URL: http://llvm.org/viewvc/llvm-project?rev=354127&view=rev
Log:
[Analyzer] Fix for test file of bug 40625

Test fixed and changed to true positive, FIXME about false positive removed.


Modified:
cfe/trunk/test/Analysis/PR40625.cpp

Modified: cfe/trunk/test/Analysis/PR40625.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/PR40625.cpp?rev=354127&r1=354126&r2=354127&view=diff
==
--- cfe/trunk/test/Analysis/PR40625.cpp (original)
+++ cfe/trunk/test/Analysis/PR40625.cpp Fri Feb 15 04:33:42 2019
@@ -3,10 +3,7 @@
 void f(const int *end);
 
 void g(const int (&arrr)[10]) {
-  f(arrr+sizeof(arrr)); // expected-warning{{1st function call argument is a 
pointer to uninitialized value}}
-  // FIXME: This is a false positive that should be fixed. Until then this
-  //tests the crash fix in FindLastStoreBRVisitor (beside
-  //uninit-vals.m).
+  f(arrr); // expected-warning{{1st function call argument is a pointer to 
uninitialized value}}
 }
 
 void h() {


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


[PATCH] D23610: [ARM] Add pre-defined macros for ROPI and RWPI

2019-02-15 Thread Kumail Ahmed via Phabricator via cfe-commits
kahmed added a comment.
Herald added subscribers: llvm-commits, jdoerfert, kristof.beyls, javed.absar.
Herald added a project: LLVM.

Ping


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D23610/new/

https://reviews.llvm.org/D23610



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


[PATCH] D58189: [clang][Index] Fix usage of IndexImplicitInstantiation

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

LGTM


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58189/new/

https://reviews.llvm.org/D58189



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


[PATCH] D58189: [clang][Index] Fix usage of IndexImplicitInstantiation

2019-02-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 186995.
kadircet marked 6 inline comments as done.
kadircet added a comment.

Address comments


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58189/new/

https://reviews.llvm.org/D58189

Files:
  lib/Index/IndexTypeSourceInfo.cpp
  test/Index/Core/index-source.cpp
  test/Index/index-refs.cpp
  unittests/Index/IndexTests.cpp

Index: unittests/Index/IndexTests.cpp
===
--- unittests/Index/IndexTests.cpp
+++ unittests/Index/IndexTests.cpp
@@ -7,7 +7,10 @@
 //===--===//
 
 #include "clang/AST/ASTConsumer.h"
+#include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Index/IndexDataConsumer.h"
@@ -23,27 +26,62 @@
 
 namespace clang {
 namespace index {
+namespace {
+struct Position {
+  size_t Line = 0;
+  size_t Column = 0;
+
+  Position(size_t Line = 0, size_t Column = 0) : Line(Line), Column(Column) {}
+
+  static Position fromSourceLocation(SourceLocation Loc,
+ const SourceManager &SM) {
+FileID FID;
+unsigned Offset;
+std::tie(FID, Offset) = SM.getDecomposedSpellingLoc(Loc);
+Position P;
+P.Line = SM.getLineNumber(FID, Offset);
+P.Column = SM.getColumnNumber(FID, Offset);
+return P;
+  }
+};
+
+bool operator==(const Position &LHS, const Position &RHS) {
+  return std::tie(LHS.Line, LHS.Column) == std::tie(RHS.Line, RHS.Column);
+}
+
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Position &Pos) {
+  return OS << Pos.Line << ':' << Pos.Column;
+}
 
 struct TestSymbol {
   std::string QName;
+  Position WrittenPos;
+  Position DeclPos;
   // FIXME: add more information.
 };
 
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const TestSymbol &S) {
-  return OS << S.QName;
+  return OS << S.QName << '[' << S.WrittenPos << ']' << '@' << S.DeclPos;
 }
 
-namespace {
 class Indexer : public IndexDataConsumer {
 public:
+  void initialize(ASTContext &Ctx) override {
+AST = &Ctx;
+IndexDataConsumer::initialize(Ctx);
+  }
+
   bool handleDeclOccurence(const Decl *D, SymbolRoleSet Roles,
-   ArrayRef, SourceLocation,
+   ArrayRef, SourceLocation Loc,
ASTNodeInfo) override {
 const auto *ND = llvm::dyn_cast(D);
 if (!ND)
   return true;
 TestSymbol S;
 S.QName = ND->getQualifiedNameAsString();
+S.WrittenPos = Position::fromSourceLocation(Loc, AST->getSourceManager());
+S.DeclPos =
+Position::fromSourceLocation(D->getLocation(), AST->getSourceManager());
 Symbols.push_back(std::move(S));
 return true;
   }
@@ -57,6 +95,7 @@
   }
 
   std::vector Symbols;
+  const ASTContext *AST = nullptr;
 };
 
 class IndexAction : public ASTFrontendAction {
@@ -93,11 +132,14 @@
   IndexingOptions Opts;
 };
 
+using testing::AllOf;
 using testing::Contains;
 using testing::Not;
 using testing::UnorderedElementsAre;
 
 MATCHER_P(QName, Name, "") { return arg.QName == Name; }
+MATCHER_P(WrittenAt, Pos, "") { return arg.WrittenPos == Pos; }
+MATCHER_P(DeclAt, Pos, "") { return arg.DeclPos == Pos; }
 
 TEST(IndexTest, Simple) {
   auto Index = std::make_shared();
@@ -134,6 +176,55 @@
   EXPECT_THAT(Index->Symbols, Not(Contains(QName("bar";
 }
 
+TEST(IndexTest, IndexExplicitTemplateInstantiation) {
+  std::string Code = R"cpp(
+template 
+struct Foo { void bar() {} };
+template <>
+struct Foo { void bar() {} };
+void foo() {
+  Foo abc;
+  Foo b;
+}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  tooling::runToolOnCode(new IndexAction(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols,
+  AllOf(Contains(AllOf(QName("Foo"), WrittenAt(Position(8, 7)),
+   DeclAt(Position(5, 12,
+Contains(AllOf(QName("Foo"), WrittenAt(Position(7, 7)),
+   DeclAt(Position(3, 12));
+
+  Index->Symbols.clear();
+  Opts.IndexImplicitInstantiation = true;
+  tooling::runToolOnCode(new IndexAction(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols,
+  AllOf(Contains(AllOf(QName("Foo"), WrittenAt(Position(8, 7)),
+   DeclAt(Position(5, 12,
+Contains(AllOf(QName("Foo"), WrittenAt(Position(7, 7)),
+   DeclAt(Position(3, 12));
+}
+
+TEST(IndexTest, IndexTemplateInstantiationPartial) {
+  std::string Code = R"cpp(
+template 
+struct Foo { void bar() {} };
+template 
+struct Foo { void bar() {} };
+void foo() {
+  Foo abc;
+  Foo b;
+}
+  )cpp";
+  auto Index = std::make_shared();

[PATCH] D58275: [clangd] Support utf-8 offsets (rather than utf-16) as a protocol extension

2019-02-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D58275#1399195 , @hokein wrote:

> The code looks good. For this protocol extension, we need supports from other 
> LSP clients, I think we may want to propose this extension to the LSP 
> specification, so that all LSP servers/clients respect it.


My reading of https://github.com/Microsoft/language-server-protocol/issues/376 
is that they may only accept a proposal that comes with patches to Microsoft's 
implementations.
I'm not likely to work on that soon (it doesn't directly get us closer to 
interop goals) so my preferred path is implement and document the extension, 
get some support from other language clients/servers, and then push again for 
standardization.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58275/new/

https://reviews.llvm.org/D58275



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


[PATCH] D58189: [clang][Index] Fix usage of IndexImplicitInstantiation

2019-02-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: unittests/Index/IndexTests.cpp:40
+Position P;
+P.Line = static_cast(SM.getLineNumber(FID, Offset)) - 1;
+P.Column = SM.getColumnNumber(FID, Offset) - 1;

ilya-biryukov wrote:
> Why do we need to `static_cast` to int? Can we leave out the cast?
it was left over of a copy paste, we don't even need subtraction.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58189/new/

https://reviews.llvm.org/D58189



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


[PATCH] D57087: [clang-tidy] add OverrideMacro to modernize-use-override check

2019-02-15 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added inline comments.
This revision now requires changes to proceed.
Herald added a subscriber: jdoerfert.



Comment at: clang-tidy/modernize/UseOverrideCheck.cpp:32
+: ClangTidyCheck(Name, Context),
+  OverrideMacro(Options.get("OverrideMacro", "override")),
+  FinalMacro(Options.get("FinalMacro", "final")) {}

MyDeveloperDay wrote:
> alexfh wrote:
> > I'd suggest to default to an empty string and use `override` as a fallback 
> > right in the code where the diagnostic is generated.
> So I tried this and and met with some issues with the unit tests where it 
> seemed to think "override" was a macro, I also found myself just simply 
> always setting OverrideMacro/Final Macro to "override" and "final" anyway.. 
> I've changed this round a little to only check for the macro when the 
> OverrideMacro isn't override. This seems to resolve the problem, let me know 
> if it still feels wrong.
In case "override" is not a macro, setting `OverrideMacro` to `override` would 
be somewhat confusing. We could make set default to `override`, if this makes 
logic simpler, but then I'd suggest to rename the option to `OverrideSpelling` 
(same for `final`).



Comment at: docs/clang-tidy/checks/modernize-use-override.rst:9
 
-Use C++11's ``override`` and remove ``virtual`` where applicable.
+virtual on non base class implementations was used to help indiciate to the 
user
+that a function was virtual. C++ compilers did not use the presence of this to

Please enclose "virtual" in double backquotes.



Comment at: docs/clang-tidy/checks/modernize-use-override.rst:13
+
+In C++ 11 ``override`` and ``final`` were introduced to allow overridden
+functions to be marked appropriately. There presence allows compilers to verify

`override` and `final` keywords were introduced ...



Comment at: docs/clang-tidy/checks/modernize-use-override.rst:14
+In C++ 11 ``override`` and ``final`` were introduced to allow overridden
+functions to be marked appropriately. There presence allows compilers to verify
+that an overridden function correctly overrides a base class implementation.

s/There/Their/



Comment at: docs/clang-tidy/checks/modernize-use-override.rst:39
+
+   For more information on the use of override see 
https://en.cppreference.com/w/cpp/language/override

Enclose `override` in double backquotes.



Comment at: test/clang-tidy/modernize-use-override-with-macro.cpp:2
+// RUN: %check_clang_tidy %s modernize-use-override %t -- \
+// RUN:   -config="{CheckOptions: [{key: 
modernize-use-nodiscard.OverrideMacro, value: 'OVERRIDE'},{key: 
modernize-use-nodiscard.FinalMacro, value: 'FINAL'}]}" \
+// RUN: -- -std=c++11

"modernize-use-nodiscard"? Does this test pass?



Comment at: test/clang-tidy/modernize-use-override-with-no-macro-inscope.cpp:2
+// RUN: %check_clang_tidy %s modernize-use-override %t -- \
+// RUN:   -config="{CheckOptions: [{key: 
modernize-use-nodiscard.OverrideMacro, value: 'CUSTOM_OVERRIDE'},{key: 
modernize-use-nodiscard.FinalMacro, value: 'FINAL'}]}" \
+// RUN: -- -std=c++11

Same here.



Comment at: test/clang-tidy/modernize-use-override-with-no-macro-inscope.cpp:16
+public:
+  virtual ~SimpleCases();
+  // CHECK-FIXES: {{^}}  virtual ~SimpleCases();

The check should still issue a warning here, imo. Maybe without a fix, but it 
should draw attention to the issue.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57087/new/

https://reviews.llvm.org/D57087



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


Re: r354074 - [Sema] Fix-up a -Wfloat-conversion diagnostic

2019-02-15 Thread Hans Wennborg via cfe-commits
Merged in r354129. Please let me know if there are any follow-ups.

Thanks,
Hans

On Fri, Feb 15, 2019 at 12:16 AM Erik Pilkington
 wrote:
>
> Hans, can you merge this diagnostic regression fix into LLVM 8?
>
> Thanks!
>
> > On Feb 14, 2019, at 2:48 PM, Erik Pilkington via cfe-commits 
> >  wrote:
> >
> > Author: epilk
> > Date: Thu Feb 14 14:48:01 2019
> > New Revision: 354074
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=354074&view=rev
> > Log:
> > [Sema] Fix-up a -Wfloat-conversion diagnostic
> >
> > We were warning on valid ObjC property reference exprs, and passing
> > in the wrong arguments to DiagnoseFloatingImpCast (leading to a badly
> > worded diagnostic).
> >
> > rdar://47644670
> >
> > Differential revision: https://reviews.llvm.org/D58145
> >
> > Modified:
> >cfe/trunk/lib/Sema/SemaChecking.cpp
> >cfe/trunk/test/SemaCXX/warn-float-conversion.cpp
> >cfe/trunk/test/SemaObjC/conversion.m
> >
> > Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
> > URL: 
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=354074&r1=354073&r2=354074&view=diff
> > ==
> > --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
> > +++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Feb 14 14:48:01 2019
> > @@ -10624,16 +10624,16 @@ static void AnalyzeCompoundAssignment(Se
> >   // The below checks assume source is floating point.
> >   if (!ResultBT || !RBT || !RBT->isFloatingPoint()) return;
> >
> > -  // If source is floating point but target is not.
> > -  if (!ResultBT->isFloatingPoint())
> > -return DiagnoseFloatingImpCast(S, E, E->getRHS()->getType(),
> > -   E->getExprLoc());
> > -
> > -  // If both source and target are floating points.
> > -  // Builtin FP kinds are ordered by increasing FP rank.
> > -  if (ResultBT->getKind() < RBT->getKind() &&
> > -  // We don't want to warn for system macro.
> > -  !S.SourceMgr.isInSystemMacro(E->getOperatorLoc()))
> > +  // If source is floating point but target is an integer.
> > +  if (ResultBT->isInteger())
> > +DiagnoseImpCast(S, E, E->getRHS()->getType(), E->getLHS()->getType(),
> > +E->getExprLoc(), diag::warn_impcast_float_integer);
> > +  // If both source and target are floating points. Builtin FP kinds are 
> > ordered
> > +  // by increasing FP rank. FIXME: except _Float16, we currently emit a 
> > bogus
> > +  // warning.
> > +  else if (ResultBT->isFloatingPoint() && ResultBT->getKind() < 
> > RBT->getKind() &&
> > +   // We don't want to warn for system macro.
> > +   !S.SourceMgr.isInSystemMacro(E->getOperatorLoc()))
> > // warn about dropping FP rank.
> > DiagnoseImpCast(S, E->getRHS(), E->getLHS()->getType(), 
> > E->getOperatorLoc(),
> > diag::warn_impcast_float_result_precision);
> >
> > Modified: cfe/trunk/test/SemaCXX/warn-float-conversion.cpp
> > URL: 
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-float-conversion.cpp?rev=354074&r1=354073&r2=354074&view=diff
> > ==
> > --- cfe/trunk/test/SemaCXX/warn-float-conversion.cpp (original)
> > +++ cfe/trunk/test/SemaCXX/warn-float-conversion.cpp Thu Feb 14 14:48:01 
> > 2019
> > @@ -44,17 +44,17 @@ void Convert(float f, double d, long dou
> > void CompoundAssignment() {
> >   int x = 3;
> >
> > -  x += 1.234;  //expected-warning{{conversion}}
> > -  x -= -0.0;  //expected-warning{{conversion}}
> > -  x *= 1.1f;  //expected-warning{{conversion}}
> > -  x /= -2.2f;  //expected-warning{{conversion}}
> > +  x += 1.234; // expected-warning {{implicit conversion turns 
> > floating-point number into integer: 'double' to 'int'}}
> > +  x -= -0.0;  // expected-warning {{implicit conversion turns 
> > floating-point number into integer: 'double' to 'int'}}
> > +  x *= 1.1f;  // expected-warning {{implicit conversion turns 
> > floating-point number into integer: 'float' to 'int'}}
> > +  x /= -2.2f; // expected-warning {{implicit conversion turns 
> > floating-point number into integer: 'float' to 'int'}}
> >
> > -  int y = x += 1.4f;  //expected-warning{{conversion}}
> > +  int y = x += 1.4f; // expected-warning {{implicit conversion turns 
> > floating-point number into integer: 'float' to 'int'}}
> >
> >   float z = 1.1f;
> >   double w = -2.2;
> >
> > -  y += z + w;  //expected-warning{{conversion}}
> > +  y += z + w; // expected-warning {{implicit conversion turns 
> > floating-point number into integer: 'double' to 'int'}}
> > }
> >
> > # 1 "foo.h" 3
> >
> > Modified: cfe/trunk/test/SemaObjC/conversion.m
> > URL: 
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/conversion.m?rev=354074&r1=354073&r2=354074&view=diff
> > ==
> > --- cfe/trunk/test/SemaObjC/conversion.m (original)
> > +++ cfe/trunk/test/SemaObjC

Re: r353943 - [Analyzer] Crash fix for FindLastStoreBRVisitor

2019-02-15 Thread Hans Wennborg via cfe-commits
Merged to release_80 in r354130. Please let me know if there are any follow-ups.

On Wed, Feb 13, 2019 at 1:25 PM Adam Balogh via cfe-commits
 wrote:
>
> Author: baloghadamsoftware
> Date: Wed Feb 13 04:25:47 2019
> New Revision: 353943
>
> URL: http://llvm.org/viewvc/llvm-project?rev=353943&view=rev
> Log:
> [Analyzer] Crash fix for FindLastStoreBRVisitor
>
> FindLastStoreBRVisitor tries to find the first node in the exploded graph 
> where
> the current value was assigned to a region. This node is called the "store
> site". It is identified by a pair of Pred and Succ nodes where Succ already 
> has
> the binding for the value while Pred does not have it. However the visitor
> mistakenly identifies a node pair as the store site where the value is a
> `LazyCompoundVal` and `Pred` does not have a store yet but `Succ` has it. In
> this case the `LazyCompoundVal` is different in the `Pred` node because it 
> also
> contains the store which is different in the two nodes. This error may lead to
> crashes (a declaration is cast to a parameter declaration without check) or
> misleading bug path notes.
>
> In this patch we fix this problem by checking for unequal `LazyCompoundVals`: 
> if
> their region is equal, and their store is the same as the store of their nodes
> we consider them as equal when looking for the "store site". This is an
> approximation because we do not check for differences of the subvalues
> (structure members or array elements) in the stores.
>
> Differential Revision: https://reviews.llvm.org/D58067
>
>
> Added:
> cfe/trunk/test/Analysis/PR40625.cpp
> Modified:
> cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
> cfe/trunk/test/Analysis/uninit-vals.m
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=353943&r1=353942&r2=353943&view=diff
> ==
> --- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Wed Feb 13 
> 04:25:47 2019
> @@ -153,6 +153,32 @@ const Expr *bugreporter::getDerefExpr(co
>return E;
>  }
>
> +/// Comparing internal representations of symbolic values (via
> +/// SVal::operator==()) is a valid way to check if the value was updated,
> +/// unless it's a LazyCompoundVal that may have a different internal
> +/// representation every time it is loaded from the state. In this function 
> we
> +/// do an approximate comparison for lazy compound values, checking that they
> +/// are the immediate snapshots of the tracked region's bindings within the
> +/// node's respective states but not really checking that these snapshots
> +/// actually contain the same set of bindings.
> +bool hasVisibleUpdate(const ExplodedNode *LeftNode, SVal LeftVal,
> +  const ExplodedNode *RightNode, SVal RightVal) {
> +  if (LeftVal == RightVal)
> +return true;
> +
> +  const auto LLCV = LeftVal.getAs();
> +  if (!LLCV)
> +return false;
> +
> +  const auto RLCV = RightVal.getAs();
> +  if (!RLCV)
> +return false;
> +
> +  return LLCV->getRegion() == RLCV->getRegion() &&
> +LLCV->getStore() == LeftNode->getState()->getStore() &&
> +RLCV->getStore() == RightNode->getState()->getStore();
> +}
> +
>  
> //===--===//
>  // Definitions for bug reporter visitors.
>  
> //===--===//
> @@ -1177,7 +1203,7 @@ FindLastStoreBRVisitor::VisitNode(const
>  if (Succ->getState()->getSVal(R) != V)
>return nullptr;
>
> -if (Pred->getState()->getSVal(R) == V) {
> +if (hasVisibleUpdate(Pred, Pred->getState()->getSVal(R), Succ, V)) {
>Optional PS = Succ->getLocationAs();
>if (!PS || PS->getLocationValue() != R)
>  return nullptr;
> @@ -1198,6 +1224,7 @@ FindLastStoreBRVisitor::VisitNode(const
>  // UndefinedVal.)
>  if (Optional CE = Succ->getLocationAs()) {
>if (const auto *VR = dyn_cast(R)) {
> +
>  const auto *Param = cast(VR->getDecl());
>
>  ProgramStateManager &StateMgr = BRC.getStateManager();
>
> Added: cfe/trunk/test/Analysis/PR40625.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/PR40625.cpp?rev=353943&view=auto
> ==
> --- cfe/trunk/test/Analysis/PR40625.cpp (added)
> +++ cfe/trunk/test/Analysis/PR40625.cpp Wed Feb 13 04:25:47 2019
> @@ -0,0 +1,16 @@
> +// RUN: %clang_analyze_cc1 -std=c++11 
> -analyzer-checker=core,alpha.core.CallAndMessageUnInitRefArg  %s -verify
> +
> +void f(const int *end);
> +
> +void g(const int (&arrr)[10]) {
> +  f(arrr+sizeof(arrr)); // expected-warning{{1st function call argument is a 
> pointer to uninitialized value}}
> +  // FIXME: Th

[PATCH] D58275: [clangd] Support utf-8 offsets (rather than utf-16) as a protocol extension

2019-02-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 187002.
sammccall added a comment.

Add tests, command-line flag, and misc cleanups.
No flag for clangd-indexer yet. It's surprisingly hard with the executor API :-(


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58275/new/

https://reviews.llvm.org/D58275

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  clangd/index/IndexAction.cpp
  clangd/tool/ClangdMain.cpp
  test/clangd/utf8.test
  unittests/clangd/SourceCodeTests.cpp

Index: unittests/clangd/SourceCodeTests.cpp
===
--- unittests/clangd/SourceCodeTests.cpp
+++ unittests/clangd/SourceCodeTests.cpp
@@ -6,6 +6,8 @@
 //
 //===--===//
 #include "Annotations.h"
+#include "Context.h"
+#include "Protocol.h"
 #include "SourceCode.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/raw_os_ostream.h"
@@ -21,14 +23,9 @@
 using llvm::HasValue;
 
 MATCHER_P2(Pos, Line, Col, "") {
-  return arg.line == Line && arg.character == Col;
+  return arg.line == int(Line) && arg.character == int(Col);
 }
 
-// The = → 🡆 below are ASCII (1 byte), BMP (3 bytes), and astral (4 bytes).
-const char File[] = R"(0:0 = 0
-1:0 → 8
-2:0 🡆 18)";
-
 /// A helper to make tests easier to read.
 Position position(int line, int character) {
   Position Pos;
@@ -52,8 +49,28 @@
   EXPECT_EQ(lspLength("¥"), 1UL);
   // astral
   EXPECT_EQ(lspLength("😂"), 2UL);
+
+  WithContextValue UTF8(kCurrentOffsetEncoding, OffsetEncoding::UTF8);
+  EXPECT_EQ(lspLength(""), 0UL);
+  EXPECT_EQ(lspLength("ascii"), 5UL);
+  // BMP
+  EXPECT_EQ(lspLength("↓"), 3UL);
+  EXPECT_EQ(lspLength("¥"), 2UL);
+  // astral
+  EXPECT_EQ(lspLength("😂"), 4UL);
 }
 
+// The = → 🡆 below are ASCII (1 byte), BMP (3 bytes), and astral (4 bytes).
+const char File[] = R"(0:0 = 0
+1:0 → 8
+2:0 🡆 18)";
+struct Line {
+  unsigned Number;
+  unsigned Offset;
+  unsigned Length;
+};
+Line FileLines[] = {Line{0, 0, 7}, Line{1, 8, 9}, Line{2, 18, 11}};
+
 TEST(SourceCodeTests, PositionToOffset) {
   // line out of bounds
   EXPECT_THAT_EXPECTED(positionToOffset(File, position(-1, 2)), llvm::Failed());
@@ -113,6 +130,23 @@
   // line out of bounds
   EXPECT_THAT_EXPECTED(positionToOffset(File, position(3, 0)), llvm::Failed());
   EXPECT_THAT_EXPECTED(positionToOffset(File, position(3, 1)), llvm::Failed());
+
+  // Test UTF-8, where transformations are trivial.
+  WithContextValue UTF8(kCurrentOffsetEncoding, OffsetEncoding::UTF8);
+  EXPECT_THAT_EXPECTED(positionToOffset(File, position(-1, 2)), llvm::Failed());
+  EXPECT_THAT_EXPECTED(positionToOffset(File, position(3, 0)), llvm::Failed());
+  for (Line L : FileLines) {
+EXPECT_THAT_EXPECTED(positionToOffset(File, position(L.Number, -1)),
+ llvm::Failed()); // out of range
+for (unsigned I = 0; I <= L.Length; ++I)
+  EXPECT_THAT_EXPECTED(positionToOffset(File, position(L.Number, I)),
+   llvm::HasValue(L.Offset + I));
+EXPECT_THAT_EXPECTED(positionToOffset(File, position(L.Number, L.Length+1)),
+ llvm::HasValue(L.Offset + L.Length));
+EXPECT_THAT_EXPECTED(
+positionToOffset(File, position(L.Number, L.Length + 1), false),
+llvm::Failed()); // out of range
+  }
 }
 
 TEST(SourceCodeTests, OffsetToPosition) {
@@ -134,6 +168,13 @@
   EXPECT_THAT(offsetToPosition(File, 28), Pos(2, 8)) << "end of last line";
   EXPECT_THAT(offsetToPosition(File, 29), Pos(2, 9)) << "EOF";
   EXPECT_THAT(offsetToPosition(File, 30), Pos(2, 9)) << "out of bounds";
+
+  WithContextValue UTF8(kCurrentOffsetEncoding, OffsetEncoding::UTF8);
+  for (Line L : FileLines) {
+for (unsigned I = 0; I <= L.Length; ++I)
+  EXPECT_THAT(offsetToPosition(File, L.Offset + I), Pos(L.Number, I));
+  }
+  EXPECT_THAT(offsetToPosition(File, 30), Pos(2, 11)) << "out of bounds";
 }
 
 TEST(SourceCodeTests, IsRangeConsecutive) {
Index: test/clangd/utf8.test
===
--- /dev/null
+++ test/clangd/utf8.test
@@ -0,0 +1,32 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+# This test verifies that we can negotiate UTF-8 offsets via protocol extension.
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{"offsetEncoding":["utf-8","utf-16"]},"trace":"off"}}
+# CHECK: "offsetEncoding": "utf-8"
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"/*ö*/int x;\nint y=x;"}}}
+---
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":1,"character":6}}}
+# /*ö*/int x;
+# 01234567890
+# x is character (and utf-16) ra

[PATCH] D56850: [ASTMatchers][NFC] Add tests for assorted `CXXMemberCallExpr` matchers.

2019-02-15 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 187003.
ymandel added a comment.
Herald added a project: clang.

Sync to head.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56850/new/

https://reviews.llvm.org/D56850

Files:
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -469,6 +469,100 @@
 
 }
 
+TEST(MatcherCXXMemberCallExpr, On) {
+  auto Snippet1 = R"cc(
+struct Y {
+  void m();
+};
+void z(Y y) { y.m(); }
+  )cc";
+  auto Snippet2 = R"cc(
+struct Y {
+  void m();
+};
+struct X : public Y {};
+void z(X x) { x.m(); }
+  )cc";
+  auto MatchesY = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y");
+  EXPECT_TRUE(matches(Snippet1, MatchesY));
+  EXPECT_TRUE(notMatches(Snippet2, MatchesY));
+
+  auto MatchesX = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("X");
+  EXPECT_TRUE(matches(Snippet2, MatchesX));
+
+  // Parens are ignored.
+  auto MatchesCall = cxxMemberCallExpr(on(callExpr()));
+  EXPECT_TRUE(matches(
+  R"cc(
+struct Y {
+  void m();
+};
+Y g();
+void z(Y y) { (g()).m(); }
+  )cc",
+  MatchesCall));
+}
+
+TEST(MatcherCXXMemberCallExpr, OnImplicitObjectArgument) {
+  auto Snippet1 = R"cc(
+struct Y {
+  void m();
+};
+void z(Y y) { y.m(); }
+  )cc";
+  auto Snippet2 = R"cc(
+struct Y {
+  void m();
+};
+struct X : public Y {};
+void z(X x) { x.m(); }
+  )cc";
+  auto MatchesY = cxxMemberCallExpr(
+  onImplicitObjectArgument(hasType(cxxRecordDecl(hasName("Y");
+  EXPECT_TRUE(matches(Snippet1, MatchesY));
+  EXPECT_TRUE(matches(Snippet2, MatchesY));
+
+  auto MatchesX = cxxMemberCallExpr(
+  onImplicitObjectArgument(hasType(cxxRecordDecl(hasName("X");
+  EXPECT_TRUE(notMatches(Snippet2, MatchesX));
+
+  // Parens are not ignored.
+  auto MatchesCall = cxxMemberCallExpr(onImplicitObjectArgument(callExpr()));
+  EXPECT_TRUE(notMatches(
+  R"cc(
+struct Y {
+  void m();
+};
+Y g();
+void z(Y y) { (g()).m(); }
+  )cc",
+  MatchesCall));
+}
+
+TEST(Matcher, HasObjectExpr) {
+  auto Snippet1 = R"cc(
+struct X {
+  int m;
+  int f(X x) { return x.m; }
+};
+  )cc";
+  auto Snippet2 = R"cc(
+struct X {
+  int m;
+  int f(X x) { return m; }
+};
+  )cc";
+  auto MatchesX =
+  memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X");
+  EXPECT_TRUE(matches(Snippet1, MatchesX));
+  EXPECT_TRUE(notMatches(Snippet2, MatchesX));
+
+  auto MatchesXPointer = memberExpr(
+  hasObjectExpression(hasType(pointsTo(cxxRecordDecl(hasName("X"));
+  EXPECT_TRUE(notMatches(Snippet1, MatchesXPointer));
+  EXPECT_TRUE(matches(Snippet2, MatchesXPointer));
+}
+
 TEST(ForEachArgumentWithParam, ReportsNoFalsePositives) {
   StatementMatcher ArgumentY =
 declRefExpr(to(varDecl(hasName("y".bind("arg");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r354075 - [clang][FileManager] fillRealPathName even if we aren't opening the file

2019-02-15 Thread Nico Weber via cfe-commits
Did you do any performance testing to check if this slows down clang?

On Thu, Feb 14, 2019 at 6:02 PM Jan Korous via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: jkorous
> Date: Thu Feb 14 15:02:35 2019
> New Revision: 354075
>
> URL: http://llvm.org/viewvc/llvm-project?rev=354075&view=rev
> Log:
> [clang][FileManager] fillRealPathName even if we aren't opening the file
>
> The pathname wasn't previously filled when the getFile() method was called
> with openFile = false.
> We are caching FileEntry-s in ParsedAST::Includes in clangd and this
> caused the problem.
>
> This fixes an internal test failure in clangd - ClangdTests.GoToInclude.All
>
> rdar://47536127
>
> Differential Revision: https://reviews.llvm.org/D58213
>
> Modified:
> cfe/trunk/lib/Basic/FileManager.cpp
> cfe/trunk/unittests/Basic/FileManagerTest.cpp
>
> Modified: cfe/trunk/lib/Basic/FileManager.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=354075&r1=354074&r2=354075&view=diff
>
> ==
> --- cfe/trunk/lib/Basic/FileManager.cpp (original)
> +++ cfe/trunk/lib/Basic/FileManager.cpp Thu Feb 14 15:02:35 2019
> @@ -267,6 +267,9 @@ const FileEntry *FileManager::getFile(St
>if (UFE.File) {
>  if (auto PathName = UFE.File->getName())
>fillRealPathName(&UFE, *PathName);
> +  } else if (!openFile) {
> +// We should still fill the path even if we aren't opening the file.
> +fillRealPathName(&UFE, InterndFileName);
>}
>return &UFE;
>  }
>
> Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=354075&r1=354074&r2=354075&view=diff
>
> ==
> --- cfe/trunk/unittests/Basic/FileManagerTest.cpp (original)
> +++ cfe/trunk/unittests/Basic/FileManagerTest.cpp Thu Feb 14 15:02:35 2019
> @@ -346,4 +346,18 @@ TEST_F(FileManagerTest, getVirtualFileFi
>EXPECT_EQ(file->tryGetRealPathName(), ExpectedResult);
>  }
>
> +TEST_F(FileManagerTest, getFileDontOpenRealPath) {
> +  auto statCache = llvm::make_unique();
> +  statCache->InjectDirectory("/tmp/abc", 42);
> +  SmallString<64> Path("/tmp/abc/foo.cpp");
> +  statCache->InjectFile(Path.str().str().c_str(), 43);
> +  manager.setStatCache(std::move(statCache));
> +
> +  const FileEntry *file = manager.getFile(Path, /*openFile=*/false);
> +
> +  ASSERT_TRUE(file != nullptr);
> +
> +  ASSERT_EQ(file->tryGetRealPathName(), Path);
> +}
> +
>  } // anonymous namespace
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57662: [clang-tidy] Parallelise clang-tidy-diff.py

2019-02-15 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tidy/tool/clang-tidy-diff.py:98
 
+  parser.add_argument('-j', type=int, default=0,
+  help='number of tidy instances to be run in parallel.')

The "clang-tidy runs are independent" assumption is unfortunately not valid for 
our internal compilation database integration, so making `-j0` the default will 
break it. Let's make it `1`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57662/new/

https://reviews.llvm.org/D57662



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


[PATCH] D58074: [OpenMP 5.0] Parsing/sema support for map clause with mapper modifier

2019-02-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: include/clang/AST/OpenMPClause.h:3626
+  struct OMPMappableExprListSizeTy {
+unsigned NumVars;
+unsigned NumUniqueDeclarations;

Add default initializers for the fields



Comment at: include/clang/AST/OpenMPClause.h:3652
+  OpenMPClauseKind K, SourceLocation StartLoc, SourceLocation LParenLoc,
+  SourceLocation EndLoc, unsigned NumVars, unsigned NumUniqueDeclarations,
+  unsigned NumComponentLists, unsigned NumComponents,

Remove this constructor, we should use only the one with 
`OMPMappableExprListSizeTy`



Comment at: include/clang/AST/OpenMPClause.h:3682-3685
+  OpenMPClauseKind K, SourceLocation StartLoc, SourceLocation LParenLoc,
+  SourceLocation EndLoc, OMPMappableExprListSizeTy Sizes,
+  NestedNameSpecifierLoc *MapperQualifierLocP = nullptr,
+  DeclarationNameInfo *MapperIdInfoP = nullptr)

I think it is worth to add `SourceLocation StartLoc`, `SourceLocation 
LParenLoc`, `SourceLocation EndLoc`, to `OMPMappableExprListSizeTy`. Of course, 
you need to rename the structure, something like `OMPMappableClauseData` is 
good enough. Or you can pack them into a different structure.



Comment at: include/clang/AST/OpenMPClause.h:4318
+  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation 
LParenLoc,
+ SourceLocation EndLoc, ArrayRef Vars,
+ ArrayRef Declarations,

Also too many params, need to "squash" some of them into a structure, maybe 
several structures.



Comment at: include/clang/Sema/Sema.h:9431
+  ArrayRef MapTypeModifiersLoc,
+  CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId,
+  OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,

Also too many params here.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58074/new/

https://reviews.llvm.org/D58074



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


[PATCH] D56644: [clang-tidy] readability-container-size-empty handle std::string length()

2019-02-15 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.
Herald added a project: clang.



Comment at: clang-tidy/readability/ContainerSizeEmptyCheck.cpp:65
   hasType(references(ValidContainer),
-callee(cxxMethodDecl(hasName("size"))), WrongUse,
+callee(cxxMethodDecl(anyOf(hasName("size"), 
hasName("length", WrongUse,
 unless(hasAncestor(cxxMethodDecl(

lebedev.ri wrote:
> lebedev.ri wrote:
> > This line looks too long, clang-format might be too intrusive, so at least
> > ```
> > callee(cxxMethodDecl(anyOf(hasName("size"), 
> >hasName("length",
> > WrongUse,
> > 
> > ```
> s/`callee(cxxMethodDecl(anyOf(hasName("size"), hasName("length", 
> WrongUse,`/`callee(cxxMethodDecl(ContainerLenghtFuncNames)), WrongUse,`/
Please use `hasAnyName(x, y)` instead of `anyOf(hasName(x), hasName(y))`. It's 
shorter and executes faster (the more arguments it has, the faster it is 
compared to the corresponding `anyOf(hasName(...), ...)` construct).



Comment at: clang-tidy/readability/ContainerSizeEmptyCheck.cpp:207
+ "for emptiness instead of '%0'")
+<< MemberCall->getMethodDecl()->getName()
 << Hint;

Did you try without `->getName()`? IIUC, it should work as well.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56644/new/

https://reviews.llvm.org/D56644



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


Re: r354109 - Revert "[Analysis] -Wunreachable-code shouldn't fire on the increment of a foreach loop"

2019-02-15 Thread Nico Weber via cfe-commits
When reverting something, can you say why you're reverting in the commit
message please?

On Fri, Feb 15, 2019 at 4:18 AM Sam McCall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: sammccall
> Date: Fri Feb 15 01:18:49 2019
> New Revision: 354109
>
> URL: http://llvm.org/viewvc/llvm-project?rev=354109&view=rev
> Log:
> Revert "[Analysis] -Wunreachable-code shouldn't fire on the increment of a
> foreach loop"
>
> This reverts commit r354102.
>
> Modified:
> cfe/trunk/lib/Analysis/ReachableCode.cpp
> cfe/trunk/test/SemaCXX/unreachable-code.cpp
>
> Modified: cfe/trunk/lib/Analysis/ReachableCode.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ReachableCode.cpp?rev=354109&r1=354108&r2=354109&view=diff
>
> ==
> --- cfe/trunk/lib/Analysis/ReachableCode.cpp (original)
> +++ cfe/trunk/lib/Analysis/ReachableCode.cpp Fri Feb 15 01:18:49 2019
> @@ -631,10 +631,6 @@ void DeadCodeScan::reportDeadCode(const
>  // a for/for-range loop.  This is the block that contains
>  // the increment code.
>  if (const Stmt *LoopTarget = B->getLoopTarget()) {
> -  // The increment on a foreach statement is not written.
> -  if (isa(LoopTarget))
> -return;
> -
>SourceLocation Loc = LoopTarget->getBeginLoc();
>SourceRange R1(Loc, Loc), R2;
>
>
> Modified: cfe/trunk/test/SemaCXX/unreachable-code.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/unreachable-code.cpp?rev=354109&r1=354108&r2=354109&view=diff
>
> ==
> --- cfe/trunk/test/SemaCXX/unreachable-code.cpp (original)
> +++ cfe/trunk/test/SemaCXX/unreachable-code.cpp Fri Feb 15 01:18:49 2019
> @@ -52,11 +52,6 @@ void test3() {
>}
>  }
>
> -void test4() {
> -  for (char c : "abc") // no-warning
> -break;
> -}
> -
>  // PR 6130 - Don't warn about bogus unreachable code with throw's and
>  // temporary objects.
>  class PR6130 {
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56850: [ASTMatchers][NFC] Add tests for assorted `CXXMemberCallExpr` matchers.

2019-02-15 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354133: Add tests for assorted `CXXMemberCallExpr` matchers. 
(authored by ymandel, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56850?vs=187003&id=187013#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56850/new/

https://reviews.llvm.org/D56850

Files:
  cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp


Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -469,6 +469,95 @@
 
 }
 
+TEST(MatcherCXXMemberCallExpr, On) {
+  auto MatchesType = 
cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("X");
+  EXPECT_TRUE(matches(
+  R"cc(
+struct Y {
+  void m();
+};
+struct X : public Y {};
+void z(X x) { x.m(); }
+  )cc",
+  MatchesType));
+  EXPECT_TRUE(notMatches(
+  R"cc(
+struct Y {
+  void m();
+};
+void z(Y y) { y.m(); }
+  )cc",
+  MatchesType));
+
+  // Parens are ignored.
+  auto MatchesCall = cxxMemberCallExpr(on(callExpr()));
+  EXPECT_TRUE(matches(
+  R"cc(
+struct Y {
+  void m();
+};
+Y g();
+void z(Y y) { (g()).m(); }
+  )cc",
+  MatchesCall));
+}
+
+TEST(MatcherCXXMemberCallExpr, OnImplicitObjectArgument) {
+  auto Snippet1 = R"cc(
+struct Y {
+  void m();
+};
+void z(Y y) { y.m(); }
+  )cc";
+  auto Snippet2 = R"cc(
+struct Y {
+  void m();
+};
+struct X : public Y {};
+void z(X x) { x.m(); }
+  )cc";
+  auto MatchesY = cxxMemberCallExpr(
+  onImplicitObjectArgument(hasType(cxxRecordDecl(hasName("Y");
+  EXPECT_TRUE(matches(Snippet1, MatchesY));
+  EXPECT_TRUE(matches(Snippet2, MatchesY));
+
+  auto MatchesX = cxxMemberCallExpr(
+  onImplicitObjectArgument(hasType(cxxRecordDecl(hasName("X");
+  EXPECT_TRUE(notMatches(Snippet2, MatchesX));
+
+  // Parens are not ignored.
+  auto MatchesCall = cxxMemberCallExpr(onImplicitObjectArgument(callExpr()));
+  EXPECT_TRUE(notMatches(
+  R"cc(
+struct Y {
+  void m();
+};
+Y g();
+void z(Y y) { (g()).m(); }
+  )cc",
+  MatchesCall));
+}
+
+TEST(Matcher, HasObjectExpr) {
+  auto M = 
memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X");
+  EXPECT_TRUE(matches(
+  R"cc(
+struct X {
+  int m;
+  int f(X x) { return x.m; }
+};
+  )cc",
+  M));
+  EXPECT_TRUE(notMatches(
+  R"cc(
+struct X {
+  int m;
+  int f(X x) { return m; }
+};
+  )cc",
+  M));
+}
+
 TEST(ForEachArgumentWithParam, ReportsNoFalsePositives) {
   StatementMatcher ArgumentY =
 declRefExpr(to(varDecl(hasName("y".bind("arg");


Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -469,6 +469,95 @@
 
 }
 
+TEST(MatcherCXXMemberCallExpr, On) {
+  auto MatchesType = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("X");
+  EXPECT_TRUE(matches(
+  R"cc(
+struct Y {
+  void m();
+};
+struct X : public Y {};
+void z(X x) { x.m(); }
+  )cc",
+  MatchesType));
+  EXPECT_TRUE(notMatches(
+  R"cc(
+struct Y {
+  void m();
+};
+void z(Y y) { y.m(); }
+  )cc",
+  MatchesType));
+
+  // Parens are ignored.
+  auto MatchesCall = cxxMemberCallExpr(on(callExpr()));
+  EXPECT_TRUE(matches(
+  R"cc(
+struct Y {
+  void m();
+};
+Y g();
+void z(Y y) { (g()).m(); }
+  )cc",
+  MatchesCall));
+}
+
+TEST(MatcherCXXMemberCallExpr, OnImplicitObjectArgument) {
+  auto Snippet1 = R"cc(
+struct Y {
+  void m();
+};
+void z(Y y) { y.m(); }
+  )cc";
+  auto Snippet2 = R"cc(
+struct Y {
+  void m();
+};
+struct X : public Y {};
+void z(X x) { x.m(); }
+  )cc";
+  auto MatchesY = cxxMemberCallExpr(
+  onImplicitObjectArgument(hasType(cxxRecordDecl(hasName("Y");
+  EXPECT_TRUE(matches(Snippet1, MatchesY));
+  EXPECT_TRUE(matches(Snippet2, MatchesY));
+
+  auto MatchesX = cxxMemberCallExpr(
+  onImplicitObjectArgument(hasType(cxxRecordDecl(hasName("X");
+  EXPECT_TRUE(notMatches(Snippet2, MatchesX));
+
+  // Parens are not ignored.
+  auto MatchesCall = cxxMemberCallExpr(onImplicitObjectArgument(callExpr()));
+  EXPECT_TRUE(notMatches(
+  R"cc(
+struct Y {
+  void m();
+};
+

r354133 - Add tests for assorted `CXXMemberCallExpr` matchers.

2019-02-15 Thread Yitzhak Mandelbaum via cfe-commits
Author: ymandel
Date: Fri Feb 15 06:43:03 2019
New Revision: 354133

URL: http://llvm.org/viewvc/llvm-project?rev=354133&view=rev
Log:
Add tests for assorted `CXXMemberCallExpr` matchers.

Summary: Add tests for matchers `on`, `onImplicitObjectArgument` and 
`hasObjectExpression`.

Reviewers: alexfh, steveire, aaron.ballman

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

Modified:
cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp?rev=354133&r1=354132&r2=354133&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp Fri Feb 15 
06:43:03 2019
@@ -469,6 +469,95 @@ TEST(Matcher, isInstanceMessage) {
 
 }
 
+TEST(MatcherCXXMemberCallExpr, On) {
+  auto MatchesType = 
cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("X");
+  EXPECT_TRUE(matches(
+  R"cc(
+struct Y {
+  void m();
+};
+struct X : public Y {};
+void z(X x) { x.m(); }
+  )cc",
+  MatchesType));
+  EXPECT_TRUE(notMatches(
+  R"cc(
+struct Y {
+  void m();
+};
+void z(Y y) { y.m(); }
+  )cc",
+  MatchesType));
+
+  // Parens are ignored.
+  auto MatchesCall = cxxMemberCallExpr(on(callExpr()));
+  EXPECT_TRUE(matches(
+  R"cc(
+struct Y {
+  void m();
+};
+Y g();
+void z(Y y) { (g()).m(); }
+  )cc",
+  MatchesCall));
+}
+
+TEST(MatcherCXXMemberCallExpr, OnImplicitObjectArgument) {
+  auto Snippet1 = R"cc(
+struct Y {
+  void m();
+};
+void z(Y y) { y.m(); }
+  )cc";
+  auto Snippet2 = R"cc(
+struct Y {
+  void m();
+};
+struct X : public Y {};
+void z(X x) { x.m(); }
+  )cc";
+  auto MatchesY = cxxMemberCallExpr(
+  onImplicitObjectArgument(hasType(cxxRecordDecl(hasName("Y");
+  EXPECT_TRUE(matches(Snippet1, MatchesY));
+  EXPECT_TRUE(matches(Snippet2, MatchesY));
+
+  auto MatchesX = cxxMemberCallExpr(
+  onImplicitObjectArgument(hasType(cxxRecordDecl(hasName("X");
+  EXPECT_TRUE(notMatches(Snippet2, MatchesX));
+
+  // Parens are not ignored.
+  auto MatchesCall = cxxMemberCallExpr(onImplicitObjectArgument(callExpr()));
+  EXPECT_TRUE(notMatches(
+  R"cc(
+struct Y {
+  void m();
+};
+Y g();
+void z(Y y) { (g()).m(); }
+  )cc",
+  MatchesCall));
+}
+
+TEST(Matcher, HasObjectExpr) {
+  auto M = 
memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X");
+  EXPECT_TRUE(matches(
+  R"cc(
+struct X {
+  int m;
+  int f(X x) { return x.m; }
+};
+  )cc",
+  M));
+  EXPECT_TRUE(notMatches(
+  R"cc(
+struct X {
+  int m;
+  int f(X x) { return m; }
+};
+  )cc",
+  M));
+}
+
 TEST(ForEachArgumentWithParam, ReportsNoFalsePositives) {
   StatementMatcher ArgumentY =
 declRefExpr(to(varDecl(hasName("y".bind("arg");


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


r354134 - Added test for matcher On.

2019-02-15 Thread Yitzhak Mandelbaum via cfe-commits
Author: ymandel
Date: Fri Feb 15 06:43:06 2019
New Revision: 354134

URL: http://llvm.org/viewvc/llvm-project?rev=354134&view=rev
Log:
Added test for matcher On.

Modified:
cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp?rev=354134&r1=354133&r2=354134&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp Fri Feb 15 
06:43:06 2019
@@ -470,24 +470,26 @@ TEST(Matcher, isInstanceMessage) {
 }
 
 TEST(MatcherCXXMemberCallExpr, On) {
-  auto MatchesType = 
cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("X");
-  EXPECT_TRUE(matches(
-  R"cc(
+  auto Snippet1 = R"cc(
 struct Y {
   void m();
 };
-struct X : public Y {};
-void z(X x) { x.m(); }
-  )cc",
-  MatchesType));
-  EXPECT_TRUE(notMatches(
-  R"cc(
+void z(Y y) { y.m(); }
+  )cc";
+  auto Snippet2 = R"cc(
 struct Y {
   void m();
 };
-void z(Y y) { y.m(); }
-  )cc",
-  MatchesType));
+struct X : public Y {};
+void z(X x) { x.m(); }
+  )cc";
+  auto MatchesY = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y");
+  EXPECT_TRUE(matches(Snippet1, MatchesY));
+  EXPECT_TRUE(notMatches(Snippet2, MatchesY));
+
+  auto MatchesX = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("X");
+  EXPECT_TRUE(notMatches(Snippet1, MatchesX));
+  EXPECT_TRUE(matches(Snippet2, MatchesX));
 
   // Parens are ignored.
   auto MatchesCall = cxxMemberCallExpr(on(callExpr()));


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


r354136 - Exteded test of .

2019-02-15 Thread Yitzhak Mandelbaum via cfe-commits
Author: ymandel
Date: Fri Feb 15 06:43:10 2019
New Revision: 354136

URL: http://llvm.org/viewvc/llvm-project?rev=354136&view=rev
Log:
Exteded test of .

Modified:
cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp?rev=354136&r1=354135&r2=354136&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp Fri Feb 15 
06:43:10 2019
@@ -540,23 +540,27 @@ TEST(MatcherCXXMemberCallExpr, OnImplici
 }
 
 TEST(Matcher, HasObjectExpr) {
-  auto M = 
memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X");
-  EXPECT_TRUE(matches(
-  R"cc(
+  auto Snippet1 = R"cc(
 struct X {
   int m;
   int f(X x) { return x.m; }
 };
-  )cc",
-  M));
-  EXPECT_TRUE(notMatches(
-  R"cc(
+  )cc";
+  auto Snippet2 = R"cc(
 struct X {
   int m;
   int f(X x) { return m; }
 };
-  )cc",
-  M));
+  )cc";
+  auto MatchesX =
+  memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X");
+  EXPECT_TRUE(matches(Snippet1, MatchesX));
+  EXPECT_TRUE(notMatches(Snippet2, MatchesX));
+
+  auto MatchesXPointer = memberExpr(
+  hasObjectExpression(hasType(pointsTo(cxxRecordDecl(hasName("X"));
+  EXPECT_TRUE(notMatches(Snippet1, MatchesXPointer));
+  EXPECT_TRUE(matches(Snippet2, MatchesXPointer));
 }
 
 TEST(ForEachArgumentWithParam, ReportsNoFalsePositives) {


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


r354135 - Remove unnecessary expectation.

2019-02-15 Thread Yitzhak Mandelbaum via cfe-commits
Author: ymandel
Date: Fri Feb 15 06:43:08 2019
New Revision: 354135

URL: http://llvm.org/viewvc/llvm-project?rev=354135&view=rev
Log:
Remove unnecessary expectation.

Modified:
cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp?rev=354135&r1=354134&r2=354135&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp Fri Feb 15 
06:43:08 2019
@@ -488,7 +488,6 @@ TEST(MatcherCXXMemberCallExpr, On) {
   EXPECT_TRUE(notMatches(Snippet2, MatchesY));
 
   auto MatchesX = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("X");
-  EXPECT_TRUE(notMatches(Snippet1, MatchesX));
   EXPECT_TRUE(matches(Snippet2, MatchesX));
 
   // Parens are ignored.


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


[PATCH] D57662: [clang-tidy] Parallelise clang-tidy-diff.py

2019-02-15 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis marked an inline comment as done.
zinovy.nis added inline comments.



Comment at: clang-tidy/tool/clang-tidy-diff.py:98
 
+  parser.add_argument('-j', type=int, default=0,
+  help='number of tidy instances to be run in parallel.')

alexfh wrote:
> The "clang-tidy runs are independent" assumption is unfortunately not valid 
> for our internal compilation database integration, so making `-j0` the 
> default will break it. Let's make it `1`.
Do you mean you run it with `-fix` or like this?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57662/new/

https://reviews.llvm.org/D57662



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


Re: r354136 - Exteded test of .

2019-02-15 Thread Roman Lebedev via cfe-commits
On Fri, Feb 15, 2019 at 5:42 PM Yitzhak Mandelbaum via cfe-commits
 wrote:
>
> Author: ymandel
> Date: Fri Feb 15 06:43:10 2019
> New Revision: 354136
>
> URL: http://llvm.org/viewvc/llvm-project?rev=354136&view=rev
> Log:
> Exteded test of .
Were last few commits were meant to be committed?
Regardless, the commit messages could use at lot more work.

> Modified:
> cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
>
> Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp?rev=354136&r1=354135&r2=354136&view=diff
> ==
> --- cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp (original)
> +++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp Fri Feb 15 
> 06:43:10 2019
> @@ -540,23 +540,27 @@ TEST(MatcherCXXMemberCallExpr, OnImplici
>  }
>
>  TEST(Matcher, HasObjectExpr) {
> -  auto M = 
> memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X");
> -  EXPECT_TRUE(matches(
> -  R"cc(
> +  auto Snippet1 = R"cc(
>  struct X {
>int m;
>int f(X x) { return x.m; }
>  };
> -  )cc",
> -  M));
> -  EXPECT_TRUE(notMatches(
> -  R"cc(
> +  )cc";
> +  auto Snippet2 = R"cc(
>  struct X {
>int m;
>int f(X x) { return m; }
>  };
> -  )cc",
> -  M));
> +  )cc";
> +  auto MatchesX =
> +  memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X");
> +  EXPECT_TRUE(matches(Snippet1, MatchesX));
> +  EXPECT_TRUE(notMatches(Snippet2, MatchesX));
> +
> +  auto MatchesXPointer = memberExpr(
> +  hasObjectExpression(hasType(pointsTo(cxxRecordDecl(hasName("X"));
> +  EXPECT_TRUE(notMatches(Snippet1, MatchesXPointer));
> +  EXPECT_TRUE(matches(Snippet2, MatchesXPointer));
>  }
>
>  TEST(ForEachArgumentWithParam, ReportsNoFalsePositives) {
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r354136 - Exteded test of .

2019-02-15 Thread Yitzhak Mandelbaum via cfe-commits
No -- That was supposed to be a single commit. I used the git llvm push
expecting it to commit the diff that I saw through arc diff, but instead
got the four separate commits. I should have squashed the 4 (local) commits
into a single commit beforehand but missed that step.

Should rollback those commits and redo as a single one?

On Fri, Feb 15, 2019 at 9:54 AM Roman Lebedev  wrote:

> On Fri, Feb 15, 2019 at 5:42 PM Yitzhak Mandelbaum via cfe-commits
>  wrote:
> >
> > Author: ymandel
> > Date: Fri Feb 15 06:43:10 2019
> > New Revision: 354136
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=354136&view=rev
> > Log:
> > Exteded test of .
> Were last few commits were meant to be committed?
> Regardless, the commit messages could use at lot more work.
>
> > Modified:
> > cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
> >
> > Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp?rev=354136&r1=354135&r2=354136&view=diff
> >
> ==
> > --- cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
> (original)
> > +++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp Fri Feb
> 15 06:43:10 2019
> > @@ -540,23 +540,27 @@ TEST(MatcherCXXMemberCallExpr, OnImplici
> >  }
> >
> >  TEST(Matcher, HasObjectExpr) {
> > -  auto M =
> memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X");
> > -  EXPECT_TRUE(matches(
> > -  R"cc(
> > +  auto Snippet1 = R"cc(
> >  struct X {
> >int m;
> >int f(X x) { return x.m; }
> >  };
> > -  )cc",
> > -  M));
> > -  EXPECT_TRUE(notMatches(
> > -  R"cc(
> > +  )cc";
> > +  auto Snippet2 = R"cc(
> >  struct X {
> >int m;
> >int f(X x) { return m; }
> >  };
> > -  )cc",
> > -  M));
> > +  )cc";
> > +  auto MatchesX =
> > +
> memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X");
> > +  EXPECT_TRUE(matches(Snippet1, MatchesX));
> > +  EXPECT_TRUE(notMatches(Snippet2, MatchesX));
> > +
> > +  auto MatchesXPointer = memberExpr(
> > +
> hasObjectExpression(hasType(pointsTo(cxxRecordDecl(hasName("X"));
> > +  EXPECT_TRUE(notMatches(Snippet1, MatchesXPointer));
> > +  EXPECT_TRUE(matches(Snippet2, MatchesXPointer));
> >  }
> >
> >  TEST(ForEachArgumentWithParam, ReportsNoFalsePositives) {
> >
> >
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>


smime.p7s
Description: S/MIME Cryptographic Signature
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53633: [AArch64] Implement FP16FML intrinsics

2019-02-15 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: cfe/trunk/test/CodeGen/aarch64-neon-fp16fml.c:12
+
+float32x2_t test_vfmlal_low_u32(float32x2_t a, float16x4_t b, float16x4_t c) {
+// CHECK-LABEL: define <2 x float> @test_vfmlal_low_u32(<2 x float> %a, <4 x 
half> %b, <4 x half> %c)

SjoerdMeijer wrote:
> ab wrote:
> > Hey folks, I'm curious: where does the "_u32" suffix come from? Should it 
> > be _f16?
> > 
> > Also, are there any new ACLE/intrinsic list documents? As far as I can tell 
> > there hasn't been any release since IHI0073B/IHI0053D.
> > Also, are there any new ACLE/intrinsic list documents? As far as I can tell 
> > there hasn't been any release since IHI0073B/IHI0053D.
> 
> I've checked, and an updated ACLE that includes these FP16FML intrinsics is 
> coming soon.
> 
> > where does the "_u32" suffix come from? Should it be _f16?
> 
> Good question. It could probably be _f32 or _f16, but _u32 doesn't seem to 
> make much sense. Looks like the spec says _u32, and that's also what GCC has 
> implemented. I think we want to update the spec and fix the name before the 
> updated spec is available. Will chase this, and let you know once I know more.
An update on this: we should change this to _f32 (because the first suffixes 
were refering to the ouput type). The ACLE will be updated accordingly, and 
also GCC will change its current implementation (from _u32 to _f32).  Many 
thanks for raising this issue.
Is there a volunteer to prepare a patch? Or do you have one already? :-) I 
could look at it, but that will be towards the end of next week.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53633/new/

https://reviews.llvm.org/D53633



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


[PATCH] D58189: [clang][Index] Fix usage of IndexImplicitInstantiation

2019-02-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 187014.
kadircet added a comment.

- Get rid of redundant test


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58189/new/

https://reviews.llvm.org/D58189

Files:
  lib/Index/IndexTypeSourceInfo.cpp
  test/Index/Core/index-source.cpp
  test/Index/index-refs.cpp
  unittests/Index/IndexTests.cpp

Index: unittests/Index/IndexTests.cpp
===
--- unittests/Index/IndexTests.cpp
+++ unittests/Index/IndexTests.cpp
@@ -7,7 +7,10 @@
 //===--===//
 
 #include "clang/AST/ASTConsumer.h"
+#include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Index/IndexDataConsumer.h"
@@ -23,27 +26,62 @@
 
 namespace clang {
 namespace index {
+namespace {
+struct Position {
+  size_t Line = 0;
+  size_t Column = 0;
+
+  Position(size_t Line = 0, size_t Column = 0) : Line(Line), Column(Column) {}
+
+  static Position fromSourceLocation(SourceLocation Loc,
+ const SourceManager &SM) {
+FileID FID;
+unsigned Offset;
+std::tie(FID, Offset) = SM.getDecomposedSpellingLoc(Loc);
+Position P;
+P.Line = SM.getLineNumber(FID, Offset);
+P.Column = SM.getColumnNumber(FID, Offset);
+return P;
+  }
+};
+
+bool operator==(const Position &LHS, const Position &RHS) {
+  return std::tie(LHS.Line, LHS.Column) == std::tie(RHS.Line, RHS.Column);
+}
+
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Position &Pos) {
+  return OS << Pos.Line << ':' << Pos.Column;
+}
 
 struct TestSymbol {
   std::string QName;
+  Position WrittenPos;
+  Position DeclPos;
   // FIXME: add more information.
 };
 
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const TestSymbol &S) {
-  return OS << S.QName;
+  return OS << S.QName << '[' << S.WrittenPos << ']' << '@' << S.DeclPos;
 }
 
-namespace {
 class Indexer : public IndexDataConsumer {
 public:
+  void initialize(ASTContext &Ctx) override {
+AST = &Ctx;
+IndexDataConsumer::initialize(Ctx);
+  }
+
   bool handleDeclOccurence(const Decl *D, SymbolRoleSet Roles,
-   ArrayRef, SourceLocation,
+   ArrayRef, SourceLocation Loc,
ASTNodeInfo) override {
 const auto *ND = llvm::dyn_cast(D);
 if (!ND)
   return true;
 TestSymbol S;
 S.QName = ND->getQualifiedNameAsString();
+S.WrittenPos = Position::fromSourceLocation(Loc, AST->getSourceManager());
+S.DeclPos =
+Position::fromSourceLocation(D->getLocation(), AST->getSourceManager());
 Symbols.push_back(std::move(S));
 return true;
   }
@@ -57,6 +95,7 @@
   }
 
   std::vector Symbols;
+  const ASTContext *AST = nullptr;
 };
 
 class IndexAction : public ASTFrontendAction {
@@ -93,11 +132,14 @@
   IndexingOptions Opts;
 };
 
+using testing::AllOf;
 using testing::Contains;
 using testing::Not;
 using testing::UnorderedElementsAre;
 
 MATCHER_P(QName, Name, "") { return arg.QName == Name; }
+MATCHER_P(WrittenAt, Pos, "") { return arg.WrittenPos == Pos; }
+MATCHER_P(DeclAt, Pos, "") { return arg.DeclPos == Pos; }
 
 TEST(IndexTest, Simple) {
   auto Index = std::make_shared();
@@ -134,6 +176,46 @@
   EXPECT_THAT(Index->Symbols, Not(Contains(QName("bar";
 }
 
+TEST(IndexTest, IndexExplicitTemplateInstantiation) {
+  std::string Code = R"cpp(
+template 
+struct Foo { void bar() {} };
+template <>
+struct Foo { void bar() {} };
+void foo() {
+  Foo abc;
+  Foo b;
+}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  tooling::runToolOnCode(new IndexAction(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols,
+  AllOf(Contains(AllOf(QName("Foo"), WrittenAt(Position(8, 7)),
+   DeclAt(Position(5, 12,
+Contains(AllOf(QName("Foo"), WrittenAt(Position(7, 7)),
+   DeclAt(Position(3, 12));
+}
+
+TEST(IndexTest, IndexTemplateInstantiationPartial) {
+  std::string Code = R"cpp(
+template 
+struct Foo { void bar() {} };
+template 
+struct Foo { void bar() {} };
+void foo() {
+  Foo abc;
+  Foo b;
+}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  tooling::runToolOnCode(new IndexAction(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("Foo"), WrittenAt(Position(8, 7)),
+ DeclAt(Position(5, 12);
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: test/Index/index-refs.cpp
===
--- test/Index/index-refs.cpp
+++ test/Index/index-refs.cpp
@@ -1

[PATCH] D56851: [ASTMatchers] Adds `CXXMemberCallExpr` matcher `invokedAtType`.

2019-02-15 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 3 inline comments as done.
ymandel added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3300
+///   matches `x.m()` and `p->m()`.
+AST_MATCHER_P_OVERLOAD(clang::CXXMemberCallExpr, invokedAtType,
+   clang::ast_matchers::internal::Matcher,

aaron.ballman wrote:
> ymandel wrote:
> > alexfh wrote:
> > > ymandel wrote:
> > > > aaron.ballman wrote:
> > > > > ymandel wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > aaron.ballman wrote:
> > > > > > > > ymandel wrote:
> > > > > > > > > ymandel wrote:
> > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > alexfh wrote:
> > > > > > > > > > > > The name of the matcher doesn't tell me much. I had to 
> > > > > > > > > > > > carefully read the documentation to understand what is 
> > > > > > > > > > > > it about. I don't have a name that would raise no 
> > > > > > > > > > > > questions and wouldn't be too verbose at the same time, 
> > > > > > > > > > > > but a bit of verbosity wouldn't hurt I guess. How about 
> > > > > > > > > > > > `objectTypeAsWritten`?
> > > > > > > > > > > Yeah, I think this would be a better name. Also, having 
> > > > > > > > > > > some examples that demonstrate where this behavior 
> > > > > > > > > > > differs from `thisPointerType` would be helpful.
> > > > > > > > > > Agreed that it needs a new name, but I'm having trouble 
> > > > > > > > > > finding one I'm satisfied with.  Here's the full 
> > > > > > > > > > description: "the type of the written implicit object 
> > > > > > > > > > argument".  I base this phrasing on the class 
> > > > > > > > > > CXXMemberCallExpr's terminology.  In `x.f(5)`, `x` is the 
> > > > > > > > > > implicit object argument, whether or not it is also 
> > > > > > > > > > implicitly surrounded by a cast.  That is, "implicit" has 
> > > > > > > > > > two different meanings in this context.
> > > > > > > > > > 
> > > > > > > > > > So, with that, how about `writtenObjectType`? It's close to 
> > > > > > > > > > `objectTypeAsWritten` but I'm hoping it makes more clear 
> > > > > > > > > > that the "written" part is the object not the type.
> > > > > > > > > I've contrasted the behavior with thisPointerType in both of 
> > > > > > > > > the examples. Do you think this helps or do you want 
> > > > > > > > > something more explicit?
> > > > > > > > Here's a totally different direction: `onOrPointsToType()`
> > > > > > > > ```
> > > > > > > > cxxMemberCallExpr(onOrPointsToType(hasDeclaration(cxxRecordDecl(hasName("Y")
> > > > > > > > ```
> > > > > > > > 
> > > > > > > I think more explicit would be better. e.g.,
> > > > > > > ```
> > > > > > > cxxMemberCallExpr(invokedAtType(hasDeclaration(cxxRecordDecl(hasName("X")
> > > > > > > matches 'x.m()' and 'p->m()'.
> > > > > > > cxxMemberCallExpr(on(thisPointerType(hasDeclaration(cxxRecordDecl(hasName("X"))
> > > > > > > matches nothing because the type of 'this' is 'Y' in both cases.
> > > > > > > ```
> > > > > > But, what about even simpler: onType? I think this parallels the 
> > > > > > intuition of the name thisPointerType.  onType(T) should match x.f 
> > > > > > and x->f, where x is type T.  
> > > > > You've pointed out why I don't think `onType` works -- it doesn't 
> > > > > match on type T -- it matches on type T, or a pointer/reference to 
> > > > > type T, which is pretty different. Someone reading the matcher may 
> > > > > expect an exact type match and insert a `pointerType()` or something 
> > > > > there thinking they need to do that to match a call through a pointer.
> > > > > 
> > > > > @alexfh, opinions?
> > > > True.  I should have explained more.  
> > > > 
> > > > 1. Ultimately, I think that none of these names really make sense on 
> > > > their own and the user will need some familiarity with the 
> > > > documentation. I spent quite a while trying to come up with better 
> > > > names and didn't find anything compelling.  I think that `onType` 
> > > > benefits from not carrying much information -- reducing the likelihood 
> > > > of misunderstanding it (they'll have to read the documentation) while 
> > > > paralleling the meaning of the matcher `on` and the behavior of 
> > > > `thisPointerType` (which also allows either the type or the pointer to 
> > > > that type).  
> > > > 
> > > > 2. My particular concern with `onOrPointsToType` is that it sounds like 
> > > > the "or" applies to the `on` but it really means "on (type or points to 
> > > > type)".  
> > > So far, my observations are:
> > > 1. three engineers quite familiar with the topic can't come up with a 
> > > name that would explain the concept behind this matcher
> > > 2. anyone reading that name would have to look up the documentation
> > > 3. the implementation of the matcher is straightforward and even shorter 
> > > than the documentation
> > > 
> > > Should we give up and let users just type `on(anyOf(hasType(Q), 
> > > hasType(pointsTo(Q`?
> > > 
> > >

[PATCH] D57948: [Sema] Fix a regression introduced in "[AST][Sema] Remove CallExpr::setNumArgs"

2019-02-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a subscriber: hans.
riccibruno added a comment.

(Following up on a discussion on IRC) I have looked at what would be needed to 
revert the set of patches which introduced this change, but this results in a 
>1k lines diff which do not apply cleanly. I think it might be safer to just 
merge this fix. Unless @aaron.ballman disagree, @hans  could you please merge 
this into the release branch ?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57948/new/

https://reviews.llvm.org/D57948



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


r354140 - [clang] Create install targets for non-shared libraries

2019-02-15 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Fri Feb 15 07:59:02 2019
New Revision: 354140

URL: http://llvm.org/viewvc/llvm-project?rev=354140&view=rev
Log:
[clang] Create install targets for non-shared libraries

I don't see a reason for these to not have install targets created,
which in turn allows them to be bundled in distributions. This doesn't
affect the "install" target, since that just runs all CMake install
rules (and we were already creating install rules for these).

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

Modified:
cfe/trunk/cmake/modules/AddClang.cmake

Modified: cfe/trunk/cmake/modules/AddClang.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/AddClang.cmake?rev=354140&r1=354139&r2=354140&view=diff
==
--- cfe/trunk/cmake/modules/AddClang.cmake (original)
+++ cfe/trunk/cmake/modules/AddClang.cmake Fri Feb 15 07:59:02 2019
@@ -103,7 +103,7 @@ macro(add_clang_library name)
 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
 RUNTIME DESTINATION bin)
 
-  if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)
+  if (NOT CMAKE_CONFIGURATION_TYPES)
 add_llvm_install_targets(install-${name}
  DEPENDS ${name}
  COMPONENT ${name})


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


r354141 - [clang] Add build and install targets for clang libraries

2019-02-15 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Fri Feb 15 07:59:04 2019
New Revision: 354141

URL: http://llvm.org/viewvc/llvm-project?rev=354141&view=rev
Log:
[clang] Add build and install targets for clang libraries

This is modeled after the existing llvm-libraries target. It's a
convenient way to include all clang libraries in a distribution.

This differs slightly from the llvm-libraries target in that it adds any
library added via add_clang_library, whereas llvm-libraries only
includes targets added via add_llvm_library that didn't use the MODULE
or BUILDTREE_ONLY arguments. add_clang_library doesn't appear to have
any equivalents of those arguments, so the conditions don't apply.

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

Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/cmake/modules/AddClang.cmake

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=354141&r1=354140&r2=354141&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Fri Feb 15 07:59:04 2019
@@ -543,6 +543,27 @@ if( CLANG_INCLUDE_DOCS )
   add_subdirectory(docs)
 endif()
 
+# Custom target to install all clang libraries.
+add_custom_target(clang-libraries)
+set_target_properties(clang-libraries PROPERTIES FOLDER "Misc")
+
+if(NOT CMAKE_CONFIGURATION_TYPES)
+  add_llvm_install_targets(install-clang-libraries
+   DEPENDS clang-libraries
+   COMPONENT clang-libraries)
+endif()
+
+get_property(CLANG_LIBS GLOBAL PROPERTY CLANG_LIBS)
+if(CLANG_LIBS)
+  list(REMOVE_DUPLICATES CLANG_LIBS)
+  foreach(lib ${CLANG_LIBS})
+add_dependencies(clang-libraries ${lib})
+if(NOT CMAKE_CONFIGURATION_TYPES)
+  add_dependencies(install-clang-libraries install-${lib})
+endif()
+  endforeach()
+endif()
+
 add_subdirectory(cmake/modules)
 
 if(CLANG_STAGE)

Modified: cfe/trunk/cmake/modules/AddClang.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/AddClang.cmake?rev=354141&r1=354140&r2=354141&view=diff
==
--- cfe/trunk/cmake/modules/AddClang.cmake (original)
+++ cfe/trunk/cmake/modules/AddClang.cmake Fri Feb 15 07:59:04 2019
@@ -108,6 +108,8 @@ macro(add_clang_library name)
  DEPENDS ${name}
  COMPONENT ${name})
   endif()
+
+  set_property(GLOBAL APPEND PROPERTY CLANG_LIBS ${name})
 endif()
 set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
   else()


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


[PATCH] D58268: [clang] Create install targets for non-shared libraries

2019-02-15 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC354140: [clang] Create install targets for non-shared 
libraries (authored by smeenai, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58268?vs=186955&id=187018#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58268/new/

https://reviews.llvm.org/D58268

Files:
  cmake/modules/AddClang.cmake


Index: cmake/modules/AddClang.cmake
===
--- cmake/modules/AddClang.cmake
+++ cmake/modules/AddClang.cmake
@@ -103,7 +103,7 @@
 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
 RUNTIME DESTINATION bin)
 
-  if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)
+  if (NOT CMAKE_CONFIGURATION_TYPES)
 add_llvm_install_targets(install-${name}
  DEPENDS ${name}
  COMPONENT ${name})


Index: cmake/modules/AddClang.cmake
===
--- cmake/modules/AddClang.cmake
+++ cmake/modules/AddClang.cmake
@@ -103,7 +103,7 @@
 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
 RUNTIME DESTINATION bin)
 
-  if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)
+  if (NOT CMAKE_CONFIGURATION_TYPES)
 add_llvm_install_targets(install-${name}
  DEPENDS ${name}
  COMPONENT ${name})
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58269: [clang] Add build and install targets for clang libraries

2019-02-15 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC354141: [clang] Add build and install targets for clang 
libraries (authored by smeenai, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58269?vs=186957&id=187019#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58269/new/

https://reviews.llvm.org/D58269

Files:
  CMakeLists.txt
  cmake/modules/AddClang.cmake


Index: cmake/modules/AddClang.cmake
===
--- cmake/modules/AddClang.cmake
+++ cmake/modules/AddClang.cmake
@@ -108,6 +108,8 @@
  DEPENDS ${name}
  COMPONENT ${name})
   endif()
+
+  set_property(GLOBAL APPEND PROPERTY CLANG_LIBS ${name})
 endif()
 set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
   else()
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -543,6 +543,27 @@
   add_subdirectory(docs)
 endif()
 
+# Custom target to install all clang libraries.
+add_custom_target(clang-libraries)
+set_target_properties(clang-libraries PROPERTIES FOLDER "Misc")
+
+if(NOT CMAKE_CONFIGURATION_TYPES)
+  add_llvm_install_targets(install-clang-libraries
+   DEPENDS clang-libraries
+   COMPONENT clang-libraries)
+endif()
+
+get_property(CLANG_LIBS GLOBAL PROPERTY CLANG_LIBS)
+if(CLANG_LIBS)
+  list(REMOVE_DUPLICATES CLANG_LIBS)
+  foreach(lib ${CLANG_LIBS})
+add_dependencies(clang-libraries ${lib})
+if(NOT CMAKE_CONFIGURATION_TYPES)
+  add_dependencies(install-clang-libraries install-${lib})
+endif()
+  endforeach()
+endif()
+
 add_subdirectory(cmake/modules)
 
 if(CLANG_STAGE)


Index: cmake/modules/AddClang.cmake
===
--- cmake/modules/AddClang.cmake
+++ cmake/modules/AddClang.cmake
@@ -108,6 +108,8 @@
  DEPENDS ${name}
  COMPONENT ${name})
   endif()
+
+  set_property(GLOBAL APPEND PROPERTY CLANG_LIBS ${name})
 endif()
 set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
   else()
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -543,6 +543,27 @@
   add_subdirectory(docs)
 endif()
 
+# Custom target to install all clang libraries.
+add_custom_target(clang-libraries)
+set_target_properties(clang-libraries PROPERTIES FOLDER "Misc")
+
+if(NOT CMAKE_CONFIGURATION_TYPES)
+  add_llvm_install_targets(install-clang-libraries
+   DEPENDS clang-libraries
+   COMPONENT clang-libraries)
+endif()
+
+get_property(CLANG_LIBS GLOBAL PROPERTY CLANG_LIBS)
+if(CLANG_LIBS)
+  list(REMOVE_DUPLICATES CLANG_LIBS)
+  foreach(lib ${CLANG_LIBS})
+add_dependencies(clang-libraries ${lib})
+if(NOT CMAKE_CONFIGURATION_TYPES)
+  add_dependencies(install-clang-libraries install-${lib})
+endif()
+  endforeach()
+endif()
+
 add_subdirectory(cmake/modules)
 
 if(CLANG_STAGE)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58284: [clang] Switch to LLVM_ENABLE_IDE

2019-02-15 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
smeenai added reviewers: beanz, phosek.
Herald added subscribers: jdoerfert, arphaman, mgorny.
Herald added a project: clang.

r344555 switched LLVM to guarding install targets with LLVM_ENABLE_IDE
instead of CMAKE_CONFIGURATION_TYPES, which expresses the intent more
directly and can be overridden by a user. Make the corresponding change
in clang. LLVM_ENABLE_IDE is computed by HandleLLVMOptions, so it should
be available for both standalone and integrated builds.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58284

Files:
  clang/CMakeLists.txt
  clang/cmake/modules/AddClang.cmake
  clang/lib/Headers/CMakeLists.txt
  clang/tools/c-index-test/CMakeLists.txt
  clang/tools/diagtool/CMakeLists.txt
  clang/tools/libclang/CMakeLists.txt

Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -149,7 +149,7 @@
 add_custom_target(libclang-headers)
 set_target_properties(libclang-headers PROPERTIES FOLDER "Misc")
 
-if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
+if (NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-libclang-headers
COMPONENT libclang-headers)
 endif()
@@ -165,7 +165,7 @@
   DESTINATION
 "lib${LLVM_LIBDIR_SUFFIX}/python${PythonVersion}/site-packages")
 endforeach()
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
   add_custom_target(libclang-python-bindings)
   add_llvm_install_targets(install-libclang-python-bindings
COMPONENT
Index: clang/tools/diagtool/CMakeLists.txt
===
--- clang/tools/diagtool/CMakeLists.txt
+++ clang/tools/diagtool/CMakeLists.txt
@@ -23,7 +23,7 @@
 COMPONENT diagtool
 RUNTIME DESTINATION bin)
 
-  if (NOT CMAKE_CONFIGURATION_TYPES)
+  if (NOT LLVM_ENABLE_IDE)
 add_llvm_install_targets(install-diagtool
   DEPENDS diagtool
   COMPONENT diagtool)
Index: clang/tools/c-index-test/CMakeLists.txt
===
--- clang/tools/c-index-test/CMakeLists.txt
+++ clang/tools/c-index-test/CMakeLists.txt
@@ -61,7 +61,7 @@
 RUNTIME DESTINATION "${INSTALL_DESTINATION}"
 COMPONENT c-index-test)
 
-  if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
+  if (NOT LLVM_ENABLE_IDE)
 add_llvm_install_targets(install-c-index-test
  DEPENDS c-index-test
  COMPONENT c-index-test)
Index: clang/lib/Headers/CMakeLists.txt
===
--- clang/lib/Headers/CMakeLists.txt
+++ clang/lib/Headers/CMakeLists.txt
@@ -178,7 +178,7 @@
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
   DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include/cuda_wrappers)
 
-if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
+if (NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-clang-headers
DEPENDS clang-headers
COMPONENT clang-headers)
Index: clang/cmake/modules/AddClang.cmake
===
--- clang/cmake/modules/AddClang.cmake
+++ clang/cmake/modules/AddClang.cmake
@@ -103,7 +103,7 @@
 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
 RUNTIME DESTINATION bin)
 
-  if (NOT CMAKE_CONFIGURATION_TYPES)
+  if (NOT LLVM_ENABLE_IDE)
 add_llvm_install_targets(install-${name}
  DEPENDS ${name}
  COMPONENT ${name})
@@ -147,7 +147,7 @@
   RUNTIME DESTINATION bin
   COMPONENT ${name})
 
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-${name}
DEPENDS ${name}
COMPONENT ${name})
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -547,7 +547,7 @@
 add_custom_target(clang-libraries)
 set_target_properties(clang-libraries PROPERTIES FOLDER "Misc")
 
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-clang-libraries
DEPENDS clang-libraries
COMPONENT clang-libraries)
@@ -558,7 +558,7 @@
   list(REMOVE_DUPLICATES CLANG_LIBS)
   foreach(lib ${CLANG_LIBS})
 add_dependencies(clang-libraries ${lib})
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
   add_dependencies(install-clang-libraries install-${lib})
 endif()
   endforeach()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58284: [clang] Switch to LLVM_ENABLE_IDE

2019-02-15 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a subscriber: lebedev.ri.
smeenai added a comment.

CC @lebedev.ri, since I believe you raised some issues during the corresponding 
LLVM change but those were addressed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58284/new/

https://reviews.llvm.org/D58284



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


[PATCH] D58284: [clang] Switch to LLVM_ENABLE_IDE

2019-02-15 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D58284#1399443 , @smeenai wrote:

> CC @lebedev.ri, since I believe you raised some issues during the 
> corresponding LLVM change but those were addressed.


Yeah, i don't think i have any comments here.
The logic to pick the default of `LLVM_ENABLE_IDE` (based on the existence of 
`CMAKE_CONFIGURATION_TYPES`) seems hacky,
but it indeed does not currently detect QtCreator's CMake integration as "IDE", 
so i don't have any additional concerns,
this looks like a straight-forward cleanup.

What i do have concerns about, is that `LLVM_ENABLE_IDE` is not documented in 
https://llvm.org/docs/CMake.html


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58284/new/

https://reviews.llvm.org/D58284



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


[PATCH] D57855: [analyzer] Reimplement checker options

2019-02-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

I guess removing some of the checker option descriptions from 
`lib/StataicAnalyzer/Checkers/` would be nice too, to easy on maintenance. One 
could always just use `-analyzer-checker-option-help` whenever in doubt.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57855/new/

https://reviews.llvm.org/D57855



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


[PATCH] D58284: [clang] Switch to LLVM_ENABLE_IDE

2019-02-15 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In D58284#1399446 , @lebedev.ri wrote:

> In D58284#1399443 , @smeenai wrote:
>
> > CC @lebedev.ri, since I believe you raised some issues during the 
> > corresponding LLVM change but those were addressed.
>
>
> Yeah, i don't think i have any comments here.
>  The logic to pick the default of `LLVM_ENABLE_IDE` (based on the existence 
> of `CMAKE_CONFIGURATION_TYPES`) seems hacky,
>  but it indeed does not currently detect QtCreator's CMake integration as 
> "IDE", so i don't have any additional concerns,
>  this looks like a straight-forward cleanup.
>
> What i do have concerns about, is that `LLVM_ENABLE_IDE` is not documented in 
> https://llvm.org/docs/CMake.html


Good point. Added documentation in D58286 .


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58284/new/

https://reviews.llvm.org/D58284



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


[PATCH] D58239: [clangd] Cache include fixes for diagnostics caused by the same unresolved name or incomplete type.

2019-02-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/IncludeFixer.cpp:130
+  // FIXME: consider batching the requests for all diagnostics.
   llvm::Optional Matched;
   Index.lookup(Req, [&](const Symbol &Sym) {

oops - this seems broken (in both the old and new form). Symbol is a shallow 
reference, and it's not valid after lookup() returns.

We can fix here or separately... one option to fix is the ResolvedSymbol struct 
suggested above.

(The fuzzyFind case looks ok)



Comment at: clangd/IncludeFixer.h:85
+  // name or incomplete type in one parse, especially when code is
+  // copy-and-pasted without #includes. As fixes are purely dependent on index
+  // requests and index results at this point, we can cache fixes by index

This seems pretty messy (the assumption that Fix depends only on the index 
lookup).
It saves some code now at the expense of being magic. If we want to e.g. insert 
qualifiers too, I worry it's going to (stop us || return incorrect cached 
results || lead to unneccesary cache misses) depending on what we do.

What would we need to store to calculate Fix?
Maybe a struct ResolvedSymbol with {scope, name, inserted header}? (or even the 
edit to insert the header)
If it's not hugely complicated, that seems both cleaner and more extensible - 
wdyt?



Comment at: clangd/IncludeFixer.h:90
+  mutable llvm::StringMap> FuzzyReqToFixesCache;
+  mutable llvm::StringMap> LookupIDToFixesCache;
 };

DenseMap?


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58239/new/

https://reviews.llvm.org/D58239



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


[PATCH] D58179: [OpenCL][PR40707] Allow OpenCL C types in C++ mode

2019-02-15 Thread Ronan Keryell via Phabricator via cfe-commits
keryell added a comment.

LGTM.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58179/new/

https://reviews.llvm.org/D58179



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


[PATCH] D58239: [clangd] Cache include fixes for diagnostics caused by the same unresolved name or incomplete type.

2019-02-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

(big thumbs up to the caching overall of course!)


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58239/new/

https://reviews.llvm.org/D58239



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


[PATCH] D58062: Support framework import/include auto-completion

2019-02-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Great, thank you! Want me to land this?

(You can certainly get your own commit access at this point if you like: 
https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access and point at 
a couple of your patches)


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58062/new/

https://reviews.llvm.org/D58062



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


[PATCH] D57112: [ASTTypeTraits] OMPClause handling

2019-02-15 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a subscriber: alexfh.
lebedev.ri added a comment.
Herald added a subscriber: jdoerfert.

Ping @hokein / @alexfh (as per git blame).
Not sure who is best suited to review this.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57112/new/

https://reviews.llvm.org/D57112



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


r354147 - Variable auto-init of blocks capturing self after init bugfix

2019-02-15 Thread JF Bastien via cfe-commits
Author: jfb
Date: Fri Feb 15 09:26:29 2019
New Revision: 354147

URL: http://llvm.org/viewvc/llvm-project?rev=354147&view=rev
Log:
Variable auto-init of blocks capturing self after init bugfix

Summary:
Blocks that capture themselves (and escape) after initialization currently 
codegen wrong because this:

  bool capturedByInit =
  Init && emission.IsEscapingByRef && isCapturedBy(D, Init);

  Address Loc =
  capturedByInit ? emission.Addr : emission.getObjectAddress(*this);

Already adjusts Loc from thr alloca to a GEP. This code:

if (emission.IsEscapingByRef)
  Loc = emitBlockByrefAddress(Loc, &D, /*follow=*/false);

Was trying to do the same adjustment, and a GEP on a GEP (returning an int) 
triggers an assertion.



Reviewers: ahatanak

Subscribers: jkorous, dexonsmith, cfe-commits, rjmccall

Tags: #clang

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

Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=354147&r1=354146&r2=354147&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Fri Feb 15 09:26:29 2019
@@ -1620,8 +1620,9 @@ void CodeGenFunction::EmitAutoVarInit(co
   bool capturedByInit =
   Init && emission.IsEscapingByRef && isCapturedBy(D, Init);
 
-  Address Loc =
-  capturedByInit ? emission.Addr : emission.getObjectAddress(*this);
+  bool locIsByrefHeader = !capturedByInit;
+  const Address Loc =
+  locIsByrefHeader ? emission.getObjectAddress(*this) : emission.Addr;
 
   // Note: constexpr already initializes everything correctly.
   LangOptions::TrivialAutoVarInitKind trivialAutoVarInit =
@@ -1637,7 +1638,7 @@ void CodeGenFunction::EmitAutoVarInit(co
   return;
 
 // Only initialize a __block's storage: we always initialize the header.
-if (emission.IsEscapingByRef)
+if (emission.IsEscapingByRef && !locIsByrefHeader)
   Loc = emitBlockByrefAddress(Loc, &D, /*follow=*/false);
 
 CharUnits Size = getContext().getTypeSizeInChars(type);
@@ -1744,10 +1745,9 @@ void CodeGenFunction::EmitAutoVarInit(co
   }
 
   llvm::Type *BP = CGM.Int8Ty->getPointerTo(Loc.getAddressSpace());
-  if (Loc.getType() != BP)
-Loc = Builder.CreateBitCast(Loc, BP);
-
-  emitStoresForConstant(CGM, D, Loc, isVolatile, Builder, constant);
+  emitStoresForConstant(
+  CGM, D, (Loc.getType() == BP) ? Loc : Builder.CreateBitCast(Loc, BP),
+  isVolatile, Builder, constant);
 }
 
 /// Emit an expression as an initializer for an object (variable, field, etc.)

Modified: cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp?rev=354147&r1=354146&r2=354147&view=diff
==
--- cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp Fri Feb 15 09:26:29 2019
@@ -45,14 +45,35 @@ void test_block() {
 // PATTERN:   %captured1 = getelementptr inbounds 
%struct.__block_byref_captured, %struct.__block_byref_captured* %captured, i32 
0, i32 4
 // PATTERN-NEXT:  store %struct.XYZ* inttoptr (i64 -6148914691236517206 to 
%struct.XYZ*), %struct.XYZ** %captured1, align 8
 // PATTERN:   %call = call %struct.XYZ* @create(
+using Block = void (^)();
+typedef struct XYZ {
+  Block block;
+} * xyz_t;
 void test_block_self_init() {
-  using Block = void (^)();
-  typedef struct XYZ {
-Block block;
-  } * xyz_t;
   extern xyz_t create(Block block);
   __block xyz_t captured = create(^() {
-(void)captured;
+used(captured);
+  });
+}
+
+// Capturing with escape after initialization is also an edge case.
+//
+// UNINIT-LABEL:  test_block_captures_self_after_init(
+// ZERO-LABEL:test_block_captures_self_after_init(
+// ZERO:  %block = alloca <{ i8*, i32, i32, i8*, 
%struct.__block_descriptor*, i8* }>, align 8
+// ZERO:  %captured1 = getelementptr inbounds 
%struct.__block_byref_captured.1, %struct.__block_byref_captured.1* %captured, 
i32 0, i32 4
+// ZERO-NEXT: store %struct.XYZ* null, %struct.XYZ** %captured1, align 8
+// ZERO:  %call = call %struct.XYZ* @create(
+// PATTERN-LABEL: test_block_captures_self_after_init(
+// PATTERN:   %block = alloca <{ i8*, i32, i32, i8*, 
%struct.__block_descriptor*, i8* }>, align 8
+// PATTERN:   %captured1 = getelementptr inbounds 
%struct.__block_byref_captured.1, %struct.__block_byref_captured.1* %captured, 
i32 0, i32 4
+// PATTERN-NEXT:  store %struct.XYZ* inttoptr (i64 -6148914691236517206 to 
%struct.XYZ*), %struct.XYZ** %captured1, align 8
+// PATTERN:   %call = call %struct.XYZ* @create(
+void test_block_captures_self_after_init() {
+  extern xyz_t create(Block blo

[PATCH] D58218: Variable auto-init of blocks capturing self after init bugfix

2019-02-15 Thread JF Bastien via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354147: Variable auto-init of blocks capturing self after 
init bugfix (authored by jfb, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58218/new/

https://reviews.llvm.org/D58218

Files:
  cfe/trunk/lib/CodeGen/CGDecl.cpp
  cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp


Index: cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp
===
--- cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp
+++ cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp
@@ -45,14 +45,35 @@
 // PATTERN:   %captured1 = getelementptr inbounds 
%struct.__block_byref_captured, %struct.__block_byref_captured* %captured, i32 
0, i32 4
 // PATTERN-NEXT:  store %struct.XYZ* inttoptr (i64 -6148914691236517206 to 
%struct.XYZ*), %struct.XYZ** %captured1, align 8
 // PATTERN:   %call = call %struct.XYZ* @create(
+using Block = void (^)();
+typedef struct XYZ {
+  Block block;
+} * xyz_t;
 void test_block_self_init() {
-  using Block = void (^)();
-  typedef struct XYZ {
-Block block;
-  } * xyz_t;
   extern xyz_t create(Block block);
   __block xyz_t captured = create(^() {
-(void)captured;
+used(captured);
+  });
+}
+
+// Capturing with escape after initialization is also an edge case.
+//
+// UNINIT-LABEL:  test_block_captures_self_after_init(
+// ZERO-LABEL:test_block_captures_self_after_init(
+// ZERO:  %block = alloca <{ i8*, i32, i32, i8*, 
%struct.__block_descriptor*, i8* }>, align 8
+// ZERO:  %captured1 = getelementptr inbounds 
%struct.__block_byref_captured.1, %struct.__block_byref_captured.1* %captured, 
i32 0, i32 4
+// ZERO-NEXT: store %struct.XYZ* null, %struct.XYZ** %captured1, align 8
+// ZERO:  %call = call %struct.XYZ* @create(
+// PATTERN-LABEL: test_block_captures_self_after_init(
+// PATTERN:   %block = alloca <{ i8*, i32, i32, i8*, 
%struct.__block_descriptor*, i8* }>, align 8
+// PATTERN:   %captured1 = getelementptr inbounds 
%struct.__block_byref_captured.1, %struct.__block_byref_captured.1* %captured, 
i32 0, i32 4
+// PATTERN-NEXT:  store %struct.XYZ* inttoptr (i64 -6148914691236517206 to 
%struct.XYZ*), %struct.XYZ** %captured1, align 8
+// PATTERN:   %call = call %struct.XYZ* @create(
+void test_block_captures_self_after_init() {
+  extern xyz_t create(Block block);
+  __block xyz_t captured;
+  captured = create(^() {
+used(captured);
   });
 }
 
Index: cfe/trunk/lib/CodeGen/CGDecl.cpp
===
--- cfe/trunk/lib/CodeGen/CGDecl.cpp
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp
@@ -1620,8 +1620,9 @@
   bool capturedByInit =
   Init && emission.IsEscapingByRef && isCapturedBy(D, Init);
 
-  Address Loc =
-  capturedByInit ? emission.Addr : emission.getObjectAddress(*this);
+  bool locIsByrefHeader = !capturedByInit;
+  const Address Loc =
+  locIsByrefHeader ? emission.getObjectAddress(*this) : emission.Addr;
 
   // Note: constexpr already initializes everything correctly.
   LangOptions::TrivialAutoVarInitKind trivialAutoVarInit =
@@ -1637,7 +1638,7 @@
   return;
 
 // Only initialize a __block's storage: we always initialize the header.
-if (emission.IsEscapingByRef)
+if (emission.IsEscapingByRef && !locIsByrefHeader)
   Loc = emitBlockByrefAddress(Loc, &D, /*follow=*/false);
 
 CharUnits Size = getContext().getTypeSizeInChars(type);
@@ -1744,10 +1745,9 @@
   }
 
   llvm::Type *BP = CGM.Int8Ty->getPointerTo(Loc.getAddressSpace());
-  if (Loc.getType() != BP)
-Loc = Builder.CreateBitCast(Loc, BP);
-
-  emitStoresForConstant(CGM, D, Loc, isVolatile, Builder, constant);
+  emitStoresForConstant(
+  CGM, D, (Loc.getType() == BP) ? Loc : Builder.CreateBitCast(Loc, BP),
+  isVolatile, Builder, constant);
 }
 
 /// Emit an expression as an initializer for an object (variable, field, etc.)


Index: cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp
===
--- cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp
+++ cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp
@@ -45,14 +45,35 @@
 // PATTERN:   %captured1 = getelementptr inbounds %struct.__block_byref_captured, %struct.__block_byref_captured* %captured, i32 0, i32 4
 // PATTERN-NEXT:  store %struct.XYZ* inttoptr (i64 -6148914691236517206 to %struct.XYZ*), %struct.XYZ** %captured1, align 8
 // PATTERN:   %call = call %struct.XYZ* @create(
+using Block = void (^)();
+typedef struct XYZ {
+  Block block;
+} * xyz_t;
 void test_block_self_init() {
-  using Block = void (^)();
-  typedef struct XYZ {
-Block block;
-  } * xyz_t;
   extern xyz_t create(Block block);
   __block xyz_t captured = create(^() {
-(void)captured;
+used(captured);
+  });
+}
+
+//

[PATCH] D58062: Support framework import/include auto-completion

2019-02-15 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

In D58062#1399499 , @sammccall wrote:

> Great, thank you! Want me to land this?
>
> (You can certainly get your own commit access at this point if you like: 
> https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access and point 
> at a couple of your patches)


Sure, you can land this one, I''ll try to get commit access in the meantime.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58062/new/

https://reviews.llvm.org/D58062



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


[PATCH] D58149: [clang] Make sure C99/C11 features in are provided in C++11

2019-02-15 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

I agree with the comments. I think we should strive to be strictly conforming. 
I make that argument all the time for libc++, so I'll be consistent :-).

https://reviews.llvm.org/D58289


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58149/new/

https://reviews.llvm.org/D58149



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


Re: r354091 - Fix implementation of [temp.local]p4.

2019-02-15 Thread Richard Smith via cfe-commits
On Thu, 14 Feb 2019, 18:35 Francis Visoiu Mistrih via cfe-commits, <
cfe-commits@lists.llvm.org> wrote:

> Hi Richard,
>
> This seems to now emit an error when building the sanitizer tests:
> http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/53965/consoleFull
> .
>
> I managed to reproduce it locally and when reverting your commit the error
> goes away.
>
> I am not sure if the error is in the sanitizer test’s code or actually a
> compiler error. Can you please take a look?
>

It's an error in the sanitizer test's code.

Thanks,
>
> --
> Francis
>
> On Feb 14, 2019, at 4:29 PM, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: rsmith
> Date: Thu Feb 14 16:29:04 2019
> New Revision: 354091
>
> URL: http://llvm.org/viewvc/llvm-project?rev=354091&view=rev
> Log:
> Fix implementation of [temp.local]p4.
>
> When a template-name is looked up, we need to give injected-class-name
> declarations of class templates special treatment, as they denote a
> template rather than a type.
>
> Previously we achieved this by applying a filter to the lookup results
> after completing name lookup, but that is incorrect in various ways, not
> least of which is that it lost all information about access and how
> members were named, and the filtering caused us to generally lose
> all ambiguity errors between templates and non-templates.
>
> We now preserve the lookup results exactly, and the few places that need
> to map from a declaration found by name lookup into a declaration of a
> template do so explicitly. Deduplication of repeated lookup results of
> the same injected-class-name declaration is done by name lookup instead
> of after the fact.
>
> Modified:
>cfe/trunk/include/clang/Sema/Lookup.h
>cfe/trunk/include/clang/Sema/Sema.h
>cfe/trunk/lib/Sema/SemaDecl.cpp
>cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>cfe/trunk/lib/Sema/SemaLookup.cpp
>cfe/trunk/lib/Sema/SemaTemplate.cpp
>cfe/trunk/test/CXX/class.access/p4.cpp
>cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p1.cpp
>cfe/trunk/test/SemaTemplate/temp.cpp
>
> Modified: cfe/trunk/include/clang/Sema/Lookup.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=354091&r1=354090&r2=354091&view=diff
>
> ==
> --- cfe/trunk/include/clang/Sema/Lookup.h (original)
> +++ cfe/trunk/include/clang/Sema/Lookup.h Thu Feb 14 16:29:04 2019
> @@ -172,7 +172,8 @@ public:
>   : SemaPtr(Other.SemaPtr), NameInfo(Other.NameInfo),
> LookupKind(Other.LookupKind), IDNS(Other.IDNS),
> Redecl(Other.Redecl),
> ExternalRedecl(Other.ExternalRedecl), HideTags(Other.HideTags),
> -AllowHidden(Other.AllowHidden) {}
> +AllowHidden(Other.AllowHidden),
> +TemplateNameLookup(Other.TemplateNameLookup) {}
>
>   // FIXME: Remove these deleted methods once the default build includes
>   // -Wdeprecated.
> @@ -193,7 +194,8 @@ public:
> HideTags(std::move(Other.HideTags)),
> Diagnose(std::move(Other.Diagnose)),
> AllowHidden(std::move(Other.AllowHidden)),
> -Shadowed(std::move(Other.Shadowed)) {
> +Shadowed(std::move(Other.Shadowed)),
> +TemplateNameLookup(std::move(Other.TemplateNameLookup)) {
> Other.Paths = nullptr;
> Other.Diagnose = false;
>   }
> @@ -216,6 +218,7 @@ public:
> Diagnose = std::move(Other.Diagnose);
> AllowHidden = std::move(Other.AllowHidden);
> Shadowed = std::move(Other.Shadowed);
> +TemplateNameLookup = std::move(Other.TemplateNameLookup);
> Other.Paths = nullptr;
> Other.Diagnose = false;
> return *this;
> @@ -286,6 +289,15 @@ public:
> HideTags = Hide;
>   }
>
> +  /// Sets whether this is a template-name lookup. For template-name
> lookups,
> +  /// injected-class-names are treated as naming a template rather than a
> +  /// template specialization.
> +  void setTemplateNameLookup(bool TemplateName) {
> +TemplateNameLookup = TemplateName;
> +  }
> +
> +  bool isTemplateNameLookup() const { return TemplateNameLookup; }
> +
>   bool isAmbiguous() const {
> return getResultKind() == Ambiguous;
>   }
> @@ -739,6 +751,9 @@ private:
>   /// declaration that we skipped. This only happens when \c LookupKind
>   /// is \c LookupRedeclarationWithLinkage.
>   bool Shadowed = false;
> +
> +  /// True if we're looking up a template-name.
> +  bool TemplateNameLookup = false;
> };
>
> /// Consumes visible declarations found when searching for
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=354091&r1=354090&r2=354091&view=diff
>
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Thu Feb 14 16:29:04 2019
> @@ -6212,9 +6212,21 @@ public:
>   // C++ Templates [C++ 14]
>   //
>   void F

r354151 - [Sema][NFC] SequenceChecker: Add tests for references/members, and prepare for the C++17 tests

2019-02-15 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Fri Feb 15 10:12:58 2019
New Revision: 354151

URL: http://llvm.org/viewvc/llvm-project?rev=354151&view=rev
Log:
[Sema][NFC] SequenceChecker: Add tests for references/members, and prepare for 
the C++17 tests

Add some tests for unsequenced operations with members and references.
For now most of it is unhandled but it shows what work needs to be done.

Also merge the tests for the C++17 sequencing rules in warn-unsequenced.cpp
since we want to make sure that the appropriate warnings are still present
in C++17 without duplicating the whole content of warn-unsequenced.cpp.


Removed:
cfe/trunk/test/SemaCXX/warn-unsequenced-cxx17.cpp
Modified:
cfe/trunk/test/SemaCXX/warn-unsequenced.cpp

Removed: cfe/trunk/test/SemaCXX/warn-unsequenced-cxx17.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unsequenced-cxx17.cpp?rev=354150&view=auto
==
--- cfe/trunk/test/SemaCXX/warn-unsequenced-cxx17.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unsequenced-cxx17.cpp (removed)
@@ -1,8 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 -Wno-unused %s
-
-void test() {
-  int xs[10];
-  int *p = xs;
-  // expected-no-diagnostics
-  p[(long long unsigned)(p = 0)]; // ok
-}

Modified: cfe/trunk/test/SemaCXX/warn-unsequenced.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unsequenced.cpp?rev=354151&r1=354150&r2=354151&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-unsequenced.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unsequenced.cpp Fri Feb 15 10:12:58 2019
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wno-unused %s
+// RUN: %clang_cc1 -fsyntax-only -verify=cxx11 -std=c++11 -Wno-unused 
-Wno-uninitialized -Wunsequenced %s
+// RUN: %clang_cc1 -fsyntax-only -verify=cxx17 -std=c++17 -Wno-unused 
-Wno-uninitialized -Wunsequenced %s
 
 int f(int, int = 0);
 
@@ -10,81 +11,107 @@ struct S {
   int n;
 };
 
+// TODO: Implement the C++17 sequencing rules.
 void test() {
   int a;
   int xs[10];
   ++a = 0; // ok
-  a + ++a; // expected-warning {{unsequenced modification and access to 'a'}}
+  a + ++a; // cxx11-warning {{unsequenced modification and access to 'a'}}
+   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   a = ++a; // ok
-  a + a++; // expected-warning {{unsequenced modification and access to 'a'}}
-  a = a++; // expected-warning {{multiple unsequenced modifications to 'a'}}
+  a + a++; // cxx11-warning {{unsequenced modification and access to 'a'}}
+   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
+  a = a++; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
+   // TODO cxx17-warning@-1 {{multiple unsequenced modifications to 
'a'}}
   ++ ++a; // ok
   (a++, a++); // ok
-  ++a + ++a; // expected-warning {{multiple unsequenced modifications to 'a'}}
-  a++ + a++; // expected-warning {{multiple unsequenced modifications}}
+  ++a + ++a; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
+ // cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
+  a++ + a++; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
+ // cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
   (a++, a) = 0; // ok, increment is sequenced before value computation of LHS
   a = xs[++a]; // ok
-  a = xs[a++]; // expected-warning {{multiple unsequenced modifications}}
-  (a ? xs[0] : xs[1]) = ++a; // expected-warning {{unsequenced modification 
and access}}
+  a = xs[a++]; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
+   // TODO cxx17-warning@-1 {{multiple unsequenced modifications 
to 'a'}}
+  (a ? xs[0] : xs[1]) = ++a; // cxx11-warning {{unsequenced modification and 
access to 'a'}}
+ // TODO cxx17-warning@-1 {{unsequenced 
modification and access to 'a'}}
   a = (++a, ++a); // ok
   a = (a++, ++a); // ok
-  a = (a++, a++); // expected-warning {{multiple unsequenced modifications}}
+  a = (a++, a++); // cxx11-warning {{multiple unsequenced modifications to 
'a'}}
+  // TODO cxx17-warning@-1 {{multiple unsequenced 
modifications to 'a'}}
   f(a, a); // ok
-  f(a = 0, a); // expected-warning {{unsequenced modification and access}}
-  f(a, a += 0); // expected-warning {{unsequenced modification and access}}
-  f(a = 0, a = 0); // expected-warning {{multiple unsequenced modifications}}
+  f(a = 0, a); // cxx11-warning {{unsequenced modification and access to 'a'}}
+   // cxx17-warning@-1 {{unsequenced modification and access to 
'a'}}
+  f(a, a += 0); // cxx11-warning {{unsequenced modification and access to 'a'}}
+// cxx17-warning@-1 {{unsequenced modification and access to 
'a'}}
+  f(a = 0, a = 0); // cxx11-warning {{multiple unsequenced modificatio

[PATCH] D57660: [Sema] SequenceChecker: Handle references and members

2019-02-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 187035.
riccibruno added a comment.
Herald added a subscriber: jdoerfert.

Rebased. Does this implementation make sense ?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57660/new/

https://reviews.llvm.org/D57660

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/SemaCXX/warn-unsequenced.cpp

Index: test/SemaCXX/warn-unsequenced.cpp
===
--- test/SemaCXX/warn-unsequenced.cpp
+++ test/SemaCXX/warn-unsequenced.cpp
@@ -161,16 +161,17 @@
 void S1::member_f(S1 &s) {
   int xs[10];
 
-  ++a + ++a; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
- // cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
-  a + ++a; // cxx11-warning {{unsequenced modification and access to 'a'}}
-   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
+  ++a + ++a; // cxx11-warning {{multiple unsequenced modifications to member 'a'}}
+ // cxx17-warning@-1 {{multiple unsequenced modifications to member 'a'}}
+  a + ++a; // cxx11-warning {{unsequenced modification and access to member 'a'}}
+   // cxx17-warning@-1 {{unsequenced modification and access to member 'a'}}
   ++a + ++b; // no-warning
   a + ++b; // no-warning
 
-  // TODO: Warn here.
-  ++s.a + ++s.a; // no-warning TODO {{multiple unsequenced modifications to}}
-  s.a + ++s.a; // no-warning TODO {{unsequenced modification and access to}}
+  ++s.a + ++s.a; // cxx11-warning {{multiple unsequenced modifications to member 'a' of 's'}}
+ // cxx17-warning@-1 {{multiple unsequenced modifications to member 'a' of 's'}}
+  s.a + ++s.a; // cxx11-warning {{unsequenced modification and access to member 'a' of 's'}}
+   // cxx17-warning@-1 {{unsequenced modification and access to member 'a' of 's'}}
   ++s.a + ++s.b; // no-warning
   s.a + ++s.b; // no-warning
 
@@ -180,16 +181,18 @@
   a + ++s.b; // no-warning
 
   // TODO Warn here for bit-fields in the same memory location.
-  ++bf1 + ++bf1; // cxx11-warning {{multiple unsequenced modifications to 'bf1'}}
- // cxx17-warning@-1 {{multiple unsequenced modifications to 'bf1'}}
-  bf1 + ++bf1; // cxx11-warning {{unsequenced modification and access to 'bf1'}}
-   // cxx17-warning@-1 {{unsequenced modification and access to 'bf1'}}
+  ++bf1 + ++bf1; // cxx11-warning {{multiple unsequenced modifications to member 'bf1'}}
+ // cxx17-warning@-1 {{multiple unsequenced modifications to member 'bf1'}}
+  bf1 + ++bf1; // cxx11-warning {{unsequenced modification and access to member 'bf1'}}
+   // cxx17-warning@-1 {{unsequenced modification and access to member 'bf1'}}
   ++bf1 + ++bf2; // no-warning TODO {{multiple unsequenced modifications to}}
   bf1 + ++bf2; // no-warning TODO {{unsequenced modification and access to}}
 
   // TODO Warn here for bit-fields in the same memory location.
-  ++s.bf1 + ++s.bf1; // no-warning TODO {{multiple unsequenced modifications to}}
-  s.bf1 + ++s.bf1; // no-warning TODO {{unsequenced modification and access to}}
+  ++s.bf1 + ++s.bf1; // cxx11-warning {{multiple unsequenced modifications to member 'bf1' of 's'}}
+ // cxx17-warning@-1 {{multiple unsequenced modifications to member 'bf1' of 's'}}
+  s.bf1 + ++s.bf1; // cxx11-warning {{unsequenced modification and access to member 'bf1' of 's'}}
+   // cxx17-warning@-1 {{unsequenced modification and access to member 'bf1' of 's'}}
   ++s.bf1 + ++s.bf2; // no-warning TODO {{multiple unsequenced modifications to}}
   s.bf1 + ++s.bf2; // no-warning TODO {{unsequenced modification and access to}}
 
@@ -205,15 +208,19 @@
 };
 
 void S2::f2() {
-  ++x + ++x; // no-warning TODO {{multiple unsequenced modifications to}}
-  x + ++x; // no-warning TODO {{unsequenced modification and access to}}
+  ++x + ++x; // cxx11-warning {{multiple unsequenced modifications to member 'x'}}
+ // cxx17-warning@-1 {{multiple unsequenced modifications to member 'x'}}
+  x + ++x; // cxx11-warning {{unsequenced modification and access to member 'x'}}
+   // cxx17-warning@-1 {{unsequenced modification and access to member 'x'}}
   ++x + ++y; // no-warning
   x + ++y; // no-warning
 }
 
 void f2(S2 &s) {
-  ++s.x + ++s.x; // no-warning TODO {{multiple unsequenced modifications to}}
-  s.x + ++s.x; // no-warning TODO {{unsequenced modification and access to}}
+  ++s.x + ++s.x; // cxx11-warning {{multiple unsequenced modifications to member 'x' of 's'}}
+ // cxx17-warning@-1 {{multiple unsequenced modifications to member 'x' of 's'}}
+  s.x + ++s.x; // cxx11-warning {{unsequenced modification and access to member 'x' of 's'}}
+   // cxx17-warning@-1 {{unsequenced modification and access to member 'x' of 's'}}
   ++s.x + ++s.y; // no-warning
   s.x + ++s.y; // no-warning
 }
@@ -229,

[PATCH] D57948: [Sema] Fix a regression introduced in "[AST][Sema] Remove CallExpr::setNumArgs"

2019-02-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a subscriber: hansw.
aaron.ballman added a comment.

In D57948#1399403 , @riccibruno wrote:

> (Following up on a discussion on IRC) I have looked at what would be needed 
> to revert the set of patches which introduced this change, but this results 
> in a >1k lines diff which do not apply cleanly. I think it might be safer to 
> just merge this fix. Unless @aaron.ballman disagree, @hans  could you please 
> merge this into the release branch ?


Thank you for looking into the 8.0 revert approach, @riccibruno! I'm okay with 
putting this patch on 8.0 instead -- you should file a new bug, mark it as 
blocking https://bugs.llvm.org/show_bug.cgi?id=40331, and make sure @hansw is 
CCed on the bug.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57948/new/

https://reviews.llvm.org/D57948



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


[PATCH] D56571: [RFC prototype] Implementation of asm-goto support in clang

2019-02-15 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 187036.
jyu2 marked an inline comment as done.
jyu2 added a comment.

Review comment addressed


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56571/new/

https://reviews.llvm.org/D56571

Files:
  include/clang/AST/Stmt.h
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/ASTImporter.cpp
  lib/AST/Stmt.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Analysis/CFG.cpp
  lib/CodeGen/CGStmt.cpp
  lib/Parse/ParseStmtAsm.cpp
  lib/Sema/JumpDiagnostics.cpp
  lib/Sema/SemaStmtAsm.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/Analysis/asm-goto.cpp
  test/CodeGen/asm-goto.c
  test/CodeGen/asm.c
  test/CodeGen/inline-asm-mixed-style.c
  test/Coverage/c-language-features.inc
  test/PCH/asm.h
  test/Parser/asm.c
  test/Parser/asm.cpp
  test/Sema/asm-goto.cpp
  test/Sema/asm.c
  test/Sema/inline-asm-validate-tmpl.cpp
  test/Sema/scope-check.c

Index: test/Sema/scope-check.c
===
--- test/Sema/scope-check.c
+++ test/Sema/scope-check.c
@@ -232,3 +232,19 @@
 
 // rdar://9024687
 int test16(int [sizeof &&z]); // expected-error {{use of address-of-label extension outside of a function body}}
+
+//Asm goto:
+int test16(int n)
+{
+  // expected-error@+2 {{cannot jump from this asm goto statement to one of its possible targets}}
+  // expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
+  asm volatile goto("testl %0, %0; jne %l1;" :: "r"(n)::label_true, loop);
+  // expected-note@+2 {{jump bypasses initialization of variable length array}}
+  // expected-note@+1 {{possible target of asm goto statement}}
+  return ({int a[n];label_true: 2;});
+  // expected-note@+1 {{jump bypasses initialization of variable length array}}
+  int b[n];
+// expected-note@+1 {{possible target of asm goto statement}}
+loop:
+  return 0;
+}
Index: test/Sema/inline-asm-validate-tmpl.cpp
===
--- test/Sema/inline-asm-validate-tmpl.cpp
+++ test/Sema/inline-asm-validate-tmpl.cpp
@@ -23,3 +23,13 @@
 	asm("rol %1, %0" :"=r"(value): "I"(N + 1));
 }
 int	foo() { testc<2>(10); }
+
+// these should compile without error
+template  bool testd()
+{
+  __asm goto ("" : : : : lab);
+  return true;
+lab:
+  return false;
+}
+bool foox() { return testd<0> (); }
Index: test/Sema/asm.c
===
--- test/Sema/asm.c
+++ test/Sema/asm.c
@@ -295,3 +295,24 @@
   return r0 + r1;
 }
 
+void test18()
+{
+  // expected-error@+2 {{duplicate use of asm operand name "lab"}}
+  // expected-note@+1 {{asm operand name "lab" first referenced here}}
+  asm goto ("" : : : : lab, lab, lab2, lab);
+  // expected-error@+2 {{duplicate use of asm operand name "lab"}}
+  // expected-note@+1 {{asm operand name "lab" first referenced here}}
+  asm goto ("xorw %[lab], %[lab]; je %l[lab]" : : [lab] "i" (0) : : lab);
+lab:;
+lab2:;
+  int x,x1;
+  // expected-error@+2 {{duplicate use of asm operand name "lab"}}
+  // expected-note@+1 {{asm operand name "lab" first referenced here}}
+  asm ("" : [lab] "=r" (x),[lab] "+r" (x) : [lab1] "r" (x));
+  // expected-error@+2 {{duplicate use of asm operand name "lab"}}
+  // expected-note@+1 {{asm operand name "lab" first referenced here}}
+  asm ("" : [lab] "=r" (x1) : [lab] "r" (x));
+  // expected-error@+1 {{invalid operand number in inline asm string}}
+  asm ("jne %l0":::);
+  asm goto ("jne %l0"lab);
+}
Index: test/Sema/asm-goto.cpp
===
--- /dev/null
+++ test/Sema/asm-goto.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 %s -triple i386-pc-linux-gnu -verify -fsyntax-only
+
+struct NonTrivial {
+  ~NonTrivial();
+  int f(int);
+private:
+  int k;
+};
+void JumpDiagnostics(int n) {
+// expected-error@+1 {{cannot jump from this goto statement to its label}}
+  goto DirectJump;
+// expected-note@+1 {{jump bypasses variable with a non-trivial destructor}}
+  NonTrivial tnp1;
+
+DirectJump:
+// expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
+  asm goto("jmp %l0;" Later);
+// expected-note@+1 {{jump bypasses variable with a non-trivial destructor}}
+  NonTrivial tnp2;
+// expected-note@+1 {{possible target of asm goto statement}}
+Later:
+  return;
+}
+
+struct S { ~S(); };
+void foo(int a) {
+  if (a) {
+FOO:
+// expected-note@+2 {{jump exits scope of variable with non-trivial destructor}}
+// expected-note@+1 {{jump exits scope of variable with non-trivial destructor}}
+S s;
+void *p = &&BAR;
+// expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
+  asm goto("jmp %l0;" BAR);
+// expected-error@+1 {{cannot jump from this indirect goto statement to one of its possible targ

[PATCH] D56571: [RFC prototype] Implementation of asm-goto support in clang

2019-02-15 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added inline comments.



Comment at: lib/Sema/JumpDiagnostics.cpp:675
+  // asm-goto.
+  //if (!IsAsmGoto && IndirectJumpTargets.empty()) {
+  if (JumpTargets.empty()) {

efriedma wrote:
> Commented-out code?
> 
> We probably don't need a diagnostic for an asm goto which doesn't have any 
> labels.  If we do, it shouldn't be here.
:-(

Yes, you are right!  We don't need a diagnostic for asm goto.  The error will 
be giving during parser.  I changed.

Thank you so much for your review.
  



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56571/new/

https://reviews.llvm.org/D56571



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


[PATCH] D58292: Add support for importing ChooseExpr AST nodes.

2019-02-15 Thread Tom Roeder via Phabricator via cfe-commits
tmroeder created this revision.
Herald added a reviewer: shafik.
Herald added subscribers: cfe-commits, jdoerfert.
Herald added a project: clang.

This allows ASTs to be merged when they contain ChooseExpr (the GNU
__builtin_choose_expr construction). This is needed, for example, for
cross-CTU analysis of C code that makes use of __builtin_choose_expr.

The node is already supported in the AST, but it didn't have a matcher
in ASTMatchers. So, this change adds the matcher and adds support to
ASTImporter.


Repository:
  rC Clang

https://reviews.llvm.org/D58292

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  lib/AST/ASTImporter.cpp
  lib/ASTMatchers/ASTMatchersInternal.cpp
  test/ASTMerge/choose-expr/Inputs/choose1.c
  test/ASTMerge/choose-expr/Inputs/choose2.c
  test/ASTMerge/choose-expr/test.c
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -563,6 +563,15 @@
   stringLiteral(hasType(asString("const char [7]"));
 }
 
+TEST_P(ImportExpr, ImportChooseExpr) {
+  MatchVerifier Verifier;
+
+  testImport(
+"void declToImport() { __builtin_choose_expr(1, 2, 3); }",
+Lang_C, "", Lang_C, Verifier,
+functionDecl(hasDescendant(chooseExpr(;
+}
+
 TEST_P(ImportExpr, ImportGNUNullExpr) {
   MatchVerifier Verifier;
   testImport(
@@ -1082,6 +1091,38 @@
   EXPECT_EQ(To, nullptr);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportChooseExpr) {
+  MatchVerifier Verifier;
+
+  // The macro in this TuDecl violates standard rules of macros (like not
+  // using a variable more than once), but it's only used to test a realistic
+  // __builtin_choose_expr construction.
+  Decl *FromTU = getTuDecl(
+  R"(
+  #define abs_int(x) __builtin_choose_expr(\
+ __builtin_types_compatible_p(__typeof(x), unsigned int),  \
+ x,\
+ __builtin_choose_expr(\
+   __builtin_types_compatible_p(__typeof(x), int), \
+   x < 0 ? -x : x, \
+   (void)0))
+  void declToImport() {
+int x = -10;
+int abs_x = abs_int(x);
+(void)abs_x;
+  }
+  )",
+  Lang_C, "input.c");
+  auto *From = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("declToImport")));
+  ASSERT_TRUE(From);
+  auto *To = Import(From, Lang_C);
+  ASSERT_TRUE(To);
+  EXPECT_TRUE(MatchVerifier().match(
+  To, functionDecl(hasName("declToImport"),
+   hasDescendant(chooseExpr(hasDescendant(chooseExpr()));
+}
+
 const internal::VariadicDynCastAllOfMatcher
 cxxPseudoDestructorExpr;
 
Index: test/ASTMerge/choose-expr/test.c
===
--- /dev/null
+++ test/ASTMerge/choose-expr/test.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/choose1.c
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/choose2.c
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1
Index: test/ASTMerge/choose-expr/Inputs/choose2.c
===
--- /dev/null
+++ test/ASTMerge/choose-expr/Inputs/choose2.c
@@ -0,0 +1,12 @@
+#define abs_int(x) __builtin_choose_expr( \
+__builtin_types_compatible_p(__typeof(x), unsigned int),  \
+x,\
+__builtin_choose_expr(\
+__builtin_types_compatible_p(__typeof(x), int),   \
+x < 0 ? -x : x,   \
+(void)0))
+void declToImport() {
+  int x = -10;
+  int abs_x = abs_int(x);
+  (void)abs_x;
+}
Index: test/ASTMerge/choose-expr/Inputs/choose1.c
===
--- /dev/null
+++ test/ASTMerge/choose-expr/Inputs/choose1.c
@@ -0,0 +1,12 @@
+#define abs_int(x) __builtin_choose_expr( \
+__builtin_types_compatible_p(__typeof(x), unsigned int),  \
+x,\
+__builtin_choose_expr(\
+__builtin_types_compatible_p(__typeof(x), int),   \
+x < 0 ? -x : x,   \
+(void)0))
+void declToImport() {
+  int x = -10;
+  int abs_x = abs_int(x);
+  (void)abs_x;
+}
Index: lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- lib/ASTMatchers/ASTMatchersInternal.cpp
+++ lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -727,6 +727,7 @@
 compoundLiteralExpr;
 const internal::VariadicDynCastAllOfMatcher
 cxxNullPtrLiteralExpr;
+const internal::VariadicDynCastAllOfMatcher chooseExpr;
 const internal::V

[PATCH] D58293: [clang][Index] Enable indexing of Template Type Parameters behind a flag

2019-02-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added reviewers: ilya-biryukov, akyrtzi.
Herald added subscribers: cfe-commits, arphaman, ioeric, kristof.beyls, 
javed.absar.
Herald added a project: clang.

clangd uses indexing api to provide references and it was not possible
to perform symbol information for template parameters. This patch enables
visiting of TemplateTypeParmTypeLocs.


Repository:
  rC Clang

https://reviews.llvm.org/D58293

Files:
  include/clang/Index/IndexingAction.h
  lib/Index/IndexTypeSourceInfo.cpp
  lib/Index/IndexingContext.cpp
  lib/Index/IndexingContext.h
  unittests/Index/IndexTests.cpp

Index: unittests/Index/IndexTests.cpp
===
--- unittests/Index/IndexTests.cpp
+++ unittests/Index/IndexTests.cpp
@@ -93,6 +93,7 @@
   IndexingOptions Opts;
 };
 
+using testing::AllOf;
 using testing::Contains;
 using testing::Not;
 using testing::UnorderedElementsAre;
@@ -134,6 +135,25 @@
   EXPECT_THAT(Index->Symbols, Not(Contains(QName("bar";
 }
 
+TEST(IndexTest, IndexTypeParmDecls) {
+  std::string Code = R"cpp(
+template  struct Foo {
+  T t = I;
+};
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  tooling::runToolOnCode(new IndexAction(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols, AllOf(Not(Contains(QName("Foo::T"))),
+Not(Contains(QName("Foo::I");
+
+  Opts.IndexTemplateParmDecls = true;
+  Index->Symbols.clear();
+  tooling::runToolOnCode(new IndexAction(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols,
+  AllOf(Contains(QName("Foo::T")), Contains(QName("Foo::I";
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: lib/Index/IndexingContext.h
===
--- lib/Index/IndexingContext.h
+++ lib/Index/IndexingContext.h
@@ -63,6 +63,8 @@
 
   bool shouldIndexParametersInDeclarations() const;
 
+  bool shouldIndexTemplateParmDecls() const;
+
   static bool isTemplateImplicitInstantiation(const Decl *D);
 
   bool handleDecl(const Decl *D, SymbolRoleSet Roles = SymbolRoleSet(),
Index: lib/Index/IndexingContext.cpp
===
--- lib/Index/IndexingContext.cpp
+++ lib/Index/IndexingContext.cpp
@@ -44,6 +44,10 @@
   return IndexOpts.IndexParametersInDeclarations;
 }
 
+bool IndexingContext::shouldIndexTemplateParmDecls() const {
+  return IndexOpts.IndexTemplateParmDecls;
+}
+
 bool IndexingContext::handleDecl(const Decl *D,
  SymbolRoleSet Roles,
  ArrayRef Relations) {
@@ -76,8 +80,10 @@
   if (!shouldIndexFunctionLocalSymbols() && isFunctionLocalSymbol(D))
 return true;
 
-  if (isa(D) || isa(D))
+  if (!shouldIndexTemplateParmDecls() &&
+  (isa(D) || isa(D))) {
 return true;
+  }
 
   return handleDeclOccurrence(D, Loc, /*IsRef=*/true, Parent, Roles, Relations,
   RefE, RefD, DC);
Index: lib/Index/IndexTypeSourceInfo.cpp
===
--- lib/Index/IndexTypeSourceInfo.cpp
+++ lib/Index/IndexTypeSourceInfo.cpp
@@ -45,6 +45,13 @@
   return false;\
   } while (0)
 
+  bool VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TTPL) {
+SourceLocation Loc = TTPL.getNameLoc();
+TemplateTypeParmDecl *TTPD = TTPL.getDecl();
+return IndexCtx.handleReference(TTPD, Loc, Parent, ParentDC,
+SymbolRoleSet());
+  }
+
   bool VisitTypedefTypeLoc(TypedefTypeLoc TL) {
 SourceLocation Loc = TL.getNameLoc();
 TypedefNameDecl *ND = TL.getTypedefNameDecl();
Index: include/clang/Index/IndexingAction.h
===
--- include/clang/Index/IndexingAction.h
+++ include/clang/Index/IndexingAction.h
@@ -46,6 +46,7 @@
   bool IndexMacrosInPreprocessor = false;
   // Has no effect if IndexFunctionLocals are false.
   bool IndexParametersInDeclarations = false;
+  bool IndexTemplateParmDecls = false;
 };
 
 /// Creates a frontend action that indexes all symbols (macros and AST decls).
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58291: [clangd] Include textual diagnostic ID as Diagnostic.code.

2019-02-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 187048.
sammccall added a comment.

Unit test.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58291/new/

https://reviews.llvm.org/D58291

Files:
  clangd/Diagnostics.cpp
  clangd/Diagnostics.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  test/clangd/compile-commands-path-in-initialize.test
  test/clangd/diagnostic-category.test
  test/clangd/diagnostics.test
  test/clangd/did-change-configuration-params.test
  test/clangd/execute-command.test
  test/clangd/fixits-codeaction.test
  test/clangd/fixits-command.test
  test/clangd/fixits-embed-in-diagnostic.test
  unittests/clangd/DiagnosticsTests.cpp

Index: unittests/clangd/DiagnosticsTests.cpp
===
--- unittests/clangd/DiagnosticsTests.cpp
+++ unittests/clangd/DiagnosticsTests.cpp
@@ -12,6 +12,7 @@
 #include "TestIndex.h"
 #include "TestTU.h"
 #include "index/MemIndex.h"
+#include "clang/Basic/DiagnosticSema.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -216,6 +217,7 @@
 
 TEST(DiagnosticsTest, ToLSP) {
   clangd::Diag D;
+  D.ID = clang::diag::err_enum_class_reference;
   D.Message = "something terrible happened";
   D.Range = {pos(1, 2), pos(3, 4)};
   D.InsideMainFile = true;
@@ -284,6 +286,8 @@
   LSPDiags,
   ElementsAre(Pair(EqualToLSPDiag(MainLSP), ElementsAre(EqualToFix(F))),
   Pair(EqualToLSPDiag(NoteInMainLSP), IsEmpty(;
+  EXPECT_EQ(LSPDiags[0].first.code, "err_enum_class_reference");
+  EXPECT_EQ(LSPDiags[1].first.code, "");
 }
 
 struct SymbolWithHeader {
Index: test/clangd/fixits-embed-in-diagnostic.test
===
--- test/clangd/fixits-embed-in-diagnostic.test
+++ test/clangd/fixits-embed-in-diagnostic.test
@@ -6,6 +6,7 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
+# CHECK-NEXT:"code": "err_use_with_wrong_tag",
 # CHECK-NEXT:"codeActions": [
 # CHECK-NEXT:  {
 # CHECK-NEXT:"edit": {
Index: test/clangd/fixits-command.test
===
--- test/clangd/fixits-command.test
+++ test/clangd/fixits-command.test
@@ -6,6 +6,7 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
+# CHECK-NEXT:"code": "warn_condition_is_assignment",
 # CHECK-NEXT:"message": "Using the result of an assignment as a condition without parentheses (fixes available)",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
Index: test/clangd/fixits-codeaction.test
===
--- test/clangd/fixits-codeaction.test
+++ test/clangd/fixits-codeaction.test
@@ -6,6 +6,7 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
+# CHECK-NEXT:"code": "warn_condition_is_assignment",
 # CHECK-NEXT:"message": "Using the result of an assignment as a condition without parentheses (fixes available)",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
@@ -23,13 +24,14 @@
 # CHECK-NEXT:"uri": "file://{{.*}}/foo.c"
 # CHECK-NEXT:  }
 ---
-{"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"test:///foo.c"},"range":{"start":{"line":0,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 37}},"severity":2,"message":"Using the result of an assignment as a condition without parentheses (fixes available)"}]}}}
+{"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"test:///foo.c"},"range":{"start":{"line":0,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 37}},"severity":2,"message":"Using the result of an assignment as a condition without parentheses (fixes available)", "code": "warn_condition_is_assignment"}]}}}
 #  CHECK:  "id": 2,
 # CHECK-NEXT:  "jsonrpc": "2.0",
 # CHECK-NEXT:  "result": [
 # CHECK-NEXT:{
 # CHECK-NEXT:  "diagnostics": [
 # CHECK-NEXT:{
+# CHECK-NEXT:  "code": "warn_condition_is_assignment",
 # CHECK-NEXT:  "message": "Using the result of an assignment as a condition without parentheses (fixes available)",
 # CHECK-NEXT:  "range": {
 # CHECK-NEXT:"end": {
@@ -82,6 +84,7 @@
 # CHECK-NEXT:{
 # CHECK-NEXT:  "diagnostics": [
 # CHECK-NEXT:{
+# CHECK-NEXT:  "code": "warn_condition_is_assignment",
 # CHECK-NEXT:  "message": "Using the result of an assignment as a condition without parentheses (fixes available)",
 # CHECK-NEXT:  "range": {
 # CHECK-NEXT:"end": {
Index: test/clangd/execute-command.test

Re: r354075 - [clang][FileManager] fillRealPathName even if we aren't opening the file

2019-02-15 Thread Galina Kistanova via cfe-commits
Hello Jan,

It looks like this commit broke tests on couple of win builders:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/23655
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win
. . .
Failing Tests (1):
Clang-Unit ::
Basic/./BasicTests.exe/FileManagerTest.getFileDontOpenRealPath

Please have a look ASAP?

Thanks

Galina

On Thu, Feb 14, 2019 at 3:02 PM Jan Korous via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: jkorous
> Date: Thu Feb 14 15:02:35 2019
> New Revision: 354075
>
> URL: http://llvm.org/viewvc/llvm-project?rev=354075&view=rev
> Log:
> [clang][FileManager] fillRealPathName even if we aren't opening the file
>
> The pathname wasn't previously filled when the getFile() method was called
> with openFile = false.
> We are caching FileEntry-s in ParsedAST::Includes in clangd and this
> caused the problem.
>
> This fixes an internal test failure in clangd - ClangdTests.GoToInclude.All
>
> rdar://47536127
>
> Differential Revision: https://reviews.llvm.org/D58213
>
> Modified:
> cfe/trunk/lib/Basic/FileManager.cpp
> cfe/trunk/unittests/Basic/FileManagerTest.cpp
>
> Modified: cfe/trunk/lib/Basic/FileManager.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=354075&r1=354074&r2=354075&view=diff
>
> ==
> --- cfe/trunk/lib/Basic/FileManager.cpp (original)
> +++ cfe/trunk/lib/Basic/FileManager.cpp Thu Feb 14 15:02:35 2019
> @@ -267,6 +267,9 @@ const FileEntry *FileManager::getFile(St
>if (UFE.File) {
>  if (auto PathName = UFE.File->getName())
>fillRealPathName(&UFE, *PathName);
> +  } else if (!openFile) {
> +// We should still fill the path even if we aren't opening the file.
> +fillRealPathName(&UFE, InterndFileName);
>}
>return &UFE;
>  }
>
> Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=354075&r1=354074&r2=354075&view=diff
>
> ==
> --- cfe/trunk/unittests/Basic/FileManagerTest.cpp (original)
> +++ cfe/trunk/unittests/Basic/FileManagerTest.cpp Thu Feb 14 15:02:35 2019
> @@ -346,4 +346,18 @@ TEST_F(FileManagerTest, getVirtualFileFi
>EXPECT_EQ(file->tryGetRealPathName(), ExpectedResult);
>  }
>
> +TEST_F(FileManagerTest, getFileDontOpenRealPath) {
> +  auto statCache = llvm::make_unique();
> +  statCache->InjectDirectory("/tmp/abc", 42);
> +  SmallString<64> Path("/tmp/abc/foo.cpp");
> +  statCache->InjectFile(Path.str().str().c_str(), 43);
> +  manager.setStatCache(std::move(statCache));
> +
> +  const FileEntry *file = manager.getFile(Path, /*openFile=*/false);
> +
> +  ASSERT_TRUE(file != nullptr);
> +
> +  ASSERT_EQ(file->tryGetRealPathName(), Path);
> +}
> +
>  } // anonymous namespace
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-02-15 Thread Khem Raj via Phabricator via cfe-commits
raj.khem added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:476
   for (const auto &Entry : DebugPrefixMap)
-if (Path.startswith(Entry.first))
-  return (Twine(Entry.second) + Path.substr(Entry.first.size())).str();
-  return Path.str();
+if (llvm::sys::path::replace_path_prefix(p, Entry.first, Entry.second))
+  break;

looking at llvm/lib/Support/Path.cpp replace_path_prefix() returns void but 
here inside if() it will expect a bool return value 


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D49466/new/

https://reviews.llvm.org/D49466



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


[PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-02-15 Thread Khem Raj via Phabricator via cfe-commits
raj.khem added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:476
   for (const auto &Entry : DebugPrefixMap)
-if (Path.startswith(Entry.first))
-  return (Twine(Entry.second) + Path.substr(Entry.first.size())).str();
-  return Path.str();
+if (llvm::sys::path::replace_path_prefix(p, Entry.first, Entry.second))
+  break;

raj.khem wrote:
> looking at llvm/lib/Support/Path.cpp replace_path_prefix() returns void but 
> here inside if() it will expect a bool return value 
nm I guess I needed to look into https://reviews.llvm.org/D56769 as well.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D49466/new/

https://reviews.llvm.org/D49466



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


[PATCH] D58074: [OpenMP 5.0] Parsing/sema support for map clause with mapper modifier

2019-02-15 Thread Lingda Li via Phabricator via cfe-commits
lildmh added inline comments.



Comment at: include/clang/AST/OpenMPClause.h:3682-3685
+  OpenMPClauseKind K, SourceLocation StartLoc, SourceLocation LParenLoc,
+  SourceLocation EndLoc, OMPMappableExprListSizeTy Sizes,
+  NestedNameSpecifierLoc *MapperQualifierLocP = nullptr,
+  DeclarationNameInfo *MapperIdInfoP = nullptr)

ABataev wrote:
> I think it is worth to add `SourceLocation StartLoc`, `SourceLocation 
> LParenLoc`, `SourceLocation EndLoc`, to `OMPMappableExprListSizeTy`. Of 
> course, you need to rename the structure, something like 
> `OMPMappableClauseData` is good enough. Or you can pack them into a different 
> structure.
I put `StartLoc`, `LParenLoc`, `EndLoc` into another struct 
`OMPMappableExprListLocTy`. I didn't combine them with 
`OMPMappableExprListSizeTy`, because some fuctions only use one of them, and 
some other functions use both of them.

Also modify `to`, `from`, `is_device`, and `use_device` clauses to use the same 
interfaces.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58074/new/

https://reviews.llvm.org/D58074



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


[PATCH] D58297: [Sema] SequenceChecker: C++17 sequencing rules for built-in operators <<, >>, .*, ->*, =, op=

2019-02-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno created this revision.
riccibruno added reviewers: rsmith, rjmccall, aaron.ballman.
riccibruno added a project: clang.
Herald added subscribers: cfe-commits, jdoerfert.

Implement the C++17 sequencing rules for the built-in operators `<<`, `>>`, 
`.*`, `->*`, `=` and `op=`.


Repository:
  rC Clang

https://reviews.llvm.org/D58297

Files:
  lib/Sema/SemaChecking.cpp
  test/SemaCXX/warn-unsequenced.cpp

Index: test/SemaCXX/warn-unsequenced.cpp
===
--- test/SemaCXX/warn-unsequenced.cpp
+++ test/SemaCXX/warn-unsequenced.cpp
@@ -24,7 +24,6 @@
   a + a++; // cxx11-warning {{unsequenced modification and access to 'a'}}
// cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   a = a++; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
-   // TODO cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
   ++ ++a; // ok
   (a++, a++); // ok
   ++a + ++a; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
@@ -34,13 +33,10 @@
   (a++, a) = 0; // ok, increment is sequenced before value computation of LHS
   a = xs[++a]; // ok
   a = xs[a++]; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
-   // TODO cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
   (a ? xs[0] : xs[1]) = ++a; // cxx11-warning {{unsequenced modification and access to 'a'}}
- // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   a = (++a, ++a); // ok
   a = (a++, ++a); // ok
   a = (a++, a++); // cxx11-warning {{multiple unsequenced modifications to 'a'}}
-  // TODO cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
   f(a, a); // ok
   f(a = 0, a); // cxx11-warning {{unsequenced modification and access to 'a'}}
// cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
@@ -59,7 +55,6 @@
   (++a, a) += 1; // ok
   a = ++a; // ok
   a += ++a; // cxx11-warning {{unsequenced modification and access to 'a'}}
-// TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
 
   A agg1 = { a++, a++ }; // ok
   A agg2 = { a++ + a, a++ }; // cxx11-warning {{unsequenced modification and access to 'a'}}
@@ -75,7 +70,6 @@
   a = S { ++a, a++ }.n; // ok
   A { ++a, a++ }.x; // ok
   a = A { ++a, a++ }.x; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
-// TODO cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
   A { ++a, a++ }.x + A { ++a, a++ }.y; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
// cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
 
@@ -110,14 +104,10 @@
   a += (a++, a) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
  // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
 
-  int *p = xs;
-  a = *(a++, p); // ok
   a = a++ && a; // ok
-  p[(long long unsigned)(p = 0)]; // cxx11-warning {{unsequenced modification and access to 'p'}}
 
   A *q = &agg1;
   (q = &agg2)->y = q->x; // cxx11-warning {{unsequenced modification and access to 'q'}}
- // TODO cxx17-warning@-1 {{unsequenced modification and access to 'q'}}
 
   // This has undefined behavior if a == 0; otherwise, the side-effect of the
   // increment is sequenced before the value computation of 'f(a, a)', which is
@@ -145,20 +135,14 @@
   xs[8] ? ++a : a++; // no-warning
   xs[8] ? a+=1 : a+= 2; // no-warning
   (xs[8] ? a+=1 : a+= 2) = a; // cxx11-warning {{unsequenced modification and access to 'a'}}
-  // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (xs[8] ? a+=1 : a) = a; // cxx11-warning {{unsequenced modification and access to 'a'}}
-  // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (xs[8] ? a : a+= 2) = a; // cxx11-warning {{unsequenced modification and access to 'a'}}
-   // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   a = (xs[8] ? a+=1 : a+= 2); // no-warning
   a += (xs[8] ? a+=1 : a+= 2); // cxx11-warning {{unsequenced modification and access to 'a'}}
-   // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
 
   (false ? a+=1 : a) = a; // no-warning
   (true ? a+=1 : a) = a; // cxx11-warning {{unsequenced modification and access to 'a'}}
- // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (false ? a : a+=2) = a; // cxx11-warning {{unsequenced modification and access to 'a'}}
-  // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (true ? a : a+=2) = a; // no-warning
 
   xs[8] && (++a + a++); // cxx11-warning {{multiple unsequenced modifications to 'a'}}
@@ -178,19 +162,15 @@
   a = ((a++, false

[PATCH] D57747: [Sema] SequenceChecker: Fix handling of operator ||, && and ?:

2019-02-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 187057.
riccibruno marked an inline comment as done.
riccibruno added a comment.
Herald added a subscriber: jdoerfert.

Rebased


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57747/new/

https://reviews.llvm.org/D57747

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/warn-unsequenced.c
  test/SemaCXX/warn-unsequenced.cpp

Index: test/SemaCXX/warn-unsequenced.cpp
===
--- test/SemaCXX/warn-unsequenced.cpp
+++ test/SemaCXX/warn-unsequenced.cpp
@@ -2,6 +2,8 @@
 // RUN: %clang_cc1 -fsyntax-only -verify=cxx17 -std=c++17 -Wno-unused -Wno-uninitialized -Wunsequenced %s
 
 int f(int, int = 0);
+int g1();
+int g2(int);
 
 struct A {
   int x, y;
@@ -77,24 +79,28 @@
   A { ++a, a++ }.x + A { ++a, a++ }.y; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
// cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
 
-  (xs[2] && (a = 0)) + a; // ok
+  (xs[2] && (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
+  // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (0 && (a = 0)) + a; // ok
   (1 && (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
 
-  (xs[3] || (a = 0)) + a; // ok
+  (xs[3] || (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
+  // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (0 || (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (1 || (a = 0)) + a; // ok
 
-  (xs[4] ? a : ++a) + a; // ok
+  (xs[4] ? a : ++a) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
+ // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (0 ? a : ++a) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
  // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (1 ? a : ++a) + a; // ok
   (0 ? a : a++) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
  // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (1 ? a : a++) + a; // ok
-  (xs[5] ? ++a : ++a) + a; // FIXME: warn here
+  (xs[5] ? ++a : ++a) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
+   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
 
   (++a, xs[6] ? ++a : 0) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
@@ -120,10 +126,13 @@
   // unconditional.
   a = a++ && f(a, a);
 
-  // This has undefined behavior if a != 0. FIXME: We should diagnose this.
-  (a && a++) + a;
+  // This has undefined behavior if a != 0.
+  (a && a++) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
+  // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
 
-  (xs[7] && ++a) * (!xs[7] && ++a); // ok
+  // FIXME: Don't warn here.
+  (xs[7] && ++a) * (!xs[7] && ++a); // cxx11-warning {{multiple unsequenced modifications to 'a'}}
+// cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
 
   xs[0] = (a = 1, a); // ok
   (a -= 128) &= 128; // ok
@@ -133,13 +142,64 @@
  // cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
   xs[8] ? 0 : ++a + a++; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
  // cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
-  xs[8] ? ++a : a++; // ok
+  xs[8] ? ++a : a++; // no-warning
+  xs[8] ? a+=1 : a+= 2; // no-warning
+  (xs[8] ? a+=1 : a+= 2) = a; // cxx11-warning {{unsequenced modification and access to 'a'}}
+  // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
+  (xs[8] ? a+=1 : a) = a; // cxx11-warning {{unsequenced modification and access to 'a'}}
+  // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
+  (xs[8] ? a : a+= 2) = a; // cxx11-warning {{unsequenced modification and access to 'a'}}
+   // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
+  a = (xs[8] ? a+=1 : a+= 2); // no-warning
+  a += (xs[8] ? a+=1 : a+= 2); // cxx11-warning {{unsequenced modification and access to 'a'}}
+   // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
+
+  (false ? a+=1 : a) = a; // no-warning
+  (true ? a+=1 : a) = a; // cxx11-warning {{unsequenced modification and access to 'a'}}
+

r354162 - [MSVC] Recognize `static_assert` keyword in C and C++98

2019-02-15 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Feb 15 11:59:45 2019
New Revision: 354162

URL: http://llvm.org/viewvc/llvm-project?rev=354162&view=rev
Log:
[MSVC] Recognize `static_assert` keyword in C and C++98

Summary:
The main effect is that clang now accepts the following conforming C11
code with MSVC headers:
  #include 
  static_assert(1, "true");

This is a non-conforming extension (the keyword is outside the
implementer's namespace), so it is placed under -fms-compatibility
instead of -fms-extensions like most MSVC-specific keyword extensions.

Normally, in C11, the compiler is supposed to provide the _Static_assert
keyword, and assert.h should define static_assert to _Static_assert.
However, that is not what MSVC does, and MSVC doesn't even provide
_Static_assert.

This also has the less important side effect of enabling static_assert
in C++98 mode with -fms-compatibility. It's exceptionally difficult to
use modern MSVC headers without C++14 even, so this is relatively
unimportant.

Fixes PR26672

Patch by Andrey Bokhanko!

Reviewers: rsmith, thakis

Subscribers: cfe-commits, STL_MSFT

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

Modified:
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/lib/Basic/IdentifierTable.cpp
cfe/trunk/test/Lexer/keywords_test.c
cfe/trunk/test/Lexer/keywords_test.cpp

Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=354162&r1=354161&r2=354162&view=diff
==
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Fri Feb 15 11:59:45 2019
@@ -243,6 +243,7 @@ PUNCTUATOR(caretcaret,"^^")
 //are enabled.
 //   KEYGNU   - This is a keyword if GNU extensions are enabled
 //   KEYMS- This is a keyword if Microsoft extensions are enabled
+//   KEYMSCOMPAT - This is a keyword if Microsoft compatibility mode is enabled
 //   KEYNOMS18 - This is a keyword that must never be enabled under
 //   MSVC <= v18.
 //   KEYOPENCLC   - This is a keyword in OpenCL C
@@ -363,7 +364,7 @@ CXX11_KEYWORD(constexpr , 0)
 CXX11_KEYWORD(decltype  , 0)
 CXX11_KEYWORD(noexcept  , 0)
 CXX11_KEYWORD(nullptr   , 0)
-CXX11_KEYWORD(static_assert , 0)
+CXX11_KEYWORD(static_assert , KEYMSCOMPAT)
 CXX11_KEYWORD(thread_local  , 0)
 
 // C++2a / concepts TS keywords

Modified: cfe/trunk/lib/Basic/IdentifierTable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/IdentifierTable.cpp?rev=354162&r1=354161&r2=354162&view=diff
==
--- cfe/trunk/lib/Basic/IdentifierTable.cpp (original)
+++ cfe/trunk/lib/Basic/IdentifierTable.cpp Fri Feb 15 11:59:45 2019
@@ -99,6 +99,7 @@ namespace {
 KEYMODULES= 0x10,
 KEYCXX2A  = 0x20,
 KEYOPENCLCXX  = 0x40,
+KEYMSCOMPAT   = 0x80,
 KEYALLCXX = KEYCXX | KEYCXX11 | KEYCXX2A,
 KEYALL = (0xff & ~KEYNOMS18 &
   ~KEYNOOPENCL) // KEYNOMS18 and KEYNOOPENCL are used to exclude.
@@ -125,6 +126,7 @@ static KeywordStatus getKeywordStatus(co
   if (LangOpts.C99 && (Flags & KEYC99)) return KS_Enabled;
   if (LangOpts.GNUKeywords && (Flags & KEYGNU)) return KS_Extension;
   if (LangOpts.MicrosoftExt && (Flags & KEYMS)) return KS_Extension;
+  if (LangOpts.MSVCCompat && (Flags & KEYMSCOMPAT)) return KS_Enabled;
   if (LangOpts.Borland && (Flags & KEYBORLAND)) return KS_Extension;
   if (LangOpts.Bool && (Flags & BOOLSUPPORT)) return KS_Enabled;
   if (LangOpts.Half && (Flags & HALFSUPPORT)) return KS_Enabled;

Modified: cfe/trunk/test/Lexer/keywords_test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/keywords_test.c?rev=354162&r1=354161&r2=354162&view=diff
==
--- cfe/trunk/test/Lexer/keywords_test.c (original)
+++ cfe/trunk/test/Lexer/keywords_test.c Fri Feb 15 11:59:45 2019
@@ -7,7 +7,7 @@
 // RUN: %clang_cc1 -std=gnu89 -fno-gnu-keywords -E %s -o - \
 // RUN: | FileCheck --check-prefix=CHECK-NONE %s
 
-// RUN: %clang_cc1 -std=c99 -fms-extensions -E %s -o - \
+// RUN: %clang_cc1 -std=c99 -fms-extensions -fms-compatibility -E %s -o - \
 // RUN: | FileCheck --check-prefix=CHECK-MS-KEYWORDS %s
 // RUN: %clang_cc1 -std=c99 -fdeclspec -E %s -o - \
 // RUN: | FileCheck --check-prefix=CHECK-DECLSPEC-KEYWORD %s
@@ -42,3 +42,13 @@ void no_declspec();
 #else
 void has_declspec();
 #endif
+
+// CHECK-NONE: no_static_assert
+// CHECK-GNU-KEYWORDS: no_static_assert
+// CHECK-MS-KEYWORDS: has_static_assert
+// CHECK-MS-KEYWORDS-WITHOUT-DECLSPEC: no_static_assert
+#if __is_identifier(static_assert)
+void no_static_assert();
+#else
+void has_static_assert();
+#endif

Modified: cfe/trunk/test/Lexer/keywords_test.cpp
URL:

[PATCH] D17444: [MSVC] Recognize "static_assert" keyword in C mode

2019-02-15 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC354162: [MSVC] Recognize `static_assert` keyword in C and 
C++98 (authored by rnk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D17444?vs=186741&id=187061#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D17444/new/

https://reviews.llvm.org/D17444

Files:
  include/clang/Basic/TokenKinds.def
  lib/Basic/IdentifierTable.cpp
  test/Lexer/keywords_test.c
  test/Lexer/keywords_test.cpp


Index: include/clang/Basic/TokenKinds.def
===
--- include/clang/Basic/TokenKinds.def
+++ include/clang/Basic/TokenKinds.def
@@ -243,6 +243,7 @@
 //are enabled.
 //   KEYGNU   - This is a keyword if GNU extensions are enabled
 //   KEYMS- This is a keyword if Microsoft extensions are enabled
+//   KEYMSCOMPAT - This is a keyword if Microsoft compatibility mode is enabled
 //   KEYNOMS18 - This is a keyword that must never be enabled under
 //   MSVC <= v18.
 //   KEYOPENCLC   - This is a keyword in OpenCL C
@@ -363,7 +364,7 @@
 CXX11_KEYWORD(decltype  , 0)
 CXX11_KEYWORD(noexcept  , 0)
 CXX11_KEYWORD(nullptr   , 0)
-CXX11_KEYWORD(static_assert , 0)
+CXX11_KEYWORD(static_assert , KEYMSCOMPAT)
 CXX11_KEYWORD(thread_local  , 0)
 
 // C++2a / concepts TS keywords
Index: test/Lexer/keywords_test.cpp
===
--- test/Lexer/keywords_test.cpp
+++ test/Lexer/keywords_test.cpp
@@ -11,9 +11,9 @@
 // RUN: %clang_cc1 -std=c++03 -fdeclspec -fno-declspec -fsyntax-only %s
 // RUN: %clang_cc1 -std=c++03 -fms-extensions -fno-declspec -fdeclspec 
-DDECLSPEC -fsyntax-only %s
 // RUN: %clang_cc1 -std=c++03 -fms-extensions -fdeclspec -fno-declspec 
-fsyntax-only %s
-// RUN: %clang -std=c++03 -target i686-windows-msvc -DDECLSPEC -fsyntax-only %s
+// RUN: %clang -std=c++03 -target i686-windows-msvc -DMS -DDECLSPEC 
-fsyntax-only %s
 // RUN: %clang -std=c++03 -target x86_64-scei-ps4 -DDECLSPEC -fsyntax-only %s
-// RUN: %clang -std=c++03 -target i686-windows-msvc -fno-declspec 
-fsyntax-only %s
+// RUN: %clang -std=c++03 -target i686-windows-msvc -DMS -fno-declspec 
-fsyntax-only %s
 // RUN: %clang -std=c++03 -target x86_64-scei-ps4 -fno-declspec -fsyntax-only 
%s
 
 #define IS_KEYWORD(NAME) _Static_assert(!__is_identifier(NAME), #NAME)
@@ -51,7 +51,12 @@
 CXX11_TYPE(char32_t);
 CXX11_KEYWORD(constexpr);
 CXX11_KEYWORD(noexcept);
+#ifndef MS
 CXX11_KEYWORD(static_assert);
+#else
+// MS compiler recognizes static_assert in all modes. So should we.
+IS_KEYWORD(static_assert);
+#endif
 CXX11_KEYWORD(thread_local);
 
 // Concepts TS keywords
Index: test/Lexer/keywords_test.c
===
--- test/Lexer/keywords_test.c
+++ test/Lexer/keywords_test.c
@@ -7,7 +7,7 @@
 // RUN: %clang_cc1 -std=gnu89 -fno-gnu-keywords -E %s -o - \
 // RUN: | FileCheck --check-prefix=CHECK-NONE %s
 
-// RUN: %clang_cc1 -std=c99 -fms-extensions -E %s -o - \
+// RUN: %clang_cc1 -std=c99 -fms-extensions -fms-compatibility -E %s -o - \
 // RUN: | FileCheck --check-prefix=CHECK-MS-KEYWORDS %s
 // RUN: %clang_cc1 -std=c99 -fdeclspec -E %s -o - \
 // RUN: | FileCheck --check-prefix=CHECK-DECLSPEC-KEYWORD %s
@@ -42,3 +42,13 @@
 #else
 void has_declspec();
 #endif
+
+// CHECK-NONE: no_static_assert
+// CHECK-GNU-KEYWORDS: no_static_assert
+// CHECK-MS-KEYWORDS: has_static_assert
+// CHECK-MS-KEYWORDS-WITHOUT-DECLSPEC: no_static_assert
+#if __is_identifier(static_assert)
+void no_static_assert();
+#else
+void has_static_assert();
+#endif
Index: lib/Basic/IdentifierTable.cpp
===
--- lib/Basic/IdentifierTable.cpp
+++ lib/Basic/IdentifierTable.cpp
@@ -99,6 +99,7 @@
 KEYMODULES= 0x10,
 KEYCXX2A  = 0x20,
 KEYOPENCLCXX  = 0x40,
+KEYMSCOMPAT   = 0x80,
 KEYALLCXX = KEYCXX | KEYCXX11 | KEYCXX2A,
 KEYALL = (0xff & ~KEYNOMS18 &
   ~KEYNOOPENCL) // KEYNOMS18 and KEYNOOPENCL are used to exclude.
@@ -125,6 +126,7 @@
   if (LangOpts.C99 && (Flags & KEYC99)) return KS_Enabled;
   if (LangOpts.GNUKeywords && (Flags & KEYGNU)) return KS_Extension;
   if (LangOpts.MicrosoftExt && (Flags & KEYMS)) return KS_Extension;
+  if (LangOpts.MSVCCompat && (Flags & KEYMSCOMPAT)) return KS_Enabled;
   if (LangOpts.Borland && (Flags & KEYBORLAND)) return KS_Extension;
   if (LangOpts.Bool && (Flags & BOOLSUPPORT)) return KS_Enabled;
   if (LangOpts.Half && (Flags & HALFSUPPORT)) return KS_Enabled;


Index: include/clang/Basic/TokenKinds.def
===
--- include/clang/Basic/TokenKinds.def
+++ include/clang/Basic/TokenKinds.def
@@ -243,6 +243,7 @@
 //are enabled.
 //   KEYGNU   - This is a keyword 

[PATCH] D58074: [OpenMP 5.0] Parsing/sema support for map clause with mapper modifier

2019-02-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: include/clang/AST/OpenMPClause.h:3666
+  OMPMappableExprListClause(
+  OpenMPClauseKind K, OMPMappableExprListLocTy Locs,
+  OMPMappableExprListSizeTy Sizes,

Pass those new structures by const reference, not by value. Do this for all the 
functions.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58074/new/

https://reviews.llvm.org/D58074



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


[PATCH] D58292: Add support for importing ChooseExpr AST nodes.

2019-02-15 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

This looks reasonable, I will wait for @martong and/or @a_sidorin to review.

FYI LLDB is the other big user of ASTImpoter so it is helpful if you can run 
`check-lldb` especially on MacOS so you can to catch regressions before 
committing. After committing please make sure to monitor the GreenDragon build 
bots:

  http://lab.llvm.org:8080/green/view/LLDB/

Thank you!


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58292/new/

https://reviews.llvm.org/D58292



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


r354164 - [ObjC] Fix non-canonical types preventing type arguments substitution.

2019-02-15 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Fri Feb 15 12:17:45 2019
New Revision: 354164

URL: http://llvm.org/viewvc/llvm-project?rev=354164&view=rev
Log:
[ObjC] Fix non-canonical types preventing type arguments substitution.

`QualType::substObjCTypeArgs` doesn't go past non-canonical types and as
the result misses some of the substitutions like `ObjCTypeParamType`.

Update `SimpleTransformVisitor` to traverse past the type sugar.

Reviewers: ahatanak, erik.pilkington

Reviewed By: erik.pilkington

Subscribers: jkorous, dexonsmith, cfe-commits

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


Modified:
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/test/SemaObjC/parameterized_classes_subst.m

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=354164&r1=354163&r2=354164&view=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Fri Feb 15 12:17:45 2019
@@ -752,6 +752,17 @@ public:
 
 #define TRIVIAL_TYPE_CLASS(Class) \
   QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
+#define SUGARED_TYPE_CLASS(Class) \
+  QualType Visit##Class##Type(const Class##Type *T) { \
+if (!T->isSugared()) \
+  return QualType(T, 0); \
+QualType desugaredType = recurse(T->desugar()); \
+if (desugaredType.isNull()) \
+  return {}; \
+if (desugaredType.getAsOpaquePtr() == T->desugar().getAsOpaquePtr()) \
+  return QualType(T, 0); \
+return desugaredType; \
+  }
 
   TRIVIAL_TYPE_CLASS(Builtin)
 
@@ -955,8 +966,8 @@ public:
 return Ctx.getParenType(innerType);
   }
 
-  TRIVIAL_TYPE_CLASS(Typedef)
-  TRIVIAL_TYPE_CLASS(ObjCTypeParam)
+  SUGARED_TYPE_CLASS(Typedef)
+  SUGARED_TYPE_CLASS(ObjCTypeParam)
 
   QualType VisitAdjustedType(const AdjustedType *T) {
 QualType originalType = recurse(T->getOriginalType());
@@ -987,15 +998,15 @@ public:
 return Ctx.getDecayedType(originalType);
   }
 
-  TRIVIAL_TYPE_CLASS(TypeOfExpr)
-  TRIVIAL_TYPE_CLASS(TypeOf)
-  TRIVIAL_TYPE_CLASS(Decltype)
-  TRIVIAL_TYPE_CLASS(UnaryTransform)
+  SUGARED_TYPE_CLASS(TypeOfExpr)
+  SUGARED_TYPE_CLASS(TypeOf)
+  SUGARED_TYPE_CLASS(Decltype)
+  SUGARED_TYPE_CLASS(UnaryTransform)
   TRIVIAL_TYPE_CLASS(Record)
   TRIVIAL_TYPE_CLASS(Enum)
 
   // FIXME: Non-trivial to implement, but important for C++
-  TRIVIAL_TYPE_CLASS(Elaborated)
+  SUGARED_TYPE_CLASS(Elaborated)
 
   QualType VisitAttributedType(const AttributedType *T) {
 QualType modifiedType = recurse(T->getModifiedType());
@@ -1030,7 +1041,7 @@ public:
   }
 
   // FIXME: Non-trivial to implement, but important for C++
-  TRIVIAL_TYPE_CLASS(TemplateSpecialization)
+  SUGARED_TYPE_CLASS(TemplateSpecialization)
 
   QualType VisitAutoType(const AutoType *T) {
 if (!T->isDeduced())
@@ -1049,7 +1060,7 @@ public:
   }
 
   // FIXME: Non-trivial to implement, but important for C++
-  TRIVIAL_TYPE_CLASS(PackExpansion)
+  SUGARED_TYPE_CLASS(PackExpansion)
 
   QualType VisitObjCObjectType(const ObjCObjectType *T) {
 QualType baseType = recurse(T->getBaseType());
@@ -1107,6 +1118,7 @@ public:
   }
 
 #undef TRIVIAL_TYPE_CLASS
+#undef SUGARED_TYPE_CLASS
 };
 
 } // namespace

Modified: cfe/trunk/test/SemaObjC/parameterized_classes_subst.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/parameterized_classes_subst.m?rev=354164&r1=354163&r2=354164&view=diff
==
--- cfe/trunk/test/SemaObjC/parameterized_classes_subst.m (original)
+++ cfe/trunk/test/SemaObjC/parameterized_classes_subst.m Fri Feb 15 12:17:45 
2019
@@ -104,6 +104,12 @@ __attribute__((objc_root_class))
 @property (nonatomic,retain) ViewType view;
 @end
 
+@interface TypedefTypeParam : NSObject
+typedef T AliasT;
+- (void)test:(AliasT)object;
+// expected-note@-1 {{parameter 'object' here}}
+@end
+
 // --
 // Nullability
 // --
@@ -190,6 +196,7 @@ void test_message_send_param(
MutableSetOfArrays *mutStringArraySet,
NSMutableSet *mutSet,
MutableSetOfArrays *mutArraySet,
+   TypedefTypeParam *typedefTypeParam,
void (^block)(void)) {
   Window *window;
 
@@ -199,6 +206,7 @@ void test_message_send_param(
   [mutStringArraySet addObject: window]; // expected-warning{{parameter of 
type 'NSArray *'}}
   [mutSet addObject: window]; // expected-warning{{parameter of incompatible 
type 'id'}}
   [mutArraySet addObject: window]; // expected-warning{{parameter of 
incompatible type 'id'}}
+  [typedefTypeParam test: window]; // expected-warning{{parameter of type 
'NSString *'}}
   [block addObject: window]; // expected-warning{{parameter of incompatible 
type 'id'}}
 }
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.or

[PATCH] D58292: Add support for importing ChooseExpr AST nodes.

2019-02-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.

Please be sure to update Registry.cpp to expose the new AST matcher to the 
dynamic matcher infrastructure, regenerate the AST matcher documentation (run 
clang\docs\tools\dump_ast_matchers.py), and add tests for the matcher.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58292/new/

https://reviews.llvm.org/D58292



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


[PATCH] D57270: [ObjC] Fix non-canonical types preventing type arguments substitution.

2019-02-15 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354164: [ObjC] Fix non-canonical types preventing type 
arguments substitution. (authored by vsapsai, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57270?vs=183664&id=187063#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57270/new/

https://reviews.llvm.org/D57270

Files:
  cfe/trunk/lib/AST/Type.cpp
  cfe/trunk/test/SemaObjC/parameterized_classes_subst.m

Index: cfe/trunk/test/SemaObjC/parameterized_classes_subst.m
===
--- cfe/trunk/test/SemaObjC/parameterized_classes_subst.m
+++ cfe/trunk/test/SemaObjC/parameterized_classes_subst.m
@@ -104,6 +104,12 @@
 @property (nonatomic,retain) ViewType view;
 @end
 
+@interface TypedefTypeParam : NSObject
+typedef T AliasT;
+- (void)test:(AliasT)object;
+// expected-note@-1 {{parameter 'object' here}}
+@end
+
 // --
 // Nullability
 // --
@@ -190,6 +196,7 @@
MutableSetOfArrays *mutStringArraySet,
NSMutableSet *mutSet,
MutableSetOfArrays *mutArraySet,
+   TypedefTypeParam *typedefTypeParam,
void (^block)(void)) {
   Window *window;
 
@@ -199,6 +206,7 @@
   [mutStringArraySet addObject: window]; // expected-warning{{parameter of type 'NSArray *'}}
   [mutSet addObject: window]; // expected-warning{{parameter of incompatible type 'id'}}
   [mutArraySet addObject: window]; // expected-warning{{parameter of incompatible type 'id'}}
+  [typedefTypeParam test: window]; // expected-warning{{parameter of type 'NSString *'}}
   [block addObject: window]; // expected-warning{{parameter of incompatible type 'id'}}
 }
 
Index: cfe/trunk/lib/AST/Type.cpp
===
--- cfe/trunk/lib/AST/Type.cpp
+++ cfe/trunk/lib/AST/Type.cpp
@@ -752,6 +752,17 @@
 
 #define TRIVIAL_TYPE_CLASS(Class) \
   QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
+#define SUGARED_TYPE_CLASS(Class) \
+  QualType Visit##Class##Type(const Class##Type *T) { \
+if (!T->isSugared()) \
+  return QualType(T, 0); \
+QualType desugaredType = recurse(T->desugar()); \
+if (desugaredType.isNull()) \
+  return {}; \
+if (desugaredType.getAsOpaquePtr() == T->desugar().getAsOpaquePtr()) \
+  return QualType(T, 0); \
+return desugaredType; \
+  }
 
   TRIVIAL_TYPE_CLASS(Builtin)
 
@@ -955,8 +966,8 @@
 return Ctx.getParenType(innerType);
   }
 
-  TRIVIAL_TYPE_CLASS(Typedef)
-  TRIVIAL_TYPE_CLASS(ObjCTypeParam)
+  SUGARED_TYPE_CLASS(Typedef)
+  SUGARED_TYPE_CLASS(ObjCTypeParam)
 
   QualType VisitAdjustedType(const AdjustedType *T) {
 QualType originalType = recurse(T->getOriginalType());
@@ -987,15 +998,15 @@
 return Ctx.getDecayedType(originalType);
   }
 
-  TRIVIAL_TYPE_CLASS(TypeOfExpr)
-  TRIVIAL_TYPE_CLASS(TypeOf)
-  TRIVIAL_TYPE_CLASS(Decltype)
-  TRIVIAL_TYPE_CLASS(UnaryTransform)
+  SUGARED_TYPE_CLASS(TypeOfExpr)
+  SUGARED_TYPE_CLASS(TypeOf)
+  SUGARED_TYPE_CLASS(Decltype)
+  SUGARED_TYPE_CLASS(UnaryTransform)
   TRIVIAL_TYPE_CLASS(Record)
   TRIVIAL_TYPE_CLASS(Enum)
 
   // FIXME: Non-trivial to implement, but important for C++
-  TRIVIAL_TYPE_CLASS(Elaborated)
+  SUGARED_TYPE_CLASS(Elaborated)
 
   QualType VisitAttributedType(const AttributedType *T) {
 QualType modifiedType = recurse(T->getModifiedType());
@@ -1030,7 +1041,7 @@
   }
 
   // FIXME: Non-trivial to implement, but important for C++
-  TRIVIAL_TYPE_CLASS(TemplateSpecialization)
+  SUGARED_TYPE_CLASS(TemplateSpecialization)
 
   QualType VisitAutoType(const AutoType *T) {
 if (!T->isDeduced())
@@ -1049,7 +1060,7 @@
   }
 
   // FIXME: Non-trivial to implement, but important for C++
-  TRIVIAL_TYPE_CLASS(PackExpansion)
+  SUGARED_TYPE_CLASS(PackExpansion)
 
   QualType VisitObjCObjectType(const ObjCObjectType *T) {
 QualType baseType = recurse(T->getBaseType());
@@ -1107,6 +1118,7 @@
   }
 
 #undef TRIVIAL_TYPE_CLASS
+#undef SUGARED_TYPE_CLASS
 };
 
 } // namespace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r354165 - Relax assertion to account for private framework modules, too.

2019-02-15 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Feb 15 12:24:26 2019
New Revision: 354165

URL: http://llvm.org/viewvc/llvm-project?rev=354165&view=rev
Log:
Relax assertion to account for private framework modules, too.

rdar://problem/48116069

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/Modules/DebugInfo-fmodule-name.c

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=354165&r1=354164&r2=354165&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Feb 15 12:24:26 2019
@@ -2299,8 +2299,8 @@ CGDebugInfo::getOrCreateModuleRef(Extern
   // When a module name is specified as -fmodule-name, that module gets a
   // clang::Module object, but it won't actually be built or imported; it will
   // be textual.
-  if (CreateSkeletonCU && IsRootModule && Mod.getASTFile().empty())
-assert((!M || (M->Name == CGM.getLangOpts().ModuleName)) &&
+  if (CreateSkeletonCU && IsRootModule && Mod.getASTFile().empty() && M)
+assert(StringRef(M->Name).startswith(CGM.getLangOpts().ModuleName) &&
"clang module without ASTFile must be specified by -fmodule-name");
 
   if (CreateSkeletonCU && IsRootModule && !Mod.getASTFile().empty()) {

Modified: cfe/trunk/test/Modules/DebugInfo-fmodule-name.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/DebugInfo-fmodule-name.c?rev=354165&r1=354164&r2=354165&view=diff
==
--- cfe/trunk/test/Modules/DebugInfo-fmodule-name.c (original)
+++ cfe/trunk/test/Modules/DebugInfo-fmodule-name.c Fri Feb 15 12:24:26 2019
@@ -1,16 +1,16 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodules -fmodule-format=obj -fmodule-name=F \
+// RUN: %clang_cc1 -fmodules -fmodule-format=obj -fmodule-name=MainA \
 // RUN: -debug-info-kind=limited -dwarf-ext-refs \
 // RUN: -fimplicit-module-maps -x c -fmodules-cache-path=%t -F %S/Inputs \
 // RUN: %s -S -emit-llvm -debugger-tuning=lldb -o - | FileCheck %s
 
-#include "F/F.h"
+#include "MainA/MainPriv.h"
 
 // CHECK: !DICompileUnit
 // CHECK-NOT: dwoId:
 
 // We still want the import, but no skeleton CU, since no PCM was built.
 
-// CHECK: !DIModule({{.*}}, name: "F"
+// CHECK: !DIModule({{.*}}, name: "APriv"
 // CHECK-NOT: !DICompileUnit
 // CHECK-NOT: dwoId:


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


r354166 - [Driver] Default all Android ARM targets to NEON.

2019-02-15 Thread Dan Albert via cfe-commits
Author: danalbert
Date: Fri Feb 15 12:31:54 2019
New Revision: 354166

URL: http://llvm.org/viewvc/llvm-project?rev=354166&view=rev
Log:
[Driver] Default all Android ARM targets to NEON.

Summary:
There are an insignificant number of ARM Android devices that don't
support NEON. Default to using NEON since that will improve
performance on the majority of devices. Users that need to target
non-NEON devices can still explicitly disable NEON.

Reviewers: srhines, pirama, kristof.beyls

Reviewed By: pirama

Subscribers: efriedma, javed.absar, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
cfe/trunk/test/Driver/arm-mfpu.c

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp?rev=354166&r1=354165&r2=354166&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp Fri Feb 15 12:31:54 2019
@@ -378,9 +378,7 @@ void arm::getARMTargetFeatures(const Too
   } else if (FPUArg) {
 getARMFPUFeatures(D, FPUArg, Args, FPUArg->getValue(), Features);
   } else if (Triple.isAndroid() && getARMSubArchVersionNumber(Triple) >= 7) {
-// Android mandates minimum FPU requirements based on OS version.
-const char *AndroidFPU =
-Triple.isAndroidVersionLT(23) ? "vfpv3-d16" : "neon";
+const char *AndroidFPU = "neon";
 if (!llvm::ARM::getFPUFeatures(llvm::ARM::parseFPU(AndroidFPU), Features))
   D.Diag(clang::diag::err_drv_clang_unsupported)
   << std::string("-mfpu=") + AndroidFPU;

Modified: cfe/trunk/test/Driver/arm-mfpu.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-mfpu.c?rev=354166&r1=354165&r2=354166&view=diff
==
--- cfe/trunk/test/Driver/arm-mfpu.c (original)
+++ cfe/trunk/test/Driver/arm-mfpu.c Fri Feb 15 12:31:54 2019
@@ -376,55 +376,23 @@
 // CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+neon"
 // CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+crypto"
 
-// RUN: %clang -target arm-linux-androideabi21 -march=armv7-a %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-MARCH-ARM7-ANDROID-FP %s
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+soft-float"
-// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+soft-float-abi"
-// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+d16"
-// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+vfp3"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+vfp4"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+fp-armv8"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+neon"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+crypto"
-
 // RUN: %clang -target armv7-linux-androideabi21 %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-L-FP-DEFAULT %s
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+d16"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+crypto"
-
-// RUN: %clang -target armv7-linux-androideabi21 -mfpu=neon %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-L-FP-NEON %s
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+crypto"
-
-// RUN: %clang -target armv7-linux-androideabi23 %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-M-FP-DEFAULT %s
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+crypto"
+// RUN:   | FileCheck --check-prefix=CHECK-ARM7-ANDROID-FP-DEFAULT %s
+// CHECK-ARM7-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM7-ANDROID-FP-DEFAULT: "-target-feature" "

[PATCH] D58153: [Driver] Default all Android ARM targets to NEON.

2019-02-15 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354166: [Driver] Default all Android ARM targets to NEON. 
(authored by danalbert, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58153?vs=186553&id=187066#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58153/new/

https://reviews.llvm.org/D58153

Files:
  cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
  cfe/trunk/test/Driver/arm-mfpu.c


Index: cfe/trunk/test/Driver/arm-mfpu.c
===
--- cfe/trunk/test/Driver/arm-mfpu.c
+++ cfe/trunk/test/Driver/arm-mfpu.c
@@ -376,55 +376,23 @@
 // CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+neon"
 // CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+crypto"
 
-// RUN: %clang -target arm-linux-androideabi21 -march=armv7-a %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-MARCH-ARM7-ANDROID-FP %s
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+soft-float"
-// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+soft-float-abi"
-// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+d16"
-// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+vfp3"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+vfp4"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+fp-armv8"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+neon"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+crypto"
-
 // RUN: %clang -target armv7-linux-androideabi21 %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-L-FP-DEFAULT %s
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+d16"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+crypto"
-
-// RUN: %clang -target armv7-linux-androideabi21 -mfpu=neon %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-L-FP-NEON %s
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+crypto"
-
-// RUN: %clang -target armv7-linux-androideabi23 %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-M-FP-DEFAULT %s
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+crypto"
-
-// RUN: %clang -target armv7-linux-androideabi23 %s -mfpu=vfp3-d16 -### -c 
2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-M-FP-D16 %s
-// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+d16"
-// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+crypto"
+// RUN:   | FileCheck --check-prefix=CHECK-ARM7-ANDROID-FP-DEFAULT %s
+// CHECK-ARM7-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM7-ANDROID-FP-DEFAULT: "-target-feature" "+soft-float-abi"
+// CHECK-ARM7-ANDROID-FP-DEFAULT: "-target-feature" "+vfp3"
+// CHECK-ARM7-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
+// CHECK-ARM7-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
+// CHECK-ARM7-ANDROID-FP-DEFAULT: "-target-feature" "+neon"
+// CHECK-ARM7-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+crypto"
+
+// RUN: %clang -target armv7-linux-androideabi21 %s -mfpu=vfp3-d16 -### -c 
2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM7-ANDROID-FP-D16 %s
+// CHECK-ARM7-ANDROID-FP-D16-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM7-ANDROID-FP-D16: "-target-feature" "+soft-float-abi"
+// CHECK-ARM7-ANDROID-FP-D16: "-target-feature" "+d16"
+// C

Re: r354075 - [clang][FileManager] fillRealPathName even if we aren't opening the file

2019-02-15 Thread Reid Kleckner via cfe-commits
Reverted:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/4351

On Fri, Feb 15, 2019 at 11:07 AM Galina Kistanova via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hello Jan,
>
> It looks like this commit broke tests on couple of win builders:
>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/23655
> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win
> . . .
> Failing Tests (1):
> Clang-Unit ::
> Basic/./BasicTests.exe/FileManagerTest.getFileDontOpenRealPath
>
> Please have a look ASAP?
>
> Thanks
>
> Galina
>
> On Thu, Feb 14, 2019 at 3:02 PM Jan Korous via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: jkorous
>> Date: Thu Feb 14 15:02:35 2019
>> New Revision: 354075
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=354075&view=rev
>> Log:
>> [clang][FileManager] fillRealPathName even if we aren't opening the file
>>
>> The pathname wasn't previously filled when the getFile() method was
>> called with openFile = false.
>> We are caching FileEntry-s in ParsedAST::Includes in clangd and this
>> caused the problem.
>>
>> This fixes an internal test failure in clangd -
>> ClangdTests.GoToInclude.All
>>
>> rdar://47536127
>>
>> Differential Revision: https://reviews.llvm.org/D58213
>>
>> Modified:
>> cfe/trunk/lib/Basic/FileManager.cpp
>> cfe/trunk/unittests/Basic/FileManagerTest.cpp
>>
>> Modified: cfe/trunk/lib/Basic/FileManager.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=354075&r1=354074&r2=354075&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Basic/FileManager.cpp (original)
>> +++ cfe/trunk/lib/Basic/FileManager.cpp Thu Feb 14 15:02:35 2019
>> @@ -267,6 +267,9 @@ const FileEntry *FileManager::getFile(St
>>if (UFE.File) {
>>  if (auto PathName = UFE.File->getName())
>>fillRealPathName(&UFE, *PathName);
>> +  } else if (!openFile) {
>> +// We should still fill the path even if we aren't opening the file.
>> +fillRealPathName(&UFE, InterndFileName);
>>}
>>return &UFE;
>>  }
>>
>> Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=354075&r1=354074&r2=354075&view=diff
>>
>> ==
>> --- cfe/trunk/unittests/Basic/FileManagerTest.cpp (original)
>> +++ cfe/trunk/unittests/Basic/FileManagerTest.cpp Thu Feb 14 15:02:35 2019
>> @@ -346,4 +346,18 @@ TEST_F(FileManagerTest, getVirtualFileFi
>>EXPECT_EQ(file->tryGetRealPathName(), ExpectedResult);
>>  }
>>
>> +TEST_F(FileManagerTest, getFileDontOpenRealPath) {
>> +  auto statCache = llvm::make_unique();
>> +  statCache->InjectDirectory("/tmp/abc", 42);
>> +  SmallString<64> Path("/tmp/abc/foo.cpp");
>> +  statCache->InjectFile(Path.str().str().c_str(), 43);
>> +  manager.setStatCache(std::move(statCache));
>> +
>> +  const FileEntry *file = manager.getFile(Path, /*openFile=*/false);
>> +
>> +  ASSERT_TRUE(file != nullptr);
>> +
>> +  ASSERT_EQ(file->tryGetRealPathName(), Path);
>> +}
>> +
>>  } // anonymous namespace
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r354169 - Revert r354075 "[clang][FileManager] fillRealPathName even if we aren't opening the file"

2019-02-15 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Feb 15 12:48:12 2019
New Revision: 354169

URL: http://llvm.org/viewvc/llvm-project?rev=354169&view=rev
Log:
Revert r354075 "[clang][FileManager] fillRealPathName even if we aren't opening 
the file"

The new test doesn't pass on Windows.

Modified:
cfe/trunk/lib/Basic/FileManager.cpp
cfe/trunk/unittests/Basic/FileManagerTest.cpp

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=354169&r1=354168&r2=354169&view=diff
==
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Fri Feb 15 12:48:12 2019
@@ -267,9 +267,6 @@ const FileEntry *FileManager::getFile(St
   if (UFE.File) {
 if (auto PathName = UFE.File->getName())
   fillRealPathName(&UFE, *PathName);
-  } else if (!openFile) {
-// We should still fill the path even if we aren't opening the file.
-fillRealPathName(&UFE, InterndFileName);
   }
   return &UFE;
 }

Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=354169&r1=354168&r2=354169&view=diff
==
--- cfe/trunk/unittests/Basic/FileManagerTest.cpp (original)
+++ cfe/trunk/unittests/Basic/FileManagerTest.cpp Fri Feb 15 12:48:12 2019
@@ -346,18 +346,4 @@ TEST_F(FileManagerTest, getVirtualFileFi
   EXPECT_EQ(file->tryGetRealPathName(), ExpectedResult);
 }
 
-TEST_F(FileManagerTest, getFileDontOpenRealPath) {
-  auto statCache = llvm::make_unique();
-  statCache->InjectDirectory("/tmp/abc", 42);
-  SmallString<64> Path("/tmp/abc/foo.cpp");
-  statCache->InjectFile(Path.str().str().c_str(), 43);
-  manager.setStatCache(std::move(statCache));
-
-  const FileEntry *file = manager.getFile(Path, /*openFile=*/false);
-
-  ASSERT_TRUE(file != nullptr);
-
-  ASSERT_EQ(file->tryGetRealPathName(), Path);
-}
-
 } // anonymous namespace


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


[PATCH] D50488: [Analyzer] Checker for non-determinism caused by sorting of pointer-like elements

2019-02-15 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

The error I now get is:

  clang is not able to compile a simple test program.
  /usr/bin/ld: unrecognised emulation mode: armelf_linux_eabi
Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu i386linux
elf_l1om elf_k1om i386pep i386pe

This is because I need to pass the correct -target and -L options to config. I 
see that there is a configure_command option that can be set. However, 
different projects use different build systems (make, cmake, bake, etc). How do 
we then pass flags to their respective configures?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D50488/new/

https://reviews.llvm.org/D50488



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


[PATCH] D58074: [OpenMP 5.0] Parsing/sema support for map clause with mapper modifier

2019-02-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: include/clang/Sema/Sema.h:9347
   ArrayRef MapTypeModifiersLoc,
+  CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId,
   OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,

ABataev wrote:
> Also would be good to pack some of the params into structure
What about this function?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58074/new/

https://reviews.llvm.org/D58074



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


[PATCH] D57948: [Sema] Fix a regression introduced in "[AST][Sema] Remove CallExpr::setNumArgs"

2019-02-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

Done, thanks!


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57948/new/

https://reviews.llvm.org/D57948



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


[PATCH] D45978: dllexport const variables must have external linkage.

2019-02-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:11370
 
+// In Microsoft C++ mode, a const variable defined in namespace scope has
+// external linkage by default if the variable is declared with

zahiraam wrote:
> aaron.ballman wrote:
> > thakis wrote:
> > > Even in unnamed namespaces?
> > That would definitely be good to test.
> It looks like not. 
> 
> ksh-3.2$ cat test4.cpp
> namespace {
> __declspec(dllexport) int const x = 3;
> }
> 
> int main ()
> {
>   int y = x + 10;
> 
>   return y;
> }
> 
> ksh-3.2$ cl -c test4.cpp
> Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x64
> Copyright (C) Microsoft Corporation.  All rights reserved.
> 
> test4.cpp
> ksh-3.2$ dumpbin /symbols test4.obj | grep External
> **008  SECT3  notype ()External | main**
> ksh-3.2$
> 
> ksh-3.2$ clang -c test4.cpp
> test4.cpp:2:33: error: '(anonymous namespace)::x' must have external linkage 
> when declared 'dllexport'
> __declspec(dllexport) int const x = 3;
> ^
> 1 error generated.
> ksh-3.2$
> 
> So the diag shouldn't go off when the variable is in an anonymous namespace? 
> Do you agree?
> 
> So the diag shouldn't go off when the variable is in an anonymous namespace? 
> Do you agree?

Correct.



Comment at: test/Sema/dllexport-2.cpp:5
+
+__declspec(dllexport) int const j; // expected-error {{default initialization 
of an object of const type 'const int'}} // expected-error {{'j' must have 
external linkage when declared 'dllexport'}}

Another test I'd like to see is using a typedef to apply the const 
qualification. e.g.,
```
typedef const int CInt;
__declspec(dllexport) CInt j2;
__declspec(dllexport) CInt j3 = 3;
```
We should match the MSVC behavior here as well (I wonder if your use of 
`isLocalConstQualified()` should actually be `isConstQualified()` instead).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D45978/new/

https://reviews.llvm.org/D45978



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


[PATCH] D58291: [clangd] Include textual diagnostic ID as Diagnostic.code.

2019-02-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: cfe-commits, jdoerfert, arphaman, jkorous, MaskRay, 
ioeric, ilya-biryukov.
Herald added a project: clang.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D58291

Files:
  clangd/Diagnostics.cpp
  clangd/Diagnostics.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  test/clangd/compile-commands-path-in-initialize.test
  test/clangd/diagnostic-category.test
  test/clangd/diagnostics.test
  test/clangd/did-change-configuration-params.test
  test/clangd/execute-command.test
  test/clangd/fixits-codeaction.test
  test/clangd/fixits-command.test
  test/clangd/fixits-embed-in-diagnostic.test

Index: test/clangd/fixits-embed-in-diagnostic.test
===
--- test/clangd/fixits-embed-in-diagnostic.test
+++ test/clangd/fixits-embed-in-diagnostic.test
@@ -6,6 +6,7 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
+# CHECK-NEXT:"code": "err_use_with_wrong_tag",
 # CHECK-NEXT:"codeActions": [
 # CHECK-NEXT:  {
 # CHECK-NEXT:"edit": {
Index: test/clangd/fixits-command.test
===
--- test/clangd/fixits-command.test
+++ test/clangd/fixits-command.test
@@ -6,6 +6,7 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
+# CHECK-NEXT:"code": "warn_condition_is_assignment",
 # CHECK-NEXT:"message": "Using the result of an assignment as a condition without parentheses (fixes available)",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
Index: test/clangd/fixits-codeaction.test
===
--- test/clangd/fixits-codeaction.test
+++ test/clangd/fixits-codeaction.test
@@ -6,6 +6,7 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
+# CHECK-NEXT:"code": "warn_condition_is_assignment",
 # CHECK-NEXT:"message": "Using the result of an assignment as a condition without parentheses (fixes available)",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
@@ -23,13 +24,14 @@
 # CHECK-NEXT:"uri": "file://{{.*}}/foo.c"
 # CHECK-NEXT:  }
 ---
-{"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"test:///foo.c"},"range":{"start":{"line":0,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 37}},"severity":2,"message":"Using the result of an assignment as a condition without parentheses (fixes available)"}]}}}
+{"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"test:///foo.c"},"range":{"start":{"line":0,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 37}},"severity":2,"message":"Using the result of an assignment as a condition without parentheses (fixes available)", "code": "warn_condition_is_assignment"}]}}}
 #  CHECK:  "id": 2,
 # CHECK-NEXT:  "jsonrpc": "2.0",
 # CHECK-NEXT:  "result": [
 # CHECK-NEXT:{
 # CHECK-NEXT:  "diagnostics": [
 # CHECK-NEXT:{
+# CHECK-NEXT:  "code": "warn_condition_is_assignment",
 # CHECK-NEXT:  "message": "Using the result of an assignment as a condition without parentheses (fixes available)",
 # CHECK-NEXT:  "range": {
 # CHECK-NEXT:"end": {
@@ -82,6 +84,7 @@
 # CHECK-NEXT:{
 # CHECK-NEXT:  "diagnostics": [
 # CHECK-NEXT:{
+# CHECK-NEXT:  "code": "warn_condition_is_assignment",
 # CHECK-NEXT:  "message": "Using the result of an assignment as a condition without parentheses (fixes available)",
 # CHECK-NEXT:  "range": {
 # CHECK-NEXT:"end": {
Index: test/clangd/execute-command.test
===
--- test/clangd/execute-command.test
+++ test/clangd/execute-command.test
@@ -6,6 +6,7 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
+# CHECK-NEXT:"code": "warn_condition_is_assignment",
 # CHECK-NEXT:"message": "Using the result of an assignment as a condition without parentheses (fixes available)",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
Index: test/clangd/did-change-configuration-params.test
===
--- test/clangd/did-change-configuration-params.test
+++ test/clangd/did-change-configuration-params.test
@@ -24,6 +24,7 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
+# CHECK-NEXT:"code": "warn_uninit_var",
 # CHECK-NEXT:"message": "Variable 'i' is uninitialized when used here (fix available)

[PATCH] D58294: [clangd] Enable indexing of template type parameters

2019-02-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, ioeric.
Herald added a project: clang.

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


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D58294

Files:
  clangd/XRefs.cpp
  clangd/index/FileIndex.cpp
  unittests/clangd/SymbolInfoTests.cpp
  unittests/clangd/XRefsTests.cpp


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -285,11 +285,10 @@
 }
   )cpp",
 
-  /* FIXME: clangIndex doesn't handle template type parameters
   R"cpp(// Template type parameter
-template <[[typename T]]>
+template 
 void foo() { ^T t; }
-  )cpp", */
+  )cpp",
 
   R"cpp(// Namespace
 namespace $decl[[ns]] {
Index: unittests/clangd/SymbolInfoTests.cpp
===
--- unittests/clangd/SymbolInfoTests.cpp
+++ unittests/clangd/SymbolInfoTests.cpp
@@ -213,14 +213,14 @@
 T^T t;
   };
 )cpp",
-  {/* not implemented */}},
+  {CreateExpectedSymbolDetails("TT", "bar::", "c:TestTU.cpp@65")}},
   {
   R"cpp( // Template parameter reference - type param
   template struct bar {
 int a = N^N;
   };
 )cpp",
-  {/* not implemented */}},
+  {CreateExpectedSymbolDetails("NN", "bar::", "c:TestTU.cpp@65")}},
   {
   R"cpp( // Class member reference - objec
   struct foo {
Index: clangd/index/FileIndex.cpp
===
--- clangd/index/FileIndex.cpp
+++ clangd/index/FileIndex.cpp
@@ -42,6 +42,7 @@
   IndexOpts.SystemSymbolFilter =
   index::IndexingOptions::SystemSymbolFilterKind::DeclarationsOnly;
   IndexOpts.IndexFunctionLocals = false;
+  IndexOpts.IndexTemplateParmDecls = true;
   if (IsIndexMainAST) {
 // We only collect refs when indexing main AST.
 CollectorOpts.RefFilter = RefKind::All;
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -39,7 +39,7 @@
   if (const auto *FD = dyn_cast(D))
 return FD->getDefinition();
   // Only a single declaration is allowed.
-  if (isa(D)) // except cases above
+  if (isa(D) || isa(D)) // except cases above
 return D;
   // Multiple definitions are allowed.
   return nullptr; // except cases above
@@ -243,6 +243,7 @@
   index::IndexingOptions::SystemSymbolFilterKind::All;
   IndexOpts.IndexFunctionLocals = true;
   IndexOpts.IndexParametersInDeclarations = true;
+  IndexOpts.IndexTemplateParmDecls = true;
   indexTopLevelDecls(AST.getASTContext(), AST.getPreprocessor(),
  AST.getLocalTopLevelDecls(), DeclMacrosFinder, IndexOpts);
 
@@ -441,6 +442,7 @@
   index::IndexingOptions::SystemSymbolFilterKind::All;
   IndexOpts.IndexFunctionLocals = true;
   IndexOpts.IndexParametersInDeclarations = true;
+  IndexOpts.IndexTemplateParmDecls = true;
   indexTopLevelDecls(AST.getASTContext(), AST.getPreprocessor(),
  AST.getLocalTopLevelDecls(), RefFinder, IndexOpts);
   return std::move(RefFinder).take();


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -285,11 +285,10 @@
 }
   )cpp",
 
-  /* FIXME: clangIndex doesn't handle template type parameters
   R"cpp(// Template type parameter
-template <[[typename T]]>
+template 
 void foo() { ^T t; }
-  )cpp", */
+  )cpp",
 
   R"cpp(// Namespace
 namespace $decl[[ns]] {
Index: unittests/clangd/SymbolInfoTests.cpp
===
--- unittests/clangd/SymbolInfoTests.cpp
+++ unittests/clangd/SymbolInfoTests.cpp
@@ -213,14 +213,14 @@
 T^T t;
   };
 )cpp",
-  {/* not implemented */}},
+  {CreateExpectedSymbolDetails("TT", "bar::", "c:TestTU.cpp@65")}},
   {
   R"cpp( // Template parameter reference - type param
   template struct bar {
 int a = N^N;
   };
 )cpp",
-  {/* not implemented */}},
+  {CreateExpectedSymbolDetails("NN", "bar::", "c:TestTU.cpp@65")}},
   {
   R"cpp( // Class member reference - objec
   struct foo {
Index: clangd/index/FileIndex.cpp
===
--- clangd/index/FileIndex.cpp
+++ clangd/index/FileIndex.cpp
@@ -42,6 +42,7 @@
   IndexOpts.SystemSymbolFilter =
   index::IndexingOptions::SystemSymbolFilterKind::DeclarationsOnly;
  

[PATCH] D56850: [ASTMatchers][NFC] Add tests for assorted `CXXMemberCallExpr` matchers.

2019-02-15 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

This broke compilation with GCC 5.4 on Ubuntu 16.04:

  ../tools/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:474:243: 
warning: missing terminating " character
  ../tools/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:474:3: 
error: missing terminating " character
 EXPECT_TRUE(matches(
 ^
  ../tools/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:480:7: 
error: stray ‘\’ in program
   void z(X x) { x.m(); }
 ^


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56850/new/

https://reviews.llvm.org/D56850



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


r354176 - Fix implementation of [temp.local]p4.

2019-02-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Feb 15 13:53:07 2019
New Revision: 354176

URL: http://llvm.org/viewvc/llvm-project?rev=354176&view=rev
Log:
Fix implementation of [temp.local]p4.

When a template-name is looked up, we need to give injected-class-name
declarations of class templates special treatment, as they denote a
template rather than a type.

Previously we achieved this by applying a filter to the lookup results
after completing name lookup, but that is incorrect in various ways, not
least of which is that it lost all information about access and how
members were named, and the filtering caused us to generally lose
all ambiguity errors between templates and non-templates.

We now preserve the lookup results exactly, and the few places that need
to map from a declaration found by name lookup into a declaration of a
template do so explicitly. Deduplication of repeated lookup results of
the same injected-class-name declaration is done by name lookup instead
of after the fact.

This reinstates r354091, which was previously reverted in r354097
because it exposed bugs in lldb and compiler-rt. Those bugs were fixed
in r354173 and r354174 respectively.

Modified:
cfe/trunk/include/clang/Sema/Lookup.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/CXX/class.access/p4.cpp
cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p1.cpp
cfe/trunk/test/SemaTemplate/temp.cpp

Modified: cfe/trunk/include/clang/Sema/Lookup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=354176&r1=354175&r2=354176&view=diff
==
--- cfe/trunk/include/clang/Sema/Lookup.h (original)
+++ cfe/trunk/include/clang/Sema/Lookup.h Fri Feb 15 13:53:07 2019
@@ -172,7 +172,8 @@ public:
   : SemaPtr(Other.SemaPtr), NameInfo(Other.NameInfo),
 LookupKind(Other.LookupKind), IDNS(Other.IDNS), Redecl(Other.Redecl),
 ExternalRedecl(Other.ExternalRedecl), HideTags(Other.HideTags),
-AllowHidden(Other.AllowHidden) {}
+AllowHidden(Other.AllowHidden),
+TemplateNameLookup(Other.TemplateNameLookup) {}
 
   // FIXME: Remove these deleted methods once the default build includes
   // -Wdeprecated.
@@ -193,7 +194,8 @@ public:
 HideTags(std::move(Other.HideTags)),
 Diagnose(std::move(Other.Diagnose)),
 AllowHidden(std::move(Other.AllowHidden)),
-Shadowed(std::move(Other.Shadowed)) {
+Shadowed(std::move(Other.Shadowed)),
+TemplateNameLookup(std::move(Other.TemplateNameLookup)) {
 Other.Paths = nullptr;
 Other.Diagnose = false;
   }
@@ -216,6 +218,7 @@ public:
 Diagnose = std::move(Other.Diagnose);
 AllowHidden = std::move(Other.AllowHidden);
 Shadowed = std::move(Other.Shadowed);
+TemplateNameLookup = std::move(Other.TemplateNameLookup);
 Other.Paths = nullptr;
 Other.Diagnose = false;
 return *this;
@@ -286,6 +289,15 @@ public:
 HideTags = Hide;
   }
 
+  /// Sets whether this is a template-name lookup. For template-name lookups,
+  /// injected-class-names are treated as naming a template rather than a
+  /// template specialization.
+  void setTemplateNameLookup(bool TemplateName) {
+TemplateNameLookup = TemplateName;
+  }
+
+  bool isTemplateNameLookup() const { return TemplateNameLookup; }
+
   bool isAmbiguous() const {
 return getResultKind() == Ambiguous;
   }
@@ -739,6 +751,9 @@ private:
   /// declaration that we skipped. This only happens when \c LookupKind
   /// is \c LookupRedeclarationWithLinkage.
   bool Shadowed = false;
+
+  /// True if we're looking up a template-name.
+  bool TemplateNameLookup = false;
 };
 
 /// Consumes visible declarations found when searching for

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=354176&r1=354175&r2=354176&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Feb 15 13:53:07 2019
@@ -6212,9 +6212,21 @@ public:
   // C++ Templates [C++ 14]
   //
   void FilterAcceptableTemplateNames(LookupResult &R,
- bool AllowFunctionTemplates = true);
+ bool AllowFunctionTemplates = true,
+ bool AllowDependent = true);
   bool hasAnyAcceptableTemplateNames(LookupResult &R,
- bool AllowFunctionTemplates = true);
+ bool AllowFunctionTemplates = true,
+ bool AllowDependent = true);
+  /// Try to interpret the lookup result D as a template-name.
+  ///
+  /// \param D A declaration found by name lookup.
+  

Re: r354091 - Fix implementation of [temp.local]p4.

2019-02-15 Thread Richard Smith via cfe-commits
On Fri, 15 Feb 2019 at 09:56, Richard Smith  wrote:
>
> On Thu, 14 Feb 2019, 18:35 Francis Visoiu Mistrih via cfe-commits, 
>  wrote:
>>
>> Hi Richard,
>>
>> This seems to now emit an error when building the sanitizer tests: 
>> http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/53965/consoleFull.
>>
>> I managed to reproduce it locally and when reverting your commit the error 
>> goes away.
>>
>> I am not sure if the error is in the sanitizer test’s code or actually a 
>> compiler error. Can you please take a look?
>
>
> It's an error in the sanitizer test's code.

lldb bug fixed in r354173, sanitizer test bug fixed in r354174,
re-committed as r354176.

>> Thanks,
>>
>> --
>> Francis
>>
>> On Feb 14, 2019, at 4:29 PM, Richard Smith via cfe-commits 
>>  wrote:
>>
>> Author: rsmith
>> Date: Thu Feb 14 16:29:04 2019
>> New Revision: 354091
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=354091&view=rev
>> Log:
>> Fix implementation of [temp.local]p4.
>>
>> When a template-name is looked up, we need to give injected-class-name
>> declarations of class templates special treatment, as they denote a
>> template rather than a type.
>>
>> Previously we achieved this by applying a filter to the lookup results
>> after completing name lookup, but that is incorrect in various ways, not
>> least of which is that it lost all information about access and how
>> members were named, and the filtering caused us to generally lose
>> all ambiguity errors between templates and non-templates.
>>
>> We now preserve the lookup results exactly, and the few places that need
>> to map from a declaration found by name lookup into a declaration of a
>> template do so explicitly. Deduplication of repeated lookup results of
>> the same injected-class-name declaration is done by name lookup instead
>> of after the fact.
>>
>> Modified:
>>cfe/trunk/include/clang/Sema/Lookup.h
>>cfe/trunk/include/clang/Sema/Sema.h
>>cfe/trunk/lib/Sema/SemaDecl.cpp
>>cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>>cfe/trunk/lib/Sema/SemaLookup.cpp
>>cfe/trunk/lib/Sema/SemaTemplate.cpp
>>cfe/trunk/test/CXX/class.access/p4.cpp
>>cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p1.cpp
>>cfe/trunk/test/SemaTemplate/temp.cpp
>>
>> Modified: cfe/trunk/include/clang/Sema/Lookup.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=354091&r1=354090&r2=354091&view=diff
>> ==
>> --- cfe/trunk/include/clang/Sema/Lookup.h (original)
>> +++ cfe/trunk/include/clang/Sema/Lookup.h Thu Feb 14 16:29:04 2019
>> @@ -172,7 +172,8 @@ public:
>>   : SemaPtr(Other.SemaPtr), NameInfo(Other.NameInfo),
>> LookupKind(Other.LookupKind), IDNS(Other.IDNS), Redecl(Other.Redecl),
>> ExternalRedecl(Other.ExternalRedecl), HideTags(Other.HideTags),
>> -AllowHidden(Other.AllowHidden) {}
>> +AllowHidden(Other.AllowHidden),
>> +TemplateNameLookup(Other.TemplateNameLookup) {}
>>
>>   // FIXME: Remove these deleted methods once the default build includes
>>   // -Wdeprecated.
>> @@ -193,7 +194,8 @@ public:
>> HideTags(std::move(Other.HideTags)),
>> Diagnose(std::move(Other.Diagnose)),
>> AllowHidden(std::move(Other.AllowHidden)),
>> -Shadowed(std::move(Other.Shadowed)) {
>> +Shadowed(std::move(Other.Shadowed)),
>> +TemplateNameLookup(std::move(Other.TemplateNameLookup)) {
>> Other.Paths = nullptr;
>> Other.Diagnose = false;
>>   }
>> @@ -216,6 +218,7 @@ public:
>> Diagnose = std::move(Other.Diagnose);
>> AllowHidden = std::move(Other.AllowHidden);
>> Shadowed = std::move(Other.Shadowed);
>> +TemplateNameLookup = std::move(Other.TemplateNameLookup);
>> Other.Paths = nullptr;
>> Other.Diagnose = false;
>> return *this;
>> @@ -286,6 +289,15 @@ public:
>> HideTags = Hide;
>>   }
>>
>> +  /// Sets whether this is a template-name lookup. For template-name 
>> lookups,
>> +  /// injected-class-names are treated as naming a template rather than a
>> +  /// template specialization.
>> +  void setTemplateNameLookup(bool TemplateName) {
>> +TemplateNameLookup = TemplateName;
>> +  }
>> +
>> +  bool isTemplateNameLookup() const { return TemplateNameLookup; }
>> +
>>   bool isAmbiguous() const {
>> return getResultKind() == Ambiguous;
>>   }
>> @@ -739,6 +751,9 @@ private:
>>   /// declaration that we skipped. This only happens when \c LookupKind
>>   /// is \c LookupRedeclarationWithLinkage.
>>   bool Shadowed = false;
>> +
>> +  /// True if we're looking up a template-name.
>> +  bool TemplateNameLookup = false;
>> };
>>
>> /// Consumes visible declarations found when searching for
>>
>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=354091&r1=354090&r2=354091&view=diff
>> 

[PATCH] D57910: [ASTImporter] Find previous friend function template

2019-02-15 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.
This revision is now accepted and ready to land.

LGTM, I just ran `check-lldb` and I don't see any regressions.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57910/new/

https://reviews.llvm.org/D57910



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


[PATCH] D58306: [AArch64] Change size suffix for FP16FML intrinsics.

2019-02-15 Thread Ahmed Bougacha via Phabricator via cfe-commits
ab created this revision.
ab added reviewers: SjoerdMeijer, bryanpkc.
ab added a project: clang.
Herald added a subscriber: javed.absar.

These currently use _u32, but they should instead use _f32 or _f16, the types 
of the accumulator, and of the multiplication.

I'm starting with _f16 (because that seems to match the various integer vmlal 
variants), but either seems fine.


Repository:
  rC Clang

https://reviews.llvm.org/D58306

Files:
  include/clang/Basic/arm_neon.td
  test/CodeGen/aarch64-neon-fp16fml.c

Index: test/CodeGen/aarch64-neon-fp16fml.c
===
--- test/CodeGen/aarch64-neon-fp16fml.c
+++ test/CodeGen/aarch64-neon-fp16fml.c
@@ -9,188 +9,188 @@
 
 // Vector form
 
-float32x2_t test_vfmlal_low_u32(float32x2_t a, float16x4_t b, float16x4_t c) {
-// CHECK-LABEL: define <2 x float> @test_vfmlal_low_u32(<2 x float> %a, <4 x half> %b, <4 x half> %c)
+float32x2_t test_vfmlal_low_f16(float32x2_t a, float16x4_t b, float16x4_t c) {
+// CHECK-LABEL: define <2 x float> @test_vfmlal_low_f16(<2 x float> %a, <4 x half> %b, <4 x half> %c)
 // CHECK: [[RESULT:%.*]] = call <2 x float> @llvm.aarch64.neon.fmlal.v2f32.v4f16(<2 x float> %a, <4 x half> %b, <4 x half> %c)
 // CHECK: ret <2 x float> [[RESULT]]
-  return vfmlal_low_u32(a, b, c);
+  return vfmlal_low_f16(a, b, c);
 }
 
-float32x2_t test_vfmlsl_low_u32(float32x2_t a, float16x4_t b, float16x4_t c) {
-// CHECK-LABEL: define <2 x float> @test_vfmlsl_low_u32(<2 x float> %a, <4 x half> %b, <4 x half> %c)
+float32x2_t test_vfmlsl_low_f16(float32x2_t a, float16x4_t b, float16x4_t c) {
+// CHECK-LABEL: define <2 x float> @test_vfmlsl_low_f16(<2 x float> %a, <4 x half> %b, <4 x half> %c)
 // CHECK: [[RESULT:%.*]] = call <2 x float> @llvm.aarch64.neon.fmlsl.v2f32.v4f16(<2 x float> %a, <4 x half> %b, <4 x half> %c)
 // CHECK: ret <2 x float> [[RESULT]]
-  return vfmlsl_low_u32(a, b, c);
+  return vfmlsl_low_f16(a, b, c);
 }
 
-float32x2_t test_vfmlal_high_u32(float32x2_t a, float16x4_t b, float16x4_t c) {
-// CHECK-LABEL: define <2 x float> @test_vfmlal_high_u32(<2 x float> %a, <4 x half> %b, <4 x half> %c)
+float32x2_t test_vfmlal_high_f16(float32x2_t a, float16x4_t b, float16x4_t c) {
+// CHECK-LABEL: define <2 x float> @test_vfmlal_high_f16(<2 x float> %a, <4 x half> %b, <4 x half> %c)
 // CHECK: [[RESULT:%.*]] = call <2 x float> @llvm.aarch64.neon.fmlal2.v2f32.v4f16(<2 x float> %a, <4 x half> %b, <4 x half> %c)
 // CHECK: ret <2 x float> [[RESULT]]
-  return vfmlal_high_u32(a, b, c);
+  return vfmlal_high_f16(a, b, c);
 }
 
-float32x2_t test_vfmlsl_high_u32(float32x2_t a, float16x4_t b, float16x4_t c) {
-// CHECK-LABEL: define <2 x float> @test_vfmlsl_high_u32(<2 x float> %a, <4 x half> %b, <4 x half> %c)
+float32x2_t test_vfmlsl_high_f16(float32x2_t a, float16x4_t b, float16x4_t c) {
+// CHECK-LABEL: define <2 x float> @test_vfmlsl_high_f16(<2 x float> %a, <4 x half> %b, <4 x half> %c)
 // CHECK: [[RESULT:%.*]] = call <2 x float> @llvm.aarch64.neon.fmlsl2.v2f32.v4f16(<2 x float> %a, <4 x half> %b, <4 x half> %c)
 // CHECK: ret <2 x float> [[RESULT]]
-  return vfmlsl_high_u32(a, b, c);
+  return vfmlsl_high_f16(a, b, c);
 }
 
-float32x4_t test_vfmlalq_low_u32(float32x4_t a, float16x8_t b, float16x8_t c) {
-// CHECK-LABEL: define <4 x float> @test_vfmlalq_low_u32(<4 x float> %a, <8 x half> %b, <8 x half> %c)
+float32x4_t test_vfmlalq_low_f16(float32x4_t a, float16x8_t b, float16x8_t c) {
+// CHECK-LABEL: define <4 x float> @test_vfmlalq_low_f16(<4 x float> %a, <8 x half> %b, <8 x half> %c)
 // CHECK: [[RESULT:%.*]] = call <4 x float> @llvm.aarch64.neon.fmlal.v4f32.v8f16(<4 x float> %a, <8 x half> %b, <8 x half> %c)
 // CHECK: ret <4 x float> [[RESULT]]
-  return vfmlalq_low_u32(a, b, c);
+  return vfmlalq_low_f16(a, b, c);
 }
 
-float32x4_t test_vfmlslq_low_u32(float32x4_t a, float16x8_t b, float16x8_t c) {
-// CHECK-LABEL: define <4 x float> @test_vfmlslq_low_u32(<4 x float> %a, <8 x half> %b, <8 x half> %c)
+float32x4_t test_vfmlslq_low_f16(float32x4_t a, float16x8_t b, float16x8_t c) {
+// CHECK-LABEL: define <4 x float> @test_vfmlslq_low_f16(<4 x float> %a, <8 x half> %b, <8 x half> %c)
 // CHECK: [[RESULT:%.*]] = call <4 x float> @llvm.aarch64.neon.fmlsl.v4f32.v8f16(<4 x float> %a, <8 x half> %b, <8 x half> %c)
 // CHECK: ret <4 x float> [[RESULT]]
-  return vfmlslq_low_u32(a, b, c);
+  return vfmlslq_low_f16(a, b, c);
 }
 
-float32x4_t test_vfmlalq_high_u32(float32x4_t a, float16x8_t b, float16x8_t c) {
-// CHECK-LABEL: define <4 x float> @test_vfmlalq_high_u32(<4 x float> %a, <8 x half> %b, <8 x half> %c)
+float32x4_t test_vfmlalq_high_f16(float32x4_t a, float16x8_t b, float16x8_t c) {
+// CHECK-LABEL: define <4 x float> @test_vfmlalq_high_f16(<4 x float> %a, <8 x half> %b, <8 x half> %c)
 // CHECK: [[RESULT:%.*]] = call <4 x float> @llvm.aarch64.neon.fmlal2.v4f32.v8f16(<4 x float> %a, <8 x half> %b, <8 x half> %c)
 // CHECK: ret <4 x float> [[RESULT]]
-  return vfmlalq_high_u32(a, b, c);
+  re

Re: [PATCH] D56850: [ASTMatchers][NFC] Add tests for assorted `CXXMemberCallExpr` matchers.

2019-02-15 Thread Yitzhak Mandelbaum via cfe-commits
Was it the complete diff or one of the intermediate commits? I accidentally
committed the diff as a series of commits rather than one (squashed)
commit.

On Fri, Feb 15, 2019 at 4:51 PM Martin Storsjö via Phabricator <
revi...@reviews.llvm.org> wrote:

> mstorsjo added a comment.
>
> This broke compilation with GCC 5.4 on Ubuntu 16.04:
>
>
> ../tools/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:474:243:
> warning: missing terminating " character
>   ../tools/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:474:3:
> error: missing terminating " character
>  EXPECT_TRUE(matches(
>  ^
>   ../tools/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:480:7:
> error: stray ‘\’ in program
>void z(X x) { x.m(); }
>  ^
>
>
> Repository:
>   rL LLVM
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D56850/new/
>
> https://reviews.llvm.org/D56850
>
>
>
>


smime.p7s
Description: S/MIME Cryptographic Signature
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >