[PATCH] D68914: [clang-format] Remove duplciate code from Invalid BOM detection

2019-10-17 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

Thanks for clearing it up!


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

https://reviews.llvm.org/D68914



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


[PATCH] D69088: [Lex] #pragma clang transform

2019-10-17 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur created this revision.
Meinersbur added reviewers: hfinkel, kbarton, SjoerdMeijer, aaron.ballman, 
ABataev, fhahn, hsaito, hans, greened, dmgreen, reames, Ayal, asavonic, rtrieu, 
dorit, rsmith, tyler.nowicki.
Herald added a reviewer: bollu.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is a series of patches that adds a new pragma for loop transformations. I 
hope for feedback before the LLVM DevMtg where this will be the topic of my 
talk . The talk will 
give an overview about how to add such an extension that touches all of clang's 
layers and would hate to give wrong advice.

The syntax is:

  #pragma clang transform distribute
  #pragma clang transform unroll/unrollandjam [full/partial(n)]
  #pragma clang transform vectorize [width(n)]
  #pragma clang transform interleave [factor(n)]

The selection is currently limited to the passes LLVM currently supports. I am 
working on more transformations that currently are only picked-up by Polly. The 
biggest difference to #pragma clang loop it allows to specify in which order 
the transformations are applied, which is ignored by clang's current LoopHint 
attribute. It is also designed a bit more carefully, e.g. vectorize and 
interleave are unambiguously different transformations and no question whether 
setting an optimization option also enables the transformations.

In the longer term, we plan to add more features such as:

- More transformations (tiling, fusion, interchange, array packing, reversal, 
wavefronting, peeling, splitting, space-filling curves, unswitching, 
collapsing, strip/strip-mining, blocking, )
- More options
- Assigning identifiers to code such that they can be referenced by 
transformations. (e.g. tile a loop nest, vectorize the second-to-innermost loop 
and parallelize the outermost).
- Non-loop transformations (code motion, versioning, ...)
- OpenMP compatibility

Regarding the latter item, we are adding loop transformation to the OpenMP 
specification. The next technical report presented at SC'19 will feature a 
tiling transformation. As such, this patch is inspired by clang's OpenMP 
implementation to make an integration later easier. It's not OpenMP though, in 
that for instance the OpenMP construct will apply tiling regardless of semantic 
equivalence while `#pragma clang transform` takes the classical compiler-hint 
approach in that it (by default) still does a correctness check, only 
influencing the profitability heuristic.

A previous prototype that was closer to how `#pragma clang loop` is implemented 
using attributes instead of adding an additional kind of AST nodes. This showed 
its limitations in that it did not allow all use-cases (such as #pragma without 
a following statement) and its argument format can only store an array of 
in-source identifiers and expressions. The prototype also used the `'#pragma 
clang loop` syntax, but it proved difficult to disambiguate whether the 
transformations are ordered or not.

The patch is split into multiple reviews:

- [this patch] The lexer part adds annotation begin- and end-tokens to the 
token stream, as OpenMP does.
- The parser part parses the tokens between the annotation tokens and calls 
`ActOn...` methods of Sema which are empty in this patch.
- The sema part also adds the AST nodes kinds: the Stmt representing the 
#pragma, the clauses and `Transform`. The latter represents the semantic 
analysis result similar to an ImplicitCast. Moreover, the AnalysisTransform 
component constructs a loop nest tree to which transformations are applied to 
such that Sema can warn about inconsistencies, e.g. there is no inner or 
ambiguous loops for unrollandjam.
- The codegen part uses the same AnalysisTransform to determine which loop 
metadata nodes to emit.
- Other parts not yet ready for a review: serialization, index, completion, 
libclang, ASTMatcher, tooling

Thanks in advance for the review!


Repository:
  rC Clang

https://reviews.llvm.org/D69088

Files:
  include/clang/Basic/TokenKinds.def
  include/clang/Parse/Parser.h
  lib/Parse/ParsePragma.cpp

Index: lib/Parse/ParsePragma.cpp
===
--- lib/Parse/ParsePragma.cpp
+++ lib/Parse/ParsePragma.cpp
@@ -225,6 +225,12 @@
 Token &FirstToken) override;
 };
 
+struct PragmaTransformHandler : public PragmaHandler {
+  PragmaTransformHandler() : PragmaHandler("transform") {}
+  void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
+Token &FirstToken) override;
+};
+
 struct PragmaMSRuntimeChecksHandler : public EmptyPragmaHandler {
   PragmaMSRuntimeChecksHandler() : EmptyPragmaHandler("runtime_checks") {}
 };
@@ -376,6 +382,9 @@
   std::make_unique("nounroll_and_jam");
   PP.AddPragmaHandler(NoUnrollAndJamHintHandler.get());
 
+  TransformHandler = std::make_unique();
+  PP.AddPragma

[PATCH] D69089: [Parser] #pragma clang transform

2019-10-17 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur created this revision.
Meinersbur added reviewers: hfinkel, kbarton, SjoerdMeijer, aaron.ballman, 
ABataev, fhahn, hsaito, hans, greened, dmgreen, reames, Ayal, asavonic, rtrieu, 
dorit, rsmith, tyler.nowicki.
Herald added a subscriber: mgorny.
Herald added a reviewer: jdoerfert.

Parse the tokens between the annotation tokens and calls ActOn... methods of 
Sema which are empty in this patch.

For a full description, see D69088 .


https://reviews.llvm.org/D69089

Files:
  include/clang/AST/StmtTransform.h
  include/clang/AST/Transform.h
  include/clang/AST/TransformKinds.def
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/AST/CMakeLists.txt
  lib/AST/StmtTransform.cpp
  lib/AST/Transform.cpp
  lib/Parse/CMakeLists.txt
  lib/Parse/ParseStmt.cpp
  lib/Parse/ParseTransform.cpp
  lib/Sema/CMakeLists.txt
  lib/Sema/SemaTransform.cpp
  test/Parser/pragma-transform.cpp

Index: test/Parser/pragma-transform.cpp
===
--- /dev/null
+++ test/Parser/pragma-transform.cpp
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+void pragma_transform(int *List, int Length) {
+// FIXME: This does not emit an error
+#pragma clang
+
+/* expected-error@+1 {{expected a transformation name}} */
+#pragma clang transform
+  for (int i = 0; i < Length; i+=1)
+  List[i] = i;
+
+/* expected-error@+1 {{unknown transformation}} */
+#pragma clang transform unknown_transformation
+  for (int i = 0; i < Length; i+=1)
+  List[i] = i;
+
+/* expected-error@+2 {{expected loop after transformation pragma}} */
+#pragma clang transform unroll
+  pragma_transform(List, Length);
+
+/* expected-error@+1 {{unknown clause name}} */
+#pragma clang transform unroll unknown_clause
+  for (int i = 0; i < Length; i+=1)
+  List[i] = i;
+
+/* expected-error@+1 {{expected '(' after 'partial'}} */
+#pragma clang transform unroll partial
+  for (int i = 0; i < Length; i+=1)
+  List[i] = i;
+
+/* expected-error@+1 {{expected expression}} */
+#pragma clang transform unroll partial(
+  for (int i = 0; i < Length; i+=1)
+  List[i] = i;
+
+/* expected-error@+1 {{expected '(' after 'partial'}} */
+#pragma clang transform unroll partial)
+  for (int i = 0; i < Length; i+=1)
+  List[i] = i;
+
+/* expected-error@+2 {{expected ')'}} */
+/* expected-note@+1 {{to match this '('}} */
+#pragma clang transform unroll partial(4
+  for (int i = 0; i < Length; i+=1)
+  List[i] = i;
+
+/* expected-error@+1 {{expected expression}} */
+#pragma clang transform unroll partial()
+  for (int i = 0; i < Length; i+=1)
+  List[i] = i;
+
+/* expected-error@+1 {{use of undeclared identifier 'badvalue'}} */
+#pragma clang transform unroll partial(badvalue)
+  for (int i = 0; i < Length; i+=1)
+  List[i] = i;
+
+  {
+/* expected-error@+2 {{expected statement}} */
+#pragma clang transform unroll
+  }
+}
+
+/* expected-error@+1 {{expected unqualified-id}} */
+#pragma clang transform unroll
+int I;
+
+/* expected-error@+1 {{expected unqualified-id}} */
+#pragma clang transform unroll
+void func();
+
+class C1 {
+/* expected-error@+1 {{expected member name or ';' after declaration specifiers}} */
+#pragma clang transform unroll
+};
+
+template
+void pragma_transform_template_func(int *List, int Length) {
+#pragma clang transform unroll partial(F)
+  for (int i = 0; i < Length; i+=1)
+  List[i] = i;
+}
+
+template
+class C2 {
+  void pragma_transform_template_class(int *List, int Length) {
+#pragma clang transform unroll partial(F)
+for (int i = 0; i < Length; i+=1)
+List[i] = i;
+  }
+};
Index: lib/Sema/SemaTransform.cpp
===
--- /dev/null
+++ lib/Sema/SemaTransform.cpp
@@ -0,0 +1,62 @@
+//=== SemaTransform.h - -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Semantic analysis for code transformations.
+//
+//===--===//
+
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/StmtTransform.h"
+#include "clang/AST/Transform.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/SemaDiagnostic.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/StringMap.h"
+
+using namespace clang;
+
+static bool isTemplateDependent(Expr *E) {
+  return E->isValueDependent() || E->isTypeDependent() ||
+ E->isInstantiationDependent() || E->containsUnexpandedParameterPack();
+}
+
+Sema::TransformResult
+Sema::ActOnTransform(Transform::Kind Kind,
+ llvm::ArrayRef Clauses,
+

[PATCH] D69090: [Try 2] Include sanitize blacklist and other extra deps as part of scan-deps output

2019-10-17 Thread Kousik Kumar via Phabricator via cfe-commits
kousikk created this revision.
kousikk added reviewers: arphaman, dexonsmith, Bigcheese, jkorous.
kousikk added a project: clang.
kousikk edited the summary of this revision.

Clang's -M mode includes these extra dependencies in its output and 
clang-scan-deps
should have equivalent behavior, so adding these extradeps to output just like
how its being done for ".d" file generation mode.

This is a retry of https://reviews.llvm.org/rC375074. From the build-bot 
failure on
Windows, it seemed like somehow the blacklist file was already added as a 
dependency.
So the extra change in this patch is that I add deps to a set in clang-scan-deps
to eliminate duplicates and print in sorted order. Having a set achieves two 
purposes:

1. Prints out the dependencies in sorted order
2. Eliminates duplicates

Windows bot failure: 
http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/15956/steps/ninja%20check%202/logs/stdio

An alternative fix to the test would have been to check only for the presence of
blacklsit file, but I didn't prefer it since explicit testing of all expected 
outputs
is better (and in this case has led us to capture duplicate outputs).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69090

Files:
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/test/ClangScanDeps/Inputs/non-header-dependency.json
  clang/test/ClangScanDeps/Inputs/sanitize-blacklist.txt
  clang/test/ClangScanDeps/non-header-dependency.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp


Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -17,6 +17,7 @@
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/Threading.h"
 #include 
+#include 
 #include 
 
 using namespace clang;
@@ -66,7 +67,7 @@
 StringRef File) override {
 if (!this->Opts)
   this->Opts = std::make_unique(Opts);
-Dependencies.push_back(File);
+Dependencies.insert(File);
   }
 
   void printDependencies(std::string &S) {
@@ -76,7 +77,7 @@
 class DependencyPrinter : public DependencyFileGenerator {
 public:
   DependencyPrinter(DependencyOutputOptions &Opts,
-ArrayRef Dependencies)
+std::set &Dependencies)
   : DependencyFileGenerator(Opts) {
 for (const auto &Dep : Dependencies)
   addDependency(Dep);
@@ -94,7 +95,7 @@
 
 private:
   std::unique_ptr Opts;
-  std::vector Dependencies;
+  std::set Dependencies;
 };
 
 DependencyPrinterConsumer Consumer;
Index: clang/test/ClangScanDeps/non-header-dependency.cpp
===
--- /dev/null
+++ clang/test/ClangScanDeps/non-header-dependency.cpp
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: cp %s %t.dir/non-header-dependency_input.cpp
+// RUN: mkdir %t.dir/Inputs
+// RUN: cp %S/Inputs/sanitize-blacklist.txt 
%t.dir/Inputs/sanitize-blacklist.txt
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/non-header-dependency.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck %s
+
+#define FOO "foo"
+
+// CHECK: Inputs{{/|\\}}sanitize-blacklist.txt
+// CHECK-NEXT: non-header-dependency_input.cpp
Index: clang/test/ClangScanDeps/Inputs/sanitize-blacklist.txt
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/sanitize-blacklist.txt
@@ -0,0 +1 @@
+fun:*
Index: clang/test/ClangScanDeps/Inputs/non-header-dependency.json
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/non-header-dependency.json
@@ -0,0 +1,7 @@
+[
+{
+  "directory": "DIR",
+  "command": "clang -E DIR/non-header-dependency_input.cpp 
-fsanitize=bounds -fsanitize-blacklist=DIR/Inputs/sanitize-blacklist.txt",
+  "file": "DIR/non-header-dependency_input.cpp"
+}
+]
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -36,6 +36,8 @@
   llvm::sys::path::remove_dots(CanonPath, /*remove_dot_dot=*/true);
   C.handleFileDependency(*Opts, CanonPath);
 }
+for (const auto& ExtraDep : Opts->ExtraDeps)
+  C.handleFileDependency(*Opts, ExtraDep);
   }
 
 private:


Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -17,6 +17,7 @@
 #include "llvm/Support

[PATCH] D63960: [C++20] Add consteval-specific semantic for functions

2019-10-17 Thread Tyker via Phabricator via cfe-commits
Tyker added a comment.

The now that constexpr destructors are legal. The code in this patch need to be 
adapted, I have question about the following code.

  struct A {
constexpr ~A() {}
  };
  
  consteval A f() {
  return A{};
  }
  
  void test() {
  A a;
  a = f(); // <-- here
  }

At the point i marked.
The invocation of f causes an immediate invocation 
(http://eel.is/c++draft/expr.const#12).
Immediate invocation are full expression 
(http://eel.is/c++draft/intro.execution#5).
Full expression resolve all there side-effects before evaluating the next full 
expression (http://eel.is/c++draft/intro.execution#9).
The return value of f() is created inside the immediate invocation.
So the destructor of the value returned by f() should be destroyed within the 
immediate evaluation.
But that value is needed for the assignment operator.
This seem contradictory. What have i misunderstood ? What should happen here ?


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

https://reviews.llvm.org/D63960



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


[PATCH] D69090: [Try 2] Include sanitize blacklist and other extra deps as part of scan-deps output

2019-10-17 Thread Kousik Kumar via Phabricator via cfe-commits
kousikk updated this revision to Diff 225375.
kousikk added a comment.

Fix tests now that output is in ascending order


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69090

Files:
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/test/ClangScanDeps/Inputs/non-header-dependency.json
  clang/test/ClangScanDeps/Inputs/sanitize-blacklist.txt
  clang/test/ClangScanDeps/header_stat_before_open.m
  clang/test/ClangScanDeps/headerwithdirname.cpp
  clang/test/ClangScanDeps/headerwithdirnamefollowedbyinclude.cpp
  clang/test/ClangScanDeps/no-werror.cpp
  clang/test/ClangScanDeps/non-header-dependency.cpp
  clang/test/ClangScanDeps/regular_cdb.cpp
  clang/test/ClangScanDeps/subframework_header_dir_symlink.m
  clang/test/ClangScanDeps/symlink.cpp
  clang/test/ClangScanDeps/vfsoverlay.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -17,6 +17,7 @@
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/Threading.h"
 #include 
+#include 
 #include 
 
 using namespace clang;
@@ -66,7 +67,7 @@
 StringRef File) override {
 if (!this->Opts)
   this->Opts = std::make_unique(Opts);
-Dependencies.push_back(File);
+Dependencies.insert(File);
   }
 
   void printDependencies(std::string &S) {
@@ -76,7 +77,7 @@
 class DependencyPrinter : public DependencyFileGenerator {
 public:
   DependencyPrinter(DependencyOutputOptions &Opts,
-ArrayRef Dependencies)
+std::set &Dependencies)
   : DependencyFileGenerator(Opts) {
 for (const auto &Dep : Dependencies)
   addDependency(Dep);
@@ -94,7 +95,7 @@
 
 private:
   std::unique_ptr Opts;
-  std::vector Dependencies;
+  std::set Dependencies;
 };
 
 DependencyPrinterConsumer Consumer;
Index: clang/test/ClangScanDeps/vfsoverlay.cpp
===
--- clang/test/ClangScanDeps/vfsoverlay.cpp
+++ clang/test/ClangScanDeps/vfsoverlay.cpp
@@ -13,5 +13,5 @@
 #include "not_real.h"
 
 // CHECK: vfsoverlay_input.o
-// CHECK-NEXT: vfsoverlay_input.cpp
 // CHECK-NEXT: Inputs{{/|\\}}header.h
+// CHECK-NEXT: vfsoverlay_input.cpp
Index: clang/test/ClangScanDeps/symlink.cpp
===
--- clang/test/ClangScanDeps/symlink.cpp
+++ clang/test/ClangScanDeps/symlink.cpp
@@ -14,10 +14,10 @@
 #include "symlink.h"
 #include "header.h"
 
-// CHECK: symlink_input.cpp
+// CHECK: Inputs{{/|\\}}header.h
 // CHECK-NEXT: Inputs{{/|\\}}symlink.h
-// CHECK-NEXT: Inputs{{/|\\}}header.h
+// CHECK-NEXT: symlink_input.cpp
 
-// CHECK: symlink_input2.cpp
+// CHECK: Inputs{{/|\\}}header.h
 // CHECK-NEXT: Inputs{{/|\\}}symlink.h
-// CHECK-NEXT: Inputs{{/|\\}}header.h
+// CHECK-NEXT: symlink_input2.cpp
\ No newline at end of file
Index: clang/test/ClangScanDeps/subframework_header_dir_symlink.m
===
--- clang/test/ClangScanDeps/subframework_header_dir_symlink.m
+++ clang/test/ClangScanDeps/subframework_header_dir_symlink.m
@@ -20,5 +20,5 @@
 // CHECK: subframework_header_dir_symlink_input.o
 // CHECK-NEXT: subframework_header_dir_symlink_input.m
 // CHECK: subframework_header_dir_symlink_input2.o
-// CHECK-NEXT: subframework_header_dir_symlink_input2.m
 // CHECK-NEXT: Inputs{{/|\\}}frameworks_symlink{{/|\\}}Framework.framework{{/|\\}}Headers{{/|\\}}Framework.h
+// CHECK-NEXT: subframework_header_dir_symlink_input2.m
Index: clang/test/ClangScanDeps/regular_cdb.cpp
===
--- clang/test/ClangScanDeps/regular_cdb.cpp
+++ clang/test/ClangScanDeps/regular_cdb.cpp
@@ -36,10 +36,11 @@
 #include "header.h"
 
 // CHECK1: regular_cdb_input2.cpp
-// CHECK1-NEXT: regular_cdb_input2.cpp
 // CHECK1-NEXT: Inputs{{/|\\}}header.h
 // CHECK1-NEXT: Inputs{{/|\\}}header2.h
+// CHECK1-NEXT: regular_cdb_input2.cpp
 
-// CHECK2: regular_cdb_input.cpp
+// CHECK2: regular_cdb_input.o
 // CHECK2-NEXT: Inputs{{/|\\}}header.h
-// CHECK2NO-NOT: header2
+// CHECK2NO-NOT: header2.h
+// CHECK2-NEXT: regular_cdb_input.cpp
Index: clang/test/ClangScanDeps/non-header-dependency.cpp
===
--- /dev/null
+++ clang/test/ClangScanDeps/non-header-dependency.cpp
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: cp %s %t.dir/non-header-dependency_input.cpp
+// RUN: mkdir %t.dir/Inputs
+// RUN: cp %S/Inputs/sanitize-blacklist.txt %t.dir/Inputs/sanitize-blacklist.txt
+// RUN: sed -e "s|DIR|%/t.d

[PATCH] D68969: [clang-format] Remove the dependency on frontend

2019-10-17 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: clang/tools/clang-format/ClangFormat.cpp:345
   if (WarnFormat && !NoWarnFormat) {
+ArrayRef> Ranges;
 for (const auto &R : Replaces) {

Looks unused?



Comment at: clang/tools/clang-format/ClangFormat.cpp:351
+  SourceLocation LineBegin = Sources.translateFileLineCol(
+  FileEntryPtr.get(), PLoc.getLine() - 1, 0);
+  SourceLocation NextLineBegin =

This is unexpected: I'd have expected this to be PLoc.getLine() here and 
PLoc.getLine() + 1 below. I'm probably missing something?


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

https://reviews.llvm.org/D68969



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


[PATCH] D68969: [clang-format] Remove the dependency on frontend

2019-10-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay marked 2 inline comments as done.
MyDeveloperDay added a comment.






Comment at: clang/tools/clang-format/ClangFormat.cpp:345
   if (WarnFormat && !NoWarnFormat) {
+ArrayRef> Ranges;
 for (const auto &R : Replaces) {

klimek wrote:
> Looks unused?
correct, I changed my mind and now call ArrayRef>() as the last argument not sure if thay would be slower than me 
creating one empty one outside the loop, any thoughts? I'll go with a consensus 
and will remove the other.



Comment at: clang/tools/clang-format/ClangFormat.cpp:351
+  SourceLocation LineBegin = Sources.translateFileLineCol(
+  FileEntryPtr.get(), PLoc.getLine() - 1, 0);
+  SourceLocation NextLineBegin =

klimek wrote:
> This is unexpected: I'd have expected this to be PLoc.getLine() here and 
> PLoc.getLine() + 1 below. I'm probably missing something?
This caught me out too, but it kept pulling the next line. So I think it must 
be a zero based line as opposed to PesumedLoc which uses line 1 to mean the 
first line..

but leet me double check.


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

https://reviews.llvm.org/D68969



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


[PATCH] D68969: [clang-format] Remove the dependency on frontend

2019-10-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay marked an inline comment as done.
MyDeveloperDay added inline comments.



Comment at: clang/tools/clang-format/ClangFormat.cpp:351
+  SourceLocation LineBegin = Sources.translateFileLineCol(
+  FileEntryPtr.get(), PLoc.getLine() - 1, 0);
+  SourceLocation NextLineBegin =

MyDeveloperDay wrote:
> klimek wrote:
> > This is unexpected: I'd have expected this to be PLoc.getLine() here and 
> > PLoc.getLine() + 1 below. I'm probably missing something?
> This caught me out too, but it kept pulling the next line. So I think it must 
> be a zero based line as opposed to PesumedLoc which uses line 1 to mean the 
> first line..
> 
> but leet me double check.
OK this then perhaps is wrong, given the assert.. let me double check what is 
going on.

```
 SourceLocation SourceManager::translateFileLineCol(const FileEntry *SourceFile,
   unsigned Line,
   unsigned Col) const {
   assert(SourceFile && "Null source file!");
   assert(Line && Col && "Line and column should start from 1!");
 
   FileID FirstFID = translateFile(SourceFile);
   return translateLineCol(FirstFID, Line, Col);
 }
```


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

https://reviews.llvm.org/D68969



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


[PATCH] D69072: [OpenCL] Added doc to describe OpenCL support

2019-10-17 Thread Marco Antognini via Phabricator via cfe-commits
mantognini added a comment.

Shouldn't this page be referenced from `clang/docs/index.rst`?

In the long run, how would this page differ from 
https://releases.llvm.org/9.0.0/tools/clang/docs/LanguageExtensions.html#opencl-features
 and 
https://releases.llvm.org/9.0.0/tools/clang/docs/UsersManual.html#opencl-features
 ? Do you think the content of those pages should be (partially) moved to the 
new one?


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

https://reviews.llvm.org/D69072



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


[PATCH] D67216: [cfi] Add flag to always generate .debug_frame

2019-10-17 Thread David Candler via Phabricator via cfe-commits
dcandler added a comment.

Ping?

I already spotted the line in CommandFlags.inc needs formatting with a couple 
of breaks. Also the help text in Options.td could be clearer. In particular, 
-gno-dwarf-frame shouldn't suggest .debug_frame won't be generated at all 
(since -g might still emit it). It should probably be more along the lines of:

-gdwarf-frame: "Emit a debug_frame section"
-gno-dwarf-frame: "Don't explicitly emit a debug_frame section"


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

https://reviews.llvm.org/D67216



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


[PATCH] D69094: [WIP] Add override relationship.

2019-10-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69094

Files:
  clang-tools-extra/clangd/index/Relation.cpp
  clang-tools-extra/clangd/index/Relation.h
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -676,6 +676,36 @@
   Contains(Relation{Base.ID, RelationKind::BaseOf, Derived.ID}));
 }
 
+TEST_F(SymbolCollectorTest, OverrideRelations) {
+  std::string Header = R"cpp(
+class Base {
+virtual void foo1();
+};
+class Derived1 : public Base {
+void foo1() override;
+virtual void foo2();
+};
+class Derived2 : public Derived1 {
+void foo2() override;
+};
+  )cpp";
+  runSymbolCollector(Header, /*Main=*/"");
+  const Symbol &Base = findSymbol(Symbols, "Base");
+  const Symbol &Derived1 = findSymbol(Symbols, "Derived1");
+  const Symbol &Derived2 = findSymbol(Symbols, "Derived2");
+  const Symbol &Foo1 = findSymbol(Symbols, "Base::foo1");
+  const Symbol &OverrideFoo1 = findSymbol(Symbols, "Derived1::foo1");
+  const Symbol &Foo2 = findSymbol(Symbols, "Derived1::foo2");
+  const Symbol &OverrideFoo2 = findSymbol(Symbols, "Derived2::foo2");
+  EXPECT_THAT(Relations,
+  UnorderedElementsAreArray({
+  Relation{Foo1.ID, RelationKind::OverridenBy, OverrideFoo1.ID},
+  Relation{Foo2.ID, RelationKind::OverridenBy, OverrideFoo2.ID},
+  Relation{Base.ID, RelationKind::BaseOf, Derived1.ID},
+  Relation{Derived1.ID, RelationKind::BaseOf, Derived2.ID},
+  }));
+}
+
 TEST_F(SymbolCollectorTest, References) {
   const std::string Header = R"(
 class W;
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -16,6 +16,7 @@
 #include "SourceCode.h"
 #include "SymbolLocation.h"
 #include "URI.h"
+#include "index/Relation.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
@@ -184,7 +185,16 @@
 
 bool shouldIndexRelation(const index::SymbolRelation &R) {
   // We currently only index BaseOf relations, for type hierarchy subtypes.
-  return R.Roles & static_cast(index::SymbolRole::RelationBaseOf);
+  return R.Roles & static_cast(index::SymbolRole::RelationBaseOf) ||
+ R.Roles & static_cast(index::SymbolRole::RelationOverrideOf);
+}
+
+llvm::Optional indexableRelation(const index::SymbolRelation &R) {
+  if (R.Roles & static_cast(index::SymbolRole::RelationBaseOf))
+return RelationKind::BaseOf;
+  if (R.Roles & static_cast(index::SymbolRole::RelationOverrideOf))
+return RelationKind::OverridenBy;
+  return None;
 }
 
 } // namespace
@@ -422,14 +432,12 @@
 void SymbolCollector::processRelations(
 const NamedDecl &ND, const SymbolID &ID,
 ArrayRef Relations) {
-  // Store subtype relations.
-  if (!dyn_cast(&ND))
-return;
-
   for (const auto &R : Relations) {
-if (!shouldIndexRelation(R))
+// if (!shouldIndexRelation(R))
+//   continue;
+auto RKind = indexableRelation(R);
+if (!RKind)
   continue;
-
 const Decl *Object = R.RelatedSymbol;
 
 auto ObjectID = getSymbolID(Object);
@@ -445,7 +453,10 @@
 //   in the index and find nothing, but that's a situation they
 //   probably need to handle for other reasons anyways.
 // We currently do (B) because it's simpler.
-this->Relations.insert(Relation{ID, RelationKind::BaseOf, *ObjectID});
+if (*RKind == RelationKind::BaseOf)
+  this->Relations.insert({ID, *RKind, *ObjectID});
+else if (*RKind == RelationKind::OverridenBy)
+  this->Relations.insert({*ObjectID, *RKind, ID});
   }
 }
 
Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -31,26 +31,6 @@
 }
 } // namespace
 
-RelationKind symbolRoleToRelationKind(index::SymbolRole Role) {
-  // SymbolRole is used to record relations in the index.
-  // Only handle the relations we actually store currently.
-  // If we start storing more relations, this list can be expanded.
-  switch (Role) {
-  case index::SymbolRole::RelationBaseOf:
-return RelationKind::BaseOf;
-  default:
-llvm_unreachable("Unsupported symbol role");
-  }
-}
-
-index::SymbolRole relationKindToS

r375094 - Reland: Dead Virtual Function Elimination

2019-10-17 Thread Oliver Stannard via cfe-commits
Author: ostannard
Date: Thu Oct 17 02:58:57 2019
New Revision: 375094

URL: http://llvm.org/viewvc/llvm-project?rev=375094&view=rev
Log:
Reland: Dead Virtual Function Elimination

Remove dead virtual functions from vtables with
replaceNonMetadataUsesWith, so that CGProfile metadata gets cleaned up
correctly.

Original commit message:

Currently, it is hard for the compiler to remove unused C++ virtual
functions, because they are all referenced from vtables, which are referenced
by constructors. This means that if the constructor is called from any live
code, then we keep every virtual function in the final link, even if there
are no call sites which can use it.

This patch allows unused virtual functions to be removed during LTO (and
regular compilation in limited circumstances) by using type metadata to match
virtual function call sites to the vtable slots they might load from. This
information can then be used in the global dead code elimination pass instead
of the references from vtables to virtual functions, to more accurately
determine which functions are reachable.

To make this transformation safe, I have changed clang's code-generation to
always load virtual function pointers using the llvm.type.checked.load
intrinsic, instead of regular load instructions. I originally tried writing
this using clang's existing code-generation, which uses the llvm.type.test
and llvm.assume intrinsics after doing a normal load. However, it is possible
for optimisations to obscure the relationship between the GEP, load and
llvm.type.test, causing GlobalDCE to fail to find virtual function call
sites.

The existing linkage and visibility types don't accurately describe the scope
in which a virtual call could be made which uses a given vtable. This is
wider than the visibility of the type itself, because a virtual function call
could be made using a more-visible base class. I've added a new
!vcall_visibility metadata type to represent this, described in
TypeMetadata.rst. The internalization pass and libLTO have been updated to
change this metadata when linking is performed.

This doesn't currently work with ThinLTO, because it needs to see every call
to llvm.type.checked.load in the linkage unit. It might be possible to
extend this optimisation to be able to use the ThinLTO summary, as was done
for devirtualization, but until then that combination is rejected in the
clang driver.

To test this, I've written a fuzzer which generates random C++ programs with
complex class inheritance graphs, and virtual functions called through object
and function pointers of different types. The programs are spread across
multiple translation units and DSOs to test the different visibility
restrictions.

I've also tried doing bootstrap builds of LLVM to test this. This isn't
ideal, because only classes in anonymous namespaces can be optimised with
-fvisibility=default, and some parts of LLVM (plugins and bugpoint) do not
work correctly with -fvisibility=hidden. However, there are only 12 test
failures when building with -fvisibility=hidden (and an unmodified compiler),
and this change does not cause any new failures for either value of
-fvisibility.

On the 7 C++ sub-benchmarks of SPEC2006, this gives a geomean code-size
reduction of ~6%, over a baseline compiled with "-O2 -flto
-fvisibility=hidden -fwhole-program-vtables". The best cases are reductions
of ~14% in 450.soplex and 483.xalancbmk, and there are no code size
increases.

I've also run this on a set of 8 mbed-os examples compiled for Armv7M, which
show a geomean size reduction of ~3%, again with no size increases.

I had hoped that this would have no effect on performance, which would allow
it to awlays be enabled (when using -fwhole-program-vtables). However, the
changes in clang to use the llvm.type.checked.load intrinsic are causing ~1%
performance regression in the C++ parts of SPEC2006. It should be possible to
recover some of this perf loss by teaching optimisations about the
llvm.type.checked.load intrinsic, which would make it worth turning this on
by default (though it's still dependent on -fwhole-program-vtables).

Differential revision: https://reviews.llvm.org/D63932

Added:
cfe/trunk/test/CodeGenCXX/vcall-visibility-metadata.cpp
cfe/trunk/test/CodeGenCXX/virtual-function-elimination.cpp
cfe/trunk/test/Driver/virtual-function-elimination.cpp
Modified:
cfe/trunk/include/clang/Basic/CodeGenOptions.def
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Basic/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CodeGenOptions.def?rev=375094&r1=375093&r2=375094&view=diff
===

[PATCH] D69072: [OpenCL] Added doc to describe OpenCL support

2019-10-17 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D69072#1712473 , @mantognini wrote:

> Shouldn't this page be referenced from `clang/docs/index.rst`?


Oops, yes! Sure. I will update. Thanks!

> In the long run, how would this page differ from 
> https://releases.llvm.org/9.0.0/tools/clang/docs/LanguageExtensions.html#opencl-features

This documents the language extensions.

> and 
> https://releases.llvm.org/9.0.0/tools/clang/docs/UsersManual.html#opencl-features
>  ?

Explains how to use OpenCL

> Do you think the content of those pages should be (partially) moved to the 
> new one?

Possibly but the page I am adding is intended to document the state of 
implementations i.e. features that are incomplete or in intermediate phase and 
potentially even what we are planning to support  in the near future. So it's 
intended more for the clang users to understand what they can or can't compile 
yet.


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

https://reviews.llvm.org/D69072



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


[PATCH] D67216: [cfi] Add flag to always generate .debug_frame

2019-10-17 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard added a comment.

I don't like the idea of adding a `-gno-dwarf-frame` option which doesn't 
always disable emission of `.debug_frame`. Since it doesn't make sense to emit 
other debug info without `.debug_frame`, maybe we should just not have a 
negative option?


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

https://reviews.llvm.org/D67216



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


[PATCH] D69043: [RFC] Adding time-trace to LLD?

2019-10-17 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added a comment.

This seems useful. Can I see an example output?

Speaking of the output file, I'd make --time-trace option to take an output 
filename, as an output executable doesn't always have an extension (On Windows 
it's almost always .exe, but on Unix, extension is usually omitted).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69043



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


r375097 - SemaDeclObjC - silence static analyzer getAs<> null dereference warnings. NFCI.

2019-10-17 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Oct 17 03:35:29 2019
New Revision: 375097

URL: http://llvm.org/viewvc/llvm-project?rev=375097&view=rev
Log:
SemaDeclObjC - silence static analyzer getAs<> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but in these 
cases we should be able to use castAs<> directly and if not assert will fire 
for us.

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

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=375097&r1=375096&r2=375097&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Oct 17 03:35:29 2019
@@ -586,7 +586,7 @@ ActOnSuperClassOfClassInterface(Scope *S
   dyn_cast_or_null(PrevDecl)) {
 QualType T = TDecl->getUnderlyingType();
 if (T->isObjCObjectType()) {
-  if (NamedDecl *IDecl = T->getAs()->getInterface()) {
+  if (NamedDecl *IDecl = T->castAs()->getInterface()) {
 SuperClassDecl = dyn_cast(IDecl);
 SuperClassType = Context.getTypeDeclType(TDecl);
 
@@ -1151,7 +1151,7 @@ Decl *Sema::ActOnCompatibilityAlias(Sour
 dyn_cast_or_null(CDeclU)) {
 QualType T = TDecl->getUnderlyingType();
 if (T->isObjCObjectType()) {
-  if (NamedDecl *IDecl = T->getAs()->getInterface()) {
+  if (NamedDecl *IDecl = T->castAs()->getInterface()) {
 ClassName = IDecl->getIdentifier();
 CDeclU = LookupSingleName(TUScope, ClassName, ClassLocation,
   LookupOrdinaryName,
@@ -4876,7 +4876,7 @@ VarDecl *Sema::BuildObjCExceptionDecl(Ty
   } else if (!T->isObjCObjectPointerType()) {
 Invalid = true;
 Diag(IdLoc, diag::err_catch_param_not_objc_type);
-  } else if (!T->getAs()->getInterfaceType()) {
+  } else if (!T->castAs()->getInterfaceType()) {
 Invalid = true;
 Diag(IdLoc, diag::err_catch_param_not_objc_type);
   }


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


[PATCH] D69072: [OpenCL] Added doc to describe OpenCL support

2019-10-17 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 225391.
Anastasia edited the summary of this revision.
Anastasia added a comment.
Herald added a subscriber: arphaman.

Added OpenCLSupport page into index.


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

https://reviews.llvm.org/D69072

Files:
  clang/docs/OpenCLSupport.rst
  clang/docs/index.rst


Index: clang/docs/index.rst
===
--- clang/docs/index.rst
+++ clang/docs/index.rst
@@ -41,6 +41,7 @@
SourceBasedCodeCoverage
Modules
MSVCCompatibility
+   OpenCLSupport
OpenMPSupport
ThinLTO
CommandGuide/index
Index: clang/docs/OpenCLSupport.rst
===
--- /dev/null
+++ clang/docs/OpenCLSupport.rst
@@ -0,0 +1,47 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.partial { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: partial
+.. role:: good
+
+.. contents::
+   :local:
+
+==
+OpenCL Support
+==
+
+Clang fully supports all OpenCL C versions from 1.1 to 2.0.
+
+Please refer to `Bugzilla
+`_
+for the most up to date bugs report.
+
+
+C++ for OpenCL Implementation Status
+
+
+Bugzilla bugs for this functionality are typically prefixed
+with '[C++]'.
+
+Differences to OpenCL C
+---
+
+TODO!
+
+Missing features or with limited support
+
+
+- Use of ObjC blocks is disabled.
+
+- Global destructor invocation is not generated correctly.
+
+- Initialization of objects in `__constant` addr spaces is not guaranteed to 
work.
+
+- `addrspace_cast` operator is not supported.


Index: clang/docs/index.rst
===
--- clang/docs/index.rst
+++ clang/docs/index.rst
@@ -41,6 +41,7 @@
SourceBasedCodeCoverage
Modules
MSVCCompatibility
+   OpenCLSupport
OpenMPSupport
ThinLTO
CommandGuide/index
Index: clang/docs/OpenCLSupport.rst
===
--- /dev/null
+++ clang/docs/OpenCLSupport.rst
@@ -0,0 +1,47 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.partial { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: partial
+.. role:: good
+
+.. contents::
+   :local:
+
+==
+OpenCL Support
+==
+
+Clang fully supports all OpenCL C versions from 1.1 to 2.0.
+
+Please refer to `Bugzilla
+`_
+for the most up to date bugs report.
+
+
+C++ for OpenCL Implementation Status
+
+
+Bugzilla bugs for this functionality are typically prefixed
+with '[C++]'.
+
+Differences to OpenCL C
+---
+
+TODO!
+
+Missing features or with limited support
+
+
+- Use of ObjC blocks is disabled.
+
+- Global destructor invocation is not generated correctly.
+
+- Initialization of objects in `__constant` addr spaces is not guaranteed to work.
+
+- `addrspace_cast` operator is not supported.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r375101 - SemaExprCXX - silence static analyzer getAs<> null dereference warnings. NFCI.

2019-10-17 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Oct 17 04:12:31 2019
New Revision: 375101

URL: http://llvm.org/viewvc/llvm-project?rev=375101&view=rev
Log:
SemaExprCXX - silence static analyzer getAs<> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but in these 
cases we should be able to use castAs<> directly and if not assert will fire 
for us.

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

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=375101&r1=375100&r2=375101&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Oct 17 04:12:31 2019
@@ -3302,7 +3302,7 @@ Sema::ActOnCXXDelete(SourceLocation Star
   //itself in this case.
   return ExprError();
 
-QualType Pointee = Type->getAs()->getPointeeType();
+QualType Pointee = Type->castAs()->getPointeeType();
 QualType PointeeElem = Context.getBaseElementType(Pointee);
 
 if (Pointee.getAddressSpace() != LangAS::Default &&
@@ -4034,8 +4034,8 @@ Sema::PerformImplicitConversion(Expr *Fr
 
   case ICK_Complex_Promotion:
   case ICK_Complex_Conversion: {
-QualType FromEl = From->getType()->getAs()->getElementType();
-QualType ToEl = ToType->getAs()->getElementType();
+QualType FromEl = From->getType()->castAs()->getElementType();
+QualType ToEl = ToType->castAs()->getElementType();
 CastKind CK;
 if (FromEl->isRealFloatingType()) {
   if (ToEl->isRealFloatingType())


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


[clang-tools-extra] r375102 - clang-tidy - silence static analyzer getAs<> null dereference warnings. NFCI.

2019-10-17 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Oct 17 04:12:53 2019
New Revision: 375102

URL: http://llvm.org/viewvc/llvm-project?rev=375102&view=rev
Log:
clang-tidy - silence static analyzer getAs<> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but in these 
cases we should be able to use castAs<> directly and if not assert will fire 
for us.

Modified:
clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp?rev=375102&r1=375101&r2=375102&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp Thu 
Oct 17 04:12:53 2019
@@ -478,7 +478,7 @@ canOverloadedOperatorArgsBeModified(cons
   // These functions must be declared const in order to not be able to modify
   // the instance of the class they are called through.
   if (ParamCount == 1 &&
-  !OperatorDecl->getType()->getAs()->isConst())
+  !OperatorDecl->getType()->castAs()->isConst())
 return true;
 
   if (isNonConstReferenceType(OperatorDecl->getParamDecl(0)->getType()))

Modified: 
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp?rev=375102&r1=375101&r2=375102&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
Thu Oct 17 04:12:53 2019
@@ -29,7 +29,7 @@ static StringRef getValueOfValueInit(con
 return "false";
 
   case Type::STK_Integral:
-switch (InitType->getAs()->getKind()) {
+switch (InitType->castAs()->getKind()) {
 case BuiltinType::Char_U:
 case BuiltinType::UChar:
 case BuiltinType::Char_S:
@@ -47,7 +47,7 @@ static StringRef getValueOfValueInit(con
 }
 
   case Type::STK_Floating:
-switch (InitType->getAs()->getKind()) {
+switch (InitType->castAs()->getKind()) {
 case BuiltinType::Half:
 case BuiltinType::Float:
   return "0.0f";
@@ -58,10 +58,10 @@ static StringRef getValueOfValueInit(con
   case Type::STK_FloatingComplex:
   case Type::STK_IntegralComplex:
 return getValueOfValueInit(
-InitType->getAs()->getElementType());
+InitType->castAs()->getElementType());
 
   case Type::STK_FixedPoint:
-switch (InitType->getAs()->getKind()) {
+switch (InitType->castAs()->getKind()) {
 case BuiltinType::ShortAccum:
 case BuiltinType::SatShortAccum:
   return "0.0hk";


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


r375104 - Include leading attributes in DeclStmt's SourceRange

2019-10-17 Thread Stephan Bergmann via cfe-commits
Author: sberg
Date: Thu Oct 17 04:20:21 2019
New Revision: 375104

URL: http://llvm.org/viewvc/llvm-project?rev=375104&view=rev
Log:
Include leading attributes in DeclStmt's SourceRange

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

Modified:
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/test/AST/sourceranges.cpp

Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=375104&r1=375103&r2=375104&view=diff
==
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Thu Oct 17 04:20:21 2019
@@ -220,6 +220,8 @@ Retry:
 Decl =
 ParseDeclaration(DeclaratorContext::BlockContext, DeclEnd, Attrs);
   }
+  if (Attrs.Range.getBegin().isValid())
+DeclStart = Attrs.Range.getBegin();
   return Actions.ActOnDeclStmt(Decl, DeclStart, DeclEnd);
 }
 

Modified: cfe/trunk/test/AST/sourceranges.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/sourceranges.cpp?rev=375104&r1=375103&r2=375104&view=diff
==
--- cfe/trunk/test/AST/sourceranges.cpp (original)
+++ cfe/trunk/test/AST/sourceranges.cpp Thu Oct 17 04:20:21 2019
@@ -92,6 +92,22 @@ struct map {
 
 }; // namespace std
 
+// CHECK: NamespaceDecl {{.*}} attributed_decl
+namespace attributed_decl {
+  void f() {
+// CHECK: DeclStmt {{.*}} 
+[[maybe_unused]] int i1;
+// CHECK: DeclStmt {{.*}} 
+__attribute__((unused)) int i2;
+// CHECK: DeclStmt {{.*}} 
+int __attribute__((unused)) i3;
+// CHECK: DeclStmt {{.*}} <:{{.*}}, {{.*}}:[[@LINE+1]]:40>
+__declspec(dllexport) extern int i4;
+// CHECK: DeclStmt {{.*}} 
+extern int __declspec(dllexport) i5;
+  }
+}
+
 #if __cplusplus >= 201703L
 // CHECK-1Z: FunctionDecl {{.*}} construct_with_init_list
 std::map construct_with_init_list() {


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


[PATCH] D69072: [OpenCL] Added doc to describe OpenCL support

2019-10-17 Thread Marco Antognini via Phabricator via cfe-commits
mantognini accepted this revision.
mantognini added a comment.
This revision is now accepted and ready to land.

Alright, thanks for the explanation. LGTM then.


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

https://reviews.llvm.org/D69072



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


[PATCH] D68581: Include leading attributes in DeclStmt's SourceRange

2019-10-17 Thread Stephan Bergmann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdc3957ec215d: Include leading attributes in DeclStmt's 
SourceRange (authored by sberg).

Changed prior to commit:
  https://reviews.llvm.org/D68581?vs=224823&id=225397#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68581

Files:
  clang/lib/Parse/ParseStmt.cpp
  clang/test/AST/sourceranges.cpp


Index: clang/test/AST/sourceranges.cpp
===
--- clang/test/AST/sourceranges.cpp
+++ clang/test/AST/sourceranges.cpp
@@ -92,6 +92,22 @@
 
 }; // namespace std
 
+// CHECK: NamespaceDecl {{.*}} attributed_decl
+namespace attributed_decl {
+  void f() {
+// CHECK: DeclStmt {{.*}} 
+[[maybe_unused]] int i1;
+// CHECK: DeclStmt {{.*}} 
+__attribute__((unused)) int i2;
+// CHECK: DeclStmt {{.*}} 
+int __attribute__((unused)) i3;
+// CHECK: DeclStmt {{.*}} <:{{.*}}, {{.*}}:[[@LINE+1]]:40>
+__declspec(dllexport) extern int i4;
+// CHECK: DeclStmt {{.*}} 
+extern int __declspec(dllexport) i5;
+  }
+}
+
 #if __cplusplus >= 201703L
 // CHECK-1Z: FunctionDecl {{.*}} construct_with_init_list
 std::map construct_with_init_list() {
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -220,6 +220,8 @@
 Decl =
 ParseDeclaration(DeclaratorContext::BlockContext, DeclEnd, Attrs);
   }
+  if (Attrs.Range.getBegin().isValid())
+DeclStart = Attrs.Range.getBegin();
   return Actions.ActOnDeclStmt(Decl, DeclStart, DeclEnd);
 }
 


Index: clang/test/AST/sourceranges.cpp
===
--- clang/test/AST/sourceranges.cpp
+++ clang/test/AST/sourceranges.cpp
@@ -92,6 +92,22 @@
 
 }; // namespace std
 
+// CHECK: NamespaceDecl {{.*}} attributed_decl
+namespace attributed_decl {
+  void f() {
+// CHECK: DeclStmt {{.*}} 
+[[maybe_unused]] int i1;
+// CHECK: DeclStmt {{.*}} 
+__attribute__((unused)) int i2;
+// CHECK: DeclStmt {{.*}} 
+int __attribute__((unused)) i3;
+// CHECK: DeclStmt {{.*}} <:{{.*}}, {{.*}}:[[@LINE+1]]:40>
+__declspec(dllexport) extern int i4;
+// CHECK: DeclStmt {{.*}} 
+extern int __declspec(dllexport) i5;
+  }
+}
+
 #if __cplusplus >= 201703L
 // CHECK-1Z: FunctionDecl {{.*}} construct_with_init_list
 std::map construct_with_init_list() {
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -220,6 +220,8 @@
 Decl =
 ParseDeclaration(DeclaratorContext::BlockContext, DeclEnd, Attrs);
   }
+  if (Attrs.Range.getBegin().isValid())
+DeclStart = Attrs.Range.getBegin();
   return Actions.ActOnDeclStmt(Decl, DeclStart, DeclEnd);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68977: [clangd] Report declaration references in findExplicitReferences.

2019-10-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:415
 
 Optional refInDecl(const Decl *D) {
   struct Visitor : ConstDeclVisitor {

ilya-biryukov wrote:
> This should return `SmallVector` now, some declarations can 
> have both decl and non-decl references.
Can you give some examples? It seems that non-decl references are handled by 
other `refIn*` functions.

```
int Foo = OtherBar; // OtherBar is captured at the momment.
```



Comment at: clang-tools-extra/clangd/FindTarget.cpp:444
+
+void VisitDeclaratorDecl(const DeclaratorDecl *ND) {
+  Ref =

ilya-biryukov wrote:
> This should be handled in `VisitNamedDecl`, we should use a helper similar to 
> `getQualifier` from `AST.h` to get the qualifier loc instead.
good point, didn't aware of this utility method, exposed it in `AST.h`.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:756
+  if (R.IsDecl)
+OS << ", decl ref";
   return OS;

ilya-biryukov wrote:
> NIT: maybe use `declaration` instead?
> `ref` is definitely redundant, we know we're printing a reference.
changed to `decl`.



Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:528
+  /// AST.
+  AllRefs annotateReferencesInMainAST(llvm::StringRef Code) {
+TestTU TU;

ilya-biryukov wrote:
> Why do we need this? Can't we test everything we do by putting into `foo`?
> 
> The original idea was to avoid too much output in the tests by letting the 
> setup code live outside the function that's being annotated.
> Any reason why we have to do the full file here?
> 
> I know it's a weird limitation, but that's one that was already made and I'd 
> keep it this way if it's possible.
I tried it but failed.

We can't test the qualified definitions (see example below) if we put 
everything into function `foo` (as defining a namespace is not allowed inside a 
function)

```
namespace $0^ns {
class $1^Foo {
 void $2^method();
};
void $3^func();
}
void $4^ns::$5^Foo::$6^method() {}
void $7^ns::$8^func() {}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68977



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


[PATCH] D68977: [clangd] Report declaration references in findExplicitReferences.

2019-10-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 225398.
hokein marked 14 inline comments as done.
hokein added a comment.

address comments:

- remove the confusing IsDeclRef
- use getQualifier from AST.h


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68977

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/FindTarget.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -2277,7 +2277,8 @@
   if (const auto *ND = llvm::dyn_cast(D))
 Names.push_back(ND->getQualifiedNameAsString());
 }
-EXPECT_THAT(Names, UnorderedElementsAreArray(C.ExpectedDecls));
+EXPECT_THAT(Names, UnorderedElementsAreArray(C.ExpectedDecls))
+<< File.code();
   }
 }
 
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -520,8 +520,28 @@
 findExplicitReferences(Func.getBody(), [&Refs](ReferenceLoc R) {
   Refs.push_back(std::move(R));
 });
+return dumpReferences(std::move(Refs), Code, AST.getSourceManager());
+  }
+
+  /// Similar to annotateReferencesInFoo, but finds all references in the main
+  /// AST.
+  AllRefs annotateReferencesInMainAST(llvm::StringRef Code) {
+TestTU TU;
+TU.Code = Code;
 
-auto &SM = AST.getSourceManager();
+auto AST = TU.build();
+std::vector Refs;
+for (const auto *ToplLevelDecl : AST.getLocalTopLevelDecls()) {
+  findExplicitReferences(ToplLevelDecl, [&Refs](ReferenceLoc R) {
+Refs.push_back(std::move(R));
+  });
+}
+return dumpReferences(std::move(Refs), Code, AST.getSourceManager());
+  }
+
+private:
+  AllRefs dumpReferences(std::vector Refs, llvm::StringRef Code,
+ const SourceManager &SM) {
 llvm::sort(Refs, [&](const ReferenceLoc &L, const ReferenceLoc &R) {
   return SM.isBeforeInTranslationUnit(L.NameLoc, R.NameLoc);
 });
@@ -600,59 +620,67 @@
   }
 )cpp",
"0: targets = {ns}\n"
-   "1: targets = {ns::global}, qualifier = 'ns::'\n"},
+   "1: targets = {ns::global}, qualifier = 'ns::', decl\n"},
   // Simple types.
   {R"cpp(
  struct Struct { int a; };
  using Typedef = int;
  void foo() {
-   $0^Struct x;
-   $1^Typedef y;
-   static_cast<$2^Struct*>(0);
+   $0^Struct $1^x;
+   $2^Typedef $3^y;
+   static_cast<$4^Struct*>(0);
  }
)cpp",
"0: targets = {Struct}\n"
-   "1: targets = {Typedef}\n"
-   "2: targets = {Struct}\n"},
+   "1: targets = {x}, decl\n"
+   "2: targets = {Typedef}\n"
+   "3: targets = {y}, decl\n"
+   "4: targets = {Struct}\n"},
   // Name qualifiers.
   {R"cpp(
  namespace a { namespace b { struct S { typedef int type; }; } }
  void foo() {
-   $0^a::$1^b::$2^S x;
-   using namespace $3^a::$4^b;
-   $5^S::$6^type y;
+   $0^a::$1^b::$2^S $3^x;
+   using namespace $4^a::$5^b;
+   $6^S::$7^type $8^y;
  }
 )cpp",
"0: targets = {a}\n"
"1: targets = {a::b}, qualifier = 'a::'\n"
"2: targets = {a::b::S}, qualifier = 'a::b::'\n"
-   "3: targets = {a}\n"
-   "4: targets = {a::b}, qualifier = 'a::'\n"
-   "5: targets = {a::b::S}\n"
-   "6: targets = {a::b::S::type}, qualifier = 'struct S::'\n"},
+   "3: targets = {x}, decl\n"
+   "4: targets = {a}\n"
+   "5: targets = {a::b}, qualifier = 'a::'\n"
+   "6: targets = {a::b::S}\n"
+   "7: targets = {a::b::S::type}, qualifier = 'struct S::'\n"
+   "8: targets = {y}, decl\n"},
   // Simple templates.
   {R"cpp(
   template  struct vector { using value_type = T; };
   template <> struct vector { using value_type = bool; };
   void foo() {
-$0^vector vi;
-$1^vector vb;
+$0^vector $1^vi;
+$2^vector $3^vb;
   }
 )cpp",
"0: targets = {vector}\n"
-   "1: targets = {vector}\n"},
+   "1: targets = {vi}, decl\n"
+   "2: targets = {vector}\n"
+   "3: targets = {vb}, decl\n"},
   // Template type aliases.
   {R"cpp(
 template  struct vector { using value_type =

[PATCH] D68977: [clangd] Report declaration references in findExplicitReferences.

2019-10-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:528
+  /// AST.
+  AllRefs annotateReferencesInMainAST(llvm::StringRef Code) {
+TestTU TU;

hokein wrote:
> ilya-biryukov wrote:
> > Why do we need this? Can't we test everything we do by putting into `foo`?
> > 
> > The original idea was to avoid too much output in the tests by letting the 
> > setup code live outside the function that's being annotated.
> > Any reason why we have to do the full file here?
> > 
> > I know it's a weird limitation, but that's one that was already made and 
> > I'd keep it this way if it's possible.
> I tried it but failed.
> 
> We can't test the qualified definitions (see example below) if we put 
> everything into function `foo` (as defining a namespace is not allowed inside 
> a function)
> 
> ```
> namespace $0^ns {
> class $1^Foo {
>  void $2^method();
> };
> void $3^func();
> }
> void $4^ns::$5^Foo::$6^method() {}
> void $7^ns::$8^func() {}
> ```
Fair point, but this patch does not add support for references in qualifiers of 
declarations.
I'd keep this change away.

We can totally test all things added by this patch inside the function body.

Could you split the part that adds tests for qualifiers into a separate change?
That would both make the current change more focused and allow to discuss 
alternatives for the testing story independently of the functionality we're 
adding here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68977



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


[PATCH] D68977: [clangd] Report declaration references in findExplicitReferences.

2019-10-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:415
 
 Optional refInDecl(const Decl *D) {
   struct Visitor : ConstDeclVisitor {

hokein wrote:
> ilya-biryukov wrote:
> > This should return `SmallVector` now, some declarations 
> > can have both decl and non-decl references.
> Can you give some examples? It seems that non-decl references are handled by 
> other `refIn*` functions.
> 
> ```
> int Foo = OtherBar; // OtherBar is captured at the momment.
> ```
```
namespace $1[[a]] = $2[[std]];
```

`$1` is a declaration of a namespace alias.
`$2` is a reference to namespace std.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68977



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


[PATCH] D68403: [OpenCL] PR43145: preserve addrspace for class accesses

2019-10-17 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D68403



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


[PATCH] D68977: [clangd] Report declaration references in findExplicitReferences.

2019-10-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:846
+ // the underlying FunctionDecl. we should report just one.
+ void $12^$13^F() {}
+   )cpp",

Could we avoid adding this test in this revision?
We could add it in a follow-up patch along with the fix.



Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:850
+   "1: targets = {Foo::Foo}, decl\n"
+   "2: targets = {Foo::~Foo}, decl\n"
+   "3: targets = {Foo}\n"

Could we avoid reporting destructor references for now? I feel they would 
create more confusion than bring value.
Mostly worried that they overlap with a reference to the type name and now all 
client code will probably want to filter out destructor references.

I believe they're not critical to any of the use-cases we have so far, having a 
``// FIXME: decide how to surface destructors when we need them` should be good 
enough for now


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68977



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


[PATCH] D68977: [clangd] Report declaration references in findExplicitReferences.

2019-10-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/AST.cpp:110
+
+static bool isAnonymous(const DeclarationName &N) {
+  return N.isIdentifier() && !N.getAsIdentifierInfo();

could you move this one back above `getQualifierLoc` ?



Comment at: clang-tools-extra/clangd/FindTarget.cpp:415
 
 Optional refInDecl(const Decl *D) {
   struct Visitor : ConstDeclVisitor {

ilya-biryukov wrote:
> hokein wrote:
> > ilya-biryukov wrote:
> > > This should return `SmallVector` now, some declarations 
> > > can have both decl and non-decl references.
> > Can you give some examples? It seems that non-decl references are handled 
> > by other `refIn*` functions.
> > 
> > ```
> > int Foo = OtherBar; // OtherBar is captured at the momment.
> > ```
> ```
> namespace $1[[a]] = $2[[std]];
> ```
> 
> `$1` is a declaration of a namespace alias.
> `$2` is a reference to namespace std.
I was just about to make the same point. After this patch lands I would like to 
detect `using namespace`s inside function body, and currently there is no way 
to distinguish between a usingdirective and a namespacealias. Since both is 
only referencing the target namespace.

So even if this starts reporting `$2` in the comment above, there should be a 
difference between that and `$3` in `using namespace $3[[std]];`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68977



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


[PATCH] D68977: [clangd] Report declaration references in findExplicitReferences.

2019-10-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:438
  D->getTargetNameLoc(),
+ /*IsDecl=*/true,
  {D->getAliasedNamespace()}};

This one is a **not** a declaration reference.
We could call `VisitNamedDecl` here to report the actual declaration.

Note that this would require returning two results from this function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68977



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


[PATCH] D68977: [clangd] Report declaration references in findExplicitReferences.

2019-10-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:415
 
 Optional refInDecl(const Decl *D) {
   struct Visitor : ConstDeclVisitor {

kadircet wrote:
> ilya-biryukov wrote:
> > hokein wrote:
> > > ilya-biryukov wrote:
> > > > This should return `SmallVector` now, some 
> > > > declarations can have both decl and non-decl references.
> > > Can you give some examples? It seems that non-decl references are handled 
> > > by other `refIn*` functions.
> > > 
> > > ```
> > > int Foo = OtherBar; // OtherBar is captured at the momment.
> > > ```
> > ```
> > namespace $1[[a]] = $2[[std]];
> > ```
> > 
> > `$1` is a declaration of a namespace alias.
> > `$2` is a reference to namespace std.
> I was just about to make the same point. After this patch lands I would like 
> to detect `using namespace`s inside function body, and currently there is no 
> way to distinguish between a usingdirective and a namespacealias. Since both 
> is only referencing the target namespace.
> 
> So even if this starts reporting `$2` in the comment above, there should be a 
> difference between that and `$3` in `using namespace $3[[std]];`
That's intentional, though. When we report references, we deliberately leave 
out information on where it's coming from - otherwise it's hard to encode it.

However, if we really need that, we could also pass a `NamedDecl*` when 
reporting declarations (that would mean a slightly different interface, though).

We still have some complexity budget in `findExplicitReferences` and we should 
probably spend it here.
OTOH, adding more stuff will probably bloat it too much, I hope we'll stop 
there... There will still be cases when one would have to write a separate AST 
traversal to do more complicated stuff. It's unfortunate that this is twice as 
expensive, but it shouldn't matter in most cases (e.g. when running inside 
`Tweak::apply`)

I'd suggest we keep this patch with `IsDecl` flag, but happy to look into your 
use-case with `using namespaces` more closely...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68977



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


Re: r374135 - [c++20] P1152R4: warn on any simple-assignment to a volatile lvalue

2019-10-17 Thread Stephan Bergmann via cfe-commits

On 09/10/2019 04:04, Richard Smith via cfe-commits wrote:

Author: rsmith
Date: Tue Oct  8 19:04:54 2019
New Revision: 374135

URL: http://llvm.org/viewvc/llvm-project?rev=374135&view=rev
Log:
[c++20] P1152R4: warn on any simple-assignment to a volatile lvalue
whose value is not ignored.

We don't warn on all the cases that are deprecated: specifically, we
choose to not warn for now if there are parentheses around the
assignment but its value is not actually used. This seems like a more
defensible rule, particularly for cases like sizeof(v = a), where the
parens are part of the operand rather than the sizeof syntax.

Modified:
 cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
 cfe/trunk/include/clang/Sema/Sema.h
 cfe/trunk/lib/Sema/SemaExpr.cpp
 cfe/trunk/lib/Sema/SemaExprCXX.cpp
 cfe/trunk/test/SemaCXX/deprecated.cpp
 cfe/trunk/www/cxx_status.html


Oh, I should probably have commented here on the mailing list rather 
than at 
:


I assume the scenario at 
 "Avoid C++20 
deprecated assignment to volatile",


  (void) (0 ? *(location) = (result) : 0);

where *(location) is of (non-class) volatile type, is a true positive 
that we indeed want to warn about?


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


[PATCH] D68377: [Builtins] Teach Clang about memccpy

2019-10-17 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Ping @aaron.ballman


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

https://reviews.llvm.org/D68377



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


[PATCH] D68581: Include leading attributes in DeclStmt's SourceRange

2019-10-17 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg marked 2 inline comments as done.
sberg added inline comments.



Comment at: clang/test/AST/sourceranges.cpp:155
+
+#if __cplusplus >= 201703L
+  void cpp17() {

aaron.ballman wrote:
> Why is this guarded on C++17? `[[maybe_unused]]` is supported in every 
> language mode used by this test (it generates a warning, but we're 
> FileCheck'ing so that's fine -- but you could use `[[deprecated("")]]` 
> instead if you want).
> 
> Additionally, I'd appreciate one more test case testing a `__declspec` 
> attribute as well, to make sure we're handling that properly as well.
Oh, didn't know that [[maybe_unused]] would also be accepted in pre-C++17  
modes (I was somehow under the false impression that this file would be 
processed as -std=c++11 by default, where [[deprecated("")]] wouldn't have 
worked either).
Testing both __attribute__ and __declspec at both the start and in the middle 
of the stmt now.  (One caveat with __declspec is that its location resolves to 
, though.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68581



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


r375111 - [OpenCL] Add doc to describe OpenCL support

2019-10-17 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Thu Oct 17 05:56:02 2019
New Revision: 375111

URL: http://llvm.org/viewvc/llvm-project?rev=375111&view=rev
Log:
[OpenCL] Add doc to describe OpenCL support

The idea of this page is to document work in progress functionality
and also describe the plan of future development work.

Patch by Anastasia Stulova.

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

Added:
cfe/trunk/docs/OpenCLSupport.rst
Modified:
cfe/trunk/docs/index.rst

Added: cfe/trunk/docs/OpenCLSupport.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/OpenCLSupport.rst?rev=375111&view=auto
==
--- cfe/trunk/docs/OpenCLSupport.rst (added)
+++ cfe/trunk/docs/OpenCLSupport.rst Thu Oct 17 05:56:02 2019
@@ -0,0 +1,47 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.partial { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: partial
+.. role:: good
+
+.. contents::
+   :local:
+
+==
+OpenCL Support
+==
+
+Clang fully supports all OpenCL C versions from 1.1 to 2.0.
+
+Please refer to `Bugzilla
+`_
+for the most up to date bug reports.
+
+
+C++ for OpenCL Implementation Status
+
+
+Bugzilla bugs for this functionality are typically prefixed
+with '[C++]'.
+
+Differences to OpenCL C
+---
+
+TODO!
+
+Missing features or with limited support
+
+
+- Use of ObjC blocks is disabled.
+
+- Global destructor invocation is not generated correctly.
+
+- Initialization of objects in `__constant` address spaces is not guaranteed 
to work.
+
+- `addrspace_cast` operator is not supported.

Modified: cfe/trunk/docs/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/index.rst?rev=375111&r1=375110&r2=375111&view=diff
==
--- cfe/trunk/docs/index.rst (original)
+++ cfe/trunk/docs/index.rst Thu Oct 17 05:56:02 2019
@@ -41,6 +41,7 @@ Using Clang as a Compiler
SourceBasedCodeCoverage
Modules
MSVCCompatibility
+   OpenCLSupport
OpenMPSupport
ThinLTO
CommandGuide/index


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


[PATCH] D69072: [OpenCL] Added doc to describe OpenCL support

2019-10-17 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5e962e8d7dc7: [OpenCL] Add doc to describe OpenCL support 
(authored by svenvh).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D69072?vs=225391&id=225413#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69072

Files:
  clang/docs/OpenCLSupport.rst
  clang/docs/index.rst


Index: clang/docs/index.rst
===
--- clang/docs/index.rst
+++ clang/docs/index.rst
@@ -41,6 +41,7 @@
SourceBasedCodeCoverage
Modules
MSVCCompatibility
+   OpenCLSupport
OpenMPSupport
ThinLTO
CommandGuide/index
Index: clang/docs/OpenCLSupport.rst
===
--- /dev/null
+++ clang/docs/OpenCLSupport.rst
@@ -0,0 +1,47 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.partial { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: partial
+.. role:: good
+
+.. contents::
+   :local:
+
+==
+OpenCL Support
+==
+
+Clang fully supports all OpenCL C versions from 1.1 to 2.0.
+
+Please refer to `Bugzilla
+`_
+for the most up to date bug reports.
+
+
+C++ for OpenCL Implementation Status
+
+
+Bugzilla bugs for this functionality are typically prefixed
+with '[C++]'.
+
+Differences to OpenCL C
+---
+
+TODO!
+
+Missing features or with limited support
+
+
+- Use of ObjC blocks is disabled.
+
+- Global destructor invocation is not generated correctly.
+
+- Initialization of objects in `__constant` address spaces is not guaranteed 
to work.
+
+- `addrspace_cast` operator is not supported.


Index: clang/docs/index.rst
===
--- clang/docs/index.rst
+++ clang/docs/index.rst
@@ -41,6 +41,7 @@
SourceBasedCodeCoverage
Modules
MSVCCompatibility
+   OpenCLSupport
OpenMPSupport
ThinLTO
CommandGuide/index
Index: clang/docs/OpenCLSupport.rst
===
--- /dev/null
+++ clang/docs/OpenCLSupport.rst
@@ -0,0 +1,47 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.partial { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: partial
+.. role:: good
+
+.. contents::
+   :local:
+
+==
+OpenCL Support
+==
+
+Clang fully supports all OpenCL C versions from 1.1 to 2.0.
+
+Please refer to `Bugzilla
+`_
+for the most up to date bug reports.
+
+
+C++ for OpenCL Implementation Status
+
+
+Bugzilla bugs for this functionality are typically prefixed
+with '[C++]'.
+
+Differences to OpenCL C
+---
+
+TODO!
+
+Missing features or with limited support
+
+
+- Use of ObjC blocks is disabled.
+
+- Global destructor invocation is not generated correctly.
+
+- Initialization of objects in `__constant` address spaces is not guaranteed to work.
+
+- `addrspace_cast` operator is not supported.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69033: [clangd] Improve symbol qualification in DefineInline code action

2019-10-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 225416.
kadircet marked an inline comment as done.
kadircet added a comment.

- Handle using directives


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69033

Files:
  clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -1045,22 +1045,20 @@
   namespace a {
 template  class Bar {};
   }
-  using namespace a;
 
   template 
   void foo()/*Comment -_-*/  ;
 
+  using namespace a;
   template 
   void f^oo() {
 Bar B;
 Bar> q;
-  }
-  )cpp"),
+  })cpp"),
 R"cpp(
   namespace a {
 template  class Bar {};
   }
-  using namespace a;
 
   template 
   void foo()/*Comment -_-*/  {
@@ -1068,7 +1066,7 @@
 a::Bar> q;
   }
 
-  
+  using namespace a;
   )cpp");
 }
 
@@ -1169,18 +1167,17 @@
 class Foo{};
 };
   }
-  using namespace a;
-  using namespace b;
-  using namespace c;
 
   void foo()/*Comment -_-*/  ;
 
+  using namespace a;
+  using namespace b;
+  using namespace c;
   void f^oo() {
 Bar B;
 b::Foo foo;
 a::Bar>::Baz> q;
-  }
-  )cpp"),
+  })cpp"),
 R"cpp(
   namespace a {
 template  class Bar {
@@ -1191,9 +1188,6 @@
 class Foo{};
 };
   }
-  using namespace a;
-  using namespace b;
-  using namespace c;
 
   void foo()/*Comment -_-*/  {
 a::Bar B;
@@ -1201,7 +1195,9 @@
 a::Bar>::Baz> q;
   }
 
-  
+  using namespace a;
+  using namespace b;
+  using namespace c;
   )cpp");
 }
 
@@ -1223,12 +1219,12 @@
 }
 }
   }
-  using namespace a;
-  using namespace b;
-  using namespace c;
 
   void foo()/*Comment -_-*/  ;
 
+  using namespace a;
+  using namespace b;
+  using namespace c;
   void f^oo() {
 a::Bar B;
 B.foo();
@@ -1239,8 +1235,7 @@
 Bar::y = 3;
 bar();
 c::test();
-  }
-  )cpp"),
+  })cpp"),
 R"cpp(
   namespace a {
 template  class Bar {
@@ -1258,9 +1253,6 @@
 }
 }
   }
-  using namespace a;
-  using namespace b;
-  using namespace c;
 
   void foo()/*Comment -_-*/  {
 a::Bar B;
@@ -1274,7 +1266,9 @@
 a::b::c::test();
   }
 
-  
+  using namespace a;
+  using namespace b;
+  using namespace c;
   )cpp");
 }
 
@@ -1402,6 +1396,138 @@
 template <> inline void foo(){})cpp")));
 }
 
+TEST_F(DefineInlineTest, DropCommonNamespecifiers) {
+  EXPECT_EQ(apply(R"cpp(
+  namespace a { namespace b { void aux(); } }
+  namespace ns1 {
+  void foo();
+  namespace qq { void test(); }
+  namespace ns2 {
+  void bar();
+  namespace ns3 { void baz(); }
+  }
+  }
+
+  using namespace a;
+  using namespace a::b;
+  using namespace ns1::qq;
+  void ns1::ns2::ns3::b^az() {
+foo();
+bar();
+baz();
+ns1::ns2::ns3::baz();
+aux();
+test();
+  })cpp"),
+R"cpp(
+  namespace a { namespace b { void aux(); } }
+  namespace ns1 {
+  void foo();
+  namespace qq { void test(); }
+  namespace ns2 {
+  void bar();
+  namespace ns3 { void baz(){
+foo();
+bar();
+baz();
+ns1::ns2::ns3::baz();
+a::b::aux();
+qq::test();
+  } }
+  }
+  }
+
+  using namespace a;
+  using namespace a::b;
+  using namespace ns1::qq;
+  )cpp");
+
+  EXPECT_EQ(apply(R"cpp(
+  namespace ns1 {
+  namespace qq { struct Foo { struct Bar {}; }; using B = Foo::Bar; }
+  namespace ns2 { void baz(); }
+  }
+
+  using namespace ns1::qq;
+  void ns1::ns2::b^az() { Foo f; B b; })cpp"),
+R"cpp(
+  namespace ns1 {
+  namespace qq { struct Foo { struct Bar {}; }; using B = Foo::Bar; }
+  namespace ns2 { void baz(){ qq::Foo f; qq::B b; } }
+  }
+
+  using namespace ns1::qq;
+  )cpp");
+
+  EXPECT_EQ(apply(R"cpp(
+  namespace ns1 {
+  namespace qq {
+template struct Foo { template  struct Bar {}; };
+template
+using B = typename Foo::template Bar;
+  }
+  namespace ns2 { void baz(); }
+  }
+
+  using namespace ns1::qq;
+  void ns1::ns2::b^az() { B b; })cpp"),
+R"cpp(
+  namespace ns1 {
+  namespace qq {
+template struct Foo { template  struct Bar {}; };
+template
+using B = typename Foo::template Bar;
+  }
+  namespace ns2 { void baz(){ qq::B b; } }
+  }
+
+  using namespace ns1::qq;
+  )cpp");
+}
+
+TEST_F(DefineInlineTest, QualifyWithUsingDirectives) {
+  // FIXME: The last reference to cux() in body of foo should not be qualified,
+  // since there is a using directive inside the function body.
+  EXPECT_EQ(apply(R"cpp(
+namespace a {
+  void bar();
+  namespace b { struct Foo{}; void aux(); }
+  namespace c { void cux(); }
+}
+using namespace a;
+using X = b::Foo;
+void foo();
+
+using namespace b;
+using namespace c;
+vo

[PATCH] D68028: [clang] Add no_builtin attribute

2019-10-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:9508-9510
+  // FIXME: We should really be doing this in SemaDeclAttr.cpp::handleNoBuiltin
+  // but there is a bug with FunctionDecl::isThisDeclarationADefinition() which
+  // always returns false before Sema::ActOnStartOfFunctionDef is called.

rsmith wrote:
> aaron.ballman wrote:
> > rsmith wrote:
> > > aaron.ballman wrote:
> > > > handleNoBuiltin -> handleNoBuiltinAttr
> > > I am not convinced that this is a bug -- the function declaration does 
> > > not become a definition until the parser reaches the definition.
> > > 
> > > In any case, I don't think the predicate you want is "is this declaration 
> > > a definition?". Rather, I think what you want is, "does this declaration 
> > > introduce an explicit function body?". In particular, we should not 
> > > permit uses of this attribute on defaulted or deleted functions, nor on 
> > > functions that have a definition by virtue of using 
> > > `__attribute__((alias))`. So it probably should be a syntactic check on 
> > > the form of the declarator (that is, the check you're perrforming here), 
> > > and the check should probably be `D.getFunctionDefinitionKind() == 
> > > FDK_Definition`. (A custom diagnostic for using the attribute on a 
> > > defaulted or deleted function would be nice too, since the existing 
> > > diagnostic text isn't really accurate in those cases.)
> > > In particular, we should not permit uses of this attribute on defaulted 
> > > or deleted functions
> > 
> > Deleted functions, sure. Defaulted functions... not so sure. I could sort 
> > of imagine wanting to instruct a defaulted assignment operator that does 
> > memberwise copy that it's not allowed to use a builtin memcpy, for 
> > instance. Or is this a bad idea for some reason I'm not thinking of?
> `-fno-builtin` does not turn off using `llvm.memcpy` for copying memory, and 
> it doesn't turn off `llvm.memcpy` being lowered to a call to `memcpy`. 
> Allowing this for defaulted functions would only give a false sense of 
> security, at least for now (though I could imagine we might find some way to 
> change that in the future).
> 
> Also, trivial defaulted functions (where we're most likely to end up with 
> `memcpy` calls) are often not emitted at all, instead being directly inlined 
> by the frontend, so there's nowhere to attach a `no-builtin-memcpy` LLVM 
> attribute (we'd need to put the attribute on all callers of those functions) 
> even if LLVM learned to not emit calls to `memcpy` to implement `llvm.memcpy` 
> when operating under a `no-builtin-memcpy` constraint.
Ah, good to know! We're in agreement on how this should proceed, thank you for 
the insights.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68028



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


[PATCH] D69033: [clangd] Improve symbol qualification in DefineInline code action

2019-10-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked 5 inline comments as done.
kadircet added a comment.

In D69033#1710955 , @ilya-biryukov 
wrote:

> We seem to have trouble only in presence of using declarations and using 
> namespace directives.
>  I wonder how complicated it would be to take them into account instead. That 
> would clearly be easier to read, as we'll hit right into the center of the 
> problem.
>
> Could you describe why handling using declarations and using namespace 
> directives looks too complicated?


As discussed offline, changed the patch to handle using directives. Using 
declarations are handled implicitly, as we bail out if they are not visible 
from target
location.




Comment at: clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp:168
+auto *NSD = llvm::dyn_cast(Context);
+assert(NSD && "Non-namespace decl context found.");
+// Again, ananoymous namespaces are not spelled while qualifying a name.

ilya-biryukov wrote:
> It might be possible to have non-namespace contexts here:
> ```
> namespace ns {
> struct X {
>   void foo();
> 
>   static void target_struct();
> };
> void target_ns();
> }
> 
> 
> void ns::X::foo() {
>   // we start with non-namespace context.
>   target_struct();
>   target_ns(); 
> }
> ```
> 
> Not sure if we run in those cases, though
the SourceContext is guaranteed to be a namespace context to be start with, 
since we only call this function in `qualifyAllDecls` after making sure current 
decl is a namespace decl.
So there is no way for any of its parents to be anything but a namespacedecl.



Comment at: clang-tools-extra/clangd/unittests/TweakTests.cpp:1417
+
+  using namespace a;
+  using namespace a::b;

ilya-biryukov wrote:
> We don't support `using namespace` and yet we choose to use them in the tests 
> here.
> Is there a case where we need to qualify without using namespace directive 
> and using declarations?
> We don't support `using namespace` and yet we choose to use them in the tests 
> here.

I believe you misunderstood the "doesn't take using directives into account" 
part. It is not that we don't support them, it is just the `getQualification` 
function generates suboptimal specifiers in the presence of using 
directives/declarations. For example:

```
namespace ns1{
 namespace ns2 { void foo(); }
 using namespace ns2;
 void bar();

 void bar() {
 foo();
 }
}
```

when we issue an inline on function `bar` the body will become `ns2::foo` 
instead of just `foo` because we didn't take `using namespace ns2` into account.



> Is there a case where we need to qualify without using namespace directive 
> and using declarations?

if there are no using directive/declarations then the visible scope of 
declaration and definition should hopefully be the same and we wouldn't need to 
qualify anything.
But as I mentioned, it is not that we are not supporting those, we are just not 
producing 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69033



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


[PATCH] D41569: [Concepts] Constraint enforcement and diagnostics

2019-10-17 Thread Saar Raz via Phabricator via cfe-commits
saar.raz updated this revision to Diff 225418.
saar.raz added a comment.

Address CR comments by rsmith.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D41569

Files:
  clang/include/clang/AST/ASTConcept.h
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/AST/ASTConcept.cpp
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/CMakeLists.txt
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.constr/function-templates.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.constr/non-function-templates.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp

Index: clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
===
--- /dev/null
+++ clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -std=c++2a -fconcepts-ts -x c++ -verify %s
+
+namespace class_templates
+{
+  template requires sizeof(T) >= 4 // expected-note {{because 'sizeof(char) >= 4' (1 >= 4) evaluated to false}}
+  struct is_same { static constexpr bool value = false; };
+
+  template requires sizeof(T*) >= 4 && sizeof(T) >= 4
+  struct is_same { static constexpr bool value = true; };
+
+  static_assert(!is_same::value);
+  static_assert(!is_same::value);
+  static_assert(is_same::value);
+  static_assert(is_same::value); // expected-error {{constraints not satisfied for class template 'is_same' [with T = char, U = char]}}
+
+  template
+  struct A { using type = typename T::type; }; // expected-error{{type 'int *' cannot be used prior to '::' because it has no members}}
+
+  template
+  struct B {};
+
+  template requires A::type // expected-note{{in instantiation of template class 'class_templates::A' requested here}}
+   // expected-note@-1{{while substituting template arguments into constraint expression here}}
+  struct B {};
+
+  template requires T{} // expected-error{{atomic constraint must be of type 'bool' (found 'int')}}
+  struct B {};
+
+  static_assert((B{}, true)); // expected-note{{while checking constraint satisfaction for class template partial specialization 'B' required here}}
+  // expected-note@-1{{while checking constraint satisfaction for class template partial specialization 'B' required here}}
+  // expected-note@-2{{during template argument deduction for class template partial specialization 'B' [with T = int *]}}
+  // expected-note@-3{{during template argument deduction for class template partial specialization 'B' [with T = int]}}
+  // expected-note@-4 2{{in instantiation of template class 'class_templates::B' requested here}}
+}
+
+namespace variable_templates
+{
+  template requires sizeof(T) >= 4
+  constexpr bool is_same_v = false;
+
+  template requires sizeof(T*) >= 4 && sizeof(T) >= 4
+  constexpr bool is_same_v = true;
+
+  static_assert(!is_same_v);
+  static_assert(!is_same_v);
+  static_assert(is_same_v);
+
+  template
+  struct A { using type = typename T::type; }; // expected-error{{type 'int *' cannot be used prior to '::' because it has no members}}
+
+  template
+  constexpr bool v1 = false;
+
+  template requires A::type // expected-note{{in instantiation of template class 'variable_templates::A' requested here}}
+   // expected-note@-1{{while substituting template arguments into constraint expression here}}
+  constexpr bool v1 = true;
+
+  template requires T{} // expected-error{{atomic constraint must be of type 'bool' (found 'int')}}
+  constexpr bool v1 = true;
+
+  static_assert(v1); // expected-note{{while checking constraint satisfaction for variable template partial specialization 'v1' required here}}
+  // expected-note@-1{{while checking constraint satisfaction for variable template partial specialization 'v1' required here}}
+  // expected-note@-2{{during template argument deduction for variable template partial specialization 'v1' [with T = int *]}}
+  // expected-note@-3{{during template argument deduction for variable template partial specialization 'v1' [with T = int]}}
+  // expected-error@-4{{static_assert failed due to requirement 'v1'}}
+
+}
\ No newline at end of file
Index: clang/test/CXX/temp/temp.constr/temp.constr.constr/non-function-templates.cpp

[PATCH] D67185: [RISCV] Add support for -ffixed-xX flags

2019-10-17 Thread Luís Marques via Phabricator via cfe-commits
luismarques added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVSubtarget.h:97
   RISCVABI::ABI getTargetABI() const { return TargetABI; }
+  bool isRegisterReservedByUser(size_t i) const {
+return UserReservedRegister[i];

This should take a `Register` argument instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67185



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


[PATCH] D69043: [RFC] Adding time-trace to LLD?

2019-10-17 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop added a comment.

In D69043#1712542 , @ruiu wrote:

> This seems useful. Can I see an example output?


Thanks.

Here's an example from Building clang with ThinLTO: F10296420: clang-10.json 


Using linker flags: -Wl,-time-trace -Wl,-time-trace-granularity=5

I increased the granularity from the default, otherwise the trace gets very 
large (~800MiB).

> Speaking of the output file, I'd make --time-trace option to take an output 
> filename, as an output executable doesn't always have an extension (On 
> Windows it's almost always .exe, but on Unix, extension is usually omitted).

Okay. I'll look at doing that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69043



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


[PATCH] D68977: [clangd] Report declaration references in findExplicitReferences.

2019-10-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:850
+   "1: targets = {Foo::Foo}, decl\n"
+   "2: targets = {Foo::~Foo}, decl\n"
+   "3: targets = {Foo}\n"

ilya-biryukov wrote:
> Could we avoid reporting destructor references for now? I feel they would 
> create more confusion than bring value.
> Mostly worried that they overlap with a reference to the type name and now 
> all client code will probably want to filter out destructor references.
> 
> I believe they're not critical to any of the use-cases we have so far, having 
> a ``// FIXME: decide how to surface destructors when we need them` should be 
> good enough for now
Agree. it is not needed in rename feature as well, we have a typeLoc occurrence 
in `~[[Foo]]`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68977



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


[PATCH] D68977: [clangd] Report declaration references in findExplicitReferences.

2019-10-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 225420.
hokein marked 6 inline comments as done.
hokein added a comment.

address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68977

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/FindTarget.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -2277,7 +2277,8 @@
   if (const auto *ND = llvm::dyn_cast(D))
 Names.push_back(ND->getQualifiedNameAsString());
 }
-EXPECT_THAT(Names, UnorderedElementsAreArray(C.ExpectedDecls));
+EXPECT_THAT(Names, UnorderedElementsAreArray(C.ExpectedDecls))
+<< File.code();
   }
 }
 
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -600,59 +600,67 @@
   }
 )cpp",
"0: targets = {ns}\n"
-   "1: targets = {ns::global}, qualifier = 'ns::'\n"},
+   "1: targets = {ns::global}, qualifier = 'ns::', decl\n"},
   // Simple types.
   {R"cpp(
  struct Struct { int a; };
  using Typedef = int;
  void foo() {
-   $0^Struct x;
-   $1^Typedef y;
-   static_cast<$2^Struct*>(0);
+   $0^Struct $1^x;
+   $2^Typedef $3^y;
+   static_cast<$4^Struct*>(0);
  }
)cpp",
"0: targets = {Struct}\n"
-   "1: targets = {Typedef}\n"
-   "2: targets = {Struct}\n"},
+   "1: targets = {x}, decl\n"
+   "2: targets = {Typedef}\n"
+   "3: targets = {y}, decl\n"
+   "4: targets = {Struct}\n"},
   // Name qualifiers.
   {R"cpp(
  namespace a { namespace b { struct S { typedef int type; }; } }
  void foo() {
-   $0^a::$1^b::$2^S x;
-   using namespace $3^a::$4^b;
-   $5^S::$6^type y;
+   $0^a::$1^b::$2^S $3^x;
+   using namespace $4^a::$5^b;
+   $6^S::$7^type $8^y;
  }
 )cpp",
"0: targets = {a}\n"
"1: targets = {a::b}, qualifier = 'a::'\n"
"2: targets = {a::b::S}, qualifier = 'a::b::'\n"
-   "3: targets = {a}\n"
-   "4: targets = {a::b}, qualifier = 'a::'\n"
-   "5: targets = {a::b::S}\n"
-   "6: targets = {a::b::S::type}, qualifier = 'struct S::'\n"},
+   "3: targets = {x}, decl\n"
+   "4: targets = {a}\n"
+   "5: targets = {a::b}, qualifier = 'a::'\n"
+   "6: targets = {a::b::S}\n"
+   "7: targets = {a::b::S::type}, qualifier = 'struct S::'\n"
+   "8: targets = {y}, decl\n"},
   // Simple templates.
   {R"cpp(
   template  struct vector { using value_type = T; };
   template <> struct vector { using value_type = bool; };
   void foo() {
-$0^vector vi;
-$1^vector vb;
+$0^vector $1^vi;
+$2^vector $3^vb;
   }
 )cpp",
"0: targets = {vector}\n"
-   "1: targets = {vector}\n"},
+   "1: targets = {vi}, decl\n"
+   "2: targets = {vector}\n"
+   "3: targets = {vb}, decl\n"},
   // Template type aliases.
   {R"cpp(
 template  struct vector { using value_type = T; };
 template <> struct vector { using value_type = bool; };
 template  using valias = vector;
 void foo() {
-  $0^valias vi;
-  $1^valias vb;
+  $0^valias $1^vi;
+  $2^valias $3^vb;
 }
   )cpp",
"0: targets = {valias}\n"
-   "1: targets = {valias}\n"},
+   "1: targets = {vi}, decl\n"
+   "2: targets = {valias}\n"
+   "3: targets = {vb}, decl\n"},
   // MemberExpr should know their using declaration.
   {R"cpp(
 struct X { void func(int); }
@@ -694,13 +702,14 @@
 };
 
 void foo() {
-  for (int x : $0^vector()) {
-$1^x = 10;
+  for (int $0^x : $1^vector()) {
+$2^x = 10;
   }
 }
 )cpp",
-   "0: targets = {vector}\n"
-   "1: targets = {x}\n"},
+   "0: targets = {x}, decl\n"
+   "1: targets = {vector}\n"
+   "2: targets = {x}\n"},
   // Handle UnresolvedLookupExpr.
   {R"c

[PATCH] D50078: clang-format: support aligned nested conditionals formatting

2019-10-17 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

This actually depends on another Diff : https://reviews.llvm.org/D32478
That other change introduces the ability to "unindent operator", which is 
required here; however, it also changes AlignOperands to have more than 2 
modes, which does not seem to be acceptable.

Before merge, should I thus merge "unindent operator" ability back in this 
change? Or create another commit for that part only, to be reviewed separately?


Repository:
  rC Clang

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

https://reviews.llvm.org/D50078



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


[PATCH] D68346: [clang-format] Add new option to add spaces around conditions

2019-10-17 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar accepted this revision.
mitchell-stellar added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68346



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


[PATCH] D68977: [clangd] Report declaration references in findExplicitReferences.

2019-10-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Mostly NITs from my side, the change LG, thanks!




Comment at: clang-tools-extra/clangd/FindTarget.cpp:422
+  // "using namespace" declaration doesn't have a name.
+  Refs.push_back({D->getQualifierLoc(),
+  D->getIdentLocation(),

Same comment as below: could you say `ReferenceLoc` explicitly here and in 
other places? 
Plain initializer lists are somewhat hard to parse



Comment at: clang-tools-extra/clangd/FindTarget.cpp:436
+  // For namespace alias, "namespace Foo = Target;", we add two references.
+  VisitNamedDecl(D); // add a declaration reference for Foo.
+  // Add a non-declaration reference for Target.

NIT: maybe put this comment on a previous line?
Should read more naturally.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:658
+} else if (auto *E = N.get()) {
+  if (auto Ref = refInExpr(E))
+return {*Ref};

I'd probably suggest to return `SmallVector` from all 
functions, so that they compose better in this situation.

Although `Optional` captures the semantics of some of those 
better, I don't think it's particularly useful at this point.
And having to deconstruct all optionals here leads to a lot of clunky code, 
it'd be much better if we could keep the structure the same as it's used to be.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:661
+} else if (auto *NNSL = N.get()) {
+  return {{NNSL->getPrefix(), NNSL->getLocalBeginLoc(), false,
+   explicitReferenceTargets(

Could we have `{ReferenceLoc{` instead of `{{`?
Plain initializer lists are hard to comprehend, especially when they're nested.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:667
+return {*Ref};
+  // return refInTypeLoc(*TL);
+} else if (const CXXCtorInitializer *CCI = N.get()) {

Remove this comment? Seems to be a leftover from experiments



Comment at: clang-tools-extra/clangd/FindTarget.cpp:670
   if (CCI->isBaseInitializer())
-return refInTypeLoc(CCI->getBaseClassLoc());
+if (auto Ref = refInTypeLoc(CCI->getBaseClassLoc()))
+  return {*Ref};

NIT: add braces around an inner multi-line if?



Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:2280
 }
-EXPECT_THAT(Names, UnorderedElementsAreArray(C.ExpectedDecls));
+EXPECT_THAT(Names, UnorderedElementsAreArray(C.ExpectedDecls))
+<< File.code();

This looks unrelated. Maybe revert and land separately?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68977



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


[PATCH] D68554: [clang-format] Proposal for clang-format to give compiler style warnings

2019-10-17 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

> I can't wait for @hans next Windows Snapshot, this is my gate for rolling 
> into our builds and CI system, after that, I'm gonna catch every single 
> person who tries to build/check in unclang-formatted.

As it happens, there's a new snapshot out today :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68554



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


[clang-tools-extra] r375117 - [clangd] Use our own relation kind.

2019-10-17 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Oct 17 07:08:28 2019
New Revision: 375117

URL: http://llvm.org/viewvc/llvm-project?rev=375117&view=rev
Log:
[clangd] Use our own relation kind.

Summary:
Move the RelationKind from Serialization.h to Relation.h. This patch doesn't
introduce any breaking changes.

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/XRefs.cpp
clang-tools-extra/trunk/clangd/index/Index.h
clang-tools-extra/trunk/clangd/index/MemIndex.cpp
clang-tools-extra/trunk/clangd/index/MemIndex.h
clang-tools-extra/trunk/clangd/index/Relation.cpp
clang-tools-extra/trunk/clangd/index/Relation.h
clang-tools-extra/trunk/clangd/index/Serialization.cpp
clang-tools-extra/trunk/clangd/index/Serialization.h
clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
clang-tools-extra/trunk/clangd/index/YAMLSerialization.cpp
clang-tools-extra/trunk/clangd/index/dex/Dex.cpp
clang-tools-extra/trunk/clangd/index/dex/Dex.h
clang-tools-extra/trunk/clangd/unittests/BackgroundIndexTests.cpp
clang-tools-extra/trunk/clangd/unittests/DexTests.cpp
clang-tools-extra/trunk/clangd/unittests/FileIndexTests.cpp
clang-tools-extra/trunk/clangd/unittests/IndexTests.cpp
clang-tools-extra/trunk/clangd/unittests/SerializationTests.cpp
clang-tools-extra/trunk/clangd/unittests/SymbolCollectorTests.cpp
clang-tools-extra/trunk/clangd/unittests/TypeHierarchyTests.cpp

Modified: clang-tools-extra/trunk/clangd/XRefs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/XRefs.cpp?rev=375117&r1=375116&r2=375117&view=diff
==
--- clang-tools-extra/trunk/clangd/XRefs.cpp (original)
+++ clang-tools-extra/trunk/clangd/XRefs.cpp Thu Oct 17 07:08:28 2019
@@ -18,6 +18,7 @@
 #include "URI.h"
 #include "index/Index.h"
 #include "index/Merge.h"
+#include "index/Relation.h"
 #include "index/SymbolCollector.h"
 #include "index/SymbolLocation.h"
 #include "clang/AST/ASTContext.h"
@@ -1107,7 +1108,7 @@ static void fillSubTypes(const SymbolID
  const SymbolIndex *Index, int Levels, PathRef TUPath) 
{
   RelationsRequest Req;
   Req.Subjects.insert(ID);
-  Req.Predicate = index::SymbolRole::RelationBaseOf;
+  Req.Predicate = RelationKind::BaseOf;
   Index->relations(Req, [&](const SymbolID &Subject, const Symbol &Object) {
 if (Optional ChildSym =
 symbolToTypeHierarchyItem(Object, Index, TUPath)) {

Modified: clang-tools-extra/trunk/clangd/index/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=375117&r1=375116&r2=375117&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Thu Oct 17 07:08:28 2019
@@ -75,7 +75,7 @@ struct RefsRequest {
 
 struct RelationsRequest {
   llvm::DenseSet Subjects;
-  index::SymbolRole Predicate;
+  RelationKind Predicate;
   /// If set, limit the number of relations returned from the index.
   llvm::Optional Limit;
 };

Modified: clang-tools-extra/trunk/clangd/index/MemIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/MemIndex.cpp?rev=375117&r1=375116&r2=375117&view=diff
==
--- clang-tools-extra/trunk/clangd/index/MemIndex.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/MemIndex.cpp Thu Oct 17 07:08:28 2019
@@ -92,7 +92,8 @@ void MemIndex::relations(
   Req.Limit.getValueOr(std::numeric_limits::max());
   for (const SymbolID &Subject : Req.Subjects) {
 LookupRequest LookupReq;
-auto It = Relations.find(std::make_pair(Subject, Req.Predicate));
+auto It = Relations.find(
+std::make_pair(Subject, static_cast(Req.Predicate)));
 if (It != Relations.end()) {
   for (const auto &Obj : It->second) {
 if (Remaining > 0) {

Modified: clang-tools-extra/trunk/clangd/index/MemIndex.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/MemIndex.h?rev=375117&r1=375116&r2=375117&view=diff
==
--- clang-tools-extra/trunk/clangd/index/MemIndex.h (original)
+++ clang-tools-extra/trunk/clangd/index/MemIndex.h Thu Oct 17 07:08:28 2019
@@ -27,8 +27,9 @@ public:
 for (const std::pair> &R : Refs)
   this->Refs.try_emplace(R.first, R.second.begin(), R.second.end());
 for (const Relation &R : Relations)
-  this->Relations[std::make_pair(R.Subject, R.Predicate)].push_back(
-  R.Object);
+  this->Relations[std::make_pair(R.Subject,
+ static_cast(R.Predicate))]
+  .push_back(R.Object)

r375118 - [OpenCL] Preserve addrspace in CGClass (PR43145)

2019-10-17 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Thu Oct 17 07:12:51 2019
New Revision: 375118

URL: http://llvm.org/viewvc/llvm-project?rev=375118&view=rev
Log:
[OpenCL] Preserve addrspace in CGClass (PR43145)

PR43145 revealed two places where Clang was attempting to create a
bitcast without considering the address space of class types during
C++ class code generation.

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

Modified:
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/test/CodeGenOpenCLCXX/addrspace-derived-base.cl

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=375118&r1=375117&r2=375118&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Thu Oct 17 07:12:51 2019
@@ -246,7 +246,8 @@ ApplyNonVirtualAndVirtualOffset(CodeGenF
 
   // Apply the base offset.
   llvm::Value *ptr = addr.getPointer();
-  ptr = CGF.Builder.CreateBitCast(ptr, CGF.Int8PtrTy);
+  unsigned AddrSpace = ptr->getType()->getPointerAddressSpace();
+  ptr = CGF.Builder.CreateBitCast(ptr, CGF.Int8Ty->getPointerTo(AddrSpace));
   ptr = CGF.Builder.CreateInBoundsGEP(ptr, baseOffset, "add.ptr");
 
   // If we have a virtual component, the alignment of the result will
@@ -381,7 +382,9 @@ CodeGenFunction::GetAddressOfDerivedClas
 
   QualType DerivedTy =
 getContext().getCanonicalType(getContext().getTagDeclType(Derived));
-  llvm::Type *DerivedPtrTy = ConvertType(DerivedTy)->getPointerTo();
+  unsigned AddrSpace =
+BaseAddr.getPointer()->getType()->getPointerAddressSpace();
+  llvm::Type *DerivedPtrTy = ConvertType(DerivedTy)->getPointerTo(AddrSpace);
 
   llvm::Value *NonVirtualOffset =
 CGM.GetNonVirtualBaseClassOffset(Derived, PathBegin, PathEnd);

Modified: cfe/trunk/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCLCXX/addrspace-derived-base.cl?rev=375118&r1=375117&r2=375118&view=diff
==
--- cfe/trunk/test/CodeGenOpenCLCXX/addrspace-derived-base.cl (original)
+++ cfe/trunk/test/CodeGenOpenCLCXX/addrspace-derived-base.cl Thu Oct 17 
07:12:51 2019
@@ -11,6 +11,7 @@ public:
 
 void foo() {
   D d;
+  //CHECK-LABEL: foo
   //CHECK: addrspacecast %class.D* %d to %class.D addrspace(4)*
   //CHECK: call spir_func i32 @_ZNU3AS41D5getmbEv(%class.D addrspace(4)*
   d.getmb();
@@ -20,3 +21,32 @@ void foo() {
 
 //CHECK: define linkonce_odr spir_func i32 @_ZNU3AS41D5getmbEv(%class.D 
addrspace(4)* %this)
 //CHECK: bitcast %class.D addrspace(4)* %this1 to %struct.B addrspace(4)*
+
+
+// Calling base method through multiple inheritance.
+
+class B2 {
+  public:
+void baseMethod() const {  }
+int bb;
+};
+
+class Derived : public B, public B2 {
+  public:
+void work() const { baseMethod(); }
+// CHECK-LABEL: work
+// CHECK: bitcast i8 addrspace(4)* %add.ptr to %class.B2 addrspace(4)*
+};
+
+void pr43145(const Derived *argDerived) {
+  argDerived->work();
+}
+
+// Casting from base to derived.
+
+void pr43145_2(B *argB) {
+  Derived *x = (Derived*)argB;
+}
+
+// CHECK-LABEL: @_Z9pr43145_2
+// CHECK: bitcast %struct.B addrspace(4)* %0 to %class.Derived addrspace(4)*


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


[PATCH] D68977: [clangd] Report declaration references in findExplicitReferences.

2019-10-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:415
 
 Optional refInDecl(const Decl *D) {
   struct Visitor : ConstDeclVisitor {

ilya-biryukov wrote:
> kadircet wrote:
> > ilya-biryukov wrote:
> > > hokein wrote:
> > > > ilya-biryukov wrote:
> > > > > This should return `SmallVector` now, some 
> > > > > declarations can have both decl and non-decl references.
> > > > Can you give some examples? It seems that non-decl references are 
> > > > handled by other `refIn*` functions.
> > > > 
> > > > ```
> > > > int Foo = OtherBar; // OtherBar is captured at the momment.
> > > > ```
> > > ```
> > > namespace $1[[a]] = $2[[std]];
> > > ```
> > > 
> > > `$1` is a declaration of a namespace alias.
> > > `$2` is a reference to namespace std.
> > I was just about to make the same point. After this patch lands I would 
> > like to detect `using namespace`s inside function body, and currently there 
> > is no way to distinguish between a usingdirective and a namespacealias. 
> > Since both is only referencing the target namespace.
> > 
> > So even if this starts reporting `$2` in the comment above, there should be 
> > a difference between that and `$3` in `using namespace $3[[std]];`
> That's intentional, though. When we report references, we deliberately leave 
> out information on where it's coming from - otherwise it's hard to encode it.
> 
> However, if we really need that, we could also pass a `NamedDecl*` when 
> reporting declarations (that would mean a slightly different interface, 
> though).
> 
> We still have some complexity budget in `findExplicitReferences` and we 
> should probably spend it here.
> OTOH, adding more stuff will probably bloat it too much, I hope we'll stop 
> there... There will still be cases when one would have to write a separate 
> AST traversal to do more complicated stuff. It's unfortunate that this is 
> twice as expensive, but it shouldn't matter in most cases (e.g. when running 
> inside `Tweak::apply`)
> 
> I'd suggest we keep this patch with `IsDecl` flag, but happy to look into 
> your use-case with `using namespaces` more closely...
as discussed offline, it is a special enough use-case to handle in 
define-inline.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68977



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


[PATCH] D69043: [RFC] Adding time-trace to LLD?

2019-10-17 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added inline comments.



Comment at: lld/ELF/Driver.cpp:515
+
+  if (llvm::timeTraceProfilerEnabled()) {
+SmallString<128> path(config->outputFile);

Could you possibly move this block (and the init block above) into a new file 
in `lld/Common/` so we can use it in the COFF driver as well?



Comment at: lld/ELF/Driver.cpp:527
+  }
+  return;
 }

Extraneous return.



Comment at: lld/ELF/Options.td:361
 
+def time_trace: F<"time-trace">, HelpText<"Record time trace">;
+

Given this option is a candidate for the other LLD drivers, I am wondering if 
we couldn't have a shared `lld/Common/CommonOpt.td`. @ruiu WDYT?



Comment at: llvm/lib/Support/TimeProfiler.cpp:70
   void begin(std::string Name, llvm::function_ref Detail) {
+std::lock_guard Lock(Mu);
 Stack.emplace_back(steady_clock::now(), TimePointType(), std::move(Name),

The lock is definitely not the way to go, it would skew all the timings 
especially on tens-of-cores machines. Like you're suggesting, make 
`TimeTraceProfilerInstance` a TLS, along with a new combiner upon the call to 
`timeTraceProfilerWrite()`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69043



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


[PATCH] D68981: [clangd] Use our own relation kind.

2019-10-17 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc8e3f43ab514: [clangd] Use our own relation kind. (authored 
by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68981

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/index/Index.h
  clang-tools-extra/clangd/index/MemIndex.cpp
  clang-tools-extra/clangd/index/MemIndex.h
  clang-tools-extra/clangd/index/Relation.cpp
  clang-tools-extra/clangd/index/Relation.h
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/index/Serialization.h
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/YAMLSerialization.cpp
  clang-tools-extra/clangd/index/dex/Dex.cpp
  clang-tools-extra/clangd/index/dex/Dex.h
  clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
  clang-tools-extra/clangd/unittests/DexTests.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/IndexTests.cpp
  clang-tools-extra/clangd/unittests/SerializationTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
  clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
  llvm/include/llvm/ADT/DenseMapInfo.h

Index: llvm/include/llvm/ADT/DenseMapInfo.h
===
--- llvm/include/llvm/ADT/DenseMapInfo.h
+++ llvm/include/llvm/ADT/DenseMapInfo.h
@@ -67,6 +67,17 @@
   }
 };
 
+// Provide DenseMapInfo for unsigned chars.
+template <> struct DenseMapInfo {
+  static inline unsigned char getEmptyKey() { return ~0; }
+  static inline unsigned char getTombstoneKey() { return ~0 - 1; }
+  static unsigned getHashValue(const unsigned char &Val) { return Val * 37U; }
+
+  static bool isEqual(const unsigned char &LHS, const unsigned char &RHS) {
+return LHS == RHS;
+  }
+};
+
 // Provide DenseMapInfo for unsigned shorts.
 template <> struct DenseMapInfo {
   static inline unsigned short getEmptyKey() { return 0x; }
Index: clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
===
--- clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
+++ clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
@@ -482,7 +482,7 @@
   std::vector Result;
   RelationsRequest Req;
   Req.Subjects.insert(Subject);
-  Req.Predicate = index::SymbolRole::RelationBaseOf;
+  Req.Predicate = RelationKind::BaseOf;
   Index->relations(Req,
[&Result](const SymbolID &Subject, const Symbol &Object) {
  Result.push_back(Object.ID);
Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -673,8 +673,7 @@
   const Symbol &Base = findSymbol(Symbols, "Base");
   const Symbol &Derived = findSymbol(Symbols, "Derived");
   EXPECT_THAT(Relations,
-  Contains(Relation{Base.ID, index::SymbolRole::RelationBaseOf,
-Derived.ID}));
+  Contains(Relation{Base.ID, RelationKind::BaseOf, Derived.ID}));
 }
 
 TEST_F(SymbolCollectorTest, References) {
Index: clang-tools-extra/clangd/unittests/SerializationTests.cpp
===
--- clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -152,9 +152,9 @@
   SymbolID Base = cantFail(SymbolID::fromStr("6481EE7AF2841756"));
   SymbolID Derived = cantFail(SymbolID::fromStr("6512AEC512EA3A2D"));
   ASSERT_TRUE(bool(ParsedYAML->Relations));
-  EXPECT_THAT(*ParsedYAML->Relations,
-  UnorderedElementsAre(
-  Relation{Base, index::SymbolRole::RelationBaseOf, Derived}));
+  EXPECT_THAT(
+  *ParsedYAML->Relations,
+  UnorderedElementsAre(Relation{Base, RelationKind::BaseOf, Derived}));
 }
 
 std::vector YAMLFromSymbols(const SymbolSlab &Slab) {
Index: clang-tools-extra/clangd/unittests/IndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -83,20 +83,15 @@
   SymbolID D{"D"};
 
   RelationSlab::Builder Builder;
-  Builder.insert(Relation{A, index::SymbolRole::RelationBaseOf, B});
-  Builder.insert(Relation{A, index::SymbolRole::RelationBaseOf, C});
-  Builder.insert(Relation{B, index::SymbolRole::RelationBaseOf, D});
-  Builder.insert(Relation{C, index::SymbolRole::RelationBaseOf, D});
-  Builder.insert(Relation{B, index::SymbolRole::RelationChildOf, A});
-  Builder.insert(Relation{C, index::SymbolRole::RelationChildOf, A});
-  Builder.insert(Relation{D, index::SymbolRole::RelationChildOf, B});
-  Builder.insert(Relation{D, inde

[PATCH] D68403: [OpenCL] PR43145: preserve addrspace for class accesses

2019-10-17 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaf6248cbb9e7: [OpenCL] Preserve addrspace in CGClass 
(PR43145) (authored by svenvh).

Changed prior to commit:
  https://reviews.llvm.org/D68403?vs=223037&id=225426#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68403

Files:
  clang/lib/CodeGen/CGClass.cpp
  clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl


Index: clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
===
--- clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
+++ clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
@@ -11,6 +11,7 @@
 
 void foo() {
   D d;
+  //CHECK-LABEL: foo
   //CHECK: addrspacecast %class.D* %d to %class.D addrspace(4)*
   //CHECK: call spir_func i32 @_ZNU3AS41D5getmbEv(%class.D addrspace(4)*
   d.getmb();
@@ -20,3 +21,32 @@
 
 //CHECK: define linkonce_odr spir_func i32 @_ZNU3AS41D5getmbEv(%class.D 
addrspace(4)* %this)
 //CHECK: bitcast %class.D addrspace(4)* %this1 to %struct.B addrspace(4)*
+
+
+// Calling base method through multiple inheritance.
+
+class B2 {
+  public:
+void baseMethod() const {  }
+int bb;
+};
+
+class Derived : public B, public B2 {
+  public:
+void work() const { baseMethod(); }
+// CHECK-LABEL: work
+// CHECK: bitcast i8 addrspace(4)* %add.ptr to %class.B2 addrspace(4)*
+};
+
+void pr43145(const Derived *argDerived) {
+  argDerived->work();
+}
+
+// Casting from base to derived.
+
+void pr43145_2(B *argB) {
+  Derived *x = (Derived*)argB;
+}
+
+// CHECK-LABEL: @_Z9pr43145_2
+// CHECK: bitcast %struct.B addrspace(4)* %0 to %class.Derived addrspace(4)*
Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -246,7 +246,8 @@
 
   // Apply the base offset.
   llvm::Value *ptr = addr.getPointer();
-  ptr = CGF.Builder.CreateBitCast(ptr, CGF.Int8PtrTy);
+  unsigned AddrSpace = ptr->getType()->getPointerAddressSpace();
+  ptr = CGF.Builder.CreateBitCast(ptr, CGF.Int8Ty->getPointerTo(AddrSpace));
   ptr = CGF.Builder.CreateInBoundsGEP(ptr, baseOffset, "add.ptr");
 
   // If we have a virtual component, the alignment of the result will
@@ -381,7 +382,9 @@
 
   QualType DerivedTy =
 getContext().getCanonicalType(getContext().getTagDeclType(Derived));
-  llvm::Type *DerivedPtrTy = ConvertType(DerivedTy)->getPointerTo();
+  unsigned AddrSpace =
+BaseAddr.getPointer()->getType()->getPointerAddressSpace();
+  llvm::Type *DerivedPtrTy = ConvertType(DerivedTy)->getPointerTo(AddrSpace);
 
   llvm::Value *NonVirtualOffset =
 CGM.GetNonVirtualBaseClassOffset(Derived, PathBegin, PathEnd);


Index: clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
===
--- clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
+++ clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
@@ -11,6 +11,7 @@
 
 void foo() {
   D d;
+  //CHECK-LABEL: foo
   //CHECK: addrspacecast %class.D* %d to %class.D addrspace(4)*
   //CHECK: call spir_func i32 @_ZNU3AS41D5getmbEv(%class.D addrspace(4)*
   d.getmb();
@@ -20,3 +21,32 @@
 
 //CHECK: define linkonce_odr spir_func i32 @_ZNU3AS41D5getmbEv(%class.D addrspace(4)* %this)
 //CHECK: bitcast %class.D addrspace(4)* %this1 to %struct.B addrspace(4)*
+
+
+// Calling base method through multiple inheritance.
+
+class B2 {
+  public:
+void baseMethod() const {  }
+int bb;
+};
+
+class Derived : public B, public B2 {
+  public:
+void work() const { baseMethod(); }
+// CHECK-LABEL: work
+// CHECK: bitcast i8 addrspace(4)* %add.ptr to %class.B2 addrspace(4)*
+};
+
+void pr43145(const Derived *argDerived) {
+  argDerived->work();
+}
+
+// Casting from base to derived.
+
+void pr43145_2(B *argB) {
+  Derived *x = (Derived*)argB;
+}
+
+// CHECK-LABEL: @_Z9pr43145_2
+// CHECK: bitcast %struct.B addrspace(4)* %0 to %class.Derived addrspace(4)*
Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -246,7 +246,8 @@
 
   // Apply the base offset.
   llvm::Value *ptr = addr.getPointer();
-  ptr = CGF.Builder.CreateBitCast(ptr, CGF.Int8PtrTy);
+  unsigned AddrSpace = ptr->getType()->getPointerAddressSpace();
+  ptr = CGF.Builder.CreateBitCast(ptr, CGF.Int8Ty->getPointerTo(AddrSpace));
   ptr = CGF.Builder.CreateInBoundsGEP(ptr, baseOffset, "add.ptr");
 
   // If we have a virtual component, the alignment of the result will
@@ -381,7 +382,9 @@
 
   QualType DerivedTy =
 getContext().getCanonicalType(getContext().getTagDeclType(Derived));
-  llvm::Type *DerivedPtrTy = ConvertType(DerivedTy)->getPointerTo();
+  unsigned AddrSpace =
+BaseAddr.getPointer()->getType()->getPointerAddressSpace();
+  llvm::

[PATCH] D68977: [clangd] Report declaration references in findExplicitReferences.

2019-10-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:2280
 }
-EXPECT_THAT(Names, UnorderedElementsAreArray(C.ExpectedDecls));
+EXPECT_THAT(Names, UnorderedElementsAreArray(C.ExpectedDecls))
+<< File.code();

ilya-biryukov wrote:
> This looks unrelated. Maybe revert and land separately?
This patch also modifies the `getNonLocalDeclRefs` which is related to the test 
here. I'd keep the change in this patch as it is minor and NFC. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68977



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


[PATCH] D68977: [clangd] Report declaration references in findExplicitReferences.

2019-10-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 225428.
hokein marked 7 inline comments as done.
hokein added a comment.

address remaining nits.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68977

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/FindTarget.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -2277,7 +2277,8 @@
   if (const auto *ND = llvm::dyn_cast(D))
 Names.push_back(ND->getQualifiedNameAsString());
 }
-EXPECT_THAT(Names, UnorderedElementsAreArray(C.ExpectedDecls));
+EXPECT_THAT(Names, UnorderedElementsAreArray(C.ExpectedDecls))
+<< File.code();
   }
 }
 
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -600,59 +600,67 @@
   }
 )cpp",
"0: targets = {ns}\n"
-   "1: targets = {ns::global}, qualifier = 'ns::'\n"},
+   "1: targets = {ns::global}, qualifier = 'ns::', decl\n"},
   // Simple types.
   {R"cpp(
  struct Struct { int a; };
  using Typedef = int;
  void foo() {
-   $0^Struct x;
-   $1^Typedef y;
-   static_cast<$2^Struct*>(0);
+   $0^Struct $1^x;
+   $2^Typedef $3^y;
+   static_cast<$4^Struct*>(0);
  }
)cpp",
"0: targets = {Struct}\n"
-   "1: targets = {Typedef}\n"
-   "2: targets = {Struct}\n"},
+   "1: targets = {x}, decl\n"
+   "2: targets = {Typedef}\n"
+   "3: targets = {y}, decl\n"
+   "4: targets = {Struct}\n"},
   // Name qualifiers.
   {R"cpp(
  namespace a { namespace b { struct S { typedef int type; }; } }
  void foo() {
-   $0^a::$1^b::$2^S x;
-   using namespace $3^a::$4^b;
-   $5^S::$6^type y;
+   $0^a::$1^b::$2^S $3^x;
+   using namespace $4^a::$5^b;
+   $6^S::$7^type $8^y;
  }
 )cpp",
"0: targets = {a}\n"
"1: targets = {a::b}, qualifier = 'a::'\n"
"2: targets = {a::b::S}, qualifier = 'a::b::'\n"
-   "3: targets = {a}\n"
-   "4: targets = {a::b}, qualifier = 'a::'\n"
-   "5: targets = {a::b::S}\n"
-   "6: targets = {a::b::S::type}, qualifier = 'struct S::'\n"},
+   "3: targets = {x}, decl\n"
+   "4: targets = {a}\n"
+   "5: targets = {a::b}, qualifier = 'a::'\n"
+   "6: targets = {a::b::S}\n"
+   "7: targets = {a::b::S::type}, qualifier = 'struct S::'\n"
+   "8: targets = {y}, decl\n"},
   // Simple templates.
   {R"cpp(
   template  struct vector { using value_type = T; };
   template <> struct vector { using value_type = bool; };
   void foo() {
-$0^vector vi;
-$1^vector vb;
+$0^vector $1^vi;
+$2^vector $3^vb;
   }
 )cpp",
"0: targets = {vector}\n"
-   "1: targets = {vector}\n"},
+   "1: targets = {vi}, decl\n"
+   "2: targets = {vector}\n"
+   "3: targets = {vb}, decl\n"},
   // Template type aliases.
   {R"cpp(
 template  struct vector { using value_type = T; };
 template <> struct vector { using value_type = bool; };
 template  using valias = vector;
 void foo() {
-  $0^valias vi;
-  $1^valias vb;
+  $0^valias $1^vi;
+  $2^valias $3^vb;
 }
   )cpp",
"0: targets = {valias}\n"
-   "1: targets = {valias}\n"},
+   "1: targets = {vi}, decl\n"
+   "2: targets = {valias}\n"
+   "3: targets = {vb}, decl\n"},
   // MemberExpr should know their using declaration.
   {R"cpp(
 struct X { void func(int); }
@@ -694,13 +702,14 @@
 };
 
 void foo() {
-  for (int x : $0^vector()) {
-$1^x = 10;
+  for (int $0^x : $1^vector()) {
+$2^x = 10;
   }
 }
 )cpp",
-   "0: targets = {vector}\n"
-   "1: targets = {x}\n"},
+   "0: targets = {x}, decl\n"
+   "1: targets = {vector}\n"
+   "2: targets = {x}\n"},
   // Handle UnresolvedLookupExpr.
 

r375119 - [OPENMP]Fix thread id passed to outlined region in sequential parallel

2019-10-17 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Oct 17 07:36:43 2019
New Revision: 375119

URL: http://llvm.org/viewvc/llvm-project?rev=375119&view=rev
Log:
[OPENMP]Fix thread id passed to outlined region in sequential parallel
regions.

The real global thread id must be passed to the outlined region instead
of the zero thread id.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/parallel_if_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=375119&r1=375118&r2=375119&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Oct 17 07:36:43 2019
@@ -3075,17 +3075,15 @@ void CGOpenMPRuntime::emitParallelCall(C
 CGF.EmitRuntimeCall(
 RT.createRuntimeFunction(OMPRTL__kmpc_serialized_parallel), Args);
 
-// OutlinedFn(&zero, &zero_bound, CapturedStruct);
-Address ZeroAddr = CGF.CreateDefaultAlignTempAlloca(CGF.Int32Ty,
-/*Name=*/".zero.addr");
-CGF.InitTempAlloca(ZeroAddr, CGF.Builder.getInt32(/*C*/ 0));
+// OutlinedFn(>id, &zero_bound, CapturedStruct);
+Address ThreadIDAddr = RT.emitThreadIDAddress(CGF, Loc);
 Address ZeroAddrBound =
 CGF.CreateDefaultAlignTempAlloca(CGF.Int32Ty,
  /*Name=*/".bound.zero.addr");
 CGF.InitTempAlloca(ZeroAddrBound, CGF.Builder.getInt32(/*C*/ 0));
 llvm::SmallVector OutlinedFnArgs;
 // ThreadId for serialized parallels is 0.
-OutlinedFnArgs.push_back(ZeroAddr.getPointer());
+OutlinedFnArgs.push_back(ThreadIDAddr.getPointer());
 OutlinedFnArgs.push_back(ZeroAddrBound.getPointer());
 OutlinedFnArgs.append(CapturedVars.begin(), CapturedVars.end());
 RT.emitOutlinedFunctionCall(CGF, Loc, OutlinedFn, OutlinedFnArgs);

Modified: cfe/trunk/test/OpenMP/parallel_if_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_if_codegen.cpp?rev=375119&r1=375118&r2=375119&view=diff
==
--- cfe/trunk/test/OpenMP/parallel_if_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_if_codegen.cpp Thu Oct 17 07:36:43 2019
@@ -30,12 +30,12 @@ void gtid_test() {
 
 // CHECK: define internal {{.*}}void [[GTID_TEST_REGION1]](i{{.+}}* noalias 
[[GTID_PARAM:%.+]], i32* noalias
 // CHECK: store i32 0, i32* [[BND_ZERO_ADDR:%.+]],
-// CHECK: store i32 0, i32* [[ZERO_ADDR:%.+]],
 // CHECK: store i{{[0-9]+}}* [[GTID_PARAM]], i{{[0-9]+}}** 
[[GTID_ADDR_REF:%.+]],
 // CHECK: [[GTID_ADDR:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** 
[[GTID_ADDR_REF]]
 // CHECK: [[GTID:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[GTID_ADDR]]
 // CHECK: call {{.*}}void @__kmpc_serialized_parallel(%{{.+}}* @{{.+}}, 
i{{.+}} [[GTID]])
-// CHECK: call void [[GTID_TEST_REGION2:@.+]](i{{[0-9]+}}* [[ZERO_ADDR]], 
i{{[0-9]+}}* [[BND_ZERO_ADDR]]
+// CHECK: [[GTID_ADDR:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** 
[[GTID_ADDR_REF]]
+// CHECK: call void [[GTID_TEST_REGION2:@.+]](i{{[0-9]+}}* [[GTID_ADDR]], 
i{{[0-9]+}}* [[BND_ZERO_ADDR]]
 // CHECK: call {{.*}}void @__kmpc_end_serialized_parallel(%{{.+}}* @{{.+}}, 
i{{.+}} [[GTID]])
 // CHECK: ret void
 
@@ -57,15 +57,14 @@ int tmain(T Arg) {
 // CHECK-LABEL: define {{.*}}i{{[0-9]+}} @main()
 int main() {
 // CHECK: store i32 0, i32* [[BND_ZERO_ADDR2:%.+]],
-// CHECK: store i32 0, i32* [[ZERO_ADDR2:%.+]],
 // CHECK: store i32 0, i32* [[BND_ZERO_ADDR1:%.+]],
-// CHECK: store i32 0, i32* [[ZERO_ADDR1:%.+]],
 // CHECK: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num(
 // CHECK: call {{.*}}void {{.+}} @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{.+}} 
0, void {{.+}}* [[CAP_FN4:@.+]] to void
 #pragma omp parallel if (true)
   fn4();
 // CHECK: call {{.*}}void @__kmpc_serialized_parallel(%{{.+}}* @{{.+}}, i32 
[[GTID]])
-// CHECK: call void [[CAP_FN5:@.+]](i32* [[ZERO_ADDR1]], i32* 
[[BND_ZERO_ADDR1]])
+// CHECK: store i32 [[GTID]], i32* [[GTID_ADDR:%.+]],
+// CHECK: call void [[CAP_FN5:@.+]](i32* [[GTID_ADDR]], i32* 
[[BND_ZERO_ADDR1]])
 // CHECK: call {{.*}}void @__kmpc_end_serialized_parallel(%{{.+}}* @{{.+}}, 
i32 [[GTID]])
 #pragma omp parallel if (false)
   fn5();
@@ -76,7 +75,8 @@ int main() {
 // CHECK: br label %[[OMP_END:.+]]
 // CHECK: [[OMP_ELSE]]
 // CHECK: call {{.*}}void @__kmpc_serialized_parallel(%{{.+}}* @{{.+}}, i32 
[[GTID]])
-// CHECK: call void [[CAP_FN6]](i32* [[ZERO_ADDR2]], i32* [[BND_ZERO_ADDR2]])
+// CHECK: store i32 [[GTID]], i32* [[GTID_ADDR:%.+]],
+// CHECK: call void [[CAP_FN6]](i32* [[GTID_ADDR]], i32* [[BND_ZERO_ADDR2]])
 // CHECK: call {{.*}}void @__kmpc_end_serialized_parallel(%{{.+}}* @{{.+}}, 
i32 [[GTID]])
 // CHECK: br label %[[OMP_END]]
 // CHECK: [[OMP_END]]
@@ -100,13 +100,12 @@ int main() {
 
 // CHECK-LABEL: define {{.+}} @{{.+}}tmain
 // CHECK: s

[PATCH] D68028: [clang] Add no_builtin attribute

2019-10-17 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3600
   "attribute">;
+def err_attribute_no_builtin_invalid_builtin_name : Error<
+  "'%0' is not a valid builtin name for %1">;

aaron.ballman wrote:
> I think this should be a warning rather than an error.
> 
> Imagine the situation where the user uses Clang 11 to write their code and 
> they disable a Clang 11-specific builtin from being used, but then they try 
> to compile the code in Clang 10 which doesn't know about the builtin.
> 
> Rather than err, it seems reasonable to warn about the unknown builtin name 
> (under a new warning flag group under `-Wattributes`) and then just ignore 
> the attribute. Because the builtin is unknown anyway, we won't transform any 
> constructs to use it.
Makes perfect sense, thx for pointing this out.



Comment at: clang/lib/Sema/SemaDecl.cpp:9508-9510
+  // FIXME: We should really be doing this in SemaDeclAttr.cpp::handleNoBuiltin
+  // but there is a bug with FunctionDecl::isThisDeclarationADefinition() which
+  // always returns false before Sema::ActOnStartOfFunctionDef is called.

rsmith wrote:
> aaron.ballman wrote:
> > rsmith wrote:
> > > aaron.ballman wrote:
> > > > handleNoBuiltin -> handleNoBuiltinAttr
> > > I am not convinced that this is a bug -- the function declaration does 
> > > not become a definition until the parser reaches the definition.
> > > 
> > > In any case, I don't think the predicate you want is "is this declaration 
> > > a definition?". Rather, I think what you want is, "does this declaration 
> > > introduce an explicit function body?". In particular, we should not 
> > > permit uses of this attribute on defaulted or deleted functions, nor on 
> > > functions that have a definition by virtue of using 
> > > `__attribute__((alias))`. So it probably should be a syntactic check on 
> > > the form of the declarator (that is, the check you're perrforming here), 
> > > and the check should probably be `D.getFunctionDefinitionKind() == 
> > > FDK_Definition`. (A custom diagnostic for using the attribute on a 
> > > defaulted or deleted function would be nice too, since the existing 
> > > diagnostic text isn't really accurate in those cases.)
> > > In particular, we should not permit uses of this attribute on defaulted 
> > > or deleted functions
> > 
> > Deleted functions, sure. Defaulted functions... not so sure. I could sort 
> > of imagine wanting to instruct a defaulted assignment operator that does 
> > memberwise copy that it's not allowed to use a builtin memcpy, for 
> > instance. Or is this a bad idea for some reason I'm not thinking of?
> `-fno-builtin` does not turn off using `llvm.memcpy` for copying memory, and 
> it doesn't turn off `llvm.memcpy` being lowered to a call to `memcpy`. 
> Allowing this for defaulted functions would only give a false sense of 
> security, at least for now (though I could imagine we might find some way to 
> change that in the future).
> 
> Also, trivial defaulted functions (where we're most likely to end up with 
> `memcpy` calls) are often not emitted at all, instead being directly inlined 
> by the frontend, so there's nowhere to attach a `no-builtin-memcpy` LLVM 
> attribute (we'd need to put the attribute on all callers of those functions) 
> even if LLVM learned to not emit calls to `memcpy` to implement `llvm.memcpy` 
> when operating under a `no-builtin-memcpy` constraint.
> I am not convinced that this is a bug -- the function declaration does not 
> become a definition until the parser reaches the definition.

@rsmith It may not be a bug but it is currently used in a buggy manner (See 
D68379).
An assert to prevent misuse would be welcome IMHO, I've added a note on the 
function meanwhile.



Comment at: clang/test/Sema/no-builtin.c:26
+int __attribute__((no_builtin("*"))) variable;
+// expected-warning@-1 {{'no_builtin' attribute only applies to functions}}

aaron.ballman wrote:
> You should probably add another test case for this situation:
> ```
> void whatever() __attribute__((no_builtin("*", "*"))) {}
> ```
> and for member functions in C++ as well:
> ```
> struct S {
>   void whatever() __attribute__((no_builtin("memcpy"))) {}
>   virtual void intentional() __attribute__((no_builtin("memcpy"))) {}
> };
> ```
```
void whatever() __attribute__((no_builtin("*", "*"))) {}
```

I've added a few ones.

```
struct S {
  void whatever() __attribute__((no_builtin("memcpy"))) {}
  virtual void intentional() __attribute__((no_builtin("memcpy"))) {}
};
```

What do you want me to test for this one?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68028



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


[PATCH] D68028: [clang] Add no_builtin attribute

2019-10-17 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet updated this revision to Diff 225435.
gchatelet marked 13 inline comments as done.
gchatelet added a comment.
Herald added subscribers: s.egerton, simoncook, aheejin, dschuff.

- Address comments
- Fix missing rename
- Address comments
- Add warning category


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68028

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/no-builtin.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/no-builtin.cpp

Index: clang/test/Sema/no-builtin.cpp
===
--- /dev/null
+++ clang/test/Sema/no-builtin.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
+
+/// Prevent use of all builtins.
+void valid_attribute_all_1() __attribute__((no_builtin)) {}
+void valid_attribute_all_2() __attribute__((no_builtin())) {}
+
+/// Prevent use of specific builtins.
+void valid_attribute_function() __attribute__((no_builtin("memcpy"))) {}
+void valid_attribute_functions() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcmp"))) {}
+
+/// Many times the same builtin is fine.
+void many_attribute_function_1() __attribute__((no_builtin)) __attribute__((no_builtin)) {}
+void many_attribute_function_2() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcpy"))) {}
+void many_attribute_function_3() __attribute__((no_builtin("memcpy", "memcpy"))) {}
+void many_attribute_function_4() __attribute__((no_builtin("memcpy", "memcpy"))) __attribute__((no_builtin("memcpy"))) {}
+
+/// Invalid builtin name.
+void invalid_builtin() __attribute__((no_builtin("not_a_builtin"))) {}
+// expected-warning@-1 {{'not_a_builtin' is not a valid builtin name for no_builtin}}
+
+/// Can't use bare no_builtin with a named one.
+void wildcard_and_functionname() __attribute__((no_builtin)) __attribute__((no_builtin("memcpy"))) {}
+// expected-error@-1 {{empty no_builtin cannot be composed with named ones}}
+
+/// Can't attach attribute to a variable.
+int __attribute__((no_builtin)) variable;
+// expected-warning@-1 {{'no_builtin' attribute only applies to functions}}
+
+/// Can't attach attribute to a declaration.
+void nobuiltin_on_declaration() __attribute__((no_builtin));
+// expected-error@-1 {{no_builtin attribute is permitted on definitions only}}
+
+struct S {
+  /// Can't attach attribute to a defaulted function,
+  S()
+  __attribute__((no_builtin)) = default;
+  // expected-error@-1 {{no_builtin attribute has no effect on defaulted or deleted functions}}
+
+  /// Can't attach attribute to a deleted function,
+  S(const S &)
+  __attribute__((no_builtin)) = delete;
+  // expected-error@-1 {{no_builtin attribute has no effect on defaulted or deleted functions}}
+};
+
+/// Can't attach attribute to an aliased function.
+void alised_function() {}
+void aliasing_function() __attribute__((no_builtin)) __attribute__((alias("alised_function")));
+// expected-error@-1 {{no_builtin attribute is permitted on definitions only}}
\ No newline at end of file
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -74,6 +74,7 @@
 // CHECK-NEXT: NSConsumed (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: NSConsumesSelf (SubjectMatchRule_objc_method)
 // CHECK-NEXT: Naked (SubjectMatchRule_function)
+// CHECK-NEXT: NoBuiltin (SubjectMatchRule_function)
 // CHECK-NEXT: NoCommon (SubjectMatchRule_variable)
 // CHECK-NEXT: NoDebug (SubjectMatchRule_type_alias, SubjectMatchRule_hasType_functionType, SubjectMatchRule_objc_method, SubjectMatchRule_variable_not_is_parameter)
 // CHECK-NEXT: NoDestroy (SubjectMatchRule_variable)
Index: clang/test/CodeGen/no-builtin.cpp
===
--- /dev/null
+++ clang/test/CodeGen/no-builtin.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: define void @foo_no_mempcy() #0
+extern "C" void foo_no_mempcy() __attribute__((no_builtin("memcpy"))) {}
+
+// CHECK-LABEL: define void @foo_no_mempcy_twice() #0
+extern "C" void foo_no_mempcy_twice() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcpy"))) {}
+
+// CHECK-LABEL: define void @foo_no_builtins() #1
+extern "C" void foo_no_builtins() __attribute__((no_builtin)) {}
+
+// CHECK-LABEL: define void @foo_no_mempcy_memset() #2
+extern "C" void foo_no_mempcy_memset() __attribute__((no_builtin

r375124 - [ObjC] Add some additional test cases around pointer conversions.

2019-10-17 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Thu Oct 17 08:18:59 2019
New Revision: 375124

URL: http://llvm.org/viewvc/llvm-project?rev=375124&view=rev
Log:
[ObjC] Add some additional test cases around pointer conversions.

This is especially important for Objective-C++, which is entirely
missing this testing at the moment.

This annotates with "FIXME" the cases which I change in the next
patch -- I primarily wanted to document the current state of things so
that the effect of the code change is made clear.

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

Added:
cfe/trunk/test/SemaObjCXX/class-method-self.mm
cfe/trunk/test/SemaObjCXX/comptypes-1.mm
cfe/trunk/test/SemaObjCXX/comptypes-7.mm
Modified:
cfe/trunk/test/SemaObjC/class-method-self.m
cfe/trunk/test/SemaObjC/comptypes-1.m
cfe/trunk/test/SemaObjC/comptypes-7.m
cfe/trunk/test/SemaObjCXX/instancetype.mm

Modified: cfe/trunk/test/SemaObjC/class-method-self.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/class-method-self.m?rev=375124&r1=375123&r2=375124&view=diff
==
--- cfe/trunk/test/SemaObjC/class-method-self.m (original)
+++ cfe/trunk/test/SemaObjC/class-method-self.m Thu Oct 17 08:18:59 2019
@@ -1,6 +1,5 @@
 // RUN: %clang_cc1 -verify -Wno-objc-root-class %s
 
-typedef struct objc_class *Class;
 @interface XX
 
 - (void)addObserver:(XX*)o; // expected-note 2{{passing argument to parameter 
'o' here}}
@@ -23,4 +22,3 @@ static XX *obj;
   [obj addObserver:whatever]; // expected-warning {{incompatible pointer types 
sending 'Class' to parameter of type 'XX *'}}
 }
 @end
-

Modified: cfe/trunk/test/SemaObjC/comptypes-1.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/comptypes-1.m?rev=375124&r1=375123&r2=375124&view=diff
==
--- cfe/trunk/test/SemaObjC/comptypes-1.m (original)
+++ cfe/trunk/test/SemaObjC/comptypes-1.m Thu Oct 17 08:18:59 2019
@@ -1,12 +1,12 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
 
 #define nil (void *)0;
-#define Nil (void *)0;
 
 extern void foo();
 
 @protocol MyProtocol
 - (void) foo;
++ (void) bar;
 @end
 
 @interface MyClass
@@ -22,7 +22,8 @@ int main()
   id obj_p = nil;
   MyClass *obj_c = nil;
   MyOtherClass *obj_cp = nil;
-  Class obj_C = Nil;
+  Class obj_C = nil;
+  Class obj_CP = nil;
 
   /* Assigning to an 'id' variable should never
  generate a warning.  */
@@ -30,12 +31,15 @@ int main()
   obj = obj_c;  /* Ok  */
   obj = obj_cp; /* Ok  */
   obj = obj_C;  /* Ok  */
-  
+  obj = obj_CP;  /* Ok  */
+
   /* Assigning to a 'MyClass *' variable should always generate a
  warning, unless done from an 'id'.  */
   obj_c = obj;/* Ok */
-  obj_c = obj_cp; // // expected-warning {{incompatible pointer types 
assigning to 'MyClass *' from 'MyOtherClass *'}}
+  obj_c = obj_p;  // expected-warning {{assigning to 'MyClass *' from 
incompatible type 'id'}}
+  obj_c = obj_cp; // expected-warning {{incompatible pointer types assigning 
to 'MyClass *' from 'MyOtherClass *'}}
   obj_c = obj_C;  // expected-warning {{incompatible pointer types assigning 
to 'MyClass *' from 'Class'}}
+  obj_c = obj_CP; // expected-warning {{incompatible pointer types assigning 
to 'MyClass *' from 'Class'}}
 
   /* Assigning to an 'id' variable should generate a
  warning if done from a 'MyClass *' (which doesn't implement
@@ -45,6 +49,7 @@ int main()
   obj_p = obj_c;  // expected-warning {{assigning to 'id' from 
incompatible type 'MyClass *'}}
   obj_p = obj_cp; /* Ok  */
   obj_p = obj_C;  // expected-warning {{incompatible pointer types assigning 
to 'id' from 'Class'}}
+  obj_p = obj_CP; // FIXME -- should warn {{assigning to 'id' from 
incompatible type 'Class'}}
 
   /* Assigning to a 'MyOtherClass *' variable should always generate
  a warning, unless done from an 'id' or an 'id' (since
@@ -53,37 +58,67 @@ int main()
   obj_cp = obj_c;  // expected-warning {{incompatible pointer types assigning 
to 'MyOtherClass *' from 'MyClass *'}}
   obj_cp = obj_p;  /* Ok */
   obj_cp = obj_C;  // expected-warning {{incompatible pointer types assigning 
to 'MyOtherClass *' from 'Class'}}
+  obj_cp = obj_CP; // expected-warning {{incompatible pointer types assigning 
to 'MyOtherClass *' from 'Class'}}
+
+  obj_C = obj; // Ok
+  obj_C = obj_p;   // expected-warning {{incompatible pointer types assigning 
to 'Class' from 'id'}}
+  obj_C = obj_c;   // expected-warning {{incompatible pointer types assigning 
to 'Class' from 'MyClass *'}}
+  obj_C = obj_cp;  // expected-warning {{incompatible pointer types assigning 
to 'Class' from 'MyOtherClass *'}}
+  obj_C = obj_CP;  // Ok
+
+  obj_CP = obj; // Ok
+  obj_CP = obj_p;   // expected-warning {{assigning to 'Class' 
from incompatible type 'id'}}
+  obj_CP = obj_c;   // expected-warning {{incompatible pointer types assigning 
to 'Class' from 'MyClass *}}
+  obj_CP = obj

[PATCH] D67982: [ObjC] Add some additional test cases around pointer conversions.

2019-10-17 Thread James Y Knight via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1c982af05997: [ObjC] Add some additional test cases around 
pointer conversions. (authored by jyknight).

Changed prior to commit:
  https://reviews.llvm.org/D67982?vs=221586&id=225439#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67982

Files:
  clang/test/SemaObjC/class-method-self.m
  clang/test/SemaObjC/comptypes-1.m
  clang/test/SemaObjC/comptypes-7.m
  clang/test/SemaObjCXX/class-method-self.mm
  clang/test/SemaObjCXX/comptypes-1.mm
  clang/test/SemaObjCXX/comptypes-7.mm
  clang/test/SemaObjCXX/instancetype.mm

Index: clang/test/SemaObjCXX/instancetype.mm
===
--- clang/test/SemaObjCXX/instancetype.mm
+++ clang/test/SemaObjCXX/instancetype.mm
@@ -5,7 +5,7 @@
 #endif
 
 @interface Root
-+ (instancetype)alloc;
++ (instancetype)alloc; // FIXME -- should note {{explicitly declared 'instancetype'}}
 - (instancetype)init; // expected-note{{overridden method is part of the 'init' method family}}
 - (instancetype)self; // expected-note {{explicitly declared 'instancetype'}}
 - (Class)class;
@@ -143,7 +143,7 @@
 
 @implementation Subclass4
 + (id)alloc {
-  return self; // FIXME: we accept this in ObjC++ but not ObjC?
+  return self; // FIXME -- should error{{cannot initialize return object of type 'Subclass4 *' with an lvalue of type 'Class'}}
 }
 
 - (Subclass3 *)init { return 0; } // don't complain: we lost the related return type
Index: clang/test/SemaObjCXX/comptypes-7.mm
===
--- /dev/null
+++ clang/test/SemaObjCXX/comptypes-7.mm
@@ -0,0 +1,74 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+
+#define nil nullptr
+
+extern void foo();
+
+@protocol MyProtocol
+- (void) method;
+@end
+
+@interface MyClass
+@end
+
+int main()
+{
+  id obj = nil;
+  id  obj_p = nil;
+  MyClass *obj_c = nil;
+  Class obj_C = nil;
+
+  int i = 0;
+  int *j = nil;
+
+  /* These should all generate errors.  */
+
+  obj = i; // expected-error {{assigning to 'id' from incompatible type 'int'}}
+  obj = j; // expected-error {{assigning to 'id' from incompatible type 'int *'}}
+
+  obj_p = i; // expected-error {{assigning to 'id' from incompatible type 'int'}}
+  obj_p = j; // expected-error {{assigning to 'id' from incompatible type 'int *'}}
+
+  obj_c = i; // expected-error {{assigning to 'MyClass *' from incompatible type 'int'}}
+  obj_c = j; // expected-error {{assigning to 'MyClass *' from incompatible type 'int *'}}
+
+  obj_C = i; // expected-error {{assigning to 'Class' from incompatible type 'int'}}
+  obj_C = j; // expected-error {{assigning to 'Class' from incompatible type 'int *'}}
+
+  i = obj;   // expected-error {{assigning to 'int' from incompatible type 'id'}}
+  i = obj_p; // expected-error {{assigning to 'int' from incompatible type 'id'}}
+  i = obj_c; // expected-error {{assigning to 'int' from incompatible type 'MyClass *'}}
+  i = obj_C; // expected-error {{assigning to 'int' from incompatible type 'Class'}}
+
+  j = obj;   // expected-error {{assigning to 'int *' from incompatible type 'id'}}
+  j = obj_p; // expected-error {{assigning to 'int *' from incompatible type 'id'}}
+  j = obj_c; // expected-error {{assigning to 'int *' from incompatible type 'MyClass *'}}
+  j = obj_C; // expected-error {{assigning to 'int *' from incompatible type 'Class'}}
+
+  if (obj == i) foo() ; // expected-error {{comparison between pointer and integer ('id' and 'int')}}
+  if (i == obj) foo() ; // expected-error {{comparison between pointer and integer ('int' and 'id')}}
+  if (obj == j) foo() ; // expected-error {{invalid operands to binary expression ('id' and 'int *')}}
+  if (j == obj) foo() ; // expected-error {{invalid operands to binary expression ('int *' and 'id')}}
+
+  if (obj_c == i) foo() ; // expected-error {{comparison between pointer and integer ('MyClass *' and 'int')}}
+  if (i == obj_c) foo() ; // expected-error {{comparison between pointer and integer ('int' and 'MyClass *')}}
+  if (obj_c == j) foo() ; // expected-error {{invalid operands to binary expression ('MyClass *' and 'int *')}}
+  if (j == obj_c) foo() ; // expected-error {{invalid operands to binary expression ('int *' and 'MyClass *')}}
+
+  if (obj_p == i) foo() ; // expected-error {{comparison between pointer and integer ('id' and 'int')}}
+  if (i == obj_p) foo() ; // expected-error {{comparison between pointer and integer ('int' and 'id')}}
+  if (obj_p == j) foo() ; // expected-error {{invalid operands to binary expression ('id' and 'int *')}}
+  if (j == obj_p) foo() ; // expected-error {{invalid operands to binary expression ('int *' and 'id')}}
+
+  if (obj_C == i) foo() ; // expected-error {{comparison between pointer and integer ('Class' and 'int')}}
+  if (i == obj_C) foo() ; // expected-error {{comparison between 

[PATCH] D68028: [clang] Add no_builtin attribute

2019-10-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:3416
+
+def NoBuiltin : InheritableAttr {
+  let Spellings = [Clang<"no_builtin">];

I think we do not want this to be an inheritable attribute, but just `Attr` 
instead, because this can only be written on definitions (so there's no way to 
inherit the attribute from previous declarations).



Comment at: clang/test/Sema/no-builtin.c:26
+int __attribute__((no_builtin("*"))) variable;
+// expected-warning@-1 {{'no_builtin' attribute only applies to functions}}

gchatelet wrote:
> aaron.ballman wrote:
> > You should probably add another test case for this situation:
> > ```
> > void whatever() __attribute__((no_builtin("*", "*"))) {}
> > ```
> > and for member functions in C++ as well:
> > ```
> > struct S {
> >   void whatever() __attribute__((no_builtin("memcpy"))) {}
> >   virtual void intentional() __attribute__((no_builtin("memcpy"))) {}
> > };
> > ```
> ```
> void whatever() __attribute__((no_builtin("*", "*"))) {}
> ```
> 
> I've added a few ones.
> 
> ```
> struct S {
>   void whatever() __attribute__((no_builtin("memcpy"))) {}
>   virtual void intentional() __attribute__((no_builtin("memcpy"))) {}
> };
> ```
> 
> What do you want me to test for this one?
> What do you want me to test for this one?

Ensuring that applying the attribute to member function definitions, including 
virtual ones, is supported and doesn't cause diagnostics. The codegen side of 
things will test that overridden virtual methods do not inherit the attribute.

Actually, there's another interesting test hiding in there for when we do want 
a diagnostic (I think):
```
struct S {
  void whatever() __attribute__((no_builtin("memcpy"))); // Should diagnose as 
not a definition
};
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68028



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


r375125 - [ObjC] Diagnose implicit type coercion from ObjC 'Class' to object

2019-10-17 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Thu Oct 17 08:27:04 2019
New Revision: 375125

URL: http://llvm.org/viewvc/llvm-project?rev=375125&view=rev
Log:
[ObjC] Diagnose implicit type coercion from ObjC 'Class' to object
pointer types.

For example, in Objective-C mode, the initialization of 'x' in:
```
  @implementation MyType
  + (void)someClassMethod {
MyType *x = self;
  }
  @end
```
is correctly diagnosed with an incompatible-pointer-types warning, but
in Objective-C++ mode, it is not diagnosed at all -- even though
incompatible pointer conversions generally become an error in C++.

This patch fixes that oversight, allowing implicit conversions
involving Class only to/from unqualified-id, and between qualified and
unqualified Class, where the protocols are compatible.

Note that this does change some behaviors in Objective-C, as well, as
shown by the modified tests.

Of particular note is that assignment from from 'Class' to
'id' now warns. (Despite appearances, those are not
compatible types. 'Class' is not expected to have instance
methods defined by 'MyProtocol', while 'id' is.)

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

Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaObjC/comptypes-1.m
cfe/trunk/test/SemaObjCXX/class-method-self.mm
cfe/trunk/test/SemaObjCXX/comptypes-1.mm
cfe/trunk/test/SemaObjCXX/comptypes-7.mm
cfe/trunk/test/SemaObjCXX/instancetype.mm

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=375125&r1=375124&r2=375125&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu Oct 17 08:27:04 2019
@@ -8025,14 +8025,15 @@ bool ASTContext::ObjCQualifiedClassTypes
 bool ASTContext::ObjCQualifiedIdTypesAreCompatible(
 const ObjCObjectPointerType *lhs, const ObjCObjectPointerType *rhs,
 bool compare) {
-  // Allow id and an 'id' or void* type in all cases.
-  if (lhs->isVoidPointerType() ||
-  lhs->isObjCIdType() || lhs->isObjCClassType())
-return true;
-  else if (rhs->isVoidPointerType() ||
-   rhs->isObjCIdType() || rhs->isObjCClassType())
+  // Allow id and an 'id' in all cases.
+  if (lhs->isObjCIdType() || rhs->isObjCIdType())
 return true;
 
+  // Don't allow id to convert to Class or Class in either direction.
+  if (lhs->isObjCClassType() || lhs->isObjCQualifiedClassType() ||
+  rhs->isObjCClassType() || rhs->isObjCQualifiedClassType())
+return false;
+
   if (lhs->isObjCQualifiedIdType()) {
 if (rhs->qual_empty()) {
   // If the RHS is a unqualified interface pointer "NSString*",
@@ -8142,9 +8143,8 @@ bool ASTContext::canAssignObjCInterfaces
   const ObjCObjectType* LHS = LHSOPT->getObjectType();
   const ObjCObjectType* RHS = RHSOPT->getObjectType();
 
-  // If either type represents the built-in 'id' or 'Class' types, return true.
-  if (LHS->isObjCUnqualifiedIdOrClass() ||
-  RHS->isObjCUnqualifiedIdOrClass())
+  // If either type represents the built-in 'id' type, return true.
+  if (LHS->isObjCUnqualifiedId() || RHS->isObjCUnqualifiedId())
 return true;
 
   // Function object that propagates a successful result or handles
@@ -8162,14 +8162,22 @@ bool ASTContext::canAssignObjCInterfaces
LHSOPT->stripObjCKindOfTypeAndQuals(*this));
   };
 
+  // Casts from or to id are allowed when the other side has compatible
+  // protocols.
   if (LHS->isObjCQualifiedId() || RHS->isObjCQualifiedId()) {
 return finish(ObjCQualifiedIdTypesAreCompatible(LHSOPT, RHSOPT, false));
   }
 
+  // Verify protocol compatibility for casts from Class to Class.
   if (LHS->isObjCQualifiedClass() && RHS->isObjCQualifiedClass()) {
 return finish(ObjCQualifiedClassTypesAreCompatible(LHSOPT, RHSOPT));
   }
 
+  // Casts from Class to Class, or vice-versa, are allowed.
+  if (LHS->isObjCClass() && RHS->isObjCClass()) {
+return true;
+  }
+
   // If we have 2 user-defined types, fall into that path.
   if (LHS->getInterface() && RHS->getInterface()) {
 return finish(canAssignObjCInterfaces(LHS, RHS));

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=375125&r1=375124&r2=375125&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Oct 17 08:27:04 2019
@@ -10068,8 +10068,8 @@ static bool convertPointersToCompositeTy
 
   QualType T = S.FindCompositePointerType(Loc, LHS, RHS);
   if (T.isNull()) {
-if ((LHSType->isPointerType() || LHSType->isMemberPointerType()) &&
-(RHSType->isPointerType() || RHSType->isMemberPointerType()))
+if ((LHSType->isAnyPointerType() || LHSType->isMemberPointerType()) &&
+(RHSType->isAnyPointerType() || RHSType-

[PATCH] D67983: [ObjC] Diagnose implicit type coercion from ObjC 'Class' to object pointer types.

2019-10-17 Thread James Y Knight via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGccc4d83cda16: [ObjC] Diagnose implicit type coercion from 
ObjC 'Class' to object pointer… (authored by jyknight).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67983

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaObjC/comptypes-1.m
  clang/test/SemaObjCXX/class-method-self.mm
  clang/test/SemaObjCXX/comptypes-1.mm
  clang/test/SemaObjCXX/comptypes-7.mm
  clang/test/SemaObjCXX/instancetype.mm

Index: clang/test/SemaObjCXX/instancetype.mm
===
--- clang/test/SemaObjCXX/instancetype.mm
+++ clang/test/SemaObjCXX/instancetype.mm
@@ -5,7 +5,7 @@
 #endif
 
 @interface Root
-+ (instancetype)alloc; // FIXME -- should note {{explicitly declared 'instancetype'}}
++ (instancetype)alloc; // expected-note {{explicitly declared 'instancetype'}}
 - (instancetype)init; // expected-note{{overridden method is part of the 'init' method family}}
 - (instancetype)self; // expected-note {{explicitly declared 'instancetype'}}
 - (Class)class;
@@ -143,7 +143,7 @@
 
 @implementation Subclass4
 + (id)alloc {
-  return self; // FIXME -- should error{{cannot initialize return object of type 'Subclass4 *' with an lvalue of type 'Class'}}
+  return self; // expected-error{{cannot initialize return object of type 'Subclass4 *' with an lvalue of type 'Class'}}
 }
 
 - (Subclass3 *)init { return 0; } // don't complain: we lost the related return type
Index: clang/test/SemaObjCXX/comptypes-7.mm
===
--- clang/test/SemaObjCXX/comptypes-7.mm
+++ clang/test/SemaObjCXX/comptypes-7.mm
@@ -47,23 +47,23 @@
 
   if (obj == i) foo() ; // expected-error {{comparison between pointer and integer ('id' and 'int')}}
   if (i == obj) foo() ; // expected-error {{comparison between pointer and integer ('int' and 'id')}}
-  if (obj == j) foo() ; // expected-error {{invalid operands to binary expression ('id' and 'int *')}}
-  if (j == obj) foo() ; // expected-error {{invalid operands to binary expression ('int *' and 'id')}}
+  if (obj == j) foo() ; // expected-error {{comparison of distinct pointer types ('id' and 'int *')}}
+  if (j == obj) foo() ; // expected-error {{comparison of distinct pointer types ('int *' and 'id')}}
 
   if (obj_c == i) foo() ; // expected-error {{comparison between pointer and integer ('MyClass *' and 'int')}}
   if (i == obj_c) foo() ; // expected-error {{comparison between pointer and integer ('int' and 'MyClass *')}}
-  if (obj_c == j) foo() ; // expected-error {{invalid operands to binary expression ('MyClass *' and 'int *')}}
-  if (j == obj_c) foo() ; // expected-error {{invalid operands to binary expression ('int *' and 'MyClass *')}}
+  if (obj_c == j) foo() ; // expected-error {{comparison of distinct pointer types ('MyClass *' and 'int *')}}
+  if (j == obj_c) foo() ; // expected-error {{comparison of distinct pointer types ('int *' and 'MyClass *')}}
 
   if (obj_p == i) foo() ; // expected-error {{comparison between pointer and integer ('id' and 'int')}}
   if (i == obj_p) foo() ; // expected-error {{comparison between pointer and integer ('int' and 'id')}}
-  if (obj_p == j) foo() ; // expected-error {{invalid operands to binary expression ('id' and 'int *')}}
-  if (j == obj_p) foo() ; // expected-error {{invalid operands to binary expression ('int *' and 'id')}}
+  if (obj_p == j) foo() ; // expected-error {{comparison of distinct pointer types ('id' and 'int *')}}
+  if (j == obj_p) foo() ; // expected-error {{comparison of distinct pointer types ('int *' and 'id')}}
 
   if (obj_C == i) foo() ; // expected-error {{comparison between pointer and integer ('Class' and 'int')}}
   if (i == obj_C) foo() ; // expected-error {{comparison between pointer and integer ('int' and 'Class')}}
-  if (obj_C == j) foo() ; // expected-error {{invalid operands to binary expression ('Class' and 'int *')}}
-  if (j == obj_C) foo() ; // expected-error {{invalid operands to binary expression ('int *' and 'Class')}}
+  if (obj_C == j) foo() ; // expected-error {{comparison of distinct pointer types ('Class' and 'int *')}}
+  if (j == obj_C) foo() ; // expected-error {{comparison of distinct pointer types ('int *' and 'Class')}}
 
   Class bar1 = nil;
   Class  bar = nil;
Index: clang/test/SemaObjCXX/comptypes-1.mm
===
--- clang/test/SemaObjCXX/comptypes-1.mm
+++ clang/test/SemaObjCXX/comptypes-1.mm
@@ -38,7 +38,7 @@
   obj_c = obj;/* Ok */
   obj_c = obj_p;  // expected-error {{assigning to 'MyClass *' from incompatible type 'id'}}
   obj_c = obj_cp; // expected-error {{assigning to 'MyClass *' from incompatible type 'MyOtherClass *'}}
-  obj_c = obj_C;  // FIXME -- should error {{assigning to 'MyClass *' from incompatible type 'C

[PATCH] D68377: [Builtins] Teach Clang about memccpy

2019-10-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D68377#1698399 , @xbolva00 wrote:

> Current solution does not work
>  /home/xbolva00/LLVM/llvm/tools/clang/include/clang/Basic/Builtins.h:50:34: 
> error: redefinition of ‘BImemccpy’
>
>   #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
>^
>
> /home/xbolva00/LLVM/llvm/tools/clang/include/clang/Basic/Builtins.h:50:34: 
> note: in definition of macro ‘BUILTIN’
>
>   #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
>   
>
> @aaron.ballman, maybe you can help me how to represent that memccpy exists 
> for GNU and MS?


We may not have the machinery needed for doing this yet, in which case, I think 
it's fine to ignore the MS builtin.


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

https://reviews.llvm.org/D68377



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


Re: r374135 - [c++20] P1152R4: warn on any simple-assignment to a volatile lvalue

2019-10-17 Thread Richard Smith via cfe-commits
On Thu, 17 Oct 2019, 05:17 Stephan Bergmann via cfe-commits, <
cfe-commits@lists.llvm.org> wrote:

> On 09/10/2019 04:04, Richard Smith via cfe-commits wrote:
> > Author: rsmith
> > Date: Tue Oct  8 19:04:54 2019
> > New Revision: 374135
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=374135&view=rev
> > Log:
> > [c++20] P1152R4: warn on any simple-assignment to a volatile lvalue
> > whose value is not ignored.
> >
> > We don't warn on all the cases that are deprecated: specifically, we
> > choose to not warn for now if there are parentheses around the
> > assignment but its value is not actually used. This seems like a more
> > defensible rule, particularly for cases like sizeof(v = a), where the
> > parens are part of the operand rather than the sizeof syntax.
> >
> > Modified:
> >  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> >  cfe/trunk/include/clang/Sema/Sema.h
> >  cfe/trunk/lib/Sema/SemaExpr.cpp
> >  cfe/trunk/lib/Sema/SemaExprCXX.cpp
> >  cfe/trunk/test/SemaCXX/deprecated.cpp
> >  cfe/trunk/www/cxx_status.html
>
> Oh, I should probably have commented here on the mailing list rather
> than at
> <
> https://github.com/llvm/llvm-project/commit/4a6861a7e5b59be24a09b8b9782255d028e7aade#commitcomment-35540755
> >:
>
> I assume the scenario at
>  "Avoid C++20
> deprecated assignment to volatile",
>
>(void) (0 ? *(location) = (result) : 0);
>
> where *(location) is of (non-class) volatile type, is a true positive
> that we indeed want to warn about?
>

Yes, that case is deprecated in C++20.

___
> 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] D67550: [AArch64][SVE] Implement unpack intrinsics

2019-10-17 Thread David Greene via Phabricator via cfe-commits
greened accepted this revision.
greened added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D67550



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


[PATCH] D67216: [cfi] Add flag to always generate .debug_frame

2019-10-17 Thread David Candler via Phabricator via cfe-commits
dcandler added a comment.

I added the negative option more as a way to disable the flag, since I'm 
currently looking at cases where it may want to be turned on by default (and a 
negative option would then allow you to only get .eh_frame in cases where you'd 
get both .debug_frame/.eh_frame).

The other suggested name of -gdwarf-frame-always might then better describe the 
behavior, as the negative -gno-dwarf-frame-always wouldn't sound quite so 
misleading (since 'not always' equates to 'sometimes').


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

https://reviews.llvm.org/D67216



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


[PATCH] D66827: Add support for MS qualifiers __ptr32, __ptr64, __sptr, __uptr.

2019-10-17 Thread Fabian Maurer via Phabricator via cfe-commits
DarkShadow44 added a comment.

@akhuang Thanks for looking into this!

I've found something else, I've written a small dumper to demonstrate. Pardon 
the long comment please.

Program:

  typedef int* __ptr32 PINT32;
  typedef int* PINT64;
  
  struct s1
  {
PINT32 i32;
PINT64 i64;
  };

AST:

  Kind: 'TranslationUnit(300)', Type: '', Name: 
'/home/fabian/Programming/Wine/wine-git/tools/test.c'
  Kind: 'TypedefDecl(20)', Type: '__ptr32_sptr int *', Name: 'PINT32'
  Kind: 'TypedefDecl(20)', Type: 'PINT64', Name: 'PINT64'
  Kind: 'StructDecl(2)', Type: 'struct s1', Name: 's1'
  Kind: 'FieldDecl(6)', Type: '__ptr32_sptr int *', Name: 'i32'
  Kind: 'TypeRef(43)', Type: '__ptr32_sptr int *', 
Name: 'PINT32'
  Kind: 'FieldDecl(6)', Type: 'PINT64', Name: 'i64'
  Kind: 'TypeRef(43)', Type: 'PINT64', Name: 'PINT64'

Note the difference between

  Type: '__ptr32_sptr int *', Name: 'PINT32'
  Type: 'PINT64', Name: 'PINT64'

3 Issues I have here:

- __ptr32_sptr doesn't exist and seems wrong
- The __ptr32 part should be right of the asterisk
- Why does PINT64 have PINT64 as type, but PINT32 not PINT32?

I'm not sure if this is/should still be part of this patchset or even is an 
issue, just pointing out inconsistencies I noticed - hope I'm not a bother.

Dumper attached, for convenience.
F10298035: dumper.cpp 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66827



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


[PATCH] D68818: [hip][cuda] Fix the extended lambda name mangling issue.

2019-10-17 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 225452.
hliao added a comment.

Force numbering on all lambdas in CUDA/HIP.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68818

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CodeGenCUDA/unnamed-types.cu

Index: clang/test/CodeGenCUDA/unnamed-types.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/unnamed-types.cu
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -std=c++11 -x hip -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix=HOST
+// RUN: %clang_cc1 -std=c++11 -x hip -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm %s -o - | FileCheck %s --check-prefix=DEVICE
+
+#include "Inputs/cuda.h"
+
+// HOST: @0 = private unnamed_addr constant [43 x i8] c"_Z2k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_\00", align 1
+
+__device__ float d0(float x) {
+  return [](float x) { return x + 2.f; }(x);
+}
+
+__device__ float d1(float x) {
+  return [](float x) { return x * 2.f; }(x);
+}
+
+// DEVICE: amdgpu_kernel void @_Z2k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_(
+template 
+__global__ void k0(float *p, F f) {
+  p[0] = f(p[0]) + d0(p[1]) + d1(p[2]);
+}
+
+void f0(float *p) {
+  [](float *p) {
+*p = 1.f;
+  }(p);
+}
+
+// The inner/outer lambdas are required to be mangled following ODR but their
+// linkages are still required to keep the original `internal` linkage.
+
+// HOST: define internal void @_ZZ2f1PfENKUlS_E_clES_(
+// DEVICE: define internal float @_ZZZ2f1PfENKUlS_E_clES_ENKUlfE_clEf(
+void f1(float *p) {
+  [](float *p) {
+k0<<<1,1>>>(p, [] __device__ (float x) { return x + 1.f; });
+  }(p);
+}
+// HOST: @__hip_register_globals
+// HOST: __hipRegisterFunction{{.*}}@_Z2k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_{{.*}}@0
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -6223,6 +6223,7 @@
 Record->push_back(Lambda.CaptureDefault);
 Record->push_back(Lambda.NumCaptures);
 Record->push_back(Lambda.NumExplicitCaptures);
+Record->push_back(Lambda.HasKnownInternalLinkage);
 Record->push_back(Lambda.ManglingNumber);
 AddDeclRef(D->getLambdaContextDecl());
 AddTypeSourceInfo(Lambda.MethodTyInfo);
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1690,6 +1690,7 @@
 Lambda.CaptureDefault = Record.readInt();
 Lambda.NumCaptures = Record.readInt();
 Lambda.NumExplicitCaptures = Record.readInt();
+Lambda.HasKnownInternalLinkage = Record.readInt();
 Lambda.ManglingNumber = Record.readInt();
 Lambda.ContextDecl = ReadDeclID();
 Lambda.Captures = (Capture *)Reader.getContext().Allocate(
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -11431,17 +11431,18 @@
 E->getCaptureDefault());
   getDerived().transformedLocalDecl(OldClass, {Class});
 
-  Optional> Mangling;
+  Optional> Mangling;
   if (getDerived().ReplacingOriginal())
-Mangling = std::make_pair(OldClass->getLambdaManglingNumber(),
-  OldClass->getLambdaContextDecl());
+Mangling = std::make_tuple(OldClass->getLambdaManglingNumber(),
+   OldClass->hasKnownInternalLinkage(),
+   OldClass->getLambdaContextDecl());
 
   // Build the call operator.
   CXXMethodDecl *NewCallOperator = getSema().startLambdaDefinition(
   Class, E->getIntroducerRange(), NewCallOpTSI,
   E->getCallOperator()->getEndLoc(),
   NewCallOpTSI->getTypeLoc().castAs().getParams(),
-  E->getCallOperator()->getConstexprKind(), Mangling);
+  E->getCallOperator()->getConstexprKind());
 
   LSI->CallOperator = NewCallOperator;
 
@@ -11461,6 +11462,9 @@
   getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
   getDerived().transformedLocalDecl(E->getCallOperator(), {NewCallOperator});
 
+  // Number the lambda for linkage purposes if necessary.
+  getSema().handleLambdaNumbering(Class, NewCallOperator, Mangling);
+
   // Introduce the context of the call operator.
   Sema::ContextRAII SavedContext(getSema(), NewCallOperator,
  /*NewThisContext*/false);
Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/Sema/SemaLamb

[PATCH] D68969: [clang-format] Remove the dependency on frontend

2019-10-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 225455.
MyDeveloperDay added a comment.

Update out by one errors and unused variables


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

https://reviews.llvm.org/D68969

Files:
  clang/tools/clang-format/CMakeLists.txt
  clang/tools/clang-format/ClangFormat.cpp


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -18,7 +18,6 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Version.h"
 #include "clang/Format/Format.h"
-#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
@@ -325,12 +324,9 @@
   IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
   DiagOpts->ShowColors = (ShowColors && !NoShowColors);
 
-  TextDiagnosticPrinter *DiagsBuffer =
-  new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts, false);
-
   IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
   IntrusiveRefCntPtr Diags(
-  new DiagnosticsEngine(DiagID, &*DiagOpts, DiagsBuffer));
+  new DiagnosticsEngine(DiagID, &*DiagOpts));
 
   IntrusiveRefCntPtr InMemoryFileSystem(
   new llvm::vfs::InMemoryFileSystem);
@@ -339,24 +335,40 @@
   FileID FileID = createInMemoryFile(AssumedFileName, Code.get(), Sources,
  Files, InMemoryFileSystem.get());
 
-  const unsigned ID = Diags->getCustomDiagID(
-  WarningsAsErrors ? clang::DiagnosticsEngine::Error
-   : clang::DiagnosticsEngine::Warning,
-  "code should be clang-formatted [-Wclang-format-violations]");
+  FileManager &FileMgr = Sources.getFileManager();
+  llvm::ErrorOr FileEntryPtr =
+  FileMgr.getFile(AssumedFileName);
 
   unsigned Errors = 0;
-  DiagsBuffer->BeginSourceFile(LangOptions(), nullptr);
   if (WarnFormat && !NoWarnFormat) {
 for (const auto &R : Replaces) {
-  Diags->Report(
-  Sources.getLocForStartOfFile(FileID).getLocWithOffset(R.getOffset()),
-  ID);
+  PresumedLoc PLoc = Sources.getPresumedLoc(
+  
Sources.getLocForStartOfFile(FileID).getLocWithOffset(R.getOffset()));
+
+  SourceLocation LineBegin =
+  Sources.translateFileLineCol(FileEntryPtr.get(), PLoc.getLine(), 1);
+  SourceLocation NextLineBegin = Sources.translateFileLineCol(
+  FileEntryPtr.get(), PLoc.getLine() + 1, 1);
+
+  const char *StartBuf = Sources.getCharacterData(LineBegin);
+  const char *EndBuf = Sources.getCharacterData(NextLineBegin);
+
+  StringRef Line(StartBuf, (EndBuf - StartBuf) - 1);
+
+  SMDiagnostic Diags(
+  llvm::SourceMgr(), SMLoc(), AssumedFileName, PLoc.getLine(),
+  PLoc.getColumn(),
+  WarningsAsErrors ? SourceMgr::DiagKind::DK_Error
+   : SourceMgr::DiagKind::DK_Warning,
+  "code should be clang-formatted [-Wclang-format-violations]", Line,
+  ArrayRef>());
+
+  Diags.print(nullptr, llvm::errs(), (ShowColors && !NoShowColors));
   Errors++;
   if (ErrorLimit && Errors >= ErrorLimit)
 break;
 }
   }
-  DiagsBuffer->EndSourceFile();
   return WarningsAsErrors;
 }
 
Index: clang/tools/clang-format/CMakeLists.txt
===
--- clang/tools/clang-format/CMakeLists.txt
+++ clang/tools/clang-format/CMakeLists.txt
@@ -7,7 +7,6 @@
 set(CLANG_FORMAT_LIB_DEPS
   clangBasic
   clangFormat
-  clangFrontend
   clangRewrite
   clangToolingCore
   )


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -18,7 +18,6 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Version.h"
 #include "clang/Format/Format.h"
-#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
@@ -325,12 +324,9 @@
   IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
   DiagOpts->ShowColors = (ShowColors && !NoShowColors);
 
-  TextDiagnosticPrinter *DiagsBuffer =
-  new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts, false);
-
   IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
   IntrusiveRefCntPtr Diags(
-  new DiagnosticsEngine(DiagID, &*DiagOpts, DiagsBuffer));
+  new DiagnosticsEngine(DiagID, &*DiagOpts));
 
   IntrusiveRefCntPtr InMemoryFileSystem(
   new llvm::vfs::InMemoryFileSystem);
@@ -339,24 +335,40 @@
   FileID FileID = createInMemoryFile(AssumedFileName, Code.get(), Sources,
  Files, InMemoryFileSystem.get());
 
-  const unsigned ID = Diags->getCustomDiagID(
-  WarningsAsErrors ? clang::DiagnosticsEngine::Error
-   : 

[PATCH] D68554: [clang-format] Proposal for clang-format to give compiler style warnings

2019-10-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D68554#1712863 , @hans wrote:

> > I can't wait for @hans next Windows Snapshot, this is my gate for rolling 
> > into our builds and CI system, after that, I'm gonna catch every single 
> > person who tries to build/check in unclang-formatted.
>
> As it happens, there's a new snapshot out today :-)


@MyDeveloperDay  awarded this comment a like token!!! (if I could)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68554



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


r375134 - [OPENMP]Improve use of the global tid parameter.

2019-10-17 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Oct 17 10:12:03 2019
New Revision: 375134

URL: http://llvm.org/viewvc/llvm-project?rev=375134&view=rev
Log:
[OPENMP]Improve use of the global tid parameter.

If we can determined, that the global tid parameter can be used in the
function, better to use it rather than calling __kmpc_global_thread_num
function.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/openmp_win_codegen.cpp
cfe/trunk/test/OpenMP/parallel_for_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=375134&r1=375133&r2=375134&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Oct 17 10:12:03 2019
@@ -1697,18 +1697,23 @@ llvm::Value *CGOpenMPRuntime::getThreadI
   return ThreadID;
   }
   // If exceptions are enabled, do not use parameter to avoid possible crash.
-  if (!CGF.EHStack.requiresLandingPad() || !CGF.getLangOpts().Exceptions ||
-  !CGF.getLangOpts().CXXExceptions ||
-  CGF.Builder.GetInsertBlock() == CGF.AllocaInsertPt->getParent()) {
-if (auto *OMPRegionInfo =
-dyn_cast_or_null(CGF.CapturedStmtInfo)) {
-  if (OMPRegionInfo->getThreadIDVariable()) {
-// Check if this an outlined function with thread id passed as 
argument.
-LValue LVal = OMPRegionInfo->getThreadIDVariableLValue(CGF);
+  if (auto *OMPRegionInfo =
+  dyn_cast_or_null(CGF.CapturedStmtInfo)) {
+if (OMPRegionInfo->getThreadIDVariable()) {
+  // Check if this an outlined function with thread id passed as argument.
+  LValue LVal = OMPRegionInfo->getThreadIDVariableLValue(CGF);
+  llvm::BasicBlock *TopBlock = CGF.AllocaInsertPt->getParent();
+  if (!CGF.EHStack.requiresLandingPad() || !CGF.getLangOpts().Exceptions ||
+  !CGF.getLangOpts().CXXExceptions ||
+  CGF.Builder.GetInsertBlock() == TopBlock ||
+  !isa(LVal.getPointer()) ||
+  cast(LVal.getPointer())->getParent() == TopBlock 
||
+  cast(LVal.getPointer())->getParent() ==
+  CGF.Builder.GetInsertBlock()) {
 ThreadID = CGF.EmitLoadOfScalar(LVal, Loc);
 // If value loaded in entry block, cache it and use it everywhere in
 // function.
-if (CGF.Builder.GetInsertBlock() == CGF.AllocaInsertPt->getParent()) {
+if (CGF.Builder.GetInsertBlock() == TopBlock) {
   auto &Elem = OpenMPLocThreadIDMap.FindAndConstruct(CGF.CurFn);
   Elem.second.ThreadID = ThreadID;
 }

Modified: cfe/trunk/test/OpenMP/openmp_win_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/openmp_win_codegen.cpp?rev=375134&r1=375133&r2=375134&view=diff
==
--- cfe/trunk/test/OpenMP/openmp_win_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/openmp_win_codegen.cpp Thu Oct 17 10:12:03 2019
@@ -50,11 +50,10 @@ int main() {
 }
 
 // CHECK: define internal void [[OUTLINED]](
-// CHECK: [[GID:%.+]] = {{.*}}call i32 
@__kmpc_global_thread_num(%struct.ident_t* {{.*}}@0)
 // CHECK: invoke void @{{.+}}foo
 // CHECK: [[CATCHSWITCH:%.+]] = catchswitch within none
 // CHECK: [[CATCHPAD:%.+]] = catchpad within [[CATCHSWITCH]]
-// CHECK: call void @__kmpc_critical(%struct.ident_t* {{.*}}@0, i32 [[GID]],
+// CHECK: call void @__kmpc_critical(%struct.ident_t* {{.*}}@0, i32 
[[GID:%.+]],
 // CHECK: invoke void @{{.+}}bar
 // CHECK: call void @__kmpc_end_critical(%struct.ident_t* {{.*}}@0, i32 
[[GID]],
 // CHECK: catchret from [[CATCHPAD]] to

Modified: cfe/trunk/test/OpenMP/parallel_for_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_for_codegen.cpp?rev=375134&r1=375133&r2=375134&view=diff
==
--- cfe/trunk/test/OpenMP/parallel_for_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_for_codegen.cpp Thu Oct 17 10:12:03 2019
@@ -40,7 +40,7 @@ void with_var_schedule() {
 // CHECK: [[CHUNK_VAL:%.+]] = load i8, i8* %
 // CHECK: [[CHUNK_SIZE:%.+]] = sext i8 [[CHUNK_VAL]] to i64
 // CHECK: call void @__kmpc_for_static_init_8u([[IDENT_T_TY]]* [[LOOP_LOC]], 
i32 [[GTID:%[^,]+]], i32 33, i32* [[IS_LAST:%[^,]+]], i64* [[OMP_LB:%[^,]+]], 
i64* [[OMP_UB:%[^,]+]], i64* [[OMP_ST:%[^,]+]], i64 1, i64 [[CHUNK_SIZE]])
-// CHECK: call void @__kmpc_for_static_fini([[IDENT_T_TY]]* [[LOOP_LOC]], i32 
[[GTID]])
+// CHECK: call void @__kmpc_for_static_fini([[IDENT_T_TY]]* [[LOOP_LOC]], i32 
[[GTID:%.+]])
 #pragma omp parallel for schedule(static, char(a)) private(a)
   for (unsigned long long i = 1; i < 2 + a; ++i) {
   }
@@ -284,7 +284,7 @@ void test_auto(float *a, float *b, float
 // CHECK: store i32* [[GTID_PARAM_ADDR]], i32** [[GTID_REF_ADDR:%.+]],
 // CHECK: call void @__kmpc_dispatch_

[PATCH] D69088: [Lex] #pragma clang transform

2019-10-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Why not try to improve the existing #pragma clang loop rather than add a new 
pragma with almost the same behavior?


Repository:
  rC Clang

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

https://reviews.llvm.org/D69088



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


[PATCH] D68720: Support -fstack-clash-protection for x86

2019-10-17 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 225462.
serge-sans-paille added a comment.

Moved the implementation to a specialization of `emitStackProbeInline` that 
used to be Windows-centric. Provide a generic implementation that generates 
inline assembly instead. that way we don't clutter existing functions, and only 
add a new case to `emitSPUpdate`.

Handle large stack allocation with a loop instead of a (large) basic block.

@rnk: this is far less intrusive and more integrated to the existing structure, 
thanks a lot for hinting in that direction.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68720

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/stack-clash-protection.c
  clang/test/Driver/stack-clash-protection.c
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/Target/X86/X86CallFrameOptimization.cpp
  llvm/lib/Target/X86/X86FrameLowering.cpp
  llvm/lib/Target/X86/X86FrameLowering.h
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.h
  llvm/lib/Target/X86/X86InstrCompiler.td
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll
  llvm/test/CodeGen/X86/stack-clash-large.ll
  llvm/test/CodeGen/X86/stack-clash-medium-natural-probes.ll
  llvm/test/CodeGen/X86/stack-clash-medium.ll
  llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll
  llvm/test/CodeGen/X86/stack-clash-small.ll

Index: llvm/test/CodeGen/X86/stack-clash-small.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-small.ll
@@ -0,0 +1,25 @@
+; RUN: llc < %s | FileCheck %s
+
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @foo() local_unnamed_addr #0 {
+; CHECK-LABEL: foo:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:  subq	$280, %rsp # imm = 0x118
+; CHECK-NEXT:  .cfi_def_cfa_offset 288
+; CHECK-NEXT:  movl	$1, 264(%rsp)
+; CHECK-NEXT:  movl	-128(%rsp), %eax
+; CHECK-NEXT:  addq	$280, %rsp # imm = 0x118
+; CHECK-NEXT:  .cfi_def_cfa_offset 8
+; CHECK-NEXT:  retq
+
+  %a = alloca i32, i64 100, align 16
+  %b = getelementptr inbounds i32, i32* %a, i64 98
+  store volatile i32 1, i32* %b
+  %c = load volatile i32, i32* %a
+  ret i32 %c
+}
+
+attributes #0 =  {"probe-stack"="inline-asm"}
Index: llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll
@@ -0,0 +1,27 @@
+; RUN: llc < %s | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @foo(i64 %i) local_unnamed_addr #0 {
+; CHECK-LABEL: foo:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:  subq	$4096, %rsp # imm = 0x1000
+; CHECK-NEXT:  movq	$0, (%rsp)
+; CHECK-NEXT:  subq	$3784, %rsp # imm = 0xEC8
+; CHECK-NEXT:  .cfi_def_cfa_offset 7888
+; CHECK-NEXT:  movl	$1, -128(%rsp,%rdi,4)
+; CHECK-NEXT:  movl	-128(%rsp), %eax
+; CHECK-NEXT:  addq	$7880, %rsp # imm = 0x1EC8
+; CHECK-NEXT:  .cfi_def_cfa_offset 8
+; CHECK-NEXT:  retq
+
+  %a = alloca i32, i32 2000, align 16
+  %b = getelementptr inbounds i32, i32* %a, i64 %i
+  store volatile i32 1, i32* %b
+  %c = load volatile i32, i32* %a
+  ret i32 %c
+}
+
+attributes #0 =  {"probe-stack"="inline-asm"}
+
Index: llvm/test/CodeGen/X86/stack-clash-medium.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-medium.ll
@@ -0,0 +1,28 @@
+; RUN: llc < %s | FileCheck %s
+
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @foo() local_unnamed_addr #0 {
+
+; CHECK-LABEL: foo:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:  subq	$4096, %rsp # imm = 0x1000
+; CHECK-NEXT:  .cfi_def_cfa_offset 7888
+; CHECK-NEXT:  movl	$1, 880(%rsp)
+; CHECK-NEXT:  subq	$3784, %rsp # imm = 0xEC8
+; CHECK-NEXT:  movq	$0, (%rsp)
+; CHECK-NEXT:  movl	-128(%rsp), %eax
+; CHECK-NEXT:  addq	$7880, %rsp # imm = 0x1EC8
+; CHECK-NEXT:  .cfi_def_cfa_offset 8
+; CHECK-NEXT:  retq
+
+  %a = alloca i32, i64 2000, align 16
+  %b = getelementptr inbounds i32, i32* %a, i64 1198
+  store volatile i32 1, i32* %b
+  %c = load volatile i32, i32* %a
+  ret i32 %c
+}
+
+attributes #0 =  {"probe-stack"="inline-asm"}
Index: llvm/test/CodeGen/X86/stack-clash-medium-natural-probes.ll
==

[PATCH] D68720: Support -fstack-clash-protection for x86

2019-10-17 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

Extra note: an older version of the patch has been tested by the firefox team 
without much performance impact, (and no test failure), see 
https://bugzilla.mozilla.org/show_bug.cgi?id=1588710


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68720



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


[PATCH] D66983: [WebAssembly] Add wasm-specific vector shuffle builtin and intrinsic

2019-10-17 Thread Thomas Lively via Phabricator via cfe-commits
tlively reclaimed this revision.
tlively added a comment.

I'm re-opening this revision. After discussion on 
https://github.com/WebAssembly/simd/issues/118, there is clear consensus that 
we do not want to break WebAssembly's abstraction and consider underlying 
platforms, so shuffles should not be merged without some sort of modification 
to the spec to serve as a platform-agnostic indication that the merged shuffle 
will be better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66983



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


[PATCH] D69122: Add support to find out resource dir and add it as compilation args

2019-10-17 Thread Kousik Kumar via Phabricator via cfe-commits
kousikk created this revision.
kousikk added reviewers: arphaman, Bigcheese, jkorous, dexonsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
kousikk edited the summary of this revision.
kousikk edited the summary of this revision.

If -resource-dir is not specified as part of the compilation command, then by 
default
clang-scan-deps picks up a directory relative to its own path as 
resource-directory.
This is probably not the right behavior - since resource directory should be 
picked relative
to the path of the clang-compiler in the compilation command.
This patch adds support for it along with a cache to store the resource-dir 
paths based on
compiler paths.

Notes:

1. "-resource-dir" is a behavior that's specific to clang, gcc does not have 
that flag. That's why if I'm not able to find a resource-dir, I quietly ignore 
it.
2. Should I also use the mtime of the compiler in the cache? I think its not 
strictly necessary since we assume the filesystem is immutable.
3. From my testing, this does not regress performance.
4. Will try to get this tested on Windows.

But basically the problem that this patch is trying to solve is, clients might 
not always want to specify
"-resource-dir" in their compile commands, so scan-deps must auto-infer it 
correctly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69122

Files:
  clang/include/clang/Tooling/ArgumentsAdjusters.h
  clang/lib/Tooling/ArgumentsAdjusters.cpp
  clang/lib/Tooling/CommonOptionsParser.cpp
  clang/lib/Tooling/Tooling.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -12,6 +12,7 @@
 #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
 #include "clang/Tooling/JSONCompilationDatabase.h"
 #include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Options.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Signals.h"
@@ -38,6 +39,64 @@
   raw_ostream &OS;
 };
 
+class ResourceDirectoryCache {
+public:
+  /// FindResourceDir finds the resource directory relative to the clang compiler
+  /// being used in Args, by running it with "-print-resource-dir" option and
+  /// cache the results for reuse.
+  /// \returns resource directory path associated with the given invocation command.
+  std::string FindResourceDir(const tooling::CommandLineArguments &Args, StringRef Directory) {
+if (Args.size() < 1)
+  return "";
+
+const std::string &ClangBinaryPath = MakeAbsolutePath(Directory, Args[0]);
+
+std::unique_lock LockGuard(CacheLock);
+const auto& CachedResourceDir = Cache.find(ClangBinaryPath);
+if (CachedResourceDir != Cache.end())
+  return CachedResourceDir->second;
+
+std::vector PrintResourceDirArgs{"clang", "-print-resource-dir"};
+llvm::SmallString<64> OutputFile, ErrorFile;
+llvm::sys::fs::createTemporaryFile("print-resource-dir-output", "" /*no-suffix*/, OutputFile);
+llvm::sys::fs::createTemporaryFile("print-resource-dir-error", ""/*no-suffix*/, ErrorFile);
+llvm::FileRemover OutputRemover(OutputFile.c_str());
+llvm::FileRemover ErrorRemover(ErrorFile.c_str());
+llvm::Optional Redirects[] = {
+  {""}, //Stdin
+  StringRef(OutputFile),
+  StringRef(ErrorFile),
+};
+if (const int RC = llvm::sys::ExecuteAndWait(ClangBinaryPath, PrintResourceDirArgs, {}, Redirects)) {
+  auto ErrorBuf = llvm::MemoryBuffer::getFile(ErrorFile.c_str());
+  llvm::errs() << ErrorBuf.get()->getBuffer();
+  return "";
+}
+
+auto OutputBuf = llvm::MemoryBuffer::getFile(OutputFile.c_str());
+if (!OutputBuf)
+  return "";
+StringRef Output = OutputBuf.get()->getBuffer().rtrim('\n');
+
+Cache[ClangBinaryPath] = Output.str();
+return Cache[ClangBinaryPath];
+  }
+
+private:
+  /// \returns the absolute path formed by joining the current directory with the given path.
+  std::string MakeAbsolutePath(StringRef CurrentDir, StringRef Path) {
+if (Path.empty())
+  return "";
+llvm::SmallString<256> InitialDirectory(CurrentDir);
+llvm::SmallString<256> AbsolutePath(Path);
+llvm::sys::fs::make_absolute(InitialDirectory, AbsolutePath);
+return AbsolutePath.str();
+  }
+
+  std::map Cache;
+  std::mutex CacheLock;
+};
+
 /// The high-level implementation of the dependency discovery tool that runs on
 /// an individual worker thread.
 class DependencyScanningTool {
@@ -218,12 +277,14 @@
   auto AdjustingCompilations =
   std::make_unique(
   std::move(Compilations));
+  ResourceDirectoryCache ResourceDirCache;
   AdjustingCompilations->appendArgumentsAdjuster(
-  [](const tooling::CommandLineArguments &Args, StringRef FileName) {
+  [&ResourceDirCache](const tooling::CommandLineArguments &Args,

[PATCH] D69124: [clang][driver] Print compilation phases with indentation.

2019-10-17 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

this patch enables the dumping of actions in the hierarchy or tree. In most 
cases, it's a linear list but, for offload compilation, a tree representation 
is more intuitive. Even though there are cross-subtree edges, they are rare and 
also noted in the corresponding actions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69124



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


[PATCH] D69124: [clang][driver] Print compilation phases with indentation.

2019-10-17 Thread Michael Liao via Phabricator via cfe-commits
hliao created this revision.
hliao added reviewers: tra, sfantao, echristo.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
hliao added a comment.

this patch enables the dumping of actions in the hierarchy or tree. In most 
cases, it's a linear list but, for offload compilation, a tree representation 
is more intuitive. Even though there are cross-subtree edges, they are rare and 
also noted in the corresponding actions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69124

Files:
  clang/lib/Driver/Driver.cpp


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1806,7 +1806,8 @@
 // and latest-occuring action. Traversal is in pre-order, visiting the
 // inputs to each action before printing the action itself.
 static unsigned PrintActions1(const Compilation &C, Action *A,
-  std::map &Ids) {
+  std::map &Ids,
+  unsigned Ident = 0) {
   if (Ids.count(A)) // A was already visited.
 return Ids[A];
 
@@ -1818,7 +1819,7 @@
 os << "\"" << IA->getInputArg().getValue() << "\"";
   } else if (BindArchAction *BIA = dyn_cast(A)) {
 os << '"' << BIA->getArchName() << '"' << ", {"
-   << PrintActions1(C, *BIA->input_begin(), Ids) << "}";
+   << PrintActions1(C, *BIA->input_begin(), Ids, Ident + 1) << "}";
   } else if (OffloadAction *OA = dyn_cast(A)) {
 bool IsFirst = true;
 OA->doOnEachDependence(
@@ -1841,7 +1842,7 @@
 os << ":" << BoundArch;
   os << ")";
   os << '"';
-  os << " {" << PrintActions1(C, A, Ids) << "}";
+  os << " {" << PrintActions1(C, A, Ids, Ident + 1) << "}";
   IsFirst = false;
 });
   } else {
@@ -1850,7 +1851,7 @@
 if (AL->size()) {
   const char *Prefix = "{";
   for (Action *PreRequisite : *AL) {
-os << Prefix << PrintActions1(C, PreRequisite, Ids);
+os << Prefix << PrintActions1(C, PreRequisite, Ids, Ident + 1);
 Prefix = ", ";
   }
   os << "}";
@@ -1874,8 +1875,9 @@
 
   unsigned Id = Ids.size();
   Ids[A] = Id;
-  llvm::errs() << Id << ": " << os.str() << ", "
-   << types::getTypeName(A->getType()) << offload_os.str() << "\n";
+  llvm::errs().indent(Ident)
+  << Id << ": " << os.str() << ", " << types::getTypeName(A->getType())
+  << offload_os.str() << "\n";
 
   return Id;
 }


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1806,7 +1806,8 @@
 // and latest-occuring action. Traversal is in pre-order, visiting the
 // inputs to each action before printing the action itself.
 static unsigned PrintActions1(const Compilation &C, Action *A,
-  std::map &Ids) {
+  std::map &Ids,
+  unsigned Ident = 0) {
   if (Ids.count(A)) // A was already visited.
 return Ids[A];
 
@@ -1818,7 +1819,7 @@
 os << "\"" << IA->getInputArg().getValue() << "\"";
   } else if (BindArchAction *BIA = dyn_cast(A)) {
 os << '"' << BIA->getArchName() << '"' << ", {"
-   << PrintActions1(C, *BIA->input_begin(), Ids) << "}";
+   << PrintActions1(C, *BIA->input_begin(), Ids, Ident + 1) << "}";
   } else if (OffloadAction *OA = dyn_cast(A)) {
 bool IsFirst = true;
 OA->doOnEachDependence(
@@ -1841,7 +1842,7 @@
 os << ":" << BoundArch;
   os << ")";
   os << '"';
-  os << " {" << PrintActions1(C, A, Ids) << "}";
+  os << " {" << PrintActions1(C, A, Ids, Ident + 1) << "}";
   IsFirst = false;
 });
   } else {
@@ -1850,7 +1851,7 @@
 if (AL->size()) {
   const char *Prefix = "{";
   for (Action *PreRequisite : *AL) {
-os << Prefix << PrintActions1(C, PreRequisite, Ids);
+os << Prefix << PrintActions1(C, PreRequisite, Ids, Ident + 1);
 Prefix = ", ";
   }
   os << "}";
@@ -1874,8 +1875,9 @@
 
   unsigned Id = Ids.size();
   Ids[A] = Id;
-  llvm::errs() << Id << ": " << os.str() << ", "
-   << types::getTypeName(A->getType()) << offload_os.str() << "\n";
+  llvm::errs().indent(Ident)
+  << Id << ": " << os.str() << ", " << types::getTypeName(A->getType())
+  << offload_os.str() << "\n";
 
   return Id;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69124: [clang][driver] Print compilation phases with indentation.

2019-10-17 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

Could you give an example of before/after output?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69124



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


[PATCH] D69090: [Try 2] Include sanitize blacklist and other extra deps as part of scan-deps output

2019-10-17 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

I think you could've just used `CHECK-DAG` to fix the tests. It *might* be a 
bit more robust. Although just reordering checks seems perfectly fine too.
https://llvm.org/docs/CommandGuide/FileCheck.html#the-check-dag-directive

Using `std::set` here sounds reasonable to me but I'd like @arphaman to be 
aware of this. BTW should we change `std::vector Dependencies;` in 
`DependencyCollector` to `set` too?

Also, I'm wondering why is the behavior different on Windows.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69090



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


[PATCH] D69124: [clang][driver] Print compilation phases with indentation.

2019-10-17 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

In D69124#1713360 , @tra wrote:

> Could you give an example of before/after output?




  $ clang -x cuda -ccc-print-phases --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_60 
-c ~/dummy.cpp 
   0: input, "/home/michliao/dummy.cpp", cuda, (host-cuda)
  1: preprocessor, {0}, cuda-cpp-output, (host-cuda)
 2: compiler, {1}, ir, (host-cuda)
   3: input, "/home/michliao/dummy.cpp", cuda, (device-cuda, sm_30)
  4: preprocessor, {3}, cuda-cpp-output, (device-cuda, sm_30)
 5: compiler, {4}, ir, (device-cuda, sm_30)
6: backend, {5}, assembler, (device-cuda, sm_30)
   7: assembler, {6}, object, (device-cuda, sm_30)
  8: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {7}, object
  9: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {6}, assembler
   10: input, "/home/michliao/dummy.cpp", cuda, (device-cuda, sm_60)
  11: preprocessor, {10}, cuda-cpp-output, (device-cuda, sm_60)
 12: compiler, {11}, ir, (device-cuda, sm_60)
13: backend, {12}, assembler, (device-cuda, sm_60)
   14: assembler, {13}, object, (device-cuda, sm_60)
  15: offload, "device-cuda (nvptx64-nvidia-cuda:sm_60)" {14}, object
  16: offload, "device-cuda (nvptx64-nvidia-cuda:sm_60)" {13}, assembler
 17: linker, {8, 9, 15, 16}, cuda-fatbin, (device-cuda)
18: offload, "host-cuda (x86_64-unknown-linux-gnu)" {2}, "device-cuda 
(nvptx64-nvidia-cuda)" {17}, ir
   19: backend, {18}, assembler, (host-cuda)
  20: assembler, {19}, object, (host-cuda)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69124



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


[PATCH] D69124: [clang][driver] Print compilation phases with indentation.

2019-10-17 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

In D69124#1713360 , @tra wrote:

> Could you give an example of before/after output?


For HIP

  $ clang -x hip -ccc-print-phases --cuda-gpu-arch=gfx900 
--cuda-gpu-arch=gfx906 -c ~/dummy.cpp 
   0: input, "/home/michliao/dummy.cpp", hip, (host-hip)
  1: preprocessor, {0}, hip-cpp-output, (host-hip)
 2: compiler, {1}, ir, (host-hip)
  3: input, "/home/michliao/dummy.cpp", hip, (device-hip, gfx900)
 4: preprocessor, {3}, hip-cpp-output, (device-hip, gfx900)
5: compiler, {4}, ir, (device-hip, gfx900)
   6: linker, {5}, image, (device-hip, gfx900)
  7: offload, "device-hip (amdgcn-amd-amdhsa:gfx900)" {6}, image
  8: input, "/home/michliao/dummy.cpp", hip, (device-hip, gfx906)
 9: preprocessor, {8}, hip-cpp-output, (device-hip, gfx906)
10: compiler, {9}, ir, (device-hip, gfx906)
   11: linker, {10}, image, (device-hip, gfx906)
  12: offload, "device-hip (amdgcn-amd-amdhsa:gfx906)" {11}, image
 13: linker, {7, 12}, hip-fatbin, (device-hip)
14: offload, "host-hip (x86_64-unknown-linux-gnu)" {2}, "device-hip 
(amdgcn-amd-amdhsa)" {13}, ir
   15: backend, {14}, assembler, (host-hip)
  16: assembler, {15}, object, (host-hip)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69124



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


[PATCH] D69129: [AMDGPU] Fix assertion due to initializer list

2019-10-17 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: rjmccall.
Herald added subscribers: t-tye, tpr, dstuttard, wdng, kzhuravl.

Sometimes a global var is replaced by a different llvm value. clang use 
GetAddrOfGlobalVar to get the original llvm global variable.
For most targets, GetAddrOfGlobalVar returns either the llvm global variable or 
a bitcast of the llvm global variable.
However, for AMDGPU target, GetAddrOfGlobalVar returns the addrspace cast or 
addrspace cast plus bitcast of the llvm global variable.
To get the llvm global variable, these casts need to be stripped, otherwise 
there is assertion.

This patch fixes that.


https://reviews.llvm.org/D69129

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGenCXX/cxx11-extern-constexpr.cpp

Index: test/CodeGenCXX/cxx11-extern-constexpr.cpp
===
--- test/CodeGenCXX/cxx11-extern-constexpr.cpp
+++ test/CodeGenCXX/cxx11-extern-constexpr.cpp
@@ -1,10 +1,13 @@
-// RUN: %clang_cc1 -std=c++11 %s -emit-llvm -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK --check-prefix=CXX11
-// RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK --check-prefix=CXX17
+// RUN: %clang_cc1 -std=c++11 %s -emit-llvm -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=X86,CXX11X86
+// RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=X86,CXX17X86
+// RUN: %clang_cc1 -std=c++11 %s -emit-llvm -o - -triple amdgcn-amd-amdhsa | FileCheck %s --check-prefixes=AMD,CXX11AMD
+// RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - -triple amdgcn-amd-amdhsa | FileCheck %s --check-prefixes=AMD,CXX17AMD
 
 struct A {
   static const int Foo = 123;
 };
-// CHECK: @_ZN1A3FooE = constant i32 123, align 4
+// X86: @_ZN1A3FooE = constant i32 123, align 4
+// AMD: @_ZN1A3FooE = addrspace(4) constant i32 123, align 4
 const int *p = &A::Foo; // emit available_externally
 const int A::Foo;   // convert to full definition
 
@@ -16,7 +19,8 @@
   // Deferred initialization of the structure here requires changing
   // the type of the global variable: the initializer list does not include
   // the tail padding.
-  // CXX11: @_ZN9CreatePOD3podE = available_externally constant { i32, i8 } { i32 42, i8 43 },
+  // CXX11X86: @_ZN9CreatePOD3podE = available_externally constant { i32, i8 } { i32 42, i8 43 },
+  // CXX11AMD: @_ZN9CreatePOD3podE = available_externally addrspace(1) constant { i32, i8 } { i32 42, i8 43 },
   static constexpr PODWithInit pod{};
 };
 const int *p_pod = &CreatePOD::pod.g;
@@ -30,29 +34,40 @@
 };
 
 struct Foo {
-  // CXX11: @_ZN3Foo21ConstexprStaticMemberE = available_externally constant i32 42,
-  // CXX17: @_ZN3Foo21ConstexprStaticMemberE = linkonce_odr constant i32 42,
+  // CXX11X86: @_ZN3Foo21ConstexprStaticMemberE = available_externally constant i32 42,
+  // CXX17X86: @_ZN3Foo21ConstexprStaticMemberE = linkonce_odr constant i32 42,
+  // CXX11AMD: @_ZN3Foo21ConstexprStaticMemberE = available_externally addrspace(4) constant i32 42,
+  // CXX17AMD: @_ZN3Foo21ConstexprStaticMemberE = linkonce_odr addrspace(4) constant i32 42,
   static constexpr int ConstexprStaticMember = 42;
-  // CHECK: @_ZN3Foo17ConstStaticMemberE = available_externally constant i32 43,
+  // X86: @_ZN3Foo17ConstStaticMemberE = available_externally constant i32 43,
+  // AMD: @_ZN3Foo17ConstStaticMemberE = available_externally addrspace(4) constant i32 43,
   static const int ConstStaticMember = 43;
 
-  // CXX11: @_ZN3Foo23ConstStaticStructMemberE = available_externally constant %struct.Bar { i32 44 },
-  // CXX17: @_ZN3Foo23ConstStaticStructMemberE = linkonce_odr constant %struct.Bar { i32 44 },
+  // CXX11X86: @_ZN3Foo23ConstStaticStructMemberE = available_externally constant %struct.Bar { i32 44 },
+  // CXX17X86: @_ZN3Foo23ConstStaticStructMemberE = linkonce_odr constant %struct.Bar { i32 44 },
+  // CXX11AMD: @_ZN3Foo23ConstStaticStructMemberE = available_externally addrspace(1) constant %struct.Bar { i32 44 },
+  // CXX17AMD: @_ZN3Foo23ConstStaticStructMemberE = linkonce_odr addrspace(1) constant %struct.Bar { i32 44 },
   static constexpr Bar ConstStaticStructMember = {44};
 
-  // CXX11: @_ZN3Foo34ConstexprStaticMutableStructMemberE = external global %struct.MutableBar,
-  // CXX17: @_ZN3Foo34ConstexprStaticMutableStructMemberE = linkonce_odr global %struct.MutableBar { i32 45 },
+  // CXX11X86: @_ZN3Foo34ConstexprStaticMutableStructMemberE = external global %struct.MutableBar,
+  // CXX17X86: @_ZN3Foo34ConstexprStaticMutableStructMemberE = linkonce_odr global %struct.MutableBar { i32 45 },
+  // CXX11AMD: @_ZN3Foo34ConstexprStaticMutableStructMemberE = external addrspace(1) global %struct.MutableBar,
+  // CXX17AMD: @_ZN3Foo34ConstexprStaticMutableStructMemberE = linkonce_odr addrspace(1) global %struct.MutableBar { i32 45 },
   static constexpr MutableBar ConstexprStaticMutableStructMember = {45};
 };

[PATCH] D69124: [clang][driver] Print compilation phases with indentation.

2019-10-17 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

This is... rather oddly-structured output. My brain refuses to accept that the 
most-indented phase is the input.
Perhaps we should do `llvm::errs().indent(MaxIdent-Ident)`. This should give us 
something like this (withMaxIdent=9), which is somewhat easier to grok, IMO:

  0: input, "/home/michliao/dummy.cpp", cuda, (host-cuda)
   1: preprocessor, {0}, cuda-cpp-output, (host-cuda)
2: compiler, {1}, ir, (host-cuda)
  3: input, "/home/michliao/dummy.cpp", cuda, (device-cuda, sm_30)
   4: preprocessor, {3}, cuda-cpp-output, (device-cuda, sm_30)
5: compiler, {4}, ir, (device-cuda, sm_30)
 6: backend, {5}, assembler, (device-cuda, sm_30)
  7: assembler, {6}, object, (device-cuda, sm_30)
   8: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {7}, object
   9: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {6}, assembler
  10: input, "/home/michliao/dummy.cpp", cuda, (device-cuda, sm_60)
   11: preprocessor, {10}, cuda-cpp-output, (device-cuda, sm_60)
12: compiler, {11}, ir, (device-cuda, sm_60)
 13: backend, {12}, assembler, (device-cuda, sm_60)
  14: assembler, {13}, object, (device-cuda, sm_60)
   15: offload, "device-cuda (nvptx64-nvidia-cuda:sm_60)" {14}, object
   16: offload, "device-cuda (nvptx64-nvidia-cuda:sm_60)" {13}, assembler
17: linker, {8, 9, 15, 16}, cuda-fatbin, (device-cuda)
 18: offload, "host-cuda (x86_64-unknown-linux-gnu)" {2}, "device-cuda 
(nvptx64-nvidia-cuda)" {17}, ir
  19: backend, {18}, assembler, (host-cuda)
   20: assembler, {19}, object, (host-cuda)




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69124



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


[PATCH] D41569: [Concepts] Constraint enforcement and diagnostics

2019-10-17 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Sema/SemaOverload.cpp:594
   };
+  struct CNSInfo {
+TemplateArgumentList *TemplateArgs;

Please add a documentation comment.



Comment at: clang/lib/Sema/SemaOverload.cpp:10707
 
-  case Sema::TDK_InstantiationDepth:
+  case Sema::TDK_ConstraintsNotSatisfied:
 return 4;

I think we should probably rank this higher -- maybe at the same level as a 
deduction or substitution failure, or maybe just above that. But I'm happy to 
wait and iterate on that once we have library code to experiment with.



Comment at: clang/lib/Sema/SemaTemplate.cpp:4235
 /*PartialTemplateArgs=*/false, Converted,
 /*UpdateArgsWithConversion=*/false))
 return ExprError();

(Not directly related to this patch, feel free to address separately:) Passing 
false for UpdateArgsWithConversion here seems surprising: shouldn't we be using 
the converted arguments in the satisfaction check and storing the converted 
arguments on the AST?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D41569



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


[PATCH] D67992: [Sema] Add MacroQualified case for FunctionTypeUnwrapper

2019-10-17 Thread Jung-uk Kim via Phabricator via cfe-commits
jkim added a comment.

Ping...  @rsmith


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67992



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


r375167 - [OPENMP]Dow not emit warnings for uninitialized loop counters.

2019-10-17 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Oct 17 13:35:08 2019
New Revision: 375167

URL: http://llvm.org/viewvc/llvm-project?rev=375167&view=rev
Log:
[OPENMP]Dow not emit warnings for uninitialized loop counters.

In OpenMP constructs all counters are initialized and we should not emit
warnings about uninitialized privatized loop control variables.

Modified:
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/test/Analysis/cfg-openmp.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_linear_messages.cpp

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=375167&r1=375166&r2=375167&view=diff
==
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Thu Oct 17 13:35:08 2019
@@ -4824,7 +4824,8 @@ CFGBlock *CFGBuilder::VisitOMPExecutable
   }
   // Visit associated structured block if any.
   if (!D->isStandaloneDirective())
-if (Stmt *S = D->getStructuredBlock()) {
+if (CapturedStmt *CS = D->getInnermostCapturedStmt()) {
+  Stmt *S = CS->getCapturedStmt();
   if (!isa(S))
 addLocalScopeAndDtors(S);
   if (CFGBlock *R = addStmt(S))

Modified: cfe/trunk/test/Analysis/cfg-openmp.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cfg-openmp.cpp?rev=375167&r1=375166&r2=375167&view=diff
==
--- cfe/trunk/test/Analysis/cfg-openmp.cpp (original)
+++ cfe/trunk/test/Analysis/cfg-openmp.cpp Thu Oct 17 13:35:08 2019
@@ -27,72 +27,6 @@ void xxx(int argc) {
 // CHECK-NEXT:   [B1.[[#CRIT+3]]];
 #pragma omp critical
   argc = x;
-// CHECK-NEXT:  [[#DPF:]]: x
-// CHECK-NEXT:  [[#DPF+1]]: [B1.[[#DPF]]] (ImplicitCastExpr, LValueToRValue, 
int)
-// CHECK-NEXT:  [[#DPF+2]]: argc
-// CHECK-NEXT:  [[#DPF+3]]: [B1.[[#DPF+2]]] = [B1.[[#DPF+1]]]
-// CHECK-NEXT:  [[#DPF+4]]: cond
-// CHECK-NEXT:  [[#DPF+5]]: [B1.[[#DPF+4]]] (ImplicitCastExpr, LValueToRValue, 
int)
-// CHECK-NEXT:  [[#DPF+6]]: [B1.[[#DPF+5]]] (ImplicitCastExpr, 
IntegralToBoolean, _Bool)
-// CHECK-NEXT:  [[#DPF+7]]: fp
-// CHECK-NEXT:  [[#DPF+8]]: rd
-// CHECK-NEXT:  [[#DPF+9]]: #pragma omp distribute parallel for if(parallel: 
cond) firstprivate(fp) reduction(+: rd)
-// CHECK-NEXT:for (int i = 0; i < 10; ++i)
-// CHECK-NEXT:[B1.[[#DPF+3]]];
-#pragma omp distribute parallel for if(parallel:cond) firstprivate(fp) 
reduction(+:rd)
-  for (int i = 0; i < 10; ++i)
-argc = x;
-// CHECK-NEXT:  [[#DPFS:]]: x
-// CHECK-NEXT:  [[#DPFS+1]]: [B1.[[#DPFS]]] (ImplicitCastExpr, LValueToRValue, 
int)
-// CHECK-NEXT:  [[#DPFS+2]]: argc
-// CHECK-NEXT:  [[#DPFS+3]]: [B1.[[#DPFS+2]]] = [B1.[[#DPFS+1]]]
-// CHECK-NEXT:  [[#DPFS+4]]: cond
-// CHECK-NEXT:  [[#DPFS+5]]: [B1.[[#DPFS+4]]] (ImplicitCastExpr, 
LValueToRValue, int)
-// CHECK-NEXT:  [[#DPFS+6]]: [B1.[[#DPFS+5]]] (ImplicitCastExpr, 
IntegralToBoolean, _Bool)
-// CHECK-NEXT:  [[#DPFS+7]]: fp
-// CHECK-NEXT:  [[#DPFS+8]]: rd
-// CHECK-NEXT:  [[#DPFS+9]]: #pragma omp distribute parallel for simd if(cond) 
firstprivate(fp) reduction(-: rd)
-// CHECK-NEXT:for (int i = 0; i < 10; ++i)
-// CHECK-NEXT:[B1.[[#DPFS+3]]];
-#pragma omp distribute parallel for simd if(cond)  firstprivate(fp) 
reduction(-:rd)
-  for (int i = 0; i < 10; ++i)
-argc = x;
-// CHECK-NEXT:  [[#DS:]]: x
-// CHECK-NEXT:  [[#DS+1]]: [B1.[[#DS]]] (ImplicitCastExpr, LValueToRValue, int)
-// CHECK-NEXT:  [[#DS+2]]: argc
-// CHECK-NEXT:  [[#DS+3]]: [B1.[[#DS+2]]] = [B1.[[#DS+1]]]
-// CHECK-NEXT:  [[#DS+4]]: #pragma omp distribute simd
-// CHECK-NEXT:for (int i = 0; i < 10; ++i)
-// CHECK-NEXT:[B1.[[#DS+3]]];
-#pragma omp distribute simd
-  for (int i = 0; i < 10; ++i)
-argc = x;
-// CHECK-NEXT:  [[#FOR:]]: x
-// CHECK-NEXT:  [[#FOR+1]]: [B1.[[#FOR]]] (ImplicitCastExpr, LValueToRValue, 
int)
-// CHECK-NEXT:  [[#FOR+2]]: argc
-// CHECK-NEXT:  [[#FOR+3]]: [B1.[[#FOR+2]]] = [B1.[[#FOR+1]]]
-// CHECK-NEXT:  [[#FOR+4]]: lin
-// CHECK-NEXT:  [[#FOR+5]]: step
-// CHECK-NEXT:  [[#FOR+6]]: [B1.[[#FOR+5]]] (ImplicitCastExpr, LValueToRValue, 
int)
-// CHECK-NEXT:  [[#FOR+7]]: #pragma omp for linear(lin: step)
-// CHECK-NEXT:for (int i = 0; i < 10; ++i)
-// CHECK-NEXT:[B1.[[#FOR+3]]];
-#pragma omp for linear(lin : step)
-  for (int i = 0; i < 10; ++i)
-argc = x;
-// CHECK-NEXT:  [[#FS:]]: x
-// CHECK-NEXT:  [[#FS+1]]: [B1.[[#FS]]] (ImplicitCastExpr, LValueToRValue, int)
-// CHECK-NEXT:  [[#FS+2]]: argc
-// CHECK-NEXT:  [[#FS+3]]: [B1.[[#FS+2]]] = [B1.[[#FS+1]]]
-// CHECK-NEXT:  [[#FS+4]]: lin
-// CHECK-NEXT:  [[#FS+5]]: step
-// CHECK-NEXT:  [[#FS+6]]: [B1.[[#FS+5]]] (ImplicitCastExpr, LValueToRValue, 
int)
-// CHECK-NEXT:  [[#FS+7]]: #pragma omp for simd linear(lin: step)
-// CHECK-NEXT:for (int i = 0; i < 10; ++i)
-// CHECK-NEXT:[B1.[[#FS+3]]];
-#pragma omp for 

[PATCH] D69088: [Lex] #pragma clang transform

2019-10-17 Thread Hideki Saito via Phabricator via cfe-commits
hsaito added a comment.

@Meinersbur, if I remember correctly, there was an RFC discussion on this 
topic, right? If yes, would you post the pointer to that? I need a refresher on 
what has been discussed/settled in the past.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69088



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


[PATCH] D69088: [Lex] #pragma clang transform

2019-10-17 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

In D69088#1713147 , @ABataev wrote:

> Why not try to improve the existing #pragma clang loop rather than add a new 
> pragma with almost the same behavior?


The behavior and syntax is different. #pragma clang loop ignores the order, i.e.

  #pragma clang loop unroll(enable)
  #pragma clang loop distribute(enable)

and

  #pragma clang loop distribute(enable)
  #pragma clang loop unroll(enable)

and

  #pragma clang loop unroll(enable) distribute(enable)

are the same. Changing that would be a breaking change.

Syntactically, every option is it's own transformation, e.g.

  #pragma clang loop unroll(enable) distribute(enable) unroll_count(2)

could be interpreted as 3 transformations (LoopUnroll even exists twice in the 
pass pipeline). I prefer OpenMP's directive-with-clauses syntax, which we need 
to implement anyway for the OpenMP loop transformations.

In the future, I would also like to add non-loop transformation, such that the 
`loop` namespace l


Repository:
  rC Clang

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

https://reviews.llvm.org/D69088



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


[PATCH] D69088: [Lex] #pragma clang transform

2019-10-17 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

In D69088#1713623 , @hsaito wrote:

> @Meinersbur, if I remember correctly, there was an RFC discussion on this 
> topic, right? If yes, would you post the pointer to that? I need a refresher 
> on what has been discussed/settled in the past.


https://lists.llvm.org/pipermail/cfe-dev/2018-May/058141.html


Repository:
  rC Clang

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

https://reviews.llvm.org/D69088



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


[PATCH] D68340: Add AIX toolchain and basic linker functionality

2019-10-17 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 225521.
stevewan added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68340

Files:
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/AIX.h
  clang/test/Driver/Inputs/aix_ppc_tree/powerpc-ibm-aix7.1.0.0/dummy.a
  clang/test/Driver/Inputs/aix_ppc_tree/usr/lib/crt0.o
  clang/test/Driver/Inputs/aix_ppc_tree/usr/lib/crt0_64.o
  clang/test/Driver/Inputs/aix_ppc_tree/usr/lib/crti.o
  clang/test/Driver/Inputs/aix_ppc_tree/usr/lib/crti_64.o
  clang/test/Driver/Inputs/aix_ppc_tree/usr/lib/gcrt0.o
  clang/test/Driver/Inputs/aix_ppc_tree/usr/lib/gcrt0_64.o
  clang/test/Driver/Inputs/aix_ppc_tree/usr/lib/mcrt0.o
  clang/test/Driver/Inputs/aix_ppc_tree/usr/lib/mcrt0_64.o
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- /dev/null
+++ clang/test/Driver/aix-ld.c
@@ -0,0 +1,177 @@
+// General tests that ld invocations on AIX targets are sane. Note that we use
+// sysroot to make these tests independent of the host system.
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target powerpc-ibm-aix7.1.0.0 \
+// RUN: --sysroot %S/Inputs/aix_ppc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD32 %s
+// CHECK-LD32-NOT: warning:
+// CHECK-LD32: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD32: "{{.*}}ld{{(.exe)?}}" 
+// CHECK-LD32-NOT: "-bnso"
+// CHECK-LD32: "-b32" 
+// CHECK-LD32: "-bpT:0x1000" "-bpD:0x2000" 
+// CHECK-LD32: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-LD32: "-L[[SYSROOT]]/usr/lib" 
+// CHECK-LD32: "-lc"
+
+// Check powerpc64-ibm-aix7.1.0.0, 64-bit.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target powerpc64-ibm-aix7.1.0.0 \
+// RUN: --sysroot %S/Inputs/aix_ppc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD64 %s
+// CHECK-LD64-NOT: warning:
+// CHECK-LD64: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0"
+// CHECK-LD64: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD64: "{{.*}}ld{{(.exe)?}}" 
+// CHECK-LD64-NOT: "-bnso"
+// CHECK-LD64: "-b64" 
+// CHECK-LD64: "-bpT:0x1" "-bpD:0x11000" 
+// CHECK-LD64: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
+// CHECK-LD64: "-L[[SYSROOT]]/usr/lib" 
+// CHECK-LD64: "-lc"
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable POSIX thread support.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -pthread \
+// RUN: -target powerpc-ibm-aix7.1.0.0 \
+// RUN: --sysroot %S/Inputs/aix_ppc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD32-PTHREAD %s
+// CHECK-LD32-PTHREAD-NOT: warning:
+// CHECK-LD32-PTHREAD: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32-PTHREAD: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD32-PTHREAD: "{{.*}}ld{{(.exe)?}}" 
+// CHECK-LD32-PTHREAD-NOT: "-bnso"
+// CHECK-LD32-PTHREAD: "-b32" 
+// CHECK-LD32-PTHREAD: "-bpT:0x1000" "-bpD:0x2000" 
+// CHECK-LD32-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-LD32-PTHREAD: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD32-PTHREAD: "-lpthreads"
+// CHECK-LD32-PTHREAD: "-lc"
+
+// Check powerpc-ibm-aix7.1.0.0, 64-bit. POSIX thread alias.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -pthreads \
+// RUN: -target powerpc64-ibm-aix7.1.0.0 \
+// RUN: --sysroot %S/Inputs/aix_ppc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD64-PTHREAD %s
+// CHECK-LD64-PTHREAD-NOT: warning:
+// CHECK-LD64-PTHREAD: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0"
+// CHECK-LD64-PTHREAD: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD64-PTHREAD: "{{.*}}ld{{(.exe)?}}" 
+// CHECK-LD64-PTHREAD-NOT: "-bnso"
+// CHECK-LD64-PTHREAD: "-b64" 
+// CHECK-LD64-PTHREAD: "-bpT:0x1" "-bpD:0x11000" 
+// CHECK-LD64-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
+// CHECK-LD64-PTHREAD: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD64-PTHREAD: "-lpthreads"
+// CHECK-LD64-PTHREAD: "-lc"
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable profiling.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -p \
+// RUN: -target powerpc-ibm-aix7.1.0.0 \
+// RUN: --sysroot %S/Inputs/aix_ppc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD32-PROF %s
+// CHECK-LD32-PROF-NOT: warning:
+// CHECK-LD32-PROF: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32-PROF: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD32-PROF: "{{.*}}ld{{(.exe)?}}" 
+// CHECK-LD32-PROF-NOT: "-bnso"
+// CHECK-LD32-PROF: "-b32" 
+// CHECK-LD32-PROF: "-bpT:0x1000" "-bpD:0x2000" 
+// CHECK-LD32-PROF:

[PATCH] D69140: [clang-offload-wrapper][NFC] Use captured name of the entry type in LIT test

2019-10-17 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev created this revision.
sdmitriev added a reviewer: ABataev.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69140

Files:
  clang/test/Driver/clang-offload-wrapper.c


Index: clang/test/Driver/clang-offload-wrapper.c
===
--- clang/test/Driver/clang-offload-wrapper.c
+++ clang/test/Driver/clang-offload-wrapper.c
@@ -31,7 +31,7 @@
 // CHECK-IR: [[ENTBEGIN:@.+]] = external hidden constant [[ENTTY]]
 // CHECK-IR: [[ENTEND:@.+]] = external hidden constant [[ENTTY]]
 
-// CHECK-IR: [[DUMMY:@.+]] = hidden constant [0 x %__tgt_offload_entry] 
zeroinitializer, section "omp_offloading_entries"
+// CHECK-IR: [[DUMMY:@.+]] = hidden constant [0 x [[ENTTY]]] zeroinitializer, 
section "omp_offloading_entries"
 
 // CHECK-IR: [[BIN:@.+]] = internal unnamed_addr constant [[BINTY:\[[0-9]+ x 
i8\]]] c"Content of device file{{.+}}"
 


Index: clang/test/Driver/clang-offload-wrapper.c
===
--- clang/test/Driver/clang-offload-wrapper.c
+++ clang/test/Driver/clang-offload-wrapper.c
@@ -31,7 +31,7 @@
 // CHECK-IR: [[ENTBEGIN:@.+]] = external hidden constant [[ENTTY]]
 // CHECK-IR: [[ENTEND:@.+]] = external hidden constant [[ENTTY]]
 
-// CHECK-IR: [[DUMMY:@.+]] = hidden constant [0 x %__tgt_offload_entry] zeroinitializer, section "omp_offloading_entries"
+// CHECK-IR: [[DUMMY:@.+]] = hidden constant [0 x [[ENTTY]]] zeroinitializer, section "omp_offloading_entries"
 
 // CHECK-IR: [[BIN:@.+]] = internal unnamed_addr constant [[BINTY:\[[0-9]+ x i8\]]] c"Content of device file{{.+}}"
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69144: [Format] Add format check for throwing negative numbers

2019-10-17 Thread Jonathan Thomas via Phabricator via cfe-commits
jonathoma created this revision.
jonathoma added a reviewer: modocache.
jonathoma added a project: clang-format.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
jonathoma edited the summary of this revision.
jonathoma added reviewers: sammccall, Quuxplusone.

The code `throw -1;` is currently formatted by clang-format as 
`throw - 1;`. This diff adds a fix for this edge case and a test to check
for this in the future.

For context, I am looking into a related bug in the clang-formatting of
coroutine keywords: `co_yield -1;` is also reformatted in this manner 
as `co_yield - 1;`. A later diff will add these changes and tests for the
`co_yield` and `co_return` keywords.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69144

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6912,6 +6912,7 @@
   verifyFormat("alignof(char);", getGoogleStyle());
 
   verifyFormat("return -1;");
+  verifyFormat("throw -1;");
   verifyFormat("switch (a) {\n"
"case -1:\n"
"  break;\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1756,7 +1756,7 @@
 // Use heuristics to recognize unary operators.
 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace))
+   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw))
   return TT_UnaryOperator;
 
 // There can't be two consecutive binary operators.


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6912,6 +6912,7 @@
   verifyFormat("alignof(char);", getGoogleStyle());
 
   verifyFormat("return -1;");
+  verifyFormat("throw -1;");
   verifyFormat("switch (a) {\n"
"case -1:\n"
"  break;\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1756,7 +1756,7 @@
 // Use heuristics to recognize unary operators.
 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace))
+   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw))
   return TT_UnaryOperator;
 
 // There can't be two consecutive binary operators.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68682: Clang-tidy fix removals removing all non-blank text from a line should remove the line

2019-10-17 Thread Conrad Poelman via Phabricator via cfe-commits
poelmanc updated this revision to Diff 225523.
poelmanc edited the summary of this revision.
poelmanc added a comment.

In D68682#1707764 , @alexfh wrote:

> cleanupAroundReplacements is not used by clang-format itself. I believe, it's 
> a part of clang-format only because it was easier to implement it on top of 
> some infrastructure clang-format provides.


Thanks for the correction @alexfh. I've updated the patch to call the line 
removal from cleanupAroundReplacements().


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D68682

Files:
  clang-tools-extra/clang-tidy/readability/RedundantControlFlowCheck.cpp
  clang-tools-extra/test/clang-tidy/readability-redundant-control-flow.cpp
  clang-tools-extra/test/clang-tidy/readability-redundant-declaration.cpp
  clang-tools-extra/test/clang-tidy/readability-redundant-member-init.cpp
  clang/include/clang/AST/CommentLexer.h
  clang/include/clang/AST/CommentParser.h
  clang/include/clang/Format/Format.h
  clang/lib/AST/CommentLexer.cpp
  clang/lib/AST/CommentParser.cpp
  clang/lib/Format/Format.cpp

Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -25,6 +25,9 @@
 #include "UnwrappedLineParser.h"
 #include "UsingDeclarationsSorter.h"
 #include "WhitespaceManager.h"
+#include "clang/AST/CommentLexer.h"
+#include "clang/AST/CommentParser.h"
+#include "clang/Basic/CharInfo.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/SourceManager.h"
@@ -2266,6 +2269,85 @@
 
 } // anonymous namespace
 
+llvm::Expected
+removeNewlyBlankLines(StringRef Code, const tooling::Replacements &Replaces) {
+  tooling::Replacements NewReplaces(Replaces);
+  // pair< LineStartPos, CheckedThroughPos > of lines that have been checked
+  // and confirmed that the replacement result so far will be entirely blank.
+  std::list> PotentialWholeLineCuts;
+  int LineStartPos = -1;
+  int LineCheckedThroughPos = -1;
+  bool LineBlankSoFar = true;
+  const char *FileText = Code.data();
+  StringRef FilePath; // Must be the same for every Replacement
+  for (const auto &R : Replaces) {
+assert(FilePath.empty() || FilePath == R.getFilePath());
+FilePath = R.getFilePath();
+const int RStartPos = R.getOffset();
+
+int CurrentRLineStartPos = RStartPos;
+while (CurrentRLineStartPos > 0 &&
+   !isVerticalWhitespace(FileText[CurrentRLineStartPos - 1])) {
+  --CurrentRLineStartPos;
+}
+
+assert(CurrentRLineStartPos >= LineStartPos);
+if (CurrentRLineStartPos != LineStartPos) {
+  // We've moved on to a new line. Wrap up the old one before moving on.
+  if (LineBlankSoFar) {
+PotentialWholeLineCuts.push_back(
+std::make_pair(LineStartPos, LineCheckedThroughPos));
+  }
+  LineCheckedThroughPos = CurrentRLineStartPos;
+  LineStartPos = CurrentRLineStartPos;
+  LineBlankSoFar = true;
+}
+
+// Check to see if line from LineCheckedThroughPos to here is blank.
+assert(RStartPos >= LineCheckedThroughPos);
+StringRef PriorTextToCheck(FileText + LineCheckedThroughPos,
+   RStartPos - LineCheckedThroughPos);
+StringRef ReplacementText = R.getReplacementText();
+LineBlankSoFar = LineBlankSoFar && isWhitespace(PriorTextToCheck) &&
+ ReplacementText.empty();
+LineCheckedThroughPos = R.getOffset() + R.getLength();
+  }
+
+  if (LineBlankSoFar) {
+PotentialWholeLineCuts.push_back(
+std::make_pair(LineStartPos, LineCheckedThroughPos));
+  }
+
+  // Now remove whole line if and only if (a) rest of line is blank, and
+  // (b) the original line was *not* blank.
+  for (const auto &LineCheckedThrough : PotentialWholeLineCuts) {
+const int LineStartPos = LineCheckedThrough.first;
+const int CheckedThroughPos = LineCheckedThrough.second;
+
+int LineEndPos = CheckedThroughPos;
+while (LineEndPos < Code.size() &&
+   !isVerticalWhitespace(FileText[LineEndPos])) {
+  ++LineEndPos;
+}
+
+assert(LineEndPos >= CheckedThroughPos);
+StringRef TrailingText(FileText + CheckedThroughPos,
+   LineEndPos - CheckedThroughPos);
+assert(LineEndPos >= LineStartPos);
+StringRef OriginalLine(FileText + LineStartPos, LineEndPos - LineStartPos);
+if (isWhitespace(TrailingText) && !isWhitespace(OriginalLine)) {
+  const char *CutTo = skipNewline(FileText + LineEndPos, Code.end());
+  int CutCount = CutTo - FileText - LineStartPos;
+  llvm::Error Err = NewReplaces.add(
+  tooling::Replacement(FilePath, LineStartPos, CutCount, ""));
+  if (Err) {
+return llvm::Expected(std::move(Err));
+  }
+}
+  }
+  return NewReplaces;
+}
+
 llvm::Expected
 cleanupAroundReplacements(Stri

[PATCH] D69140: [clang-offload-wrapper][NFC] Use captured name of the entry type in LIT test

2019-10-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69140



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


r375177 - [clang-offload-wrapper][NFC] Use captured name of the entry type in LIT test

2019-10-17 Thread Sergey Dmitriev via cfe-commits
Author: sdmitriev
Date: Thu Oct 17 14:55:39 2019
New Revision: 375177

URL: http://llvm.org/viewvc/llvm-project?rev=375177&view=rev
Log:
[clang-offload-wrapper][NFC] Use captured name of the entry type in LIT test

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

Modified:
cfe/trunk/test/Driver/clang-offload-wrapper.c

Modified: cfe/trunk/test/Driver/clang-offload-wrapper.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang-offload-wrapper.c?rev=375177&r1=375176&r2=375177&view=diff
==
--- cfe/trunk/test/Driver/clang-offload-wrapper.c (original)
+++ cfe/trunk/test/Driver/clang-offload-wrapper.c Thu Oct 17 14:55:39 2019
@@ -31,7 +31,7 @@
 // CHECK-IR: [[ENTBEGIN:@.+]] = external hidden constant [[ENTTY]]
 // CHECK-IR: [[ENTEND:@.+]] = external hidden constant [[ENTTY]]
 
-// CHECK-IR: [[DUMMY:@.+]] = hidden constant [0 x %__tgt_offload_entry] 
zeroinitializer, section "omp_offloading_entries"
+// CHECK-IR: [[DUMMY:@.+]] = hidden constant [0 x [[ENTTY]]] zeroinitializer, 
section "omp_offloading_entries"
 
 // CHECK-IR: [[BIN:@.+]] = internal unnamed_addr constant [[BINTY:\[[0-9]+ x 
i8\]]] c"Content of device file{{.+}}"
 


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


r375179 - [ARM] Fix arm_neon.h with -flax-vector-conversions=none, part 3

2019-10-17 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Thu Oct 17 14:57:28 2019
New Revision: 375179

URL: http://llvm.org/viewvc/llvm-project?rev=375179&view=rev
Log:
[ARM] Fix arm_neon.h with -flax-vector-conversions=none, part 3

It's completely impossible to check that I've actually found all the
issues, due to the use of macros in arm_neon.h, but hopefully this time
it'll take more than a few hours for someone to find another issue.

I have no idea why, but apparently there's a rule that some, but not
all, builtins which should take an fp16 vector actually take an int8
vector as an argument.  Fix this, and add test coverage.

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


Modified:
cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
cfe/trunk/utils/TableGen/NeonEmitter.cpp

Modified: cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c?rev=375179&r1=375178&r2=375179&view=diff
==
--- cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c Thu Oct 17 14:57:28 
2019
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon 
-target-feature +fullfp16 -target-feature +v8.2a\
-// RUN: -fallow-half-arguments-and-returns -S -disable-O0-optnone -emit-llvm 
-o - %s \
+// RUN: -fallow-half-arguments-and-returns -flax-vector-conversions=none -S 
-disable-O0-optnone -emit-llvm -o - %s \
 // RUN: | opt -S -mem2reg \
 // RUN: | FileCheck %s
 

Modified: cfe/trunk/utils/TableGen/NeonEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/NeonEmitter.cpp?rev=375179&r1=375178&r2=375179&view=diff
==
--- cfe/trunk/utils/TableGen/NeonEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/NeonEmitter.cpp Thu Oct 17 14:57:28 2019
@@ -1442,7 +1442,8 @@ void Intrinsic::emitBodyAsBuiltinCall()
 }
 
 // Check if an explicit cast is needed.
-if (CastToType.isVector() && LocalCK == ClassB) {
+if (CastToType.isVector() &&
+(LocalCK == ClassB || (T.isHalf() && !T.isScalarForMangling( {
   CastToType.makeInteger(8, true);
   Arg = "(" + CastToType.str() + ")" + Arg;
 } else if (CastToType.isVector() && LocalCK == ClassI) {


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


  1   2   >