[PATCH] D68120: [clangd] Handle type template parameters in findExplicitReferences

2019-09-26 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman, jkorous, MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68120

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -706,6 +706,18 @@
"0: targets = {x}\n"
"1: targets = {X::func, X::func}\n"
"2: targets = {t}\n"},
+  // Type template parameters.
+  {R"cpp(
+template 
+void foo() {
+  static_cast<$0^T>(0);
+  $1^T();
+  $2^T t;
+}
+)cpp",
+   "0: targets = {T}\n"
+   "1: targets = {T}\n"
+   "2: targets = {T}\n"},
   };
 
   for (const auto &C : Cases) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -489,6 +489,11 @@
   ReferenceLoc{NestedNameSpecifierLoc(), L.getNameLoc(), 
{L.getDecl()}};
 }
 
+void VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc L) {
+  Ref =
+  ReferenceLoc{NestedNameSpecifierLoc(), L.getNameLoc(), 
{L.getDecl()}};
+}
+
 void VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc L) {
   Ref = ReferenceLoc{
   NestedNameSpecifierLoc(), L.getTemplateNameLoc(),


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -706,6 +706,18 @@
"0: targets = {x}\n"
"1: targets = {X::func, X::func}\n"
"2: targets = {t}\n"},
+  // Type template parameters.
+  {R"cpp(
+template 
+void foo() {
+  static_cast<$0^T>(0);
+  $1^T();
+  $2^T t;
+}
+)cpp",
+   "0: targets = {T}\n"
+   "1: targets = {T}\n"
+   "2: targets = {T}\n"},
   };
 
   for (const auto &C : Cases) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -489,6 +489,11 @@
   ReferenceLoc{NestedNameSpecifierLoc(), L.getNameLoc(), {L.getDecl()}};
 }
 
+void VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc L) {
+  Ref =
+  ReferenceLoc{NestedNameSpecifierLoc(), L.getNameLoc(), {L.getDecl()}};
+}
+
 void VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc L) {
   Ref = ReferenceLoc{
   NestedNameSpecifierLoc(), L.getTemplateNameLoc(),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68119: [clangd] Handle OverloadExpr in targetDecl

2019-09-26 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous, MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68119

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -391,6 +391,32 @@
   EXPECT_DECLS("DeclRefExpr", "auto int x = 1");
 }
 
+TEST_F(TargetDeclTest, OverloadExpr) {
+  Code = R"cpp(
+void func(int*);
+void func(char*);
+
+template 
+void foo(T t) {
+  [[func]](t);
+};
+  )cpp";
+  EXPECT_DECLS("UnresolvedLookupExpr", "void func(int *)", "void func(char 
*)");
+
+  Code = R"cpp(
+struct X {
+  void func(int*);
+  void func(char*);
+};
+
+template 
+void foo(X x, T t) {
+  x.[[func]](t);
+};
+  )cpp";
+  EXPECT_DECLS("UnresolvedMemberExpr", "void func(int *)", "void func(char 
*)");
+}
+
 TEST_F(TargetDeclTest, ObjC) {
   Flags = {"-xobjective-c"};
   Code = R"cpp(
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -188,6 +188,10 @@
   D = USD;
 Outer.add(D, Flags);
   }
+  void VisitOverloadExpr(const OverloadExpr *OE) {
+for (auto *D : OE->decls())
+  Outer.add(D, Flags);
+  }
   void VisitCXXConstructExpr(const CXXConstructExpr *CCE) {
 Outer.add(CCE->getConstructor(), Flags);
   }


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -391,6 +391,32 @@
   EXPECT_DECLS("DeclRefExpr", "auto int x = 1");
 }
 
+TEST_F(TargetDeclTest, OverloadExpr) {
+  Code = R"cpp(
+void func(int*);
+void func(char*);
+
+template 
+void foo(T t) {
+  [[func]](t);
+};
+  )cpp";
+  EXPECT_DECLS("UnresolvedLookupExpr", "void func(int *)", "void func(char *)");
+
+  Code = R"cpp(
+struct X {
+  void func(int*);
+  void func(char*);
+};
+
+template 
+void foo(X x, T t) {
+  x.[[func]](t);
+};
+  )cpp";
+  EXPECT_DECLS("UnresolvedMemberExpr", "void func(int *)", "void func(char *)");
+}
+
 TEST_F(TargetDeclTest, ObjC) {
   Flags = {"-xobjective-c"};
   Code = R"cpp(
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -188,6 +188,10 @@
   D = USD;
 Outer.add(D, Flags);
   }
+  void VisitOverloadExpr(const OverloadExpr *OE) {
+for (auto *D : OE->decls())
+  Outer.add(D, Flags);
+  }
   void VisitCXXConstructExpr(const CXXConstructExpr *CCE) {
 Outer.add(CCE->getConstructor(), Flags);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68118: [clangd] Support OverloadExpr in findExplicitReferences

2019-09-26 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman, jkorous, MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68118

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -10,8 +10,10 @@
 #include "Selection.h"
 #include "TestTU.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Testing/Support/Annotations.h"
 #include "gmock/gmock.h"
@@ -482,7 +484,11 @@
 TU.Code = Code;
 
 auto AST = TU.build();
-auto &Func = llvm::cast(findDecl(AST, "foo"));
+
+auto *TestDecl = &findDecl(AST, "foo");
+if (auto *T = llvm::dyn_cast(TestDecl))
+  TestDecl = T->getTemplatedDecl();
+auto &Func = llvm::cast(*TestDecl);
 
 std::vector Refs;
 findExplicitReferences(Func.getBody(), [&Refs](ReferenceLoc R) {
@@ -671,6 +677,35 @@
 )cpp",
"0: targets = {vector}\n"
"1: targets = {x}\n"},
+  // Handle UnresolvedLookupExpr.
+  {R"cpp(
+namespace ns1 { void func(char*); }
+namespace ns2 { void func(int*); }
+using namespace ns1;
+using namespace ns2;
+
+template 
+void foo(T t) {
+  $0^func($1^t);
+}
+)cpp",
+   "0: targets = {ns1::func, ns2::func}\n"
+   "1: targets = {t}\n"},
+  // Handle UnresolvedMemberExpr.
+  {R"cpp(
+struct X {
+  void func(char*);
+  void func(int*);
+};
+
+template 
+void foo(X x, T t) {
+  $0^x.$1^func($2^t);
+}
+)cpp",
+   "0: targets = {x}\n"
+   "1: targets = {X::func, X::func}\n"
+   "2: targets = {t}\n"},
   };
 
   for (const auto &C : Cases) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -16,6 +16,7 @@
 #include "clang/AST/DeclVisitor.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/PrettyPrinter.h"
@@ -449,6 +450,12 @@
  E->getMemberNameInfo().getLoc(),
  {E->getFoundDecl()}};
 }
+
+void VisitOverloadExpr(const OverloadExpr *E) {
+  Ref = ReferenceLoc{E->getQualifierLoc(), E->getNameInfo().getLoc(),
+ llvm::SmallVector(
+ E->decls().begin(), E->decls().end())};
+}
   };
 
   Visitor V;


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -10,8 +10,10 @@
 #include "Selection.h"
 #include "TestTU.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Testing/Support/Annotations.h"
 #include "gmock/gmock.h"
@@ -482,7 +484,11 @@
 TU.Code = Code;
 
 auto AST = TU.build();
-auto &Func = llvm::cast(findDecl(AST, "foo"));
+
+auto *TestDecl = &findDecl(AST, "foo");
+if (auto *T = llvm::dyn_cast(TestDecl))
+  TestDecl = T->getTemplatedDecl();
+auto &Func = llvm::cast(*TestDecl);
 
 std::vector Refs;
 findExplicitReferences(Func.getBody(), [&Refs](ReferenceLoc R) {
@@ -671,6 +677,35 @@
 )cpp",
"0: targets = {vector}\n"
"1: targets = {x}\n"},
+  // Handle UnresolvedLookupExpr.
+  {R"cpp(
+namespace ns1 { void func(char*); }
+namespace ns2 { void func(int*); }
+using namespace ns1;
+using namespace ns2;
+
+template 
+void foo(T t) {
+  $0^func($1^t);
+}
+)cpp",
+   "0: targets = {ns1::func, ns2::func}\n"
+   "1: targets = {t}\n"},
+  // Handle UnresolvedMemberExpr.
+  {R"cpp(
+struct X {
+  void func(char*);
+  void func(int*);
+};
+
+template 
+void foo(X x, T t) {
+  $0^

[libclc] r373046 - travis: Switch to Ubuntu 16.04 (xenial)

2019-09-26 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Sep 26 22:57:38 2019
New Revision: 373046

URL: http://llvm.org/viewvc/llvm-project?rev=373046&view=rev
Log:
travis: Switch to Ubuntu 16.04 (xenial)

Use native packages up to llvm-6.

Reviewer: tstellar
Signed-off-by: Jan Vesely 

Modified:
libclc/trunk/.travis.yml

Modified: libclc/trunk/.travis.yml
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/.travis.yml?rev=373046&r1=373045&r2=373046&view=diff
==
--- libclc/trunk/.travis.yml (original)
+++ libclc/trunk/.travis.yml Thu Sep 26 22:57:38 2019
@@ -1,11 +1,6 @@
 language: cpp
 
-sudo: false
-dist: trusty
-
-cache:
-  apt: true
-
+dist: xenial
 
 matrix:
   include:
@@ -15,12 +10,7 @@ matrix:
 - CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc nvptx--nvidiacl.bc 
nvptx64--nvidiacl.bc"
   addons:
 apt:
-  sources:
-- llvm-toolchain-trusty-3.9
   packages:
-- libedit-dev
-- g++-4.8
-# From sources above
 - llvm-3.9-dev
 - clang-3.9
 - env:
@@ -29,12 +19,7 @@ matrix:
 - CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc 
tahiti-amdgcn-mesa-mesa3d.bc nvptx--nvidiacl.bc nvptx64--nvidiacl.bc"
   addons:
 apt:
-  sources:
-- llvm-toolchain-trusty-4.0
   packages:
-- libedit-dev
-- g++-4.8
-# From sources above
 - llvm-4.0-dev
 - clang-4.0
 - env:
@@ -43,41 +28,28 @@ matrix:
 - CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc 
tahiti-amdgcn-mesa-mesa3d.bc nvptx--nvidiacl.bc nvptx64--nvidiacl.bc"
   addons:
 apt:
-  sources:
-- llvm-toolchain-trusty-5.0
   packages:
-- libedit-dev
-- g++-4.8
-# From sources above
 - llvm-5.0-dev
 - clang-5.0
 - env:
 - LABEL="make gcc LLVM-6.0"
 - LLVM_VERSION=6.0
 - CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc 
tahiti-amdgcn-mesa-mesa3d.bc nvptx--nvidiacl.bc nvptx64--nvidiacl.bc"
-# llvm passes -Werror=date-time which is only supported in gcc-4.9+
-- MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"
   addons:
 apt:
-  sources:
-- llvm-toolchain-trusty-6.0
-- ubuntu-toolchain-r-test
   packages:
-- libedit-dev
-# LLVM-6 needs libstdc++4.9
-- g++-4.9
-# From sources above
 - llvm-6.0-dev
 - clang-6.0
 - env:
 - LABEL="make gcc LLVM-7"
 - LLVM_VERSION=7
 - CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc 
tahiti-amdgcn-mesa-mesa3d.bc nvptx--nvidiacl.bc nvptx64--nvidiacl.bc"
+# llvm passes -Werror=date-time which is only supported in gcc-4.9+
 - MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
   addons:
 apt:
   sources:
-- sourceline: 'deb http://apt.llvm.org/trusty/ 
llvm-toolchain-trusty-7 main'
+- sourceline: 'deb http://apt.llvm.org/xenial/ 
llvm-toolchain-xenial-7 main'
   key_url: https://apt.llvm.org/llvm-snapshot.gpg.key
 - ubuntu-toolchain-r-test
   packages:
@@ -90,11 +62,12 @@ matrix:
 - LABEL="make gcc LLVM-8"
 - LLVM_VERSION=8
 - CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc 
tahiti-amdgcn-mesa-mesa3d.bc nvptx--nvidiacl.bc nvptx64--nvidiacl.bc"
+# llvm passes -Werror=date-time which is only supported in gcc-4.9+
 - MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
   addons:
 apt:
   sources:
-- sourceline: 'deb http://apt.llvm.org/trusty/ 
llvm-toolchain-trusty-8 main'
+- sourceline: 'deb http://apt.llvm.org/xenial/ 
llvm-toolchain-xenial-8 main'
   key_url: https://apt.llvm.org/llvm-snapshot.gpg.key
 - ubuntu-toolchain-r-test
   packages:
@@ -109,12 +82,7 @@ matrix:
 - CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc nvptx--nvidiacl.bc 
nvptx64--nvidiacl.bc"
   addons:
 apt:
-  sources:
-- llvm-toolchain-trusty-3.9
   packages:
-- libedit-dev
-- g++-4.8
-# From sources above
 - llvm-3.9-dev
 - clang-3.9
 - env:
@@ -123,12 +91,7 @@ matrix:
 - CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tah

[libclc] r373047 - travis: Add LLVM 9 build

2019-09-26 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Sep 26 22:58:15 2019
New Revision: 373047

URL: http://llvm.org/viewvc/llvm-project?rev=373047&view=rev
Log:
travis: Add LLVM 9 build

Reviewer: tstellar
Signed-off-by: Jan Vesely 

Modified:
libclc/trunk/.travis.yml

Modified: libclc/trunk/.travis.yml
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/.travis.yml?rev=373047&r1=373046&r2=373047&view=diff
==
--- libclc/trunk/.travis.yml (original)
+++ libclc/trunk/.travis.yml Thu Sep 26 22:58:15 2019
@@ -77,6 +77,23 @@ matrix:
 - llvm-8-dev
 - clang-8
 - env:
+- LABEL="make gcc LLVM-9"
+- LLVM_VERSION=9
+- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc 
tahiti-amdgcn-mesa-mesa3d.bc nvptx--nvidiacl.bc nvptx64--nvidiacl.bc"
+- MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
+  addons:
+apt:
+  sources:
+- sourceline: 'deb http://apt.llvm.org/xenial/ 
llvm-toolchain-xenial-9 main'
+  key_url: https://apt.llvm.org/llvm-snapshot.gpg.key
+- ubuntu-toolchain-r-test
+  packages:
+- libedit-dev
+- g++-6
+# From sources above
+- llvm-9-dev
+- clang-9
+- env:
 - LABEL="cmake gcc LLVM-3.9"
 - LLVM_VERSION=3.9
 - CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc nvptx--nvidiacl.bc 
nvptx64--nvidiacl.bc"
@@ -148,6 +165,23 @@ matrix:
 # From sources above
 - llvm-8-dev
 - clang-8
+- env:
+- LABEL="cmake gcc LLVM-9"
+- LLVM_VERSION=9
+- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc 
tahiti-amdgcn-mesa-mesa3d.bc nvptx--nvidiacl.bc nvptx64--nvidiacl.bc"
+- MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
+  addons:
+apt:
+  sources:
+- sourceline: 'deb http://apt.llvm.org/xenial/ 
llvm-toolchain-xenial-9 main'
+  key_url: https://apt.llvm.org/llvm-snapshot.gpg.key
+- ubuntu-toolchain-r-test
+  packages:
+- libedit-dev
+- g++-6
+# From sources above
+- llvm-9-dev
+- clang-9
 
 before_install:
 - eval "${MATRIX_EVAL}"


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


r373043 - [test] Use %clang_cc1 instead of %clang -cc1

2019-09-26 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Thu Sep 26 22:37:06 2019
New Revision: 373043

URL: http://llvm.org/viewvc/llvm-project?rev=373043&view=rev
Log:
[test] Use %clang_cc1 instead of %clang -cc1

Modified:
cfe/trunk/test/CodeGen/align-global-large.c
cfe/trunk/test/CodeGenObjC/protocol-comdat.m
cfe/trunk/test/Frontend/cc1-return-codes.c
cfe/trunk/test/Frontend/nostdlib-for-asmpp.s
cfe/trunk/test/Misc/diag-macro-backtrace2.c
cfe/trunk/test/Misc/driver-verify.c
cfe/trunk/test/Modules/builtin-import.mm
cfe/trunk/test/Modules/umbrella-header-include-builtin.mm
cfe/trunk/test/Preprocessor/pragma_module.c

Modified: cfe/trunk/test/CodeGen/align-global-large.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/align-global-large.c?rev=373043&r1=373042&r2=373043&view=diff
==
--- cfe/trunk/test/CodeGen/align-global-large.c (original)
+++ cfe/trunk/test/CodeGen/align-global-large.c Thu Sep 26 22:37:06 2019
@@ -1,5 +1,5 @@
 // PR13606 - Clang crashes with large alignment attribute
-// RUN: %clang -cc1 -S -emit-llvm %s -o - -triple i686-pc-gnu | FileCheck %s
+// RUN: %clang_cc1 -S -emit-llvm %s -o - -triple i686-pc-gnu | FileCheck %s
 
 // CHECK: x
 // CHECK: align

Modified: cfe/trunk/test/CodeGenObjC/protocol-comdat.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/protocol-comdat.m?rev=373043&r1=373042&r2=373043&view=diff
==
--- cfe/trunk/test/CodeGenObjC/protocol-comdat.m (original)
+++ cfe/trunk/test/CodeGenObjC/protocol-comdat.m Thu Sep 26 22:37:06 2019
@@ -1,4 +1,4 @@
-// RUN: %clang -cc1 -triple thumbv7--windows-itanium -fobjc-runtime=ios 
-emit-llvm -o - %s -Wno-objc-root-class | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv7--windows-itanium -fobjc-runtime=ios 
-emit-llvm -o - %s -Wno-objc-root-class | FileCheck %s
 
 @protocol P
 - (void) method;

Modified: cfe/trunk/test/Frontend/cc1-return-codes.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/cc1-return-codes.c?rev=373043&r1=373042&r2=373043&view=diff
==
--- cfe/trunk/test/Frontend/cc1-return-codes.c (original)
+++ cfe/trunk/test/Frontend/cc1-return-codes.c Thu Sep 26 22:37:06 2019
@@ -1,4 +1,4 @@
 // cc1 immediate arguments (arguments which displays information and exits)
 // shall exit indicating success (return code 0)
-// RUN: %clang -cc1 -help
-// RUN: %clang -cc1 -version
+// RUN: %clang_cc1 -help
+// RUN: %clang_cc1 -version

Modified: cfe/trunk/test/Frontend/nostdlib-for-asmpp.s
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/nostdlib-for-asmpp.s?rev=373043&r1=373042&r2=373043&view=diff
==
--- cfe/trunk/test/Frontend/nostdlib-for-asmpp.s (original)
+++ cfe/trunk/test/Frontend/nostdlib-for-asmpp.s Thu Sep 26 22:37:06 2019
@@ -1,4 +1,4 @@
-// RUN: %clang -cc1 -x assembler-with-cpp -triple arm64-apple-ios6.0.0 
-isysroot %S/doesnotexist -std=c++11 -v %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -x assembler-with-cpp -triple arm64-apple-ios6.0.0 
-isysroot %S/doesnotexist -std=c++11 -v %s 2>&1 | FileCheck %s
 // The C++ stdlib path should not be included for an assembly source.
 
 // CHECK-NOT: usr/include/c++/

Modified: cfe/trunk/test/Misc/diag-macro-backtrace2.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/diag-macro-backtrace2.c?rev=373043&r1=373042&r2=373043&view=diff
==
--- cfe/trunk/test/Misc/diag-macro-backtrace2.c (original)
+++ cfe/trunk/test/Misc/diag-macro-backtrace2.c Thu Sep 26 22:37:06 2019
@@ -1,4 +1,4 @@
-// RUN: not %clang -cc1 -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s
 
 #define a b
 #define b c

Modified: cfe/trunk/test/Misc/driver-verify.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/driver-verify.c?rev=373043&r1=373042&r2=373043&view=diff
==
--- cfe/trunk/test/Misc/driver-verify.c (original)
+++ cfe/trunk/test/Misc/driver-verify.c Thu Sep 26 22:37:06 2019
@@ -1,5 +1,5 @@
 // RUN: not %clang -verify %s 2>&1 | FileCheck %s
-// RUN: %clang -cc1 -verify %s
+// RUN: %clang_cc1 -verify %s
 // expected-no-diagnostics
 
 // Test that -verify is strictly rejected as unknown by the driver.

Modified: cfe/trunk/test/Modules/builtin-import.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/builtin-import.mm?rev=373043&r1=373042&r2=373043&view=diff
==
--- cfe/trunk/test/Modules/builtin-import.mm (original)
+++ cfe/trunk/test/Modules/builtin-import.mm Thu Sep 26 22:37:06 2019
@@ -1,5 +1,5 @@
 // RUN: rm -rf %t
-// RUN: %clang

r373042 - Fix use-after-free found in Clang's testsuite.

2019-09-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Sep 26 22:36:16 2019
New Revision: 373042

URL: http://llvm.org/viewvc/llvm-project?rev=373042&view=rev
Log:
Fix use-after-free found in Clang's testsuite.

We need to discard all remaining cleanups if an earlier cleanup failed,
otherwise we may try to rerun the remaining cleanups later, potentially
after the scope containing the object is destroyed. (This can happen
when checking a potential constant expression.)

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

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=373042&r1=373041&r2=373042&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Sep 26 22:36:16 2019
@@ -1239,11 +1239,14 @@ namespace {
 
   // Run all cleanups for a block scope, and non-lifetime-extended cleanups
   // for a full-expression scope.
+  bool Success = true;
   for (unsigned I = Info.CleanupStack.size(); I > OldStackSize; --I) {
 if (!(IsFullExpression &&
   Info.CleanupStack[I - 1].isLifetimeExtended())) {
-  if (!Info.CleanupStack[I - 1].endLifetime(Info, RunDestructors))
-return false;
+  if (!Info.CleanupStack[I - 1].endLifetime(Info, RunDestructors)) {
+Success = false;
+break;
+  }
 }
   }
 
@@ -1254,7 +1257,7 @@ namespace {
 std::remove_if(NewEnd, Info.CleanupStack.end(),
[](Cleanup &C) { return !C.isLifetimeExtended(); });
   Info.CleanupStack.erase(NewEnd, Info.CleanupStack.end());
-  return true;
+  return Success;
 }
   };
   typedef ScopeRAII BlockScopeRAII;


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


[PATCH] D68117: [DWARF-5] Support for C++11 defaulted, deleted member functions.

2019-09-26 Thread Sourabh Singh Tomar via Phabricator via cfe-commits
SouraVX updated this revision to Diff 222079.
SouraVX added a comment.

Minor refactor.


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

https://reviews.llvm.org/D68117

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
  llvm/include/llvm/BinaryFormat/Dwarf.h
  llvm/include/llvm/IR/DebugInfoFlags.def
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/BinaryFormat/Dwarf.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp

Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1296,6 +1296,19 @@
 addFlag(SPDie, dwarf::DW_AT_elemental);
   if (SP->isRecursive())
 addFlag(SPDie, dwarf::DW_AT_recursive);
+  if (DD->getDwarfVersion() >= 5) {
+if (SP->isDefaultedInClass())
+  addUInt(SPDie, dwarf::DW_AT_defaulted, dwarf::DW_FORM_data1,
+  dwarf::DW_DEFAULTED_in_class);
+if (SP->isDefaultedOutOfClass())
+  addUInt(SPDie, dwarf::DW_AT_defaulted, dwarf::DW_FORM_data1,
+  dwarf::DW_DEFAULTED_out_of_class);
+if (SP->isNotDefaulted())
+  addUInt(SPDie, dwarf::DW_AT_defaulted, dwarf::DW_FORM_data1,
+  dwarf::DW_DEFAULTED_no);
+if (SP->isDeleted())
+  addFlag(SPDie, dwarf::DW_AT_deleted);
+  }
 }
 
 void DwarfUnit::constructSubrangeDIE(DIE &Buffer, const DISubrange *SR,
Index: llvm/lib/BinaryFormat/Dwarf.cpp
===
--- llvm/lib/BinaryFormat/Dwarf.cpp
+++ llvm/lib/BinaryFormat/Dwarf.cpp
@@ -271,6 +271,19 @@
   return StringRef();
 }
 
+StringRef llvm::dwarf::DefaultedMemberString(unsigned DefaultedEncodings) {
+  switch (DefaultedEncodings) {
+  // Defaulted Member Encodings codes
+  case DW_DEFAULTED_no:
+return "DW_DEFAULTED_no";
+  case DW_DEFAULTED_in_class:
+return "DW_DEFAULTED_in_class";
+  case DW_DEFAULTED_out_of_class:
+return "DW_DEFAULTED_out_of_class";
+  }
+  return StringRef();
+}
+
 StringRef llvm::dwarf::VisibilityString(unsigned Visibility) {
   switch (Visibility) {
   case DW_VIS_local:
@@ -601,6 +614,8 @@
 return ArrayOrderString(Val);
   case DW_AT_APPLE_runtime_class:
 return LanguageString(Val);
+  case DW_AT_defaulted:
+return DefaultedMemberString(Val);
   }
 
   return StringRef();
Index: llvm/include/llvm/IR/DebugInfoMetadata.h
===
--- llvm/include/llvm/IR/DebugInfoMetadata.h
+++ llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -1758,6 +1758,14 @@
   bool isPure() const { return getSPFlags() & SPFlagPure; }
   bool isElemental() const { return getSPFlags() & SPFlagElemental; }
   bool isRecursive() const { return getSPFlags() & SPFlagRecursive; }
+  bool isDefaultedInClass() const {
+return getSPFlags() & SPFlagDefaultedInClass;
+  }
+  bool isDefaultedOutOfClass() const {
+return getSPFlags() & SPFlagDefaultedOutOfClass;
+  }
+  bool isNotDefaulted() const { return getSPFlags() & SPFlagNotDefaulted; }
+  bool isDeleted() const { return getSPFlags() & SPFlagDeleted; }
 
   /// Check if this is reference-qualified.
   ///
Index: llvm/include/llvm/IR/DebugInfoFlags.def
===
--- llvm/include/llvm/IR/DebugInfoFlags.def
+++ llvm/include/llvm/IR/DebugInfoFlags.def
@@ -88,11 +88,15 @@
 HANDLE_DISP_FLAG((1u << 6), Elemental)
 HANDLE_DISP_FLAG((1u << 7), Recursive)
 HANDLE_DISP_FLAG((1u << 8), MainSubprogram)
+HANDLE_DISP_FLAG((1u << 9), NotDefaulted)
+HANDLE_DISP_FLAG((1u << 10), DefaultedInClass)
+HANDLE_DISP_FLAG((1u << 11), DefaultedOutOfClass)
+HANDLE_DISP_FLAG((1u << 12), Deleted)
 
 #ifdef DISP_FLAG_LARGEST_NEEDED
 // Intended to be used with ADT/BitmaskEnum.h.
 // NOTE: Always must be equal to largest flag, check this when adding new flags.
-HANDLE_DISP_FLAG((1 << 8), Largest)
+HANDLE_DISP_FLAG((1 << 12), Largest)
 #undef DISP_FLAG_LARGEST_NEEDED
 #endif
 
Index: llvm/include/llvm/BinaryFormat/Dwarf.h
===
--- llvm/include/llvm/BinaryFormat/Dwarf.h
+++ llvm/include/llvm/BinaryFormat/Dwarf.h
@@ -411,6 +411,7 @@
 StringRef DecimalSignString(unsigned Sign);
 StringRef EndianityString(unsigned Endian);
 StringRef AccessibilityString(unsigned Access);
+StringRef DefaultedMemberString(unsigned DefaultedEncodings);
 StringRef VisibilityString(unsigned Visibility);
 StringRef VirtualityString(unsigned Virtuality);
 StringRef LanguageString(unsigned Language);
Index: clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
===
--- clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
+++ clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
@@ -4,8 +4,7 @@
 // RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple %s -o - \
 // RUN:   -O1 -disable-llvm-passes \
 // RUN:  

[PATCH] D68117: [DWARF-5] Support for C++11 defaulted, deleted member functions.

2019-09-26 Thread Sourabh Singh Tomar via Phabricator via cfe-commits
SouraVX created this revision.
SouraVX added reviewers: aprantl, dblaikie, probinson.
SouraVX added projects: LLVM, clang, debug-info.
Herald added a subscriber: hiraditya.

This patch provides DWARF5 support for C++11 defaulted, deleted member. 
Added support in clang C++ frontend, llvm, and llvm-dwarfdump.


https://reviews.llvm.org/D68117

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
  clang/test/CodeGenCXX/debug-info-decl-nested.cpp
  llvm/include/llvm/BinaryFormat/Dwarf.h
  llvm/include/llvm/IR/DebugInfoFlags.def
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/BinaryFormat/Dwarf.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp

Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1296,6 +1296,19 @@
 addFlag(SPDie, dwarf::DW_AT_elemental);
   if (SP->isRecursive())
 addFlag(SPDie, dwarf::DW_AT_recursive);
+  if (DD->getDwarfVersion() >= 5) {
+if (SP->isDefaultedInClass())
+  addUInt(SPDie, dwarf::DW_AT_defaulted, dwarf::DW_FORM_data1,
+  dwarf::DW_DEFAULTED_in_class);
+if (SP->isDefaultedOutOfClass())
+  addUInt(SPDie, dwarf::DW_AT_defaulted, dwarf::DW_FORM_data1,
+  dwarf::DW_DEFAULTED_out_of_class);
+if (SP->isNotDefaulted())
+  addUInt(SPDie, dwarf::DW_AT_defaulted, dwarf::DW_FORM_data1,
+  dwarf::DW_DEFAULTED_no);
+if (SP->isDeleted())
+  addFlag(SPDie, dwarf::DW_AT_deleted);
+  }
 }
 
 void DwarfUnit::constructSubrangeDIE(DIE &Buffer, const DISubrange *SR,
Index: llvm/lib/BinaryFormat/Dwarf.cpp
===
--- llvm/lib/BinaryFormat/Dwarf.cpp
+++ llvm/lib/BinaryFormat/Dwarf.cpp
@@ -271,6 +271,19 @@
   return StringRef();
 }
 
+StringRef llvm::dwarf::DefaultedMemberString(unsigned DefaultedEncodings) {
+  switch (DefaultedEncodings) {
+  // Defaulted Member Encodings codes
+  case DW_DEFAULTED_no:
+return "DW_DEFAULTED_no";
+  case DW_DEFAULTED_in_class:
+return "DW_DEFAULTED_in_class";
+  case DW_DEFAULTED_out_of_class:
+return "DW_DEFAULTED_out_of_class";
+  }
+  return StringRef();
+}
+
 StringRef llvm::dwarf::VisibilityString(unsigned Visibility) {
   switch (Visibility) {
   case DW_VIS_local:
@@ -601,6 +614,8 @@
 return ArrayOrderString(Val);
   case DW_AT_APPLE_runtime_class:
 return LanguageString(Val);
+  case DW_AT_defaulted:
+return DefaultedMemberString(Val);
   }
 
   return StringRef();
Index: llvm/include/llvm/IR/DebugInfoMetadata.h
===
--- llvm/include/llvm/IR/DebugInfoMetadata.h
+++ llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -1758,6 +1758,14 @@
   bool isPure() const { return getSPFlags() & SPFlagPure; }
   bool isElemental() const { return getSPFlags() & SPFlagElemental; }
   bool isRecursive() const { return getSPFlags() & SPFlagRecursive; }
+  bool isDefaultedInClass() const {
+return getSPFlags() & SPFlagDefaultedInClass;
+  }
+  bool isDefaultedOutOfClass() const {
+return getSPFlags() & SPFlagDefaultedOutOfClass;
+  }
+  bool isNotDefaulted() const { return getSPFlags() & SPFlagNotDefaulted; }
+  bool isDeleted() const { return getSPFlags() & SPFlagDeleted; }
 
   /// Check if this is reference-qualified.
   ///
Index: llvm/include/llvm/IR/DebugInfoFlags.def
===
--- llvm/include/llvm/IR/DebugInfoFlags.def
+++ llvm/include/llvm/IR/DebugInfoFlags.def
@@ -88,11 +88,15 @@
 HANDLE_DISP_FLAG((1u << 6), Elemental)
 HANDLE_DISP_FLAG((1u << 7), Recursive)
 HANDLE_DISP_FLAG((1u << 8), MainSubprogram)
+HANDLE_DISP_FLAG((1u << 9), NotDefaulted)
+HANDLE_DISP_FLAG((1u << 10), DefaultedInClass)
+HANDLE_DISP_FLAG((1u << 11), DefaultedOutOfClass)
+HANDLE_DISP_FLAG((1u << 12), Deleted)
 
 #ifdef DISP_FLAG_LARGEST_NEEDED
 // Intended to be used with ADT/BitmaskEnum.h.
 // NOTE: Always must be equal to largest flag, check this when adding new flags.
-HANDLE_DISP_FLAG((1 << 8), Largest)
+HANDLE_DISP_FLAG((1 << 12), Largest)
 #undef DISP_FLAG_LARGEST_NEEDED
 #endif
 
Index: llvm/include/llvm/BinaryFormat/Dwarf.h
===
--- llvm/include/llvm/BinaryFormat/Dwarf.h
+++ llvm/include/llvm/BinaryFormat/Dwarf.h
@@ -411,6 +411,7 @@
 StringRef DecimalSignString(unsigned Sign);
 StringRef EndianityString(unsigned Endian);
 StringRef AccessibilityString(unsigned Access);
+StringRef DefaultedMemberString(unsigned DefaultedEncodings);
 StringRef VisibilityString(unsigned Visibility);
 StringRef VirtualityString(unsigned Virtuality);
 StringRef LanguageString(unsigned Language);
Index: clang/test/CodeGenCXX/debug-info-decl-nested.cpp
===
--- clang/test/CodeGenCXX/debug-info-decl-nested.c

[PATCH] D68072: Reference qualifiers in member templates causing extra indentation.

2019-09-26 Thread Andreas Wass via Phabricator via cfe-commits
AndWass added a comment.

@klimek I don't have commit access yet, could you please commit it for me? 
Thanks


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D68072



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


[PATCH] D66834: Driver tests: set `--sysroot=""` to support clang with `DEFAULT_SYSROOT`

2019-09-26 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

In D66834#1653334 , @broadwaylamb 
wrote:

> In D66834#1652756 , @compnerd wrote:
>
> > I think that this is pretty easy to forget.  Fortunately, last argument 
> > wins.  Why not sink this into the `%clang` substitution in lit?  That 
> > ensures that we run with an empty sysroot and then when the test needs to 
> > adjust the sysroot, it can do so explicitly.
>
>
> I've just tried to do it, but unfortunately some tests are failing, for 
> example, `Driver/cc1-response-files.c`. The problem is that `%clang` is 
> expanded to `/path/to/clang --sysroot=`, but the succeeding flags (such as 
> `-cc1`) may be incompatible with `--sysroot`.


Does the issue manifests itself with `-cc1` only? We usually use `%clang_cc1` 
in such cases, so probably those tests require update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66834



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


[PATCH] D68115: Zero initialize padding in unions

2019-09-26 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/test/CodeGen/init.c:197
   // CHECK-LABEL: @nonzeroPaddedUnionMemset(
-  // CHECK-NOT: store
-  // CHECK-NOT: memcpy
-  // CHECK: call void @llvm.memset.p0i8.i32(i8* {{.*}}, i8 -16, i32 36, i1 
false)
+  // CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 {{.*}}, i8* align 
4 {{.*}} [[INIT_PADDEDUNION]], {{.*}}, i32 36, i1 false)
 }

This is C++ aggregate initialization and not value-initialization. The wording 
you quoted from the C++ standard is for zero-initialization, which might be 
part of value initialization, but you have not shown that aggregate 
initialization of a union involves zero-initialization of that union.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68115



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


[PATCH] D68049: Propeller: Clang options for basic block sections

2019-09-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:631
+if (A->getOption().matches(options::OPT_fpropeller_optimize_EQ)) {
+  if (!Args.getLastArgValue(options::OPT_fuse_ld_EQ).equals_lower("lld"))
+D.Diag(clang::diag::err_drv_unsupported_opt)

tmsriram wrote:
> MaskRay wrote:
> > This check is overly constrained. Some systems default to use lld (e.g. 
> > installed at /usr/bin/ld). I suggest removing this check.
> I see what you mean, can we follow this up in some manner with a check to see 
> if the underlying linker supports Propeller?  
Some systems install lld at /usr/bin/ld. This will work even if -fuse-ld=lld is 
not specified. lld can also be used with -fuse-ld=/path/to/ld.lld . I think the 
best is just not to have the check.



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:642
+  CmdArgs.push_back("-z");
+  CmdArgs.push_back("nokeep-text-section-prefix");
+  CmdArgs.push_back("--no-warn-symbol-ordering");

tmsriram wrote:
> MaskRay wrote:
> > This will silently ignore user specified `-z keep-text-section-prefix`.
> > 
> > With `-z nokeep-text-section-prefix`, an input section `.text.hot.foo` will 
> > go to the output section `.text`, instead of `.text.hot`. Why do you need 
> > the option?
> We are planning to restore keep-text-section-prefix in some manner with 
> Propeller.  Since propeller shuffles sections what is hot is not clearly 
> defined by a prefix so this option won't make sense with Propeller.  We will 
> use a heuristic to compute hotness and then regenerate the section markers in 
> the final binary.  
OK, thanks for the clarification. The two disabled features deserve comments, 
even if they are TODO.


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

https://reviews.llvm.org/D68049



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


[PATCH] D68115: Zero initialize padding in unions

2019-09-26 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 222071.
vitalybuka added a comment.

remove unused var


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68115

Files:
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/test/CodeGen/2008-08-07-AlignPadding1.c
  clang/test/CodeGen/64bit-swiftcall.c
  clang/test/CodeGen/arm-swiftcall.c
  clang/test/CodeGen/designated-initializers.c
  clang/test/CodeGen/init.c
  clang/test/CodeGen/union-init2.c
  clang/test/CodeGen/windows-swiftcall.c
  clang/test/CodeGenCXX/auto-var-init.cpp
  clang/test/CodeGenCXX/const-init-cxx11.cpp
  clang/test/CodeGenCXX/cxx11-initializer-aggregate.cpp
  clang/test/CodeGenCXX/designated-init.cpp
  clang/test/CodeGenCXX/static-init.cpp

Index: clang/test/CodeGenCXX/static-init.cpp
===
--- clang/test/CodeGenCXX/static-init.cpp
+++ clang/test/CodeGenCXX/static-init.cpp
@@ -5,7 +5,7 @@
 // CHECK: @base_req = global [4 x i8] c"foo\00", align 1
 // CHECK: @base_req_uchar = global [4 x i8] c"bar\00", align 1
 
-// CHECK: @_ZZN5test31BC1EvE1u = internal global { i8, [3 x i8] } { i8 97, [3 x i8] undef }, align 4
+// CHECK: @_ZZN5test31BC1EvE1u = internal global { i8, [3 x i8] } { i8 97, [3 x i8] zeroinitializer }, align 4
 
 // CHECK: @_ZZ2h2vE1i = linkonce_odr global i32 0, comdat, align 4
 // CHECK: @_ZGVZ2h2vE1i = linkonce_odr global i64 0, comdat, align 8{{$}}
Index: clang/test/CodeGenCXX/designated-init.cpp
===
--- clang/test/CodeGenCXX/designated-init.cpp
+++ clang/test/CodeGenCXX/designated-init.cpp
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -std=c++98 -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck %s
-// RUN: %clang_cc1 -std=c++11 -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 -w -std=c++98 -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN: %clang_cc1 -w -std=c++11 -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN: %clang_cc1 -w -std=c++98 -emit-llvm -o - %s -triple aarch64_be-none-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang_cc1 -w -std=c++11 -emit-llvm -o - %s -triple aarch64_be-none-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-BE
 
 struct A { int x, y[3]; };
 struct B { A a; };
@@ -34,7 +36,8 @@
   int n;
   Bitfield b;
 };
-// CHECK: @bitfield = {{.*}} { i32 1, { i8, i8, [2 x i8] } { i8 42, i8 2, [2 x i8] undef } }
+// CHECK-LE: @bitfield = {{.*}} { i32 1, { i8, i8, [2 x i8] } { i8 42, i8 2, [2 x i8] undef } }
+// CHECK-BE: @bitfield = {{.*}} { i32 1, { i8, i8, [2 x i8] } { i8 74, i8 64, [2 x i8] undef } }
 WithBitfield bitfield = {1, (Bitfield){2, 3, 4}, .b.b = 5};
 
 struct String {
@@ -62,5 +65,6 @@
 struct WithOverwritePaddingWithBitfield {
   OverwritePaddingWithBitfield a;
 };
-// CHECK: @overwrite_padding = global { { i8, i8 } } { { i8, i8 } { i8 3, i8 1 } }
+// CHECK-LE: @overwrite_padding = global { { i8, i8 } } { { i8, i8 } { i8 3, i8 0 } }
+// CHECK-BE: @overwrite_padding = global { { i8, i8, i8, i8 } } { { i8, i8, i8, i8 } { i8 96, i8 0, i8 0, i8 0 } }
 WithOverwritePaddingWithBitfield overwrite_padding = {(OverwritePaddingWithBitfield){1}, .a.bitfield = 3};
Index: clang/test/CodeGenCXX/cxx11-initializer-aggregate.cpp
===
--- clang/test/CodeGenCXX/cxx11-initializer-aggregate.cpp
+++ clang/test/CodeGenCXX/cxx11-initializer-aggregate.cpp
@@ -23,27 +23,24 @@
 char x;
 int a;
   };
-  // FIXME: [dcl.init]p2, the padding bits of the union object should be
-  // initialized to 0, not undef, which would allow us to collapse the tail
-  // of these arrays to zeroinitializer.
-  // CHECK-DAG: @_ZN7PR375601cE = global <{ { i8, [3 x i8] } }> <{ { i8, [3 x i8] } { i8 0, [3 x i8] undef } }>
+  // CHECK-DAG: @_ZN7PR375601cE = global [1 x [[UU:%"[^"]*"]]] zeroinitializer
   U c[1] = {};
-  // CHECK-DAG: @_ZN7PR375601dE = global {{.*}} <{ { i8, [3 x i8] } { i8 97, [3 x i8] undef }, %"{{[^"]*}}" { i32 123 }, { i8, [3 x i8] } { i8 98, [3 x i8] undef }, { i8, [3 x i8] } { i8 0, [3 x i8] undef },
+  // CHECK-DAG: @_ZN7PR375601dE = global <{ { i8, [3 x i8] }, [[UU]], { i8, [3 x i8] }, [13 x [[UU]]] }> <{ { i8, [3 x i8] } { i8 97, [3 x i8] zeroinitializer }, [[UU]] { i32 123 }, { i8, [3 x i8] } { i8 98, [3 x i8] zeroinitializer }, [13 x [[UU]]] zeroinitializer }>
   U d[16] = {'a', {.a = 123}, 'b'};
-  // CHECK-DAG: @_ZN7PR375601eE = global {{.*}} <{ %"{{[^"]*}}" { i32 123 }, %"{{[^"]*}}" { i32 456 }, { i8, [3 x i8] } { i8 0, [3 x i8] undef },
+  // CHECK-DAG: @_ZN7PR375601eE = global <{ [[UU]], [[UU]], [14 x [[UU]]] }> <{ [[UU]] { i32 123 }, [[UU]] { i32 456 }, [14 x [[UU]]] zeroinitializer }>
   U e[16] = {{.a = 123}, {.a = 456}};
 
   union V {
 int a;
 char x;
   };
-  // CHECK-DAG: @_ZN7PR375601fE =

[PATCH] D68115: Zero initialize padding in unions

2019-09-26 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka marked an inline comment as done.
vitalybuka added inline comments.



Comment at: clang/test/CodeGenCXX/designated-init.cpp:68
 };
-// CHECK: @overwrite_padding = global { { i8, i8 } } { { i8, i8 } { i8 3, i8 1 
} }
+// CHECK-LE: @overwrite_padding = global { { i8, i8 } } { { i8, i8 } { i8 3, 
i8 0 } }
+// CHECK-BE: @overwrite_padding = global { { i8, i8, i8, i8 } } { { i8, i8, 
i8, i8 } { i8 96, i8 0, i8 0, i8 0 } }

vitalybuka wrote:
> "1->0" here is suspicions
interesting that I can't compile it with GCC as C++

I can compile the following as C with GCC and C/C++ with Clang
struct WithOverwritePaddingWithBitfield overwrite_padding = {{1}, .a.bitfield = 
3};
but even without the patch it was 0 in the last byte



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68115



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


[PATCH] D68115: Zero initialize padding in unions

2019-09-26 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka marked an inline comment as done.
vitalybuka added inline comments.



Comment at: clang/test/CodeGenCXX/designated-init.cpp:68
 };
-// CHECK: @overwrite_padding = global { { i8, i8 } } { { i8, i8 } { i8 3, i8 1 
} }
+// CHECK-LE: @overwrite_padding = global { { i8, i8 } } { { i8, i8 } { i8 3, 
i8 0 } }
+// CHECK-BE: @overwrite_padding = global { { i8, i8, i8, i8 } } { { i8, i8, 
i8, i8 } { i8 96, i8 0, i8 0, i8 0 } }

"1->0" here is suspicions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68115



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


r373039 - Revert r373034

2019-09-26 Thread Nicholas Allegra via cfe-commits
Author: comex
Date: Thu Sep 26 18:58:31 2019
New Revision: 373039

URL: http://llvm.org/viewvc/llvm-project?rev=373039&view=rev
Log:
Revert r373034

It breaks the build on MSVC.


Modified:
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/Analysis/Consumed.cpp

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=373039&r1=373038&r2=373039&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Thu Sep 26 18:58:31 2019
@@ -1041,8 +1041,7 @@ protected:
   template
   struct CastIterator
   : llvm::iterator_adaptor_base, StmtPtr *,
-std::random_access_iterator_tag, TPtr,
-int, void, TPtr> {
+std::random_access_iterator_tag, TPtr> {
 using Base = typename CastIterator::iterator_adaptor_base;
 
 CastIterator() : Base(nullptr) {}

Modified: cfe/trunk/lib/Analysis/Consumed.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/Consumed.cpp?rev=373039&r1=373038&r2=373039&view=diff
==
--- cfe/trunk/lib/Analysis/Consumed.cpp (original)
+++ cfe/trunk/lib/Analysis/Consumed.cpp Thu Sep 26 18:58:31 2019
@@ -494,10 +494,8 @@ public:
   void checkCallability(const PropagationInfo &PInfo,
 const FunctionDecl *FunDecl,
 SourceLocation BlameLoc);
-
-  using ArgRange = llvm::iterator_range;
-  bool handleCall(const Expr *Call, const Expr *ObjArg,
-  ArgRange args, const FunctionDecl *FunD);
+  bool handleCall(const CallExpr *Call, const Expr *ObjArg,
+  const FunctionDecl *FunD);
 
   void VisitBinaryOperator(const BinaryOperator *BinOp);
   void VisitCallExpr(const CallExpr *Call);
@@ -610,21 +608,22 @@ void ConsumedStmtVisitor::checkCallabili
 // Factors out common behavior for function, method, and operator calls.
 // Check parameters and set parameter state if necessary.
 // Returns true if the state of ObjArg is set, or false otherwise.
-bool ConsumedStmtVisitor::handleCall(const Expr *Call,
- const Expr *ObjArg,
- ArgRange Args,
+bool ConsumedStmtVisitor::handleCall(const CallExpr *Call, const Expr *ObjArg,
  const FunctionDecl *FunD) {
+  unsigned Offset = 0;
+  if (isa(Call) && isa(FunD))
+Offset = 1;  // first argument is 'this'
+
   // check explicit parameters
-  unsigned Index = 0;
-  for (const Expr *Arg : Args) {
+  for (unsigned Index = Offset; Index < Call->getNumArgs(); ++Index) {
 // Skip variable argument lists.
-if (Index >= FunD->getNumParams())
+if (Index - Offset >= FunD->getNumParams())
   break;
 
-const ParmVarDecl *Param = FunD->getParamDecl(Index++);
+const ParmVarDecl *Param = FunD->getParamDecl(Index - Offset);
 QualType ParamType = Param->getType();
 
-InfoEntry Entry = findInfo(Arg);
+InfoEntry Entry = findInfo(Call->getArg(Index));
 
 if (Entry == PropagationMap.end() || Entry->second.isTest())
   continue;
@@ -637,7 +636,7 @@ bool ConsumedStmtVisitor::handleCall(con
 
   if (ParamState != ExpectedState)
 Analyzer.WarningsHandler.warnParamTypestateMismatch(
-  Arg->getExprLoc(),
+  Call->getArg(Index)->getExprLoc(),
   stateToString(ExpectedState), stateToString(ParamState));
 }
 
@@ -750,7 +749,7 @@ void ConsumedStmtVisitor::VisitCallExpr(
 return;
   }
 
-  handleCall(Call, nullptr, Call->arguments(), FunDecl);
+  handleCall(Call, nullptr, FunDecl);
   propagateReturnType(Call, FunDecl);
 }
 
@@ -806,7 +805,7 @@ void ConsumedStmtVisitor::VisitCXXMember
   if (!MD)
 return;
 
-  handleCall(Call, Call->getImplicitObjectArgument(), Call->arguments(), MD);
+  handleCall(Call, Call->getImplicitObjectArgument(), MD);
   propagateReturnType(Call, MD);
 }
 
@@ -814,20 +813,18 @@ void ConsumedStmtVisitor::VisitCXXOperat
 const CXXOperatorCallExpr *Call) {
   const auto *FunDecl = 
dyn_cast_or_null(Call->getDirectCallee());
   if (!FunDecl) return;
-  ArgRange Args = Call->arguments();
 
   if (Call->getOperator() == OO_Equal) {
-ConsumedState CS = getInfo(llvm::index(Args, 1));
-if (!handleCall(Call, llvm::index(Args, 0), llvm::drop_begin(Args, 1),
-FunDecl))
-  setInfo(llvm::index(Args, 0), CS);
+ConsumedState CS = getInfo(Call->getArg(1));
+if (!handleCall(Call, Call->getArg(0), FunDecl))
+  setInfo(Call->getArg(0), CS);
 return;
   }
 
-  if (isa(FunDecl))
-handleCall(Call, llvm::index(Args, 0), llvm::drop_begin(Args, 1), FunDecl);
+  if (const auto *MCall = dyn_cast(Call))
+handleCall(MCall, MCall->getImplicitObjectArgument(), FunDecl);
   else
-han

[PATCH] D61446: Generalize the pass registration mechanism used by Polly to any third-party tool

2019-09-26 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added inline comments.



Comment at: polly/lib/Support/RegisterPasses.cpp:726
+
+#ifndef LLVM_POLLY_LINK_INTO_TOOLS
+extern "C" LLVM_ATTRIBUTE_WEAK ::llvm::PassPluginLibraryInfo

Meinersbur wrote:
> [serious] `LLVM_POLLY_LINK_INTO_TOOLS` is a cmake configuration parameter, 
> but not a preprocessor symbol. Hence, `LLVM_POLLY_LINK_INTO_TOOLS` is never 
> defined.
> 
> Error on Windows:
> ```
> Bye.lib(Bye.cpp.obj) : error LNK2005: llvmGetPassPluginInfo already defined 
> in Polly.lib(RegisterPasses.cpp.obj)
> bin\opt.exe : fatal error LNK1169: one or more multiply defined symbols found
> ```
Before you try to fix this preprocessor symbol, consider that Polly compiles a 
loadable module (to be used with `-load`) __and__ a library (static or dynamic 
depending on `BUILD_SHARED_LIBS`) __independent__ of 
`LLVM_POLLY_LINK_INTO_TOOLS`. That is, the loadable module must contain 
`llvmGetPassPluginInfo`, but not the library. That is, a preprocessor symbol 
that is the same for both will not work.

PLEASE, just keep the Polly.cpp (and move `llvmGetPassPluginInfo` in there; the 
static initializer indeed has to stay here as it will be used by both), it will 
make things easier as it already has been shown to work already. Do the same 
for Bye. 

If you really insist on removing the `Polly.cpp`, do so in a follow-up patch. 
In that case you will have to rework the CMakeLists.txt to only build one, 
either the loadable module or the library.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61446



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


[PATCH] D68115: Zero initialize padding in unions

2019-09-26 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka created this revision.
vitalybuka added reviewers: rsmith, jfb.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.
vitalybuka edited the summary of this revision.
vitalybuka edited the summary of this revision.

Existing implementation puts undef into padding bits which almost always
compiled into zeroes. However with -ftrivial-auto-var-init=pattern those undefs
became 0xAA pattern and break some code. We need to zero initialized them.

C++ requires zeroes in padding bit.

  11.6 Initializers
  (6.3) — if T is a (possibly cv-qualified) union type, its padding bits (6.7) 
are initialized to zero bits

Looks like C does not require, as union is not aggregate, but a lot of code 
already relies on this behavior.

  6.7.9 Initialization
  10. If an object that has automatic storage duration is not initialized 
explicitly, its value is indeterminate.
  If an object that has static or thread storage duration is not initialized 
explicitly, then:
  — if it is a union, the first named member is initialized (recursively) 
according to these rules, and
  any padding is initialized to zero bits;
  21. If there are fewer initializers in a brace-enclosed list than there are 
elements or members of an
  aggregate, or fewer characters in a string literal used to initialize an 
array of known size than there
  are elements in the array, the remainder of the aggregate shall be 
initialized implicitly the same as
  objects that have static storage duration.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68115

Files:
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/test/CodeGen/2008-08-07-AlignPadding1.c
  clang/test/CodeGen/64bit-swiftcall.c
  clang/test/CodeGen/arm-swiftcall.c
  clang/test/CodeGen/designated-initializers.c
  clang/test/CodeGen/init.c
  clang/test/CodeGen/union-init2.c
  clang/test/CodeGen/windows-swiftcall.c
  clang/test/CodeGenCXX/auto-var-init.cpp
  clang/test/CodeGenCXX/const-init-cxx11.cpp
  clang/test/CodeGenCXX/cxx11-initializer-aggregate.cpp
  clang/test/CodeGenCXX/designated-init.cpp
  clang/test/CodeGenCXX/static-init.cpp

Index: clang/test/CodeGenCXX/static-init.cpp
===
--- clang/test/CodeGenCXX/static-init.cpp
+++ clang/test/CodeGenCXX/static-init.cpp
@@ -5,7 +5,7 @@
 // CHECK: @base_req = global [4 x i8] c"foo\00", align 1
 // CHECK: @base_req_uchar = global [4 x i8] c"bar\00", align 1
 
-// CHECK: @_ZZN5test31BC1EvE1u = internal global { i8, [3 x i8] } { i8 97, [3 x i8] undef }, align 4
+// CHECK: @_ZZN5test31BC1EvE1u = internal global { i8, [3 x i8] } { i8 97, [3 x i8] zeroinitializer }, align 4
 
 // CHECK: @_ZZ2h2vE1i = linkonce_odr global i32 0, comdat, align 4
 // CHECK: @_ZGVZ2h2vE1i = linkonce_odr global i64 0, comdat, align 8{{$}}
Index: clang/test/CodeGenCXX/designated-init.cpp
===
--- clang/test/CodeGenCXX/designated-init.cpp
+++ clang/test/CodeGenCXX/designated-init.cpp
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -std=c++98 -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck %s
-// RUN: %clang_cc1 -std=c++11 -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 -w -std=c++98 -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN: %clang_cc1 -w -std=c++11 -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN: %clang_cc1 -w -std=c++98 -emit-llvm -o - %s -triple aarch64_be-none-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang_cc1 -w -std=c++11 -emit-llvm -o - %s -triple aarch64_be-none-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-BE
 
 struct A { int x, y[3]; };
 struct B { A a; };
@@ -34,7 +36,8 @@
   int n;
   Bitfield b;
 };
-// CHECK: @bitfield = {{.*}} { i32 1, { i8, i8, [2 x i8] } { i8 42, i8 2, [2 x i8] undef } }
+// CHECK-LE: @bitfield = {{.*}} { i32 1, { i8, i8, [2 x i8] } { i8 42, i8 2, [2 x i8] undef } }
+// CHECK-BE: @bitfield = {{.*}} { i32 1, { i8, i8, [2 x i8] } { i8 74, i8 64, [2 x i8] undef } }
 WithBitfield bitfield = {1, (Bitfield){2, 3, 4}, .b.b = 5};
 
 struct String {
@@ -62,5 +65,6 @@
 struct WithOverwritePaddingWithBitfield {
   OverwritePaddingWithBitfield a;
 };
-// CHECK: @overwrite_padding = global { { i8, i8 } } { { i8, i8 } { i8 3, i8 1 } }
+// CHECK-LE: @overwrite_padding = global { { i8, i8 } } { { i8, i8 } { i8 3, i8 0 } }
+// CHECK-BE: @overwrite_padding = global { { i8, i8, i8, i8 } } { { i8, i8, i8, i8 } { i8 96, i8 0, i8 0, i8 0 } }
 WithOverwritePaddingWithBitfield overwrite_padding = {(OverwritePaddingWithBitfield){1}, .a.bitfield = 3};
Index: clang/test/CodeGenCXX/cxx11-initializer-aggregate.cpp
===
--- clang/test/CodeGenCXX/cxx11-initializer-aggregate.cpp
+++ clang/test/CodeGenCXX/cxx11-initializer-aggregate.cpp
@@ -23,27 +23,24 @@
 char x;
 int a;
 

r373037 - For P0784R7: add support for new (std::nothrow).

2019-09-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Sep 26 18:26:49 2019
New Revision: 373037

URL: http://llvm.org/viewvc/llvm-project?rev=373037&view=rev
Log:
For P0784R7: add support for new (std::nothrow).

Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx2a.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=373037&r1=373036&r2=373037&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Thu Sep 26 18:26:49 2019
@@ -2056,6 +2056,7 @@ public:
   bool isCARCBridgableType() const;
   bool isTemplateTypeParmType() const;  // C++ template type parameter
   bool isNullPtrType() const;   // C++11 std::nullptr_t
+  bool isNothrowT() const;  // C++   std::nothrow_t
   bool isAlignValT() const; // C++17 std::align_val_t
   bool isStdByteType() const;   // C++17 std::byte
   bool isAtomicType() const;// C11 _Atomic()

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=373037&r1=373036&r2=373037&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Thu Sep 26 18:26:49 2019
@@ -2977,8 +2977,7 @@ bool FunctionDecl::isReplaceableGlobalAl
 Ty = Ty->getPointeeType();
 if (Ty.getCVRQualifiers() != Qualifiers::Const)
   return false;
-const CXXRecordDecl *RD = Ty->getAsCXXRecordDecl();
-if (RD && isNamed(RD, "nothrow_t") && RD->isInStdNamespace())
+if (Ty->isNothrowT())
   Consume();
   }
 

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=373037&r1=373036&r2=373037&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Sep 26 18:26:49 2019
@@ -8043,6 +8043,9 @@ static bool EvaluateArrayNewInitList(Eva
  QualType AllocType);
 
 bool PointerExprEvaluator::VisitCXXNewExpr(const CXXNewExpr *E) {
+  if (!Info.getLangOpts().CPlusPlus2a)
+Info.CCEDiag(E, diag::note_constexpr_new);
+
   // We cannot speculatively evaluate a delete expression.
   if (Info.SpeculativeEvaluationDepth)
 return false;
@@ -8054,17 +8057,27 @@ bool PointerExprEvaluator::VisitCXXNewEx
 return false;
   }
 
-  // FIXME: There is no restriction on this, but it's not clear that it
-  // makes any sense. We get here for cases such as:
-  //
-  //   new (std::align_val_t{N}) X(int)
-  //
-  // (which should presumably be valid only if N is a multiple of
-  // alignof(int).
-  if (E->getNumPlacementArgs())
-return Error(E, diag::note_constexpr_new_placement);
-  if (!Info.getLangOpts().CPlusPlus2a)
-Info.CCEDiag(E, diag::note_constexpr_new);
+  bool IsNothrow = false;
+  if (E->getNumPlacementArgs()) {
+// The only new-placement list we support is of the form (std::nothrow).
+//
+// FIXME: There is no restriction on this, but it's not clear that any
+// other form makes any sense. We get here for cases such as:
+//
+//   new (std::align_val_t{N}) X(int)
+//
+// (which should presumably be valid only if N is a multiple of
+// alignof(int), and in any case can't be deallocated unless N is
+// alignof(X) and X has new-extended alignment).
+if (E->getNumPlacementArgs() != 1 ||
+!E->getPlacementArg(0)->getType()->isNothrowT())
+  return Error(E, diag::note_constexpr_new_placement);
+
+LValue Nothrow;
+if (!EvaluateLValue(E->getPlacementArg(0), Nothrow, Info))
+  return false;
+IsNothrow = true;
+  }
 
   const Expr *Init = E->getInitializer();
   const InitListExpr *ResizedArrayILE = nullptr;
@@ -8087,6 +8100,9 @@ bool PointerExprEvaluator::VisitCXXNewEx
 //   -- [...] its value before converting to size_t [or] applying the
 //  second standard conversion sequence is less than zero
 if (ArrayBound.isSigned() && ArrayBound.isNegative()) {
+  if (IsNothrow)
+return ZeroInitialization(E);
+
   Info.FFDiag(*ArraySize, diag::note_constexpr_new_negative)
   << ArrayBound << (*ArraySize)->getSourceRange();
   return false;
@@ -8097,6 +8113,9 @@ bool PointerExprEvaluator::VisitCXXNewEx
 if (ConstantArrayType::getNumAddressingBits(Info.Ctx, AllocType,
 ArrayBound) >
 ConstantArrayType::getMaxSizeBits(Info.Ctx)) {
+  if (IsNothrow)
+return ZeroInitialization(E);
+
   Info.FFDiag(*ArraySize, diag::note_constexpr_new_too

r373036 - For P0784R7: Add support for dynamic allocation with new / delete during

2019-09-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Sep 26 18:26:47 2019
New Revision: 373036

URL: http://llvm.org/viewvc/llvm-project?rev=373036&view=rev
Log:
For P0784R7: Add support for dynamic allocation with new / delete during
constant evaluation.

Added:
cfe/trunk/test/CodeGenCXX/const-init-cxx2a.cpp
Modified:
cfe/trunk/include/clang/AST/APValue.h
cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
cfe/trunk/lib/AST/APValue.cpp
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp
cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx2a.cpp

Modified: cfe/trunk/include/clang/AST/APValue.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/APValue.h?rev=373036&r1=373035&r2=373036&view=diff
==
--- cfe/trunk/include/clang/AST/APValue.h (original)
+++ cfe/trunk/include/clang/AST/APValue.h Thu Sep 26 18:26:47 2019
@@ -53,6 +53,34 @@ public:
 
   void print(llvm::raw_ostream &Out, const PrintingPolicy &Policy) const;
 };
+
+/// Symbolic representation of a dynamic allocation.
+class DynamicAllocLValue {
+  unsigned Index;
+
+public:
+  DynamicAllocLValue() : Index(0) {}
+  explicit DynamicAllocLValue(unsigned Index) : Index(Index + 1) {}
+  unsigned getIndex() { return Index - 1; }
+
+  explicit operator bool() const { return Index != 0; }
+
+  void *getOpaqueValue() {
+return reinterpret_cast(static_cast(Index)
+<< NumLowBitsAvailable);
+  }
+  static DynamicAllocLValue getFromOpaqueValue(void *Value) {
+DynamicAllocLValue V;
+V.Index = reinterpret_cast(Value) >> NumLowBitsAvailable;
+return V;
+  }
+
+  static unsigned getMaxIndex() {
+return (std::numeric_limits::max() >> NumLowBitsAvailable) - 1;
+  }
+
+  static constexpr int NumLowBitsAvailable = 3;
+};
 }
 
 namespace llvm {
@@ -67,6 +95,17 @@ template<> struct PointerLikeTypeTraits<
   // to include Type.h.
   static constexpr int NumLowBitsAvailable = 3;
 };
+
+template<> struct PointerLikeTypeTraits {
+  static void *getAsVoidPointer(clang::DynamicAllocLValue V) {
+return V.getOpaqueValue();
+  }
+  static clang::DynamicAllocLValue getFromVoidPointer(void *P) {
+return clang::DynamicAllocLValue::getFromOpaqueValue(P);
+  }
+  static constexpr int NumLowBitsAvailable =
+  clang::DynamicAllocLValue::NumLowBitsAvailable;
+};
 }
 
 namespace clang {
@@ -97,13 +136,15 @@ public:
   };
 
   class LValueBase {
-typedef llvm::PointerUnion
+typedef llvm::PointerUnion
 PtrTy;
 
   public:
 LValueBase() : Local{} {}
 LValueBase(const ValueDecl *P, unsigned I = 0, unsigned V = 0);
 LValueBase(const Expr *P, unsigned I = 0, unsigned V = 0);
+static LValueBase getDynamicAlloc(DynamicAllocLValue LV, QualType Type);
 static LValueBase getTypeInfo(TypeInfoLValue LV, QualType TypeInfo);
 
 template 
@@ -124,6 +165,7 @@ public:
 unsigned getCallIndex() const;
 unsigned getVersion() const;
 QualType getTypeInfoType() const;
+QualType getDynamicAllocType() const;
 
 friend bool operator==(const LValueBase &LHS, const LValueBase &RHS);
 friend bool operator!=(const LValueBase &LHS, const LValueBase &RHS) {
@@ -140,6 +182,8 @@ public:
   LocalState Local;
   /// The type std::type_info, if this is a TypeInfoLValue.
   void *TypeInfoType;
+  /// The QualType, if this is a DynamicAllocLValue.
+  void *DynamicAllocType;
 };
   };
 

Modified: cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td?rev=373036&r1=373035&r2=373036&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td Thu Sep 26 18:26:47 2019
@@ -53,6 +53,9 @@ def note_constexpr_nonliteral : Note<
 def note_constexpr_non_global : Note<
   "%select{pointer|reference}0 to %select{|subobject of }1"
   "%select{temporary|%3}2 is not a constant expression">;
+def note_constexpr_dynamic_alloc : Note<
+  "%select{pointer|reference}0 to %select{|subobject of }1"
+  "heap-allocated object is not a constant expression">;
 def note_constexpr_uninitialized : Note<
   "%select{|sub}0object of type %1 is not initialized">;
 def note_constexpr_subobject_declared_here : Note<
@@ -100,6 +103,7 @@ def note_constexpr_typeid_polymorphic :
 def note_constexpr_void_comparison : Note<
   "comparison between unequal pointers to void has unspecified result">;
 def note_constexpr_temporary_here : Note<"temporary created here">;
+def note_constexpr_dynamic_alloc_here : Note<"heap allocation performed here">;
 def note_constexpr_conditional_never_const : Note<
   "both arms of conditional operator a

[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2019-09-26 Thread Lingda Li via Phabricator via cfe-commits
lildmh updated this revision to Diff 222066.
lildmh added a comment.

Rebase


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

https://reviews.llvm.org/D67833

Files:
  include/clang/AST/OpenMPClause.h
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  test/OpenMP/capturing_in_templates.cpp
  test/OpenMP/declare_mapper_codegen.cpp
  test/OpenMP/declare_target_link_codegen.cpp
  test/OpenMP/distribute_codegen.cpp
  test/OpenMP/distribute_firstprivate_codegen.cpp
  test/OpenMP/distribute_lastprivate_codegen.cpp
  test/OpenMP/distribute_parallel_for_codegen.cpp
  test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  test/OpenMP/distribute_parallel_for_if_codegen.cpp
  test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  test/OpenMP/distribute_parallel_for_private_codegen.cpp
  test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
  test/OpenMP/distribute_parallel_for_reduction_codegen.cpp
  test/OpenMP/distribute_parallel_for_simd_codegen.cpp
  test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp
  test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
  test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp
  test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
  test/OpenMP/distribute_parallel_for_simd_proc_bind_codegen.cpp
  test/OpenMP/distribute_private_codegen.cpp
  test/OpenMP/distribute_simd_codegen.cpp
  test/OpenMP/distribute_simd_firstprivate_codegen.cpp
  test/OpenMP/distribute_simd_lastprivate_codegen.cpp
  test/OpenMP/distribute_simd_private_codegen.cpp
  test/OpenMP/distribute_simd_reduction_codegen.cpp
  test/OpenMP/nvptx_lambda_capturing.cpp
  test/OpenMP/nvptx_lambda_pointer_capturing.cpp
  test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
  test/OpenMP/openmp_offload_codegen.cpp
  test/OpenMP/target_codegen.cpp
  test/OpenMP/target_data_codegen.cpp
  test/OpenMP/target_depend_codegen.cpp
  test/OpenMP/target_enter_data_codegen.cpp
  test/OpenMP/target_enter_data_depend_codegen.cpp
  test/OpenMP/target_exit_data_codegen.cpp
  test/OpenMP/target_exit_data_depend_codegen.cpp
  test/OpenMP/target_firstprivate_codegen.cpp
  test/OpenMP/target_is_device_ptr_codegen.cpp
  test/OpenMP/target_map_codegen.cpp
  test/OpenMP/target_parallel_codegen.cpp
  test/OpenMP/target_parallel_depend_codegen.cpp
  test/OpenMP/target_parallel_for_codegen.cpp
  test/OpenMP/target_parallel_for_depend_codegen.cpp
  test/OpenMP/target_parallel_for_simd_codegen.cpp
  test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
  test/OpenMP/target_parallel_if_codegen.cpp
  test/OpenMP/target_parallel_num_threads_codegen.cpp
  test/OpenMP/target_simd_codegen.cpp
  test/OpenMP/target_simd_depend_codegen.cpp
  test/OpenMP/target_teams_codegen.cpp
  test/OpenMP/target_teams_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_codegen.cpp
  test/OpenMP/target_teams_distribute_collapse_codegen.cpp
  test/OpenMP/target_teams_distribute_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_dist_schedule_codegen.cpp
  test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
  test/OpenMP/target_teams_distribute_lastprivate_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_collapse_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_lastprivate_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_private_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_proc_bind_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_reduction_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_schedule_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_collapse_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
  
test/OpenMP/target_teams_distribute_parallel_for_simd_dist_schedule_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_lastprivate_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_private_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_proc_bind_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_reduction_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_schedule_codegen.cpp
  

[PATCH] D67740: [Consumed] Refactor and improve diagnostics

2019-09-26 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/Sema/SemaDeclAttr.cpp:1249
+  Diag(A->getLoc(), diag::warn_consumable_attr_for_unconsumable_type) <<
+A << (isa(D) ? 0 : 1) << Type;
+  return false;

Do you need the "? 0 : 1" here? Or would the boolean value be sufficient to use 
directly?



Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:609-610
 
+if (isa(TmplAttr) || 
isa(TmplAttr)) {
+  if (!CheckParamOrReturnTypestateAttr(TmplAttr, New, Tmpl))
+continue; // don't add

Collapse these two conditions into one 'if', perhaps?


Repository:
  rC Clang

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

https://reviews.llvm.org/D67740



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


[PATCH] D67740: [Consumed] Refactor and improve diagnostics

2019-09-26 Thread Nicholas Allegra via Phabricator via cfe-commits
comex added a comment.

Ping...


Repository:
  rC Clang

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

https://reviews.llvm.org/D67740



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


[PATCH] D68114: Fix for expanding __pragmas in macro arguments

2019-09-26 Thread Amy Huang via Phabricator via cfe-commits
akhuang created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Avoid parsing __pragma into an annotation token when macro arguments are 
pre-expanded.
This is what clang currently does when parsing _Pragmas.

Fixes https://bugs.llvm.org/show_bug.cgi?id=41128, where clang crashed
when trying to get the length of an annotation token.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68114

Files:
  clang/lib/Lex/Pragma.cpp
  clang/test/Preprocessor/pragma_microsoft.c

Index: clang/test/Preprocessor/pragma_microsoft.c
===
--- clang/test/Preprocessor/pragma_microsoft.c
+++ clang/test/Preprocessor/pragma_microsoft.c
@@ -51,6 +51,8 @@
   __pragma(warning(pop)); \
 }
 
+#define __PRAGMA_IN_ARG(p) p
+
 void f()
 {
   __pragma() // expected-warning{{unknown pragma ignored}}
@@ -64,6 +66,10 @@
 // CHECK: #pragma warning(disable: 1)
 // CHECK: ; 1 + (2 > 3) ? 4 : 5;
 // CHECK: #pragma warning(pop)
+
+  // Check that __pragma can be in a macro argument.
+  __PRAGMA_IN_ARG(__pragma(pack()))
+// CHECK: #pragma pack()
 }
 
 
Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -165,7 +165,6 @@
   //
   // In Case #2, we check the syntax now, but then put the tokens back into the
   // token stream for later consumption.
-
   struct TokenCollector {
 Preprocessor &Self;
 bool Collect;
@@ -194,7 +193,6 @@
   Tok = *Tokens.begin();
 }
   };
-
   TokenCollector Toks = {*this, InMacroArgPreExpansion, {}, Tok};
 
   // Remember the pragma token location.
@@ -328,11 +326,41 @@
 /// HandleMicrosoft__pragma - Like Handle_Pragma except the pragma text
 /// is not enclosed within a string literal.
 void Preprocessor::HandleMicrosoft__pragma(Token &Tok) {
+  struct TokenCollector {
+Preprocessor &Self;
+bool Collect;
+SmallVector Tokens;
+Token &Tok;
+
+void lex() {
+  if (Collect)
+Tokens.push_back(Tok);
+  Self.Lex(Tok);
+}
+
+void revert() {
+  assert(Collect && "did not collect tokens");
+  assert(!Tokens.empty() && "collected unexpected number of tokens");
+
+  // Push the pragma content tokens into the token stream.
+  auto Toks = std::make_unique(Tokens.size());
+  std::copy(Tokens.begin() + 1, Tokens.end(), Toks.get());
+  Toks[Tokens.size() - 1] = Tok;
+  Self.EnterTokenStream(std::move(Toks), Tokens.size(),
+/*DisableMacroExpansion*/ true,
+/*IsReinject*/ true);
+
+  // ... and return the _Pragma token unchanged.
+  Tok = *Tokens.begin();
+}
+  };
+  TokenCollector Toks = {*this, InMacroArgPreExpansion, {}, Tok};
+
   // Remember the pragma token location.
   SourceLocation PragmaLoc = Tok.getLocation();
 
   // Read the '('.
-  Lex(Tok);
+  Toks.lex();
   if (Tok.isNot(tok::l_paren)) {
 Diag(PragmaLoc, diag::err__Pragma_malformed);
 return;
@@ -341,14 +369,14 @@
   // Get the tokens enclosed within the __pragma(), as well as the final ')'.
   SmallVector PragmaToks;
   int NumParens = 0;
-  Lex(Tok);
+  Toks.lex();
   while (Tok.isNot(tok::eof)) {
 PragmaToks.push_back(Tok);
 if (Tok.is(tok::l_paren))
   NumParens++;
 else if (Tok.is(tok::r_paren) && NumParens-- == 0)
   break;
-Lex(Tok);
+Toks.lex();
   }
 
   if (Tok.is(tok::eof)) {
@@ -356,6 +384,12 @@
 return;
   }
 
+  // If we're expanding a macro argument, put the tokens back.
+  if (InMacroArgPreExpansion) {
+Toks.revert();
+return;
+  }
+
   PragmaToks.front().setFlag(Token::LeadingSpace);
 
   // Replace the ')' with an EOD to mark the end of the pragma.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68108: Redeclare Objective-C property accessors inside the ObjCImplDecl in which they are synthesized.

2019-09-26 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl updated this revision to Diff 222056.
aprantl added a comment.

Remove `#if 0` from test I used during debugging. (It still passes!)


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

https://reviews.llvm.org/D68108

Files:
  clang/include/clang/AST/DeclObjC.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclObjC.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGObjCGNU.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Frontend/Rewrite/RewriteObjC.cpp
  clang/lib/Index/IndexDecl.cpp
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/test/AST/ast-dump-decl-json.m
  clang/test/Analysis/Inputs/expected-plists/nullability-notes.m.plist
  clang/test/CodeGenObjC/debug-info-synthesis.m
  clang/test/CodeGenObjC/debug-property-synth.m
  clang/test/CodeGenObjC/debuginfo-properties.m
  clang/test/CodeGenObjC/instance-method-metadata.m

Index: clang/test/CodeGenObjC/instance-method-metadata.m
===
--- clang/test/CodeGenObjC/instance-method-metadata.m
+++ clang/test/CodeGenObjC/instance-method-metadata.m
@@ -1,6 +1,5 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -S -o %t %s 
-// RUN: FileCheck < %t %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -S %s -o - | FileCheck %s
 
 // rdar://9072317
 
Index: clang/test/CodeGenObjC/debuginfo-properties.m
===
--- clang/test/CodeGenObjC/debuginfo-properties.m
+++ clang/test/CodeGenObjC/debuginfo-properties.m
@@ -11,19 +11,6 @@
 
 @protocol HasASelection 
 @property (nonatomic, retain) Selection* selection;
-// CHECK: !DISubprogram(name: "-[MyClass selection]"
-// CHECK-SAME:  line: [[@LINE-2]]
-// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK: !DISubprogram(name: "-[MyClass setSelection:]"
-// CHECK-SAME:  line: [[@LINE-5]]
-// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK: !DISubprogram(name: "-[OtherClass selection]"
-// CHECK-SAME:  line: [[@LINE-8]]
-// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK: !DISubprogram(name: "-[OtherClass setSelection:]"
-// CHECK-SAME:  line: [[@LINE-11]]
-// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
-
 @end
 
 @interface MyClass : NSObject  {
@@ -33,6 +20,12 @@
 
 @implementation MyClass
 @synthesize selection = _selection;
+// CHECK: !DISubprogram(name: "-[MyClass selection]"
+// CHECK-SAME:  line: [[@LINE-2]]
+// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK: !DISubprogram(name: "-[MyClass setSelection:]"
+// CHECK-SAME:  line: [[@LINE-5]]
+// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
 @end
 
 @interface OtherClass : NSObject  {
@@ -41,4 +34,10 @@
 @end
 @implementation OtherClass
 @synthesize selection = _selection;
+// CHECK: !DISubprogram(name: "-[OtherClass selection]"
+// CHECK-SAME:  line: [[@LINE-2]]
+// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK: !DISubprogram(name: "-[OtherClass setSelection:]"
+// CHECK-SAME:  line: [[@LINE-5]]
+// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
 @end
Index: clang/test/CodeGenObjC/debug-property-synth.m
===
--- clang/test/CodeGenObjC/debug-property-synth.m
+++ clang/test/CodeGenObjC/debug-property-synth.m
@@ -7,6 +7,10 @@
 @interface I {
   int _p1;
 }
+@property int p1;
+@end
+
+@implementation I
 // Test that the linetable entries for the synthesized getter and
 // setter are correct.
 //
@@ -22,10 +26,6 @@
 // CHECK: ![[DBG1]] = !DILocation(line: [[@LINE+3]],
 // CHECK: !DISubprogram(name: "-[I setP1:]",{{.*}} line: [[@LINE+2]],{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK: ![[DBG2]] = !DILocation(line: [[@LINE+1]],
-@property int p1;
-@end
-
-@implementation I
 @synthesize p1 = _p1;
 @end
 
Index: clang/test/CodeGenObjC/debug-info-synthesis.m
===
--- clang/test/CodeGenObjC/debug-info-synthesis.m
+++ clang/test/CodeGenObjC/debug-info-synthesis.m
@@ -30,8 +30,8 @@
   }
 }
 
-// CHECK: ![[FILE:.*]] = !DIFile(filename: "{{[^"]+}}foo.h"
+// CHECK: ![[FILE:.*]] = !DIFile(filename: "foo.m"
 // CHECK: !DISubprogram(name: "-[Foo setDict:]"
 // CHECK-SAME:  file: ![[FILE]],
-// CHECK-SAME:  line: 8,
+// CHECK-SAME:  line: 7,
 // CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
Index: clang/test/Analy

[PATCH] D67567: [clang-tidy] New check to warn when storing dispatch_once_t in non-static, non-global storage

2019-09-26 Thread Michael Wyman via Phabricator via cfe-commits
mwyman added a comment.

In D67567#1685036 , @gribozavr wrote:

> Sorry, I reverted it in r373032 because the test fails on Linux: 
> http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/18323 . 
> Could you please take a look? Thanks!


What's the process for re-landing a change? New Differential, or update this 
one?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67567



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


[PATCH] D66121: Debug Info: Nest Objective-C property function decls inside their container.

2019-09-26 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl updated this revision to Diff 222048.
aprantl added a comment.

Factored out the general AST changes into https://reviews.llvm.org/D68108.


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

https://reviews.llvm.org/D66121

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/test/CodeGenObjC/debug-info-objc-property-dwarf5.m

Index: clang/test/CodeGenObjC/debug-info-objc-property-dwarf5.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/debug-info-objc-property-dwarf5.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -dwarf-version=5 %s -o - | FileCheck %s
+
+@protocol NSObject
+@end
+
+@interface NSObject  {}
+@end
+
+struct Bar {};
+
+@protocol BarProto
+@property struct Bar *bar;
+@end
+
+@interface Foo 
+@end
+
+@implementation Foo {}
+@synthesize bar = _bar;
+- (void)f {}
+@end
+
+// CHECK: ![[FOO:[0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Foo"
+
+// CHECK: ![[DECL:[0-9]+]] = !DISubprogram(name: "-[Foo setBar:]",
+// CHECK-SAME:  scope: ![[FOO]]
+
+// CHECK: distinct !DISubprogram(name: "-[Foo setBar:]",
+// CHECK-SAME:  declaration: ![[DECL:[0-9]+]]
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -601,6 +601,17 @@
   /// declaration for the given method definition.
   llvm::DISubprogram *getFunctionDeclaration(const Decl *D);
 
+  /// \return  debug info descriptor to the describe method declaration
+  ///  for the given method definition.
+  /// \param FnTypeFor Objective-C methods, their type.
+  /// \param LineNoThe declaration's line number.
+  /// \param Flags The DIFlags for the method declaration.
+  /// \param SPFlags   The subprogram-spcific flags for the method declaration.
+  llvm::DISubprogram *
+  getObjCMethodDeclaration(const Decl *D, llvm::DISubroutineType *FnType,
+   unsigned LineNo, llvm::DINode::DIFlags Flags,
+   llvm::DISubprogram::DISPFlags SPFlags);
+
   /// \return debug info descriptor to describe in-class static data
   /// member declaration for the given out-of-class definition.  If D
   /// is an out-of-class definition of a static data member of a
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2572,8 +2572,8 @@
   SourceLocation Loc = PD->getLocation();
   llvm::DIFile *PUnit = getOrCreateFile(Loc);
   unsigned PLine = getLineNumber(Loc);
-  ObjCMethodDecl *Getter = PD->getGetterMethodDecl();
-  ObjCMethodDecl *Setter = PD->getSetterMethodDecl();
+  ObjCMethodDecl *Getter = PImpD->getGetterMethodDecl();
+  ObjCMethodDecl *Setter = PImpD->getSetterMethodDecl();
   PropertyNode = DBuilder.createObjCProperty(
   PD->getName(), PUnit, PLine,
   hasDefaultGetterName(PD, Getter)
@@ -3455,6 +3455,39 @@
   return nullptr;
 }
 
+llvm::DISubprogram *CGDebugInfo::getObjCMethodDeclaration(
+const Decl *D, llvm::DISubroutineType *FnType, unsigned LineNo,
+llvm::DINode::DIFlags Flags, llvm::DISubprogram::DISPFlags SPFlags) {
+  if (!D || DebugKind <= codegenoptions::DebugLineTablesOnly)
+return nullptr;
+
+  if (CGM.getCodeGenOpts().DwarfVersion < 5)
+return nullptr;
+
+  // Starting with DWARF V5 method declarations are emitted as children of
+  // the interface type.
+  if (const auto *OMD = dyn_cast_or_null(D)) {
+auto *ID = dyn_cast_or_null(D->getDeclContext());
+if (!ID)
+  ID = OMD->getClassInterface();
+if (ID) {
+  QualType QTy(ID->getTypeForDecl(), 0);
+  auto It = TypeCache.find(QTy.getAsOpaquePtr());
+  if (It != TypeCache.end()) {
+auto *InterfaceType = cast(It->second);
+llvm::DISubprogram *FD = DBuilder.createFunction(
+InterfaceType, getObjCMethodName(OMD), StringRef(),
+InterfaceType->getFile(), LineNo, FnType, LineNo, Flags,
+SPFlags);
+DBuilder.finalizeSubprogram(FD);
+ObjCMethodCache[ID].push_back(FD);
+return FD;
+  }
+}
+  }
+  return nullptr;
+}
+
 // getOrCreateFunctionType - Construct type. If it is a c++ method, include
 // implicit parameter "this".
 llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D,
@@ -3597,6 +3630,12 @@
 
   unsigned LineNo = getLineNumber(Loc);
   unsigned ScopeLine = getLineNumber(ScopeLoc);
+  llvm::DISubroutineType *DIFnType = getOrCreateFunctionType(D, FnType, Unit);
+  llvm::DISubprogram *Decl = nullptr;
+  if (D)
+Decl = isa(D)
+   ? getObjCMethodDeclaration(D, DIFnType, LineNo, Flags, SPFlags)
+   : getFunctionDeclaration(D);
 
   // FIXME: The functio

[PATCH] D68108: Redeclare Objective-C property accessors inside the ObjCImplDecl in which they are synthesized.

2019-09-26 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl created this revision.
aprantl added reviewers: rjmccall, dergachev.a, dcoughlin, theraven, ahatanak, 
erik.pilkington, davide.
Herald added subscribers: arphaman, dexonsmith.
Herald added a project: clang.
aprantl added a child revision: D66121: Debug Info: Nest Objective-C property 
function decls inside their container..

This patch is motivated by (and factored out from) 
https://reviews.llvm.org/D66121 which is a debug info bugfix. Starting with 
DWARF 5 all Objective-C methods are nested inside their containing type, and 
that patch implements this for synthesized Objective-C properties.

This patch became much longer than I hoped it would be but most of the changes 
are mechanical in nature.

1. SemaObjCProperty populates a list of synthesized accessors that may need to 
inserted into an ObjCImplDecl.
2. SemaDeclObjC::ActOnEnd inserts forward-declarations for all accessors for 
which no override was provided into their ObjCImplDecl. This patch does *not* 
synthesize AST function *bodies*. Moving that code from the static analyzer 
into Sema may be a good idea though.
3. Places that expect all methods to have bodies have been updated.

Most of the updates are very straightforward, the most irritating part was 
updating the static analyzer, there may be a more elegant way to do this.
I'm somewhat concerned that I didn't have to update the GNU Objective-C runtime 
for the testsuite to pass. I did not update the static analyzer's inliner for 
synthesized properties to point back to the property declaration (see 
test/Analysis/Inputs/expected-plists/nullability-notes.m.plist), which I 
believed to be more bug than a feature.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68108

Files:
  clang/include/clang/AST/DeclObjC.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclObjC.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGObjCGNU.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Frontend/Rewrite/RewriteObjC.cpp
  clang/lib/Index/IndexDecl.cpp
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/test/AST/ast-dump-decl-json.m
  clang/test/Analysis/Inputs/expected-plists/nullability-notes.m.plist
  clang/test/Analysis/properties.m
  clang/test/CodeGenObjC/debug-info-synthesis.m
  clang/test/CodeGenObjC/debug-property-synth.m
  clang/test/CodeGenObjC/debuginfo-properties.m
  clang/test/CodeGenObjC/instance-method-metadata.m

Index: clang/test/CodeGenObjC/instance-method-metadata.m
===
--- clang/test/CodeGenObjC/instance-method-metadata.m
+++ clang/test/CodeGenObjC/instance-method-metadata.m
@@ -1,6 +1,5 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -S -o %t %s 
-// RUN: FileCheck < %t %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -S %s -o - | FileCheck %s
 
 // rdar://9072317
 
Index: clang/test/CodeGenObjC/debuginfo-properties.m
===
--- clang/test/CodeGenObjC/debuginfo-properties.m
+++ clang/test/CodeGenObjC/debuginfo-properties.m
@@ -11,19 +11,6 @@
 
 @protocol HasASelection 
 @property (nonatomic, retain) Selection* selection;
-// CHECK: !DISubprogram(name: "-[MyClass selection]"
-// CHECK-SAME:  line: [[@LINE-2]]
-// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK: !DISubprogram(name: "-[MyClass setSelection:]"
-// CHECK-SAME:  line: [[@LINE-5]]
-// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK: !DISubprogram(name: "-[OtherClass selection]"
-// CHECK-SAME:  line: [[@LINE-8]]
-// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK: !DISubprogram(name: "-[OtherClass setSelection:]"
-// CHECK-SAME:  line: [[@LINE-11]]
-// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
-
 @end
 
 @interface MyClass : NSObject  {
@@ -33,6 +20,12 @@
 
 @implementation MyClass
 @synthesize selection = _selection;
+// CHECK: !DISubprogram(name: "-[MyClass selection]"
+// CHECK-SAME:  line: [[@LINE-2]]
+// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK: !DISubprogram(name: "-[MyClass setSelection:]"
+// CHECK-SAME:  line: [[@LINE-5]]
+// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
 @end
 
 @interface OtherClass : NSObject  {
@@ -41,4 +34,10 @@
 @end
 @implementation OtherClass
 @synthesize selection = _selection;
+// CHECK: !DISubprogram(name: "-[OtherClass selection]"
+// CHECK-SAME:  line: [[@LINE-2]]
+// CHECK-SAME:  DISPFlagLocalToUnit | DISPFla

r373034 - [Consumed][NFC] Refactor handleCall to take function argument list.

2019-09-26 Thread Nicholas Allegra via cfe-commits
Author: comex
Date: Thu Sep 26 16:47:18 2019
New Revision: 373034

URL: http://llvm.org/viewvc/llvm-project?rev=373034&view=rev
Log:
[Consumed][NFC] Refactor handleCall to take function argument list.

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


Modified:
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/Analysis/Consumed.cpp

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=373034&r1=373033&r2=373034&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Thu Sep 26 16:47:18 2019
@@ -1041,7 +1041,8 @@ protected:
   template
   struct CastIterator
   : llvm::iterator_adaptor_base, StmtPtr *,
-std::random_access_iterator_tag, TPtr> {
+std::random_access_iterator_tag, TPtr,
+int, void, TPtr> {
 using Base = typename CastIterator::iterator_adaptor_base;
 
 CastIterator() : Base(nullptr) {}

Modified: cfe/trunk/lib/Analysis/Consumed.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/Consumed.cpp?rev=373034&r1=373033&r2=373034&view=diff
==
--- cfe/trunk/lib/Analysis/Consumed.cpp (original)
+++ cfe/trunk/lib/Analysis/Consumed.cpp Thu Sep 26 16:47:18 2019
@@ -494,8 +494,10 @@ public:
   void checkCallability(const PropagationInfo &PInfo,
 const FunctionDecl *FunDecl,
 SourceLocation BlameLoc);
-  bool handleCall(const CallExpr *Call, const Expr *ObjArg,
-  const FunctionDecl *FunD);
+
+  using ArgRange = llvm::iterator_range;
+  bool handleCall(const Expr *Call, const Expr *ObjArg,
+  ArgRange args, const FunctionDecl *FunD);
 
   void VisitBinaryOperator(const BinaryOperator *BinOp);
   void VisitCallExpr(const CallExpr *Call);
@@ -608,22 +610,21 @@ void ConsumedStmtVisitor::checkCallabili
 // Factors out common behavior for function, method, and operator calls.
 // Check parameters and set parameter state if necessary.
 // Returns true if the state of ObjArg is set, or false otherwise.
-bool ConsumedStmtVisitor::handleCall(const CallExpr *Call, const Expr *ObjArg,
+bool ConsumedStmtVisitor::handleCall(const Expr *Call,
+ const Expr *ObjArg,
+ ArgRange Args,
  const FunctionDecl *FunD) {
-  unsigned Offset = 0;
-  if (isa(Call) && isa(FunD))
-Offset = 1;  // first argument is 'this'
-
   // check explicit parameters
-  for (unsigned Index = Offset; Index < Call->getNumArgs(); ++Index) {
+  unsigned Index = 0;
+  for (const Expr *Arg : Args) {
 // Skip variable argument lists.
-if (Index - Offset >= FunD->getNumParams())
+if (Index >= FunD->getNumParams())
   break;
 
-const ParmVarDecl *Param = FunD->getParamDecl(Index - Offset);
+const ParmVarDecl *Param = FunD->getParamDecl(Index++);
 QualType ParamType = Param->getType();
 
-InfoEntry Entry = findInfo(Call->getArg(Index));
+InfoEntry Entry = findInfo(Arg);
 
 if (Entry == PropagationMap.end() || Entry->second.isTest())
   continue;
@@ -636,7 +637,7 @@ bool ConsumedStmtVisitor::handleCall(con
 
   if (ParamState != ExpectedState)
 Analyzer.WarningsHandler.warnParamTypestateMismatch(
-  Call->getArg(Index)->getExprLoc(),
+  Arg->getExprLoc(),
   stateToString(ExpectedState), stateToString(ParamState));
 }
 
@@ -749,7 +750,7 @@ void ConsumedStmtVisitor::VisitCallExpr(
 return;
   }
 
-  handleCall(Call, nullptr, FunDecl);
+  handleCall(Call, nullptr, Call->arguments(), FunDecl);
   propagateReturnType(Call, FunDecl);
 }
 
@@ -805,7 +806,7 @@ void ConsumedStmtVisitor::VisitCXXMember
   if (!MD)
 return;
 
-  handleCall(Call, Call->getImplicitObjectArgument(), MD);
+  handleCall(Call, Call->getImplicitObjectArgument(), Call->arguments(), MD);
   propagateReturnType(Call, MD);
 }
 
@@ -813,18 +814,20 @@ void ConsumedStmtVisitor::VisitCXXOperat
 const CXXOperatorCallExpr *Call) {
   const auto *FunDecl = 
dyn_cast_or_null(Call->getDirectCallee());
   if (!FunDecl) return;
+  ArgRange Args = Call->arguments();
 
   if (Call->getOperator() == OO_Equal) {
-ConsumedState CS = getInfo(Call->getArg(1));
-if (!handleCall(Call, Call->getArg(0), FunDecl))
-  setInfo(Call->getArg(0), CS);
+ConsumedState CS = getInfo(llvm::index(Args, 1));
+if (!handleCall(Call, llvm::index(Args, 0), llvm::drop_begin(Args, 1),
+FunDecl))
+  setInfo(llvm::index(Args, 0), CS);
 return;
   }
 
-  if (const auto *MCall = dyn_cast(Call))
-handleCall(MCall, MCall->getImplicitObjectArgument(), FunDecl);
+  if (isa(FunDecl))
+handleCall(Ca

[PATCH] D67567: [clang-tidy] New check to warn when storing dispatch_once_t in non-static, non-global storage

2019-09-26 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

I had a fix, but I was too slow. Here's what you need for the reland: 
http://codepad.org/3klmw1JV

The commit also broke sphinx with this:

  `
  6.290 [0/1/1] Generating html Sphinx documentation for clang-tools into 
"/home/buildbot/llvm-build-dir/clang-tools-sphinx-docs/llvm/build/tools/clang/tools/extra/docs/html"
  FAILED: tools/clang/tools/extra/docs/CMakeFiles/docs-clang-tools-html 
  cd 
/home/buildbot/llvm-build-dir/clang-tools-sphinx-docs/llvm/build/tools/clang/tools/extra/docs
 && /usr/bin/sphinx-build -b html -d 
/home/buildbot/llvm-build-dir/clang-tools-sphinx-docs/llvm/build/tools/clang/tools/extra/docs/_doctrees-clang-tools-html
 -q -W 
/home/buildbot/llvm-build-dir/clang-tools-sphinx-docs/llvm/src/tools/clang/tools/extra/docs
 
/home/buildbot/llvm-build-dir/clang-tools-sphinx-docs/llvm/build/tools/clang/tools/extra/docs/html
  
  Warning, treated as error:
  
/home/buildbot/llvm-build-dir/clang-tools-sphinx-docs/llvm/src/tools/clang/tools/extra/docs/ReleaseNotes.rst:82:
 WARNING: Inline interpreted text or phrase reference start-string without 
end-string.

Please try to fix that for the reland as well :)


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67567



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


[PATCH] D67567: [clang-tidy] New check to warn when storing dispatch_once_t in non-static, non-global storage

2019-09-26 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

Sorry, I reverted it in r373032 because the test fails on Linux: 
http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/18323 . Could 
you please take a look? Thanks!


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67567



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


[clang-tools-extra] r373032 - Revert "[clang-tidy] New check to warn when storing dispatch_once_t in non-static, non-global storage"

2019-09-26 Thread Dmitri Gribenko via cfe-commits
Author: gribozavr
Date: Thu Sep 26 16:28:31 2019
New Revision: 373032

URL: http://llvm.org/viewvc/llvm-project?rev=373032&view=rev
Log:
Revert "[clang-tidy] New check to warn when storing dispatch_once_t in 
non-static, non-global storage"

This reverts commit r373028, because the new test fails on Linux.

Removed:
clang-tools-extra/trunk/clang-tidy/darwin/

clang-tools-extra/trunk/docs/clang-tidy/checks/darwin-dispatch-once-nonstatic.rst
clang-tools-extra/trunk/test/clang-tidy/darwin-dispatch-once-nonstatic.mm
Modified:
clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h
clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/CMakeLists.txt?rev=373032&r1=373031&r2=373032&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/CMakeLists.txt Thu Sep 26 16:28:31 2019
@@ -43,7 +43,6 @@ add_subdirectory(boost)
 add_subdirectory(bugprone)
 add_subdirectory(cert)
 add_subdirectory(cppcoreguidelines)
-add_subdirectory(darwin)
 add_subdirectory(fuchsia)
 add_subdirectory(google)
 add_subdirectory(hicpp)

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h?rev=373032&r1=373031&r2=373032&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h Thu Sep 26 
16:28:31 2019
@@ -50,11 +50,6 @@ extern volatile int CppCoreGuidelinesMod
 static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination =
 CppCoreGuidelinesModuleAnchorSource;
 
-// This anchor is used to force the linker to link the DarwinModule.
-extern volatile int DarwinModuleAnchorSource;
-static int LLVM_ATTRIBUTE_UNUSED DarwinModuleAnchorDestination =
-DarwinModuleAnchorSource;
-
 // This anchor is used to force the linker to link the FuchsiaModule.
 extern volatile int FuchsiaModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED FuchsiaModuleAnchorDestination =

Modified: clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt?rev=373032&r1=373031&r2=373032&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt Thu Sep 26 
16:28:31 2019
@@ -14,7 +14,6 @@ add_clang_library(clangTidyPlugin
   clangTidyBugproneModule
   clangTidyCERTModule
   clangTidyCppCoreGuidelinesModule
-  clangTidyDarwinModule
   clangTidyFuchsiaModule
   clangTidyGoogleModule
   clangTidyHICPPModule

Modified: clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt?rev=373032&r1=373031&r2=373032&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt Thu Sep 26 16:28:31 
2019
@@ -23,7 +23,6 @@ target_link_libraries(clang-tidy
   clangTidyBugproneModule
   clangTidyCERTModule
   clangTidyCppCoreGuidelinesModule
-  clangTidyDarwinModule
   clangTidyFuchsiaModule
   clangTidyGoogleModule
   clangTidyHICPPModule

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=373032&r1=373031&r2=373032&view=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Thu Sep 26 16:28:31 2019
@@ -123,7 +123,6 @@ add_clang_library(clangDaemon
   clangTidyBugproneModule
   clangTidyCERTModule
   clangTidyCppCoreGuidelinesModule
-  clangTidyDarwinModule
   clangTidyFuchsiaModule
   clangTidyGoogleModule
   clangTidyHICPPModule

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=373032&r1=373031&r2=373032&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Thu Se

[clang-tools-extra] r373028 - [clang-tidy] New check to warn when storing dispatch_once_t in non-static, non-global storage

2019-09-26 Thread Stephane Moore via cfe-commits
Author: stephanemoore
Date: Thu Sep 26 16:04:59 2019
New Revision: 373028

URL: http://llvm.org/viewvc/llvm-project?rev=373028&view=rev
Log:
[clang-tidy] New check to warn when storing dispatch_once_t in non-static, 
non-global storage

Summary:
Creates a new darwin ClangTidy module and adds the 
darwin-dispatch-once-nonstatic check that warns about dispatch_once_t variables 
not in static or global storage. This catches a missing static for local 
variables in e.g. singleton initialization behavior, and also warns on storing 
dispatch_once_t values in Objective-C instance variables. C/C++ struct/class 
instances may potentially live in static/global storage, and are ignored for 
this check.

The osx.API static analysis checker can find the non-static storage use of 
dispatch_once_t; I thought it useful to also catch this issue in clang-tidy 
when possible.

Contributed By: mwyman

Reviewers: benhamilton, hokein, stephanemoore, aaron.ballman, gribozavr

Reviewed By: stephanemoore, gribozavr

Subscribers: jkorous, arphaman, kadircet, usaxena95, NoQ, xazax.hun, 
lebedev.ri, mgorny, cfe-commits

Tags: #clang, #clang-tools-extra

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

Added:
clang-tools-extra/trunk/clang-tidy/darwin/
clang-tools-extra/trunk/clang-tidy/darwin/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/darwin/DarwinTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/darwin/DispatchOnceNonstaticCheck.cpp
clang-tools-extra/trunk/clang-tidy/darwin/DispatchOnceNonstaticCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/darwin-dispatch-once-nonstatic.rst
clang-tools-extra/trunk/test/clang-tidy/darwin-dispatch-once-nonstatic.mm
Modified:
clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h
clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/CMakeLists.txt?rev=373028&r1=373027&r2=373028&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/CMakeLists.txt Thu Sep 26 16:04:59 2019
@@ -43,6 +43,7 @@ add_subdirectory(boost)
 add_subdirectory(bugprone)
 add_subdirectory(cert)
 add_subdirectory(cppcoreguidelines)
+add_subdirectory(darwin)
 add_subdirectory(fuchsia)
 add_subdirectory(google)
 add_subdirectory(hicpp)

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h?rev=373028&r1=373027&r2=373028&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h Thu Sep 26 
16:04:59 2019
@@ -50,6 +50,11 @@ extern volatile int CppCoreGuidelinesMod
 static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination =
 CppCoreGuidelinesModuleAnchorSource;
 
+// This anchor is used to force the linker to link the DarwinModule.
+extern volatile int DarwinModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED DarwinModuleAnchorDestination =
+DarwinModuleAnchorSource;
+
 // This anchor is used to force the linker to link the FuchsiaModule.
 extern volatile int FuchsiaModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED FuchsiaModuleAnchorDestination =

Added: clang-tools-extra/trunk/clang-tidy/darwin/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/darwin/CMakeLists.txt?rev=373028&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/darwin/CMakeLists.txt (added)
+++ clang-tools-extra/trunk/clang-tidy/darwin/CMakeLists.txt Thu Sep 26 
16:04:59 2019
@@ -0,0 +1,15 @@
+set(LLVM_LINK_COMPONENTS support)
+
+add_clang_library(clangTidyDarwinModule
+  DarwinTidyModule.cpp
+  DispatchOnceNonstaticCheck.cpp
+
+  LINK_LIBS
+  clangAnalysis
+  clangAST
+  clangASTMatchers
+  clangBasic
+  clangLex
+  clangTidy
+  clangTidyUtils
+  )

Added: clang-tools-extra/trunk/clang-tidy/darwin/DarwinTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/darwin/DarwinTidyModule.cpp?rev=373028&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/darwin/DarwinTidyModule.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/darwin/DarwinTidyModule.cpp Thu Sep 26 
16:04:59 2019
@@ -0,0 +1,37 @@
+//===--- MiscTidyModule.cpp - clang-tidy 
--

[PATCH] D67567: [clang-tidy] New check to warn when storing dispatch_once_t in non-static, non-global storage

2019-09-26 Thread Stephane Moore via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373028: [clang-tidy] New check to warn when storing 
dispatch_once_t in non-static, non… (authored by stephanemoore, committed by ).
Herald added subscribers: llvm-commits, ilya-biryukov.
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D67567?vs=222036&id=222043#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67567

Files:
  clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h
  clang-tools-extra/trunk/clang-tidy/darwin/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/darwin/DarwinTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/darwin/DispatchOnceNonstaticCheck.cpp
  clang-tools-extra/trunk/clang-tidy/darwin/DispatchOnceNonstaticCheck.h
  clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/trunk/clangd/CMakeLists.txt
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/darwin-dispatch-once-nonstatic.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/test/clang-tidy/darwin-dispatch-once-nonstatic.mm

Index: clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h
===
--- clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h
@@ -50,6 +50,11 @@
 static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination =
 CppCoreGuidelinesModuleAnchorSource;
 
+// This anchor is used to force the linker to link the DarwinModule.
+extern volatile int DarwinModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED DarwinModuleAnchorDestination =
+DarwinModuleAnchorSource;
+
 // This anchor is used to force the linker to link the FuchsiaModule.
 extern volatile int FuchsiaModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED FuchsiaModuleAnchorDestination =
Index: clang-tools-extra/trunk/clang-tidy/darwin/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/darwin/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/darwin/CMakeLists.txt
@@ -0,0 +1,15 @@
+set(LLVM_LINK_COMPONENTS support)
+
+add_clang_library(clangTidyDarwinModule
+  DarwinTidyModule.cpp
+  DispatchOnceNonstaticCheck.cpp
+
+  LINK_LIBS
+  clangAnalysis
+  clangAST
+  clangASTMatchers
+  clangBasic
+  clangLex
+  clangTidy
+  clangTidyUtils
+  )
Index: clang-tools-extra/trunk/clang-tidy/darwin/DispatchOnceNonstaticCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/darwin/DispatchOnceNonstaticCheck.h
+++ clang-tools-extra/trunk/clang-tidy/darwin/DispatchOnceNonstaticCheck.h
@@ -0,0 +1,35 @@
+//===--- DispatchOnceNonstaticCheck.h - clang-tidy --*- 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
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_DARWIN_DISPATCHONCENONSTATICCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_DARWIN_DISPATCHONCENONSTATICCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace darwin {
+
+/// Finds variables of type dispatch_once_t that do not have static or global
+/// storage duration, as required by the libdispatch documentation.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/darwin-dispatch-once-nonstatic.html
+class DispatchOnceNonstaticCheck : public ClangTidyCheck {
+public:
+  DispatchOnceNonstaticCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace darwin
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_DARWIN_DISPATCHONCENONSTATICCHECK_H
Index: clang-tools-extra/trunk/clang-tidy/darwin/DispatchOnceNonstaticCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/darwin/DispatchOnceNonstaticCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/darwin/DispatchOnceNonstaticCheck.cpp
@@ -0,0 +1,62 @@
+//===--- DispatchOnceNonstaticCheck.cpp - clang-tidy --===//
+//
+// 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
+/

[PATCH] D67567: [clang-tidy] New check to warn when storing dispatch_once_t in non-static, non-global storage

2019-09-26 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore added a comment.

It looks like everything is in order. I will proceed with landing the patch on 
your behalf 👍


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

https://reviews.llvm.org/D67567



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


[PATCH] D67978: [OpenMP 5.0] Fix user-defined mapper lookup in sema

2019-09-26 Thread Michael Kruse via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373023: [OpenMP 5.0] Fix user-defined mapper lookup in sema 
(authored by Meinersbur, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67978?vs=221991&id=222041#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67978

Files:
  cfe/trunk/lib/Sema/SemaOpenMP.cpp
  cfe/trunk/test/OpenMP/declare_mapper_messages.c
  cfe/trunk/test/OpenMP/declare_mapper_messages.cpp

Index: cfe/trunk/test/OpenMP/declare_mapper_messages.cpp
===
--- cfe/trunk/test/OpenMP/declare_mapper_messages.cpp
+++ cfe/trunk/test/OpenMP/declare_mapper_messages.cpp
@@ -64,6 +64,7 @@
 {
 #pragma omp declare mapper(id: vec v) map(v.len)
   vec vv, v1;
+  vec arr[10];
 #pragma omp target map(mapper)  // expected-error {{use of undeclared identifier 'mapper'}}
   {}
 #pragma omp target map(mapper:vv)   // expected-error {{expected '(' after 'mapper'}}
@@ -82,7 +83,9 @@
   {}
 #pragma omp target map(mapper(N1::aa) alloc:vv) // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'aa'}}
   {}
-#pragma omp target map(mapper(aa) to:vv) map(close mapper(aa) from:v1)
+#pragma omp target map(mapper(N1::aa) alloc:arr[0:2])   // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'aa'}}
+  {}
+#pragma omp target map(mapper(aa) to:vv) map(close mapper(aa) from:v1) map(mapper(aa) to:arr[0])
   {}
 #pragma omp target map(mapper(N1::stack::id) to:vv)
   {}
@@ -96,8 +99,9 @@
 #pragma omp target update to(mapper(N1:: :vv)   // expected-error {{illegal OpenMP user-defined mapper identifier}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update to(mapper(N1::aa) :vv)// expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'aa'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update to(mapper(ab):vv) // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'ab'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to(mapper(ab):arr[0:2])   // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'ab'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update to(mapper(aa) a:vv)   // expected-warning {{missing ':' after ) - ignoring}}
-#pragma omp target update to(mapper(aa):vv)
+#pragma omp target update to(mapper(aa):vv) to(mapper(aa):arr[0])
 #pragma omp target update to(mapper(N1::stack::id) :vv)
 
 #pragma omp target update from(mapper)  // expected-error {{expected '(' after 'mapper'}} expected-error {{expected expression}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
@@ -109,8 +113,9 @@
 #pragma omp target update from(mapper(N1:: :vv) // expected-error {{illegal OpenMP user-defined mapper identifier}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update from(mapper(N1::aa) :vv)  // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'aa'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update from(mapper(ab):vv)   // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'ab'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update from(mapper(ab):arr[0:2]) // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'ab'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update from(mapper(aa) a:vv) // expected-warning {{missing ':' after ) - ignoring}}
-#pragma omp target update from(mapper(aa):vv)
+#pragma omp target update from(mapper(aa):vv) from(mapper(aa):arr[0])
 #pragma omp target update from(mapper(N1::stack::id) :vv)
 }
 #pragma omp declare mapper(id: vec v) map(v.len)   

r373023 - [OpenMP 5.0] Fix user-defined mapper lookup in sema

2019-09-26 Thread Michael Kruse via cfe-commits
Author: meinersbur
Date: Thu Sep 26 15:53:01 2019
New Revision: 373023

URL: http://llvm.org/viewvc/llvm-project?rev=373023&view=rev
Log:
[OpenMP 5.0] Fix user-defined mapper lookup in sema

This patches fixes the case when a user-defined mapper is attached to
the elements of an array, and to report error when a mapper is used for
types other than struct, class, and union.

Patch by Lingda Li 

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

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

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=373023&r1=373022&r2=373023&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Sep 26 15:53:01 2019
@@ -14754,6 +14754,11 @@ static ExprResult buildUserDefinedMapper
 Expr *UnresolvedMapper) {
   if (MapperIdScopeSpec.isInvalid())
 return ExprError();
+  // Get the actual type for the array type.
+  if (Type->isArrayType()) {
+assert(Type->getAsArrayTypeUnsafe() && "Expect to get a valid array type");
+Type = Type->getAsArrayTypeUnsafe()->getElementType().getCanonicalType();
+  }
   // Find all user-defined mappers with the given MapperId.
   SmallVector, 4> Lookups;
   LookupResult Lookup(SemaRef, MapperId, Sema::LookupOMPMapperName);
@@ -14800,11 +14805,14 @@ static ExprResult buildUserDefinedMapper
 MapperIdScopeSpec.getWithLocInContext(SemaRef.Context), MapperId,
 /*ADL=*/false, /*Overloaded=*/true, URS.begin(), URS.end());
   }
+  SourceLocation Loc = MapperId.getLoc();
   // [OpenMP 5.0], 2.19.7.3 declare mapper Directive, Restrictions
   //  The type must be of struct, union or class type in C and C++
-  if (!Type->isStructureOrClassType() && !Type->isUnionType())
-return ExprEmpty();
-  SourceLocation Loc = MapperId.getLoc();
+  if (!Type->isStructureOrClassType() && !Type->isUnionType() &&
+  (MapperIdScopeSpec.isSet() || MapperId.getAsString() != "default")) {
+SemaRef.Diag(Loc, diag::err_omp_mapper_wrong_type);
+return ExprError();
+  }
   // Perform argument dependent lookup.
   if (SemaRef.getLangOpts().CPlusPlus && !MapperIdScopeSpec.isSet())
 argumentDependentLookup(SemaRef, MapperId, Loc, Type, Lookups);

Modified: cfe/trunk/test/OpenMP/declare_mapper_messages.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_mapper_messages.c?rev=373023&r1=373022&r2=373023&view=diff
==
--- cfe/trunk/test/OpenMP/declare_mapper_messages.c (original)
+++ cfe/trunk/test/OpenMP/declare_mapper_messages.c Thu Sep 26 15:53:01 2019
@@ -36,6 +36,8 @@ int fun(int arg) {
 {
 #pragma omp declare mapper(id: struct vec v) map(v.len) allocate(v)   // 
expected-error {{unexpected OpenMP clause 'allocate' in directive '#pragma omp 
declare mapper'}}
   struct vec vv, v1;
+  struct vec arr[10];
+  double d;
 #pragma omp target map(mapper)  // 
expected-error {{use of undeclared identifier 'mapper'}}
   {}
 #pragma omp target map(mapper:vv)   // 
expected-error {{expected '(' after 'mapper'}}
@@ -46,9 +48,13 @@ int fun(int arg) {
   {}
 #pragma omp target map(mapper(ab) :vv)  // 
expected-error {{missing map type}} expected-error {{cannot find a valid 
user-defined mapper for type 'struct vec' with name 'ab'}}
   {}
+#pragma omp target map(mapper(ab) :arr[0:2])// 
expected-error {{missing map type}} expected-error {{cannot find a valid 
user-defined mapper for type 'struct vec' with name 'ab'}}
+  {}
 #pragma omp target map(mapper(aa) :vv)  // 
expected-error {{missing map type}}
   {}
-#pragma omp target map(mapper(aa) to:vv) map(close mapper(aa) from:v1)
+#pragma omp target map(mapper(aa) to:d) // 
expected-error {{mapper type must be of struct, union or class type}}
+  {}
+#pragma omp target map(mapper(aa) to:vv) map(close mapper(aa) from:v1) 
map(mapper(aa) to:arr[0])
   {}
 
 #pragma omp target update to(mapper)// 
expected-error {{expected '(' after 'mapper'}} expected-error {{expected 
expression}} expected-error {{expected at least one 'to' clause or 'from' 
clause specified to '#pragma omp target update'}}
@@ -57,7 +63,10 @@ int fun(int arg) {
 #pragma omp target update to(mapper(:vv)// 
expected-error {{illegal OpenMP user-defined mapper identifier}} expected-error 
{{expected at least one 'to' clause or 'from' clause specified to '#pragma omp 
target update'}}
 #pragma omp tar

[PATCH] D67567: [clang-tidy] New check to warn when storing dispatch_once_t in non-static, non-global storage

2019-09-26 Thread Michael Wyman via Phabricator via cfe-commits
mwyman updated this revision to Diff 222036.
mwyman marked 4 inline comments as done.
mwyman added a comment.

Addressed Stephane's review feedback.


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

https://reviews.llvm.org/D67567

Files:
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
  clang-tools-extra/clang-tidy/darwin/CMakeLists.txt
  clang-tools-extra/clang-tidy/darwin/DarwinTidyModule.cpp
  clang-tools-extra/clang-tidy/darwin/DispatchOnceNonstaticCheck.cpp
  clang-tools-extra/clang-tidy/darwin/DispatchOnceNonstaticCheck.h
  clang-tools-extra/clang-tidy/plugin/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/darwin-dispatch-once-nonstatic.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/darwin-dispatch-once-nonstatic.mm

Index: clang-tools-extra/test/clang-tidy/darwin-dispatch-once-nonstatic.mm
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/darwin-dispatch-once-nonstatic.mm
@@ -0,0 +1,48 @@
+// RUN: %check_clang_tidy %s darwin-dispatch-once-nonstatic %t
+
+typedef int dispatch_once_t;
+extern void dispatch_once(dispatch_once_t *pred, void(^block)(void));
+
+
+void bad_dispatch_once(dispatch_once_t once, void(^block)(void)) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: dispatch_once_t variables must have static or global storage duration; function parameters should be pointer references [darwin-dispatch-once-nonstatic]
+
+// file-scope dispatch_once_ts have static storage duration.
+dispatch_once_t global_once;
+static dispatch_once_t file_static_once;
+namespace {
+dispatch_once_t anonymous_once;
+} // end anonymous namespace
+
+int Correct(void) {
+  static int value;
+  static dispatch_once_t once;
+  dispatch_once(&once, ^{
+value = 1;
+  });
+  return value;
+}
+
+int Incorrect(void) {
+  static int value;
+  dispatch_once_t once;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: dispatch_once_t variables must have static or global storage duration [darwin-dispatch-once-nonstatic]
+  // CHECK-FIXES: static dispatch_once_t once;
+  dispatch_once(&once, ^{
+value = 1;
+  });
+  return value;
+}
+
+struct OnceStruct {
+  static dispatch_once_t staticOnce; // Allowed
+  int value;
+  dispatch_once_t once;  // Allowed (at this time)
+};
+
+@interface MyObject {
+  dispatch_once_t _once;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: dispatch_once_t variables must have static or global storage duration and cannot be Objective-C instance variables [darwin-dispatch-once-nonstatic]
+  // CHECK-FIXES: dispatch_once_t _once;
+}
+@end
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -212,6 +212,7 @@
cppcoreguidelines-pro-type-vararg
cppcoreguidelines-slicing
cppcoreguidelines-special-member-functions
+   darwin-dispatch-once-nonstatic
fuchsia-default-arguments-calls
fuchsia-default-arguments-declarations
fuchsia-header-anon-namespaces (redirects to google-build-namespaces) 
Index: clang-tools-extra/docs/clang-tidy/checks/darwin-dispatch-once-nonstatic.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/darwin-dispatch-once-nonstatic.rst
@@ -0,0 +1,22 @@
+.. title:: clang-tidy - darwin-dispatch-once-nonstatic
+
+darwin-dispatch-once-nonstatic
+==
+
+Finds declarations of ``dispatch_once_t`` variables without static or global
+storage. The behavior of using ``dispatch_once_t`` predicates with automatic or
+dynamic storage is undefined by libdispatch, and should be avoided.
+
+It is a common pattern to have functions initialize internal static or global
+data once when the function runs, but programmers have been known to miss the
+static on the ``dispatch_once_t`` predicate, leading to an uninitialized flag
+value at the mercy of the stack.
+
+Programmers have also been known to make ``dispatch_once_t`` variables be
+members of structs or classes, with the intent to lazily perform some expensive
+struct or class member initialization only once; however, this violates the
+libdispatch requirements.
+
+See the discussion section of
+`Apple's dispatch_once documentation `_
+for more information.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -79,6 +79,12 @@
   Finds obvious infinite loops (loops where the condition variable is not
   changed

Re: r369999 - Don't lose the FoundDecl and template arguments for a DeclRefExpr in

2019-09-26 Thread Richard Smith via cfe-commits
On Wed, 25 Sep 2019 at 11:48, Peter Collingbourne via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi Richard, it looks like this commit caused an assertion failure on the
> following input:
>
> $ cat test2.ii
> # 2 "" 3
> namespace a {
> enum { b };
> }
> template  void c() {
>   auto d = [](auto) {
> using a::b;
> b;
>   };
>   d(0);
> }
> void e() { c; }
> $ clang test2.ii
> clang: ../clang/lib/Sema/SemaTemplateInstantiate.cpp:2985:
> llvm::PointerUnion
> *clang::LocalInstantiationScope::findInstantiationOf(const clang::Decl *):
> Assertion `isa(D) && "declaration not instantiated in this
> scope"' failed.
>
> Can you please take a look?
>

Thanks, great testcase. Fixed in r373022.


> Peter
>
> On Mon, Aug 26, 2019 at 6:04 PM Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Mon Aug 26 18:06:21 2019
>> New Revision: 36
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=36&view=rev
>> Log:
>> Don't lose the FoundDecl and template arguments for a DeclRefExpr in
>> TreeTransform.
>>
>> Modified:
>> cfe/trunk/lib/Sema/TreeTransform.h
>>
>> Modified: cfe/trunk/lib/Sema/TreeTransform.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=36&r1=369998&r2=36&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/TreeTransform.h (original)
>> +++ cfe/trunk/lib/Sema/TreeTransform.h Mon Aug 26 18:06:21 2019
>> @@ -2167,13 +2167,12 @@ public:
>>ExprResult RebuildDeclRefExpr(NestedNameSpecifierLoc QualifierLoc,
>>  ValueDecl *VD,
>>  const DeclarationNameInfo &NameInfo,
>> +NamedDecl *Found,
>>  TemplateArgumentListInfo *TemplateArgs) {
>>  CXXScopeSpec SS;
>>  SS.Adopt(QualifierLoc);
>> -
>> -// FIXME: loses template args.
>> -
>> -return getSema().BuildDeclarationNameExpr(SS, NameInfo, VD);
>> +return getSema().BuildDeclarationNameExpr(SS, NameInfo, VD, Found,
>> +  TemplateArgs);
>>}
>>
>>/// Build a new expression in parentheses.
>> @@ -9204,6 +9203,14 @@ TreeTransform::TransformDeclRef
>>if (!ND)
>>  return ExprError();
>>
>> +  NamedDecl *Found = ND;
>> +  if (E->getFoundDecl() != E->getDecl()) {
>> +Found = cast_or_null(
>> +getDerived().TransformDecl(E->getLocation(), E->getFoundDecl()));
>> +if (!Found)
>> +  return ExprError();
>> +  }
>> +
>>DeclarationNameInfo NameInfo = E->getNameInfo();
>>if (NameInfo.getName()) {
>>  NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
>> @@ -9236,7 +9243,7 @@ TreeTransform::TransformDeclRef
>>}
>>
>>return getDerived().RebuildDeclRefExpr(QualifierLoc, ND, NameInfo,
>> - TemplateArgs);
>> + Found, TemplateArgs);
>>  }
>>
>>  template
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
> --
> --
> Peter
> ___
> 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] D67414: [AST] Treat "inline gnu_inline" the same way as "extern inline gnu_inline" in C++ mode

2019-09-26 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Looks good to me, thanks.


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

https://reviews.llvm.org/D67414



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


r373022 - Always rebuild a DeclRefExpr if its FoundDecl would change.

2019-09-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Sep 26 15:28:32 2019
New Revision: 373022

URL: http://llvm.org/viewvc/llvm-project?rev=373022&view=rev
Log:
Always rebuild a DeclRefExpr if its FoundDecl would change.

Fixes a regression introduced by r36.

Added:
cfe/trunk/test/SemaTemplate/using-decl.cpp
Modified:
cfe/trunk/lib/Sema/TreeTransform.h

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=373022&r1=373021&r2=373022&view=diff
==
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Thu Sep 26 15:28:32 2019
@@ -9219,6 +9219,7 @@ TreeTransform::TransformDeclRef
   if (!getDerived().AlwaysRebuild() &&
   QualifierLoc == E->getQualifierLoc() &&
   ND == E->getDecl() &&
+  Found == E->getFoundDecl() &&
   NameInfo.getName() == E->getDecl()->getDeclName() &&
   !E->hasExplicitTemplateArgs()) {
 

Added: cfe/trunk/test/SemaTemplate/using-decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/using-decl.cpp?rev=373022&view=auto
==
--- cfe/trunk/test/SemaTemplate/using-decl.cpp (added)
+++ cfe/trunk/test/SemaTemplate/using-decl.cpp Thu Sep 26 15:28:32 2019
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -std=c++2a -verify %s
+// expected-no-diagnostics
+
+namespace UsingInGenericLambda {
+  namespace a {
+enum { b };
+  }
+  template void c() {
+auto d = [](auto) {
+  using a::b;
+  (void)b;
+};
+d(0);
+  }
+  void e() { c(); }
+}


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


[PATCH] D68049: Propeller: Clang options for basic block sections

2019-09-26 Thread Sriraman Tallam via Phabricator via cfe-commits
tmsriram marked 13 inline comments as done.
tmsriram added inline comments.



Comment at: clang/include/clang/Basic/CodeGenOptions.def:341
+CODEGENOPT(RelocateWithSymbols, 1, 0)
+
 /// Whether we should use the undefined behaviour optimization for control flow

mehdi_amini wrote:
> Can you add a doc here? (possibly referring to somewhere else if it is 
> extensively documented elsewhere?)
I am unable to find a doc for this.  I added comments on this based on what 
"shouldRelocateWithSymbol" in ELFObjectWriter does and why it prefers 
relocating with sections rather than symbols.



Comment at: clang/include/clang/Driver/Options.td:1873
+def fbasicblock_sections_EQ : Joined<["-"], "fbasicblock-sections=">, 
Group, Flags<[CC1Option, CC1AsOption]>,
+  HelpText<"Place each function's basic blocks in unique sections (ELF Only) : 
all | labels | none | ">;
 def fdata_sections : Flag <["-"], "fdata-sections">, Group,

mehdi_amini wrote:
> Is the "labels" options dependent/related to the previous -fpropeller-label 
> one?
Yes, -fpropeller-label is the umbrella propeller option that turns on 
-fbasicblock-sections=labels.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:348
+Twine NewName = Section + Name;
+Fn->setSection(NewName.str());
+  }

mehdi_amini wrote:
> Is this related to these new option? It this change the behavior of 
> -ffunction-sections?
Yes, this is related to function sections getting it right which is important 
for Propeller.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:1032
 }
-
+  }
   return Out.str();

mehdi_amini wrote:
> I agree with the improvement, but as nit this isn't related to the current 
> patch or even in a function you're otherwise touching. (it creates an extra 
> hunk in the review)
Removed it and will add it independently.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:1103
+  dyn_cast(GD.getDecl()) &&
+  this->getFunctionLinkage(GD) == llvm::GlobalValue::InternalLinkage) {
+std::string UniqueSuffix = getUniqueModuleId(&getModule(), true);

MaskRay wrote:
> ```
>   if (getCodeGenOpts().UniqueInternalFuncNames &&
>   isa(GD.getDecl()) &&
>   getFunctionLinkage(GD) == llvm::GlobalValue::InternalLinkage) {
> ```
> 
> How does it interop with `MangledName = 
> getCUDARuntime().getDeviceStubName(MangledName);` below?
The .stub will be suffixed and it will demangle correctly.



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:631
+if (A->getOption().matches(options::OPT_fpropeller_optimize_EQ)) {
+  if (!Args.getLastArgValue(options::OPT_fuse_ld_EQ).equals_lower("lld"))
+D.Diag(clang::diag::err_drv_unsupported_opt)

MaskRay wrote:
> This check is overly constrained. Some systems default to use lld (e.g. 
> installed at /usr/bin/ld). I suggest removing this check.
I see what you mean, can we follow this up in some manner with a check to see 
if the underlying linker supports Propeller?  



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:640
+  CmdArgs.push_back("--optimize-bb-jumps");
+  CmdArgs.push_back("--no-call-graph-profile-sort");
+  CmdArgs.push_back("-z");

MaskRay wrote:
> Why --no-call-graph-profile-sort?
Call graph profile sort conflicts with the reordering we do and cannot be on at 
the same time.  We have plans to merge the two, so until then.



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:642
+  CmdArgs.push_back("-z");
+  CmdArgs.push_back("nokeep-text-section-prefix");
+  CmdArgs.push_back("--no-warn-symbol-ordering");

MaskRay wrote:
> This will silently ignore user specified `-z keep-text-section-prefix`.
> 
> With `-z nokeep-text-section-prefix`, an input section `.text.hot.foo` will 
> go to the output section `.text`, instead of `.text.hot`. Why do you need the 
> option?
We are planning to restore keep-text-section-prefix in some manner with 
Propeller.  Since propeller shuffles sections what is hot is not clearly 
defined by a prefix so this option won't make sense with Propeller.  We will 
use a heuristic to compute hotness and then regenerate the section markers in 
the final binary.  


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

https://reviews.llvm.org/D68049



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


[PATCH] D68049: Propeller: Clang options for basic block sections

2019-09-26 Thread Sriraman Tallam via Phabricator via cfe-commits
tmsriram updated this revision to Diff 222035.
tmsriram added a comment.

Updated patch to address the comments.


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

https://reviews.llvm.org/D68049

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/basicblock-sections.c
  clang/test/CodeGen/basicblock-sections.funcnames
  clang/test/CodeGen/unique_internal_funcnames.c
  clang/test/Driver/propeller-flags.c
  clang/tools/driver/cc1as_main.cpp

Index: clang/tools/driver/cc1as_main.cpp
===
--- clang/tools/driver/cc1as_main.cpp
+++ clang/tools/driver/cc1as_main.cpp
@@ -90,6 +90,7 @@
   unsigned SaveTemporaryLabels : 1;
   unsigned GenDwarfForAssembly : 1;
   unsigned RelaxELFRelocations : 1;
+  unsigned RelocateWithSymbols : 1;
   unsigned DwarfVersion;
   std::string DwarfDebugFlags;
   std::string DwarfDebugProducer;
@@ -236,6 +237,7 @@
   }
 
   Opts.RelaxELFRelocations = Args.hasArg(OPT_mrelax_relocations);
+  Opts.RelocateWithSymbols = Args.hasArg(OPT_mrelocate_with_symbols);
   Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 2, Diags);
   Opts.DwarfDebugFlags = Args.getLastArgValue(OPT_dwarf_debug_flags);
   Opts.DwarfDebugProducer = Args.getLastArgValue(OPT_dwarf_debug_producer);
@@ -361,6 +363,7 @@
   MAI->setCompressDebugSections(Opts.CompressDebugSections);
 
   MAI->setRelaxELFRelocations(Opts.RelaxELFRelocations);
+  MAI->setRelocateWithSymbols(Opts.RelocateWithSymbols);
 
   bool IsBinary = Opts.OutputType == AssemblerInvocation::FT_Obj;
   if (Opts.OutputPath.empty())
Index: clang/test/Driver/propeller-flags.c
===
--- /dev/null
+++ clang/test/Driver/propeller-flags.c
@@ -0,0 +1,13 @@
+// Check that -fpropeller flag invokes the correct options.
+// RUN: %clang -### %s -target x86_64-unknown-linux -fpropeller-label -flto=thin 2>&1 | FileCheck %s -check-prefix=CHECK_PROPELLER_LABEL
+// RUN: %clang -### %s -target x86_64-unknown-linux -fpropeller-optimize=perf.propeller -flto=thin 2>&1 | FileCheck %s -check-prefix=CHECK_PROPELLER_OPT
+
+// CHECK_PROPELLER_LABEL: "-fbasicblock-sections=labels"
+// CHECK_PROPELLER_LABEL: "-funique-internal-funcnames"
+// CHECK_PROPELLER_LABEL: "--lto-basicblock-sections=labels"
+//
+// CHECK_PROPELLER_OPT: "-fbasicblock-sections=perf.propeller"
+// CHECK_PROPELLER_OPT: "-funique-internal-funcnames"
+// CHECK_PROPELLER_OPT: "--propeller=perf.propeller"
+// CHECK_PROPELLER_OPT: "--lto-basicblock-sections=perf.propeller"
+// CHECK_PROPELLER_OPT: "--optimize-bb-jumps"
Index: clang/test/CodeGen/unique_internal_funcnames.c
===
--- /dev/null
+++ clang/test/CodeGen/unique_internal_funcnames.c
@@ -0,0 +1,18 @@
+// REQUIRES: x86-registered-target
+
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -o - < %s | FileCheck %s --check-prefix=PLAIN
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -funique-internal-funcnames -fno-unique-internal-funcnames -o - < %s | FileCheck %s --check-prefix=PLAIN
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -funique-internal-funcnames -o - < %s | FileCheck %s --check-prefix=UNIQUE
+
+
+static int foo() {
+  return 0;
+}
+
+int (*bar()) () {
+   return foo;
+}
+
+// PLAIN: foo:
+// UNIQUE-NOT: foo:
+// UNIQUE: foo.$
Index: clang/test/CodeGen/basicblock-sections.funcnames
===
--- /dev/null
+++ clang/test/CodeGen/basicblock-sections.funcnames
@@ -0,0 +1 @@
+!world
Index: clang/test/CodeGen/basicblock-sections.c
===
--- /dev/null
+++ clang/test/CodeGen/basicblock-sections.c
@@ -0,0 +1,47 @@
+// REQUIRES: x86-registered-target
+
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -o - < %s | FileCheck %s --check-prefix=PLAIN
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fbasicblock-sections=all -fbasicblock-sections=none -o - < %s | FileCheck %s --check-prefix=PLAIN
+
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fbasicblock-sections=labels -o - < %s | FileCheck %s --check-prefix=BB_LABELS
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fbasicblock-sections=all -o - < %s | FileCheck %s --check-prefix=BB_WORLD --check-prefix=BB_ALL
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fbasicblock-sections=%S/basicblock-sections.funcnames -o - < %s | FileCheck %s --check-prefix=BB_WORLD --check-prefix=BB_LIST
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fbasicblock-sections=all -funique-bb-section-names -

[PATCH] D65543: [Windows] Autolink with basenames and add libdir to libpath

2019-09-26 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I happened to notice that I felt the same way about this in 2014 that I do 
today:
https://reviews.llvm.org/D4428#56536
That makes me feel like I should keep pushing for this change, even though so 
far people don't seem enthusiastic about it. :)

I changed the driver to add the library path to the link line when the driver 
is used to link. This fixes the vanilla GCC-style driver usage in the ubsan 
test suite.

Obviously, most users of clang-cl don't use clang-cl to link, so they won't get 
this behavior, but in the absence of documentation, it shows how things are 
intended to work. Chromium already happens to put clang's library directory on 
the link line, so everything should work for them.

Does this seem like reasonable behavior for now? I'd modify the msbuild 
integration myself to make this stuff work out of the box, but I honestly don't 
know how to test it or change it. The other thing worth checking is the clang 
PGO self-host on Windows. This has the potential to break that, and the fix 
would be to add a linker flag in LLVM's cmake.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65543



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


[PATCH] D67567: [clang-tidy] New check to warn when storing dispatch_once_t in non-static, non-global storage

2019-09-26 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore added a comment.

> Does the check allow variables in anonymous namespaces?
> 
>   namespace {
>   dispatch_once_t onceToken;
>   }
> 
> 
> I //think// such variables should satisfy initialization requirements.
> 
> If not, can we update the check to not trigger on variables? Either way, can 
> we add a test to verify behavior for variables in anonymous namespaces?

Nevermind, I overlooked that there is already a variable in an anonymous 
namespace in the test 😅 Thanks for that!


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

https://reviews.llvm.org/D67567



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


[PATCH] D67647: [Consumed] Refactor handleCall to take function argument list. NFC.

2019-09-26 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: llvm/include/llvm/ADT/iterator_range.h:27-33
+template 
+constexpr bool is_random_iterator() {
+  return std::is_same<
+typename std::iterator_traits::iterator_category,
+std::random_access_iterator_tag>::value;
+}
+

comex wrote:
> dblaikie wrote:
> > Is this how the C++ standard is doing things these days? Or is it usually 
> > done with variable templates?
> "Type trait"-like things have gone through three different evolutions:
> 
> - C++11 struct templates: `std::is_integral::value`
> - C++17 variable templates: `std::is_integral_v`
> - C++20 concepts: `std::integral`
> 
> In fact, the C++20 draft has a `random_access_iterator` concept, though 
> there is no `is_random_access_iterator` in prior versions.
> 
> However, with LLVM still built as C++11, this helper has to be a struct 
> template or a constexpr function.  It seemed a bit simpler to use a constexpr 
> function, since template specialization wasn't needed.
Fair enough - thanks for the details :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67647



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


[PATCH] D67567: [clang-tidy] New check to warn when storing dispatch_once_t in non-static, non-global storage

2019-09-26 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore added a comment.

Looks good! A couple nits/questions.

Does the check allow variables in anonymous namespaces?

  namespace {
  dispatch_once_t onceToken;
  }

I //think// such variables should satisfy initialization requirements.

If not, can we update the check to not trigger on variables? Either way, can we 
add a test to verify behavior for variables in anonymous namespaces?




Comment at: clang-tools-extra/clang-tidy/darwin/CMakeLists.txt:13
+  clangLex
+  clangSerialization
+  clangTidy

Is this library necessary?



Comment at: clang-tools-extra/clang-tidy/darwin/CMakeLists.txt:16
+  clangTidyUtils
+  clangTooling
+  )

Is this library necessary?



Comment at: 
clang-tools-extra/clang-tidy/darwin/DispatchOnceNonstaticCheck.cpp:44
+  diag(PD->getTypeSpecStartLoc(),
+   "dispatch_once_ts must have static or global storage duration; "
+   "function parameters should be pointer references");

"dispatch_once_t variables" to be consistent.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/darwin-dispatch-once-nonstatic.rst:15
+
+Programmers have also been known to make ``dispatch_once_t``s be members of
+structs/classes, with the intent to lazily perform some expensive struct or

Maybe rephrase to this:
```
``dispatch_once_t`` variables
```



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/darwin-dispatch-once-nonstatic.rst:16
+Programmers have also been known to make ``dispatch_once_t``s be members of
+structs/classes, with the intent to lazily perform some expensive struct or
+class member initialization only once; however, this violates the libdispatch

"structs or classes"


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

https://reviews.llvm.org/D67567



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


[PATCH] D67647: [Consumed] Refactor handleCall to take function argument list. NFC.

2019-09-26 Thread Nicholas Allegra via Phabricator via cfe-commits
comex marked 2 inline comments as done.
comex added inline comments.



Comment at: llvm/include/llvm/ADT/iterator_range.h:27-33
+template 
+constexpr bool is_random_iterator() {
+  return std::is_same<
+typename std::iterator_traits::iterator_category,
+std::random_access_iterator_tag>::value;
+}
+

dblaikie wrote:
> Is this how the C++ standard is doing things these days? Or is it usually 
> done with variable templates?
"Type trait"-like things have gone through three different evolutions:

- C++11 struct templates: `std::is_integral::value`
- C++17 variable templates: `std::is_integral_v`
- C++20 concepts: `std::integral`

In fact, the C++20 draft has a `random_access_iterator` concept, though 
there is no `is_random_access_iterator` in prior versions.

However, with LLVM still built as C++11, this helper has to be a struct 
template or a constexpr function.  It seemed a bit simpler to use a constexpr 
function, since template specialization wasn't needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67647



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


[PATCH] D67122: [UBSan][clang][compiler-rt] Applying non-zero offset to nullptr is undefined behaviour

2019-09-26 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:63
 
+* As per C++ and C Standards (C++: ``[expr.add]``; C17: 6.5.6p8), applying
+  non-zero offset to ``nullptr`` (or making non-``nullptr`` a ``nullptr``,

aaron.ballman wrote:
> rsmith wrote:
> > In C, even adding 0 to a null pointer is undefined. Did this change in C17?
> I don't see what words in the C standard make this UB. If it's 
> UB-by-omission, I think it's unintentional. I mean, this language allows 
> `&*some_null_pointer` without UB, so I would be really surprised if 
> `some_null_ptr + 0` was UB. Do you have a source in the C standard for the UB?
C11 6.5.6/8: "If both the pointer operand and the result point to elements of 
the same array object, or one past the last element of the array object, the 
evaluation shall not produce an overflow; otherwise, the behavior is undefined."

Pointer arithmetic in C11 is only defined if the pointer points to an array 
object (where per /7, a pointer to a non-array object is treated as a pointer 
to an array of length 1). So arithmetic on null pointers is undefined, even if 
you add zero. This rule was explicitly changed in C++ to permit adding zero to 
a null pointer. Similar analysis applies to taking the difference of two 
pointers, where C++ explicitly says `null_pointer - null_pointer` is zero and 
C11 says both pointers need to point to the same array object or you get 
undefined behavior (C11 6.5.6/9: "When two pointers are subtracted, both shall 
point to elements of the same array object, or one past the last element of the 
array object").

In contrast, C explicitly calls out the `&*null_pointer` case (C11 6.5.3.2/3: " 
If the operand is the result of a unary `*` operator, neither that operator nor 
the `&` operator is evaluated and the result is as if both were omitted"). The 
corresponding case is undefined in C++, but that's likely to be addressed by a 
defect report resolution (see http://wg21.link/cwg232).

I don't think these two things are all that closely related, though. The C 
model, as I understand it, is that the null pointer is not a pointer to any 
object, whereas the C++ model is as if there is an object of type `T[0]` at the 
null address for every object type `T`, and a null pointer to object type 
points to (== past the end of) that object. And the `&*` thing is just a very 
specific, weird C special case, and only applies to certain very specific 
syntactic forms (but that's OK in C, because there are only a very small number 
of syntactic forms for lvalues).



Comment at: 
clang/test/CodeGen/catch-nullptr-and-nonzero-offset-in-offsetof-idiom.c:14
+uintptr_t get_offset_of_y() {
+  // CHECK:  define i64 @{{.*}}() {{.*}} {
+  // CHECK-NEXT: [[ENTRY:.*]]:

lebedev.ri wrote:
> vsk wrote:
> > nit: CHECK-LABEL: define i64 @get_offset_of_y(
> No, because this runs both in C mode and in C++ mode, so the name may be 
> mangled.
`CHECK-LABEL: define i64 @{{.*}}get_offset_of_y{{.*}}(` ?

(Even if you don't add the function names, please do add the `-LABEL`.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67122



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


[PATCH] D67978: [OpenMP 5.0] Fix user-defined mapper lookup in sema

2019-09-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D67978#1684845 , @lildmh wrote:

> Thanks Alexey! Please check the other 2 mapper patches at 
> https://reviews.llvm.org/D67833 and https://reviews.llvm.org/D68100 when you 
> have time. They should be the last mapper patches.


Sure, will do this tomorrow.


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

https://reviews.llvm.org/D67978



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


[PATCH] D67978: [OpenMP 5.0] Fix user-defined mapper lookup in sema

2019-09-26 Thread Lingda Li via Phabricator via cfe-commits
lildmh added a comment.

Thanks Alexey! Please check the other 2 mapper patches at 
https://reviews.llvm.org/D67833 and https://reviews.llvm.org/D68100 when you 
have time. They should be the last mapper patches.


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

https://reviews.llvm.org/D67978



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


[PATCH] D67978: [OpenMP 5.0] Fix user-defined mapper lookup in sema

2019-09-26 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.




Comment at: lib/Sema/SemaOpenMP.cpp:14805
+  if (!Type->isStructureOrClassType() && !Type->isUnionType() &&
+  (MapperIdScopeSpec.isSet() || MapperId.getAsString() != "default")) {
+SemaRef.Diag(Loc, diag::err_omp_mapper_wrong_type);

lildmh wrote:
> ABataev wrote:
> > lildmh wrote:
> > > ABataev wrote:
> > > > lildmh wrote:
> > > > > ABataev wrote:
> > > > > > lildmh wrote:
> > > > > > > ABataev wrote:
> > > > > > > > Why need an additional check for scope and not "default" id? I 
> > > > > > > > don't see this additional requirement in the standard. 
> > > > > > > It's because every variable in map clauses will check this, 
> > > > > > > including those are not struct, class, or union.
> > > > > > > 
> > > > > > > Using this, e.g., mapping an integer won't report error that it 
> > > > > > > doesn't have a mapper.
> > > > > > Maybe just move the check to the end of the function?
> > > > > It will do some additional useless work if I move it to the end. I 
> > > > > don't think it is necessary to move it back.
> > > > > 
> > > > > But if you believe it's better, I can do it.
> > > > Could you add tests for this new functionality?
> > > I already add the test in declare_mapper_message.c. I think nothing is 
> > > needed for ast print test.
> > I mean, for this error message. I did not see the change in the tests when 
> > you added this new check.
> line 55, 68, 79 in declare_mapper_messages.c is added for this new check.
Ah, ok, found it, thanks!


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

https://reviews.llvm.org/D67978



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


[PATCH] D67978: [OpenMP 5.0] Fix user-defined mapper lookup in sema

2019-09-26 Thread Lingda Li via Phabricator via cfe-commits
lildmh marked an inline comment as done.
lildmh added inline comments.



Comment at: lib/Sema/SemaOpenMP.cpp:14805
+  if (!Type->isStructureOrClassType() && !Type->isUnionType() &&
+  (MapperIdScopeSpec.isSet() || MapperId.getAsString() != "default")) {
+SemaRef.Diag(Loc, diag::err_omp_mapper_wrong_type);

ABataev wrote:
> lildmh wrote:
> > ABataev wrote:
> > > lildmh wrote:
> > > > ABataev wrote:
> > > > > lildmh wrote:
> > > > > > ABataev wrote:
> > > > > > > Why need an additional check for scope and not "default" id? I 
> > > > > > > don't see this additional requirement in the standard. 
> > > > > > It's because every variable in map clauses will check this, 
> > > > > > including those are not struct, class, or union.
> > > > > > 
> > > > > > Using this, e.g., mapping an integer won't report error that it 
> > > > > > doesn't have a mapper.
> > > > > Maybe just move the check to the end of the function?
> > > > It will do some additional useless work if I move it to the end. I 
> > > > don't think it is necessary to move it back.
> > > > 
> > > > But if you believe it's better, I can do it.
> > > Could you add tests for this new functionality?
> > I already add the test in declare_mapper_message.c. I think nothing is 
> > needed for ast print test.
> I mean, for this error message. I did not see the change in the tests when 
> you added this new check.
line 55, 68, 79 in declare_mapper_messages.c is added for this new check.


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

https://reviews.llvm.org/D67978



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


[PATCH] D67978: [OpenMP 5.0] Fix user-defined mapper lookup in sema

2019-09-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Sema/SemaOpenMP.cpp:14805
+  if (!Type->isStructureOrClassType() && !Type->isUnionType() &&
+  (MapperIdScopeSpec.isSet() || MapperId.getAsString() != "default")) {
+SemaRef.Diag(Loc, diag::err_omp_mapper_wrong_type);

lildmh wrote:
> ABataev wrote:
> > lildmh wrote:
> > > ABataev wrote:
> > > > lildmh wrote:
> > > > > ABataev wrote:
> > > > > > Why need an additional check for scope and not "default" id? I 
> > > > > > don't see this additional requirement in the standard. 
> > > > > It's because every variable in map clauses will check this, including 
> > > > > those are not struct, class, or union.
> > > > > 
> > > > > Using this, e.g., mapping an integer won't report error that it 
> > > > > doesn't have a mapper.
> > > > Maybe just move the check to the end of the function?
> > > It will do some additional useless work if I move it to the end. I don't 
> > > think it is necessary to move it back.
> > > 
> > > But if you believe it's better, I can do it.
> > Could you add tests for this new functionality?
> I already add the test in declare_mapper_message.c. I think nothing is needed 
> for ast print test.
I mean, for this error message. I did not see the change in the tests when you 
added this new check.


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

https://reviews.llvm.org/D67978



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


[PATCH] D67978: [OpenMP 5.0] Fix user-defined mapper lookup in sema

2019-09-26 Thread Lingda Li via Phabricator via cfe-commits
lildmh marked an inline comment as done.
lildmh added inline comments.



Comment at: lib/Sema/SemaOpenMP.cpp:14805
+  if (!Type->isStructureOrClassType() && !Type->isUnionType() &&
+  (MapperIdScopeSpec.isSet() || MapperId.getAsString() != "default")) {
+SemaRef.Diag(Loc, diag::err_omp_mapper_wrong_type);

ABataev wrote:
> lildmh wrote:
> > ABataev wrote:
> > > lildmh wrote:
> > > > ABataev wrote:
> > > > > Why need an additional check for scope and not "default" id? I don't 
> > > > > see this additional requirement in the standard. 
> > > > It's because every variable in map clauses will check this, including 
> > > > those are not struct, class, or union.
> > > > 
> > > > Using this, e.g., mapping an integer won't report error that it doesn't 
> > > > have a mapper.
> > > Maybe just move the check to the end of the function?
> > It will do some additional useless work if I move it to the end. I don't 
> > think it is necessary to move it back.
> > 
> > But if you believe it's better, I can do it.
> Could you add tests for this new functionality?
I already add the test in declare_mapper_message.c. I think nothing is needed 
for ast print test.


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

https://reviews.llvm.org/D67978



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


[PATCH] D67567: [clang-tidy] New check to warn when storing dispatch_once_t in non-static, non-global storage

2019-09-26 Thread Michael Wyman via Phabricator via cfe-commits
mwyman updated this revision to Diff 222016.
mwyman added a comment.

Rebased patch to apply to current master.


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

https://reviews.llvm.org/D67567

Files:
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
  clang-tools-extra/clang-tidy/darwin/CMakeLists.txt
  clang-tools-extra/clang-tidy/darwin/DarwinTidyModule.cpp
  clang-tools-extra/clang-tidy/darwin/DispatchOnceNonstaticCheck.cpp
  clang-tools-extra/clang-tidy/darwin/DispatchOnceNonstaticCheck.h
  clang-tools-extra/clang-tidy/plugin/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/darwin-dispatch-once-nonstatic.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/darwin-dispatch-once-nonstatic.mm

Index: clang-tools-extra/test/clang-tidy/darwin-dispatch-once-nonstatic.mm
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/darwin-dispatch-once-nonstatic.mm
@@ -0,0 +1,48 @@
+// RUN: %check_clang_tidy %s darwin-dispatch-once-nonstatic %t
+
+typedef int dispatch_once_t;
+extern void dispatch_once(dispatch_once_t *pred, void(^block)(void));
+
+
+void bad_dispatch_once(dispatch_once_t once, void(^block)(void)) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: dispatch_once_ts must have static or global storage duration; function parameters should be pointer references [darwin-dispatch-once-nonstatic]
+
+// file-scope dispatch_once_ts have static storage duration.
+dispatch_once_t global_once;
+static dispatch_once_t file_static_once;
+namespace {
+dispatch_once_t anonymous_once;
+} // end anonymous namespace
+
+int Correct(void) {
+  static int value;
+  static dispatch_once_t once;
+  dispatch_once(&once, ^{
+value = 1;
+  });
+  return value;
+}
+
+int Incorrect(void) {
+  static int value;
+  dispatch_once_t once;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: dispatch_once_t variables must have static or global storage duration [darwin-dispatch-once-nonstatic]
+  // CHECK-FIXES: static dispatch_once_t once;
+  dispatch_once(&once, ^{
+value = 1;
+  });
+  return value;
+}
+
+struct OnceStruct {
+  static dispatch_once_t staticOnce; // Allowed
+  int value;
+  dispatch_once_t once;  // Allowed (at this time)
+};
+
+@interface MyObject {
+  dispatch_once_t _once;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: dispatch_once_t variables must have static or global storage duration and cannot be Objective-C instance variables [darwin-dispatch-once-nonstatic]
+  // CHECK-FIXES: dispatch_once_t _once;
+}
+@end
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -212,6 +212,7 @@
cppcoreguidelines-pro-type-vararg
cppcoreguidelines-slicing
cppcoreguidelines-special-member-functions
+   darwin-dispatch-once-nonstatic
fuchsia-default-arguments-calls
fuchsia-default-arguments-declarations
fuchsia-header-anon-namespaces (redirects to google-build-namespaces) 
Index: clang-tools-extra/docs/clang-tidy/checks/darwin-dispatch-once-nonstatic.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/darwin-dispatch-once-nonstatic.rst
@@ -0,0 +1,22 @@
+.. title:: clang-tidy - darwin-dispatch-once-nonstatic
+
+darwin-dispatch-once-nonstatic
+==
+
+Finds declarations of ``dispatch_once_t`` variables without static or global
+storage. The behavior of using ``dispatch_once_t`` predicates with automatic
+or dynamic storage is undefined by libdispatch, and should be avoided.
+
+It is a common pattern to have functions initialize internal static or global
+data once when the function runs, but programmers have been known to miss the
+static on the ``dispatch_once_t`` predicate, leading to an uninitialized flag
+value at the mercy of the stack.
+
+Programmers have also been known to make ``dispatch_once_t``s be members of
+structs/classes, with the intent to lazily perform some expensive struct or
+class member initialization only once; however, this violates the libdispatch
+requirements.
+
+See the discussion section of
+`Apple's dispatch_once documentation `_
+for more information.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -79,6 +79,12 @@
   Finds obvious infinite loops (loops where the condition variable is not
   changed at all).
 
+- New :doc:`darwin-dispatch-once-nonstatic
+ 

[PATCH] D67567: [clang-tidy] New check to warn when storing dispatch_once_t in non-static, non-global storage

2019-09-26 Thread Michael Wyman via Phabricator via cfe-commits
mwyman added a comment.

In D67567#1684785 , @gribozavr wrote:

> Sorry, could you rebase the patch to apply cleanly to master? Seems like 
> someone else edited ReleaseNotes.rst in the meanwhile.
>
>   $ arc patch D67567
>   ...
>   Checking patch clang-tools-extra/docs/ReleaseNotes.rst...
>   error: while searching for:
> Finds instances where variables with static storage are initialized
> dynamically in header files.
>


Just rebased, resolved the conflict and uploaded, should be good.


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

https://reviews.llvm.org/D67567



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


r373010 - [OPENMP50]Emit warnings if the functions was defined/used before marked

2019-09-26 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Sep 26 13:04:15 2019
New Revision: 373010

URL: http://llvm.org/viewvc/llvm-project?rev=373010&view=rev
Log:
[OPENMP50]Emit warnings if the functions was defined/used before marked
declare variant.

We can use the original function if it was used/emitted already. So,
just use warnings for these cases, not errors.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp
cfe/trunk/test/OpenMP/declare_variant_messages.c
cfe/trunk/test/OpenMP/declare_variant_messages.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=373010&r1=373009&r2=373010&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Sep 26 13:04:15 
2019
@@ -9452,9 +9452,12 @@ def warn_omp_declare_target_after_first_
   InGroup;
 def err_omp_declare_variant_incompat_attributes : Error<
   "'#pragma omp declare variant' is not compatible with any target-specific 
attributes">;
-def err_omp_declare_variant_after_used : Error<
+def warn_omp_declare_variant_after_used : Warning<
   "'#pragma omp declare variant' cannot be applied for function after first "
-  "usage">;
+  "usage; the original function might be used">, InGroup;
+def warn_omp_declare_variant_after_emitted : Warning<
+  "'#pragma omp declare variant' cannot be applied to the function that was 
defined already;"
+  " the original function might be used">, InGroup;
 def err_omp_declare_variant_noproto : Error<
   "function with '#pragma omp declare variant' must have a prototype">;
 def note_omp_declare_variant_specified_here : Note<

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=373010&r1=373009&r2=373010&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Sep 26 13:04:15 2019
@@ -4931,11 +4931,15 @@ Sema::checkOpenMPDeclareVariantFunction(
   }
 
   // Allow #pragma omp declare variant only if the function is not used.
-  if (FD->isUsed(false)) {
-Diag(SR.getBegin(), diag::err_omp_declare_variant_after_used)
+  if (FD->isUsed(false))
+Diag(SR.getBegin(), diag::warn_omp_declare_variant_after_used)
+<< FD->getLocation();
+
+  // Check if the function was emitted already.
+  if ((LangOpts.EmitAllDecls && FD->isDefined()) ||
+  Context.DeclMustBeEmitted(FD))
+Diag(SR.getBegin(), diag::warn_omp_declare_variant_after_emitted)
 << FD->getLocation();
-return None;
-  }
 
   // The VariantRef must point to function.
   if (!VariantRef) {

Modified: cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp?rev=373010&r1=373009&r2=373010&view=diff
==
--- cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp Thu Sep 26 13:04:15 2019
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++14 -fexceptions 
-fcxx-exceptions %s -ast-print -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++14 -fexceptions 
-fcxx-exceptions %s -ast-print -o - -Wno-source-uses-openmp | FileCheck %s
 
-// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -std=c++14 -fexceptions 
-fcxx-exceptions %s -ast-print -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -std=c++14 -fexceptions 
-fcxx-exceptions %s -ast-print -o - -Wno-source-uses-openmp | FileCheck %s
 
 // expected-no-diagnostics
 

Modified: cfe/trunk/test/OpenMP/declare_variant_messages.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_variant_messages.c?rev=373010&r1=373009&r2=373010&view=diff
==
--- cfe/trunk/test/OpenMP/declare_variant_messages.c (original)
+++ cfe/trunk/test/OpenMP/declare_variant_messages.c Thu Sep 26 13:04:15 2019
@@ -76,9 +76,12 @@ int bar() {
   return after_use();
 }
 
-// expected-error@+1 {{'#pragma omp declare variant' cannot be applied for 
function after first usage}}
+// expected-warning@+1 {{'#pragma omp declare variant' cannot be applied for 
function after first usage; the original function might be used}}
 #pragma omp declare variant(after_use_variant) match(xxx={})
 int after_use(void);
+// expected-warning@+1 {{#pragma omp declare variant' cannot be applied to the 
function that was defined already; the original function might be used}}
+#pragma omp declare variant(after_use_variant) match(xxx={})
+int defined(

[PATCH] D67122: [UBSan][clang][compiler-rt] Applying non-zero offset to nullptr is undefined behaviour

2019-09-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:63
 
+* As per C++ and C Standards (C++: ``[expr.add]``; C17: 6.5.6p8), applying
+  non-zero offset to ``nullptr`` (or making non-``nullptr`` a ``nullptr``,

rsmith wrote:
> In C, even adding 0 to a null pointer is undefined. Did this change in C17?
I don't see what words in the C standard make this UB. If it's UB-by-omission, 
I think it's unintentional. I mean, this language allows `&*some_null_pointer` 
without UB, so I would be really surprised if `some_null_ptr + 0` was UB. Do 
you have a source in the C standard for the UB?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67122



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


[PATCH] D67567: [clang-tidy] New check to warn when storing dispatch_once_t in non-static, non-global storage

2019-09-26 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

Sorry, could you rebase the patch to apply cleanly to master? Seems like 
someone else edited ReleaseNotes.rst in the meanwhile.

  $ arc patch D67567
  ...
  Checking patch clang-tools-extra/docs/ReleaseNotes.rst...
  error: while searching for:
Finds instances where variables with static storage are initialized
dynamically in header files.


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

https://reviews.llvm.org/D67567



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


[PATCH] D67122: [UBSan][clang][compiler-rt] Applying non-zero offset to nullptr is undefined behaviour

2019-09-26 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri marked 2 inline comments as done.
lebedev.ri added a comment.






Comment at: clang/docs/ReleaseNotes.rst:238
 
-- ...
+- * ``pointer-overflow`` check was extended added to catch the cases where
+a non-zero offset being applied, either to a ``nullptr``, or the result

rsmith wrote:
> Reusing this group seems a little surprising, since the new checks don't seem 
> to have anything to do with overflow. Is the general idea that this warning 
> identifies places where pointer artihmetic leaves the complete object (where, 
> for now, we only catch the case where it wraps around the address space or 
> leaves / reaches a hypothetical size-0 object at the null address)?
As it can be seen in the patch history i initially added this as a new group,
but then merged it back into this group as per @vsk request in 
D67122#inline-602602 :
> Separately, the proposed 'nullptr-and-nonzero-offset' check is interesting 
> only/exactly when the existing 'pointer-overflow' check is interesting, and 
> vice versa. So I don't see the need to make them distinct.

So yes, the idea is that in the retrospect, the `pointer-overflow` name might 
be just too specific,
but this is the same UB, so there is no point in fragmenting it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67122



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


[PATCH] D67978: [OpenMP 5.0] Fix user-defined mapper lookup in sema

2019-09-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Sema/SemaOpenMP.cpp:14805
+  if (!Type->isStructureOrClassType() && !Type->isUnionType() &&
+  (MapperIdScopeSpec.isSet() || MapperId.getAsString() != "default")) {
+SemaRef.Diag(Loc, diag::err_omp_mapper_wrong_type);

lildmh wrote:
> ABataev wrote:
> > lildmh wrote:
> > > ABataev wrote:
> > > > Why need an additional check for scope and not "default" id? I don't 
> > > > see this additional requirement in the standard. 
> > > It's because every variable in map clauses will check this, including 
> > > those are not struct, class, or union.
> > > 
> > > Using this, e.g., mapping an integer won't report error that it doesn't 
> > > have a mapper.
> > Maybe just move the check to the end of the function?
> It will do some additional useless work if I move it to the end. I don't 
> think it is necessary to move it back.
> 
> But if you believe it's better, I can do it.
Could you add tests for this new functionality?


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

https://reviews.llvm.org/D67978



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


[PATCH] D68099: [MS ABI]: Fix mangling function arguments for template types to be compatible with MSVC

2019-09-26 Thread Adam Folwarczny via Phabricator via cfe-commits
adamf created this revision.
adamf added reviewers: rnk, thakis.
adamf added a project: clang.
Herald added a subscriber: cfe-commits.

MS name mangling supports cache for first 10 distinct function arguments.
The error was when non cached template type occurred twice (e.g. 11th and 12th).
For such case there is another cache table TemplateArgStrings.
Then one '@' character at the end of the mangled name taken from this table was 
missing.
For other cases the missing '@' character was added in mangleSourceName 
function.


Repository:
  rC Clang

https://reviews.llvm.org/D68099

Files:
  clang/lib/AST/MicrosoftMangle.cpp
  clang/test/CodeGenCXX/mangle-ms-back-references.cpp


Index: clang/test/CodeGenCXX/mangle-ms-back-references.cpp
===
--- clang/test/CodeGenCXX/mangle-ms-back-references.cpp
+++ clang/test/CodeGenCXX/mangle-ms-back-references.cpp
@@ -66,3 +66,20 @@
 void foo() { }
 // CHECK: "?foo@0@YAXXZ"
 }
+
+class T01;
+class T02;
+class T03;
+class T04;
+class T05;
+class T06;
+class T07;
+class T08;
+class T09;
+class T10;
+class T11;
+template 
+class H;
+
+void ManyParams(T01 &, T02 &, T03 &, T04 &, T05 &, T06 &, T07 &, T08 &, T09 &, 
T10 &, H &, H &) {}
+// CHECK: 
"?ManyParams@@YAXAAVT01@@AAVT02@@AAVT03@@AAVT04@@AAVT05@@AAVT06@@AAVT07@@AAVT08@@AAVT09@@AAVT10@@AAV?$H@VT11AAV?$H@VT11@Z"
Index: clang/lib/AST/MicrosoftMangle.cpp
===
--- clang/lib/AST/MicrosoftMangle.cpp
+++ clang/lib/AST/MicrosoftMangle.cpp
@@ -846,7 +846,7 @@
   TemplateArgStringStorage.save(TemplateMangling.str());
 }
   } else {
-Out << Found->second; // Outputs a StringRef.
+Out << Found->second << '@'; // Outputs a StringRef.
   }
 } else {
   Out << Found->second; // Outputs a back reference (an int).


Index: clang/test/CodeGenCXX/mangle-ms-back-references.cpp
===
--- clang/test/CodeGenCXX/mangle-ms-back-references.cpp
+++ clang/test/CodeGenCXX/mangle-ms-back-references.cpp
@@ -66,3 +66,20 @@
 void foo() { }
 // CHECK: "?foo@0@YAXXZ"
 }
+
+class T01;
+class T02;
+class T03;
+class T04;
+class T05;
+class T06;
+class T07;
+class T08;
+class T09;
+class T10;
+class T11;
+template 
+class H;
+
+void ManyParams(T01 &, T02 &, T03 &, T04 &, T05 &, T06 &, T07 &, T08 &, T09 &, T10 &, H &, H &) {}
+// CHECK: "?ManyParams@@YAXAAVT01@@AAVT02@@AAVT03@@AAVT04@@AAVT05@@AAVT06@@AAVT07@@AAVT08@@AAVT09@@AAVT10@@AAV?$H@VT11AAV?$H@VT11@Z"
Index: clang/lib/AST/MicrosoftMangle.cpp
===
--- clang/lib/AST/MicrosoftMangle.cpp
+++ clang/lib/AST/MicrosoftMangle.cpp
@@ -846,7 +846,7 @@
   TemplateArgStringStorage.save(TemplateMangling.str());
 }
   } else {
-Out << Found->second; // Outputs a StringRef.
+Out << Found->second << '@'; // Outputs a StringRef.
   }
 } else {
   Out << Found->second; // Outputs a back reference (an int).
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67122: [UBSan][clang][compiler-rt] Applying non-zero offset to nullptr is undefined behaviour

2019-09-26 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:63
 
+* As per C++ and C Standards (C++: ``[expr.add]``; C17: 6.5.6p8), applying
+  non-zero offset to ``nullptr`` (or making non-``nullptr`` a ``nullptr``,

In C, even adding 0 to a null pointer is undefined. Did this change in C17?



Comment at: clang/docs/ReleaseNotes.rst:68
+  (`D66608 `_ ``[InstCombine] icmp eq/ne (gep
+  inbounds P, Idx..), null -> icmp eq/ne P, null``) LLVM middle-end uses those
+  guarantees for transformations. If the source contains such UB's, said code

LLVM -> the LLVM



Comment at: clang/docs/ReleaseNotes.rst:69
+  inbounds P, Idx..), null -> icmp eq/ne P, null``) LLVM middle-end uses those
+  guarantees for transformations. If the source contains such UB's, said code
+  may now be miscompiled. Undefined Behaviour Sanitizer

"undefined behavior", like (eg) "code", is generally treated as an uncountable 
noun, so this should be "If the source contains such undefined behavior, said 
code [...]" rather than "If the source contains such undefined behavior*s*, 
said code [...]".



Comment at: clang/docs/ReleaseNotes.rst:238
 
-- ...
+- * ``pointer-overflow`` check was extended added to catch the cases where
+a non-zero offset being applied, either to a ``nullptr``, or the result

Reusing this group seems a little surprising, since the new checks don't seem 
to have anything to do with overflow. Is the general idea that this warning 
identifies places where pointer artihmetic leaves the complete object (where, 
for now, we only catch the case where it wraps around the address space or 
leaves / reaches a hypothetical size-0 object at the null address)?



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:4659
+  // and only in the default address space
+  bool ShallPerformOverflowCheck =
+  !isa(GEPVal) && PtrTy->getPointerAddressSpace() == 0;

Remove the `Shall`s here. They don't add anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67122



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


[PATCH] D68052: [clang-scan-deps] Allow continuation line backslashes followed by whitespace in the dependency source minimizer

2019-09-26 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
arphaman marked 3 inline comments as done.
Closed by commit rG15d5f5dd350e: [clang-scan-deps] Allow continuation line 
backslashes followed by whitespace in… (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D68052?vs=221836&id=222009#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68052

Files:
  clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
  clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp

Index: clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
===
--- clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
+++ clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
@@ -157,19 +157,19 @@
 
   ASSERT_FALSE(minimizeSourceToDependencyDirectives(
   "#define MACRO(\t)\tcon \t tent\t", Out));
-  EXPECT_STREQ("#define MACRO() con \t tent\t\n", Out.data());
+  EXPECT_STREQ("#define MACRO() con \t tent\n", Out.data());
 
   ASSERT_FALSE(minimizeSourceToDependencyDirectives(
   "#define MACRO(\f)\fcon \f tent\f", Out));
-  EXPECT_STREQ("#define MACRO() con \f tent\f\n", Out.data());
+  EXPECT_STREQ("#define MACRO() con \f tent\n", Out.data());
 
   ASSERT_FALSE(minimizeSourceToDependencyDirectives(
   "#define MACRO(\v)\vcon \v tent\v", Out));
-  EXPECT_STREQ("#define MACRO() con \v tent\v\n", Out.data());
+  EXPECT_STREQ("#define MACRO() con \v tent\n", Out.data());
 
   ASSERT_FALSE(minimizeSourceToDependencyDirectives(
   "#define MACRO \t\v\f\v\t con\f\t\vtent\v\f \v", Out));
-  EXPECT_STREQ("#define MACRO con\f\t\vtent\v\n", Out.data());
+  EXPECT_STREQ("#define MACRO con\f\t\vtent\n", Out.data());
 }
 
 TEST(MinimizeSourceToDependencyDirectivesTest, DefineMultilineArgs) {
@@ -476,6 +476,17 @@
   EXPECT_STREQ("#define GUA RD\n", Out.data());
 }
 
+TEST(MinimizeSourceToDependencyDirectivesTest,
+ WhitespaceAfterLineContinuationSlash) {
+  SmallVector Out;
+
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives("#define A 1 + \\  \n"
+"2 + \\\t\n"
+"3\n",
+Out));
+  EXPECT_STREQ("#define A 1 + 2 + 3\n", Out.data());
+}
+
 TEST(MinimizeSourceToDependencyDirectivesTest, PoundWarningAndError) {
   SmallVector Out;
 
Index: clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -244,14 +244,20 @@
   }
 }
 
-static const char *reverseOverSpaces(const char *First, const char *Last) {
+static const char *findLastNonSpace(const char *First, const char *Last) {
   assert(First <= Last);
-  const char *PrevLast = Last;
-  while (First != Last && isHorizontalWhitespace(Last[-1])) {
-PrevLast = Last;
+  while (First != Last && isHorizontalWhitespace(Last[-1]))
 --Last;
-  }
-  return PrevLast;
+  return Last;
+}
+
+static const char *findFirstTrailingSpace(const char *First,
+  const char *Last) {
+  const char *LastNonSpace = findLastNonSpace(First, Last);
+  if (Last == LastNonSpace)
+return Last;
+  assert(isHorizontalWhitespace(LastNonSpace[0]));
+  return LastNonSpace + 1;
 }
 
 static void skipLineComment(const char *&First, const char *const End) {
@@ -385,7 +391,7 @@
   }
 
   // Deal with "//..." and "/*...*/".
-  append(First, reverseOverSpaces(First, Last));
+  append(First, findFirstTrailingSpace(First, Last));
   First = Last;
 
   if (Last[1] == '/') {
@@ -400,15 +406,20 @@
 } while (Last != End && !isVerticalWhitespace(*Last));
 
 // Print out the string.
-if (Last == End || Last == First || Last[-1] != '\\') {
-  append(First, reverseOverSpaces(First, Last));
+const char *LastBeforeTrailingSpace = findLastNonSpace(First, Last);
+if (Last == End || LastBeforeTrailingSpace == First ||
+LastBeforeTrailingSpace[-1] != '\\') {
+  append(First, LastBeforeTrailingSpace);
   First = Last;
   skipNewline(First, End);
   return;
 }
 
-// Print up to the backslash, backing up over spaces.
-append(First, reverseOverSpaces(First, Last - 1));
+// Print up to the backslash, backing up over spaces. Preserve at least one
+// space, as the space matters when tokens are separated by a line
+// continuation.
+append(First, findFirstTrailingSpace(
+  First, LastBeforeTrailingSpace - 1));
 
 First = Last;
 skipNewline(First, End);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r373007 - [clang-scan-deps] Allow continuation line backslashes followed by whitespace

2019-09-26 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Sep 26 12:28:51 2019
New Revision: 373007

URL: http://llvm.org/viewvc/llvm-project?rev=373007&view=rev
Log:
[clang-scan-deps] Allow continuation line backslashes followed by whitespace
in the dependency source minimizer

Clang allows continuations that have whitespace between the backslash and the 
newline.
This patch ensures that the dependency source minimizer can handle the 
whitespace between
the backslash and the newline when looking for a line continuation.

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

Modified:
cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
cfe/trunk/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp

Modified: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp?rev=373007&r1=373006&r2=373007&view=diff
==
--- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp (original)
+++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp Thu Sep 26 
12:28:51 2019
@@ -244,14 +244,20 @@ static void skipToNewlineRaw(const char
   }
 }
 
-static const char *reverseOverSpaces(const char *First, const char *Last) {
+static const char *findLastNonSpace(const char *First, const char *Last) {
   assert(First <= Last);
-  const char *PrevLast = Last;
-  while (First != Last && isHorizontalWhitespace(Last[-1])) {
-PrevLast = Last;
+  while (First != Last && isHorizontalWhitespace(Last[-1]))
 --Last;
-  }
-  return PrevLast;
+  return Last;
+}
+
+static const char *findFirstTrailingSpace(const char *First,
+  const char *Last) {
+  const char *LastNonSpace = findLastNonSpace(First, Last);
+  if (Last == LastNonSpace)
+return Last;
+  assert(isHorizontalWhitespace(LastNonSpace[0]));
+  return LastNonSpace + 1;
 }
 
 static void skipLineComment(const char *&First, const char *const End) {
@@ -385,7 +391,7 @@ void Minimizer::printToNewline(const cha
   }
 
   // Deal with "//..." and "/*...*/".
-  append(First, reverseOverSpaces(First, Last));
+  append(First, findFirstTrailingSpace(First, Last));
   First = Last;
 
   if (Last[1] == '/') {
@@ -400,15 +406,20 @@ void Minimizer::printToNewline(const cha
 } while (Last != End && !isVerticalWhitespace(*Last));
 
 // Print out the string.
-if (Last == End || Last == First || Last[-1] != '\\') {
-  append(First, reverseOverSpaces(First, Last));
+const char *LastBeforeTrailingSpace = findLastNonSpace(First, Last);
+if (Last == End || LastBeforeTrailingSpace == First ||
+LastBeforeTrailingSpace[-1] != '\\') {
+  append(First, LastBeforeTrailingSpace);
   First = Last;
   skipNewline(First, End);
   return;
 }
 
-// Print up to the backslash, backing up over spaces.
-append(First, reverseOverSpaces(First, Last - 1));
+// Print up to the backslash, backing up over spaces. Preserve at least one
+// space, as the space matters when tokens are separated by a line
+// continuation.
+append(First, findFirstTrailingSpace(
+  First, LastBeforeTrailingSpace - 1));
 
 First = Last;
 skipNewline(First, End);

Modified: cfe/trunk/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp?rev=373007&r1=373006&r2=373007&view=diff
==
--- cfe/trunk/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp 
(original)
+++ cfe/trunk/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp Thu Sep 
26 12:28:51 2019
@@ -157,19 +157,19 @@ TEST(MinimizeSourceToDependencyDirective
 
   ASSERT_FALSE(minimizeSourceToDependencyDirectives(
   "#define MACRO(\t)\tcon \t tent\t", Out));
-  EXPECT_STREQ("#define MACRO() con \t tent\t\n", Out.data());
+  EXPECT_STREQ("#define MACRO() con \t tent\n", Out.data());
 
   ASSERT_FALSE(minimizeSourceToDependencyDirectives(
   "#define MACRO(\f)\fcon \f tent\f", Out));
-  EXPECT_STREQ("#define MACRO() con \f tent\f\n", Out.data());
+  EXPECT_STREQ("#define MACRO() con \f tent\n", Out.data());
 
   ASSERT_FALSE(minimizeSourceToDependencyDirectives(
   "#define MACRO(\v)\vcon \v tent\v", Out));
-  EXPECT_STREQ("#define MACRO() con \v tent\v\n", Out.data());
+  EXPECT_STREQ("#define MACRO() con \v tent\n", Out.data());
 
   ASSERT_FALSE(minimizeSourceToDependencyDirectives(
   "#define MACRO \t\v\f\v\t con\f\t\vtent\v\f \v", Out));
-  EXPECT_STREQ("#define MACRO con\f\t\vtent\v\n", Out.data());
+  EXPECT_STREQ("#define MACRO con\f\t\vtent\n", Out.data());
 }
 
 TEST(MinimizeSourceToDependencyDirectivesTest, DefineMultilineArgs) {
@@ -476,6 +476,17 @@ TEST(MinimizeSourceToDependencyDirective
   EXPECT_STREQ("#define GUA RD\n", Ou

[PATCH] D67978: [OpenMP 5.0] Fix user-defined mapper lookup in sema

2019-09-26 Thread Lingda Li via Phabricator via cfe-commits
lildmh marked an inline comment as done.
lildmh added inline comments.



Comment at: lib/Sema/SemaOpenMP.cpp:14805
+  if (!Type->isStructureOrClassType() && !Type->isUnionType() &&
+  (MapperIdScopeSpec.isSet() || MapperId.getAsString() != "default")) {
+SemaRef.Diag(Loc, diag::err_omp_mapper_wrong_type);

ABataev wrote:
> lildmh wrote:
> > ABataev wrote:
> > > Why need an additional check for scope and not "default" id? I don't see 
> > > this additional requirement in the standard. 
> > It's because every variable in map clauses will check this, including those 
> > are not struct, class, or union.
> > 
> > Using this, e.g., mapping an integer won't report error that it doesn't 
> > have a mapper.
> Maybe just move the check to the end of the function?
It will do some additional useless work if I move it to the end. I don't think 
it is necessary to move it back.

But if you believe it's better, I can do it.


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

https://reviews.llvm.org/D67978



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


r373005 - Revert "[analyzer] A speculative attempt to avoid gcc-7 crashes..."

2019-09-26 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu Sep 26 11:52:00 2019
New Revision: 373005

URL: http://llvm.org/viewvc/llvm-project?rev=373005&view=rev
Log:
Revert "[analyzer] A speculative attempt to avoid gcc-7 crashes..."

This reverts commit r372940 which was an overreaction to a flaky buildbot.

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

Modified: cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp?rev=373005&r1=373004&r2=373005&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp Thu Sep 26 11:52:00 2019
@@ -51,11 +51,8 @@ StoreRef StoreManager::enterStackFrame(S
   SmallVector InitialBindings;
   Call.getInitialStackFrameContents(LCtx, InitialBindings);
 
-  for (const auto &I : InitialBindings) {
-Loc L = I.first.castAs();
-SVal V = I.second;
-Store = Bind(Store.getStore(), L, V);
-  }
+  for (const auto &I : InitialBindings)
+Store = Bind(Store.getStore(), I.first.castAs(), I.second);
 
   return Store;
 }


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


[PATCH] D67978: [OpenMP 5.0] Fix user-defined mapper lookup in sema

2019-09-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Sema/SemaOpenMP.cpp:14805
+  if (!Type->isStructureOrClassType() && !Type->isUnionType() &&
+  (MapperIdScopeSpec.isSet() || MapperId.getAsString() != "default")) {
+SemaRef.Diag(Loc, diag::err_omp_mapper_wrong_type);

lildmh wrote:
> ABataev wrote:
> > Why need an additional check for scope and not "default" id? I don't see 
> > this additional requirement in the standard. 
> It's because every variable in map clauses will check this, including those 
> are not struct, class, or union.
> 
> Using this, e.g., mapping an integer won't report error that it doesn't have 
> a mapper.
Maybe just move the check to the end of the function?


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

https://reviews.llvm.org/D67978



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


[PATCH] D67978: [OpenMP 5.0] Fix user-defined mapper lookup in sema

2019-09-26 Thread Lingda Li via Phabricator via cfe-commits
lildmh marked an inline comment as done.
lildmh added inline comments.



Comment at: lib/Sema/SemaOpenMP.cpp:14805
+  if (!Type->isStructureOrClassType() && !Type->isUnionType() &&
+  (MapperIdScopeSpec.isSet() || MapperId.getAsString() != "default")) {
+SemaRef.Diag(Loc, diag::err_omp_mapper_wrong_type);

ABataev wrote:
> Why need an additional check for scope and not "default" id? I don't see this 
> additional requirement in the standard. 
It's because every variable in map clauses will check this, including those are 
not struct, class, or union.

Using this, e.g., mapping an integer won't report error that it doesn't have a 
mapper.


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

https://reviews.llvm.org/D67978



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


[PATCH] D67978: [OpenMP 5.0] Fix user-defined mapper lookup in sema

2019-09-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Sema/SemaOpenMP.cpp:14805
+  if (!Type->isStructureOrClassType() && !Type->isUnionType() &&
+  (MapperIdScopeSpec.isSet() || MapperId.getAsString() != "default")) {
+SemaRef.Diag(Loc, diag::err_omp_mapper_wrong_type);

Why need an additional check for scope and not "default" id? I don't see this 
additional requirement in the standard. 


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

https://reviews.llvm.org/D67978



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


[PATCH] D67978: [OpenMP 5.0] Fix user-defined mapper lookup in sema

2019-09-26 Thread Lingda Li via Phabricator via cfe-commits
lildmh updated this revision to Diff 221991.
lildmh added a comment.

Fix mapper type checking


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

https://reviews.llvm.org/D67978

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/declare_mapper_messages.c
  test/OpenMP/declare_mapper_messages.cpp

Index: test/OpenMP/declare_mapper_messages.cpp
===
--- test/OpenMP/declare_mapper_messages.cpp
+++ test/OpenMP/declare_mapper_messages.cpp
@@ -64,6 +64,7 @@
 {
 #pragma omp declare mapper(id: vec v) map(v.len)
   vec vv, v1;
+  vec arr[10];
 #pragma omp target map(mapper)  // expected-error {{use of undeclared identifier 'mapper'}}
   {}
 #pragma omp target map(mapper:vv)   // expected-error {{expected '(' after 'mapper'}}
@@ -82,7 +83,9 @@
   {}
 #pragma omp target map(mapper(N1::aa) alloc:vv) // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'aa'}}
   {}
-#pragma omp target map(mapper(aa) to:vv) map(close mapper(aa) from:v1)
+#pragma omp target map(mapper(N1::aa) alloc:arr[0:2])   // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'aa'}}
+  {}
+#pragma omp target map(mapper(aa) to:vv) map(close mapper(aa) from:v1) map(mapper(aa) to:arr[0])
   {}
 #pragma omp target map(mapper(N1::stack::id) to:vv)
   {}
@@ -96,8 +99,9 @@
 #pragma omp target update to(mapper(N1:: :vv)   // expected-error {{illegal OpenMP user-defined mapper identifier}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update to(mapper(N1::aa) :vv)// expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'aa'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update to(mapper(ab):vv) // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'ab'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to(mapper(ab):arr[0:2])   // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'ab'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update to(mapper(aa) a:vv)   // expected-warning {{missing ':' after ) - ignoring}}
-#pragma omp target update to(mapper(aa):vv)
+#pragma omp target update to(mapper(aa):vv) to(mapper(aa):arr[0])
 #pragma omp target update to(mapper(N1::stack::id) :vv)
 
 #pragma omp target update from(mapper)  // expected-error {{expected '(' after 'mapper'}} expected-error {{expected expression}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
@@ -109,8 +113,9 @@
 #pragma omp target update from(mapper(N1:: :vv) // expected-error {{illegal OpenMP user-defined mapper identifier}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update from(mapper(N1::aa) :vv)  // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'aa'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update from(mapper(ab):vv)   // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'ab'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update from(mapper(ab):arr[0:2]) // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'ab'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update from(mapper(aa) a:vv) // expected-warning {{missing ':' after ) - ignoring}}
-#pragma omp target update from(mapper(aa):vv)
+#pragma omp target update from(mapper(aa):vv) from(mapper(aa):arr[0])
 #pragma omp target update from(mapper(N1::stack::id) :vv)
 }
 #pragma omp declare mapper(id: vec v) map(v.len)// expected-error {{redefinition of user-defined mapper for type 'vec' with name 'id'}}
Index: test/OpenMP/declare_mapper_messages.c
===
--- test/OpenMP/declare_mapper_messages.c
+++ test/OpenMP/declare_mapper_messages.c
@@ -36,6 +36,8 @@
 {
 #pragma omp decla

[PATCH] D67978: [OpenMP 5.0] Fix user-defined mapper lookup in sema

2019-09-26 Thread Lingda Li via Phabricator via cfe-commits
lildmh updated this revision to Diff 221990.
lildmh retitled this revision from "[OpenMP 5.0] Fix user-defined mapper lookup 
in sema for arrays" to "[OpenMP 5.0] Fix user-defined mapper lookup in sema".
lildmh edited the summary of this revision.

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

https://reviews.llvm.org/D67978

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/declare_mapper_messages.c
  test/OpenMP/declare_mapper_messages.cpp

Index: test/OpenMP/declare_mapper_messages.cpp
===
--- test/OpenMP/declare_mapper_messages.cpp
+++ test/OpenMP/declare_mapper_messages.cpp
@@ -64,6 +64,7 @@
 {
 #pragma omp declare mapper(id: vec v) map(v.len)
   vec vv, v1;
+  vec arr[10];
 #pragma omp target map(mapper)  // expected-error {{use of undeclared identifier 'mapper'}}
   {}
 #pragma omp target map(mapper:vv)   // expected-error {{expected '(' after 'mapper'}}
@@ -82,7 +83,9 @@
   {}
 #pragma omp target map(mapper(N1::aa) alloc:vv) // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'aa'}}
   {}
-#pragma omp target map(mapper(aa) to:vv) map(close mapper(aa) from:v1)
+#pragma omp target map(mapper(N1::aa) alloc:arr[0:2])   // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'aa'}}
+  {}
+#pragma omp target map(mapper(aa) to:vv) map(close mapper(aa) from:v1) map(mapper(aa) to:arr[0])
   {}
 #pragma omp target map(mapper(N1::stack::id) to:vv)
   {}
@@ -96,8 +99,9 @@
 #pragma omp target update to(mapper(N1:: :vv)   // expected-error {{illegal OpenMP user-defined mapper identifier}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update to(mapper(N1::aa) :vv)// expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'aa'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update to(mapper(ab):vv) // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'ab'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to(mapper(ab):arr[0:2])   // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'ab'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update to(mapper(aa) a:vv)   // expected-warning {{missing ':' after ) - ignoring}}
-#pragma omp target update to(mapper(aa):vv)
+#pragma omp target update to(mapper(aa):vv) to(mapper(aa):arr[0])
 #pragma omp target update to(mapper(N1::stack::id) :vv)
 
 #pragma omp target update from(mapper)  // expected-error {{expected '(' after 'mapper'}} expected-error {{expected expression}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
@@ -109,8 +113,9 @@
 #pragma omp target update from(mapper(N1:: :vv) // expected-error {{illegal OpenMP user-defined mapper identifier}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update from(mapper(N1::aa) :vv)  // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'aa'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update from(mapper(ab):vv)   // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'ab'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update from(mapper(ab):arr[0:2]) // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'ab'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update from(mapper(aa) a:vv) // expected-warning {{missing ':' after ) - ignoring}}
-#pragma omp target update from(mapper(aa):vv)
+#pragma omp target update from(mapper(aa):vv) from(mapper(aa):arr[0])
 #pragma omp target update from(mapper(N1::stack::id) :vv)
 }
 #pragma omp declare mapper(id: vec v) map(v.len)// expected-error {{redefinition of user-defined mapper for type 'vec' with name 'id'}}
Index: test/OpenMP/declare_mapper_messages.c
===

r373004 - Only pass -coverage-notes-file when emitting coverage

2019-09-26 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Sep 26 11:13:19 2019
New Revision: 373004

URL: http://llvm.org/viewvc/llvm-project?rev=373004&view=rev
Log:
Only pass -coverage-notes-file when emitting coverage

The only functional change here is that -coverage-notes-file is not
passed to -cc1 in some situations.

This code appears to be trying to put the gcno and gcda output next to
the final object file, but it's doing that in a really convoluted way
that needs to be re-examined. It looks for -c or -S in the original
command, and then looks at the -o argument if present in order to handle
the -fno-integrated-as case. However, this doesn't work if this is a
link command with multiple inputs. I looked into fixing this, but the
check-profile test suite has a lot of dependencies on this behavior, so
I left it all alone.

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/coverage_no_integrated_as.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=373004&r1=373003&r2=373004&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Sep 26 11:13:19 2019
@@ -832,12 +832,14 @@ static void addPGOAndCoverageFlags(const
 }
   }
 
-  if (Args.hasArg(options::OPT_ftest_coverage) ||
-  Args.hasArg(options::OPT_coverage))
+  bool EmitCovNotes = Args.hasArg(options::OPT_ftest_coverage) ||
+  Args.hasArg(options::OPT_coverage);
+  bool EmitCovData = Args.hasFlag(options::OPT_fprofile_arcs,
+  options::OPT_fno_profile_arcs, false) ||
+ Args.hasArg(options::OPT_coverage);
+  if (EmitCovNotes)
 CmdArgs.push_back("-femit-coverage-notes");
-  if (Args.hasFlag(options::OPT_fprofile_arcs, options::OPT_fno_profile_arcs,
-   false) ||
-  Args.hasArg(options::OPT_coverage))
+  if (EmitCovData)
 CmdArgs.push_back("-femit-coverage-data");
 
   if (Args.hasFlag(options::OPT_fcoverage_mapping,
@@ -873,40 +875,48 @@ static void addPGOAndCoverageFlags(const
 CmdArgs.push_back(Args.MakeArgString(Twine("-fprofile-filter-files=" + 
v)));
   }
 
-  if (C.getArgs().hasArg(options::OPT_c) ||
-  C.getArgs().hasArg(options::OPT_S)) {
-if (Output.isFilename()) {
-  CmdArgs.push_back("-coverage-notes-file");
-  SmallString<128> OutputFilename;
-  if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o))
-OutputFilename = FinalOutput->getValue();
-  else
-OutputFilename = llvm::sys::path::filename(Output.getBaseInput());
-  SmallString<128> CoverageFilename = OutputFilename;
-  if (llvm::sys::path::is_relative(CoverageFilename)) {
-SmallString<128> Pwd;
-if (!llvm::sys::fs::current_path(Pwd)) {
-  llvm::sys::path::append(Pwd, CoverageFilename);
-  CoverageFilename.swap(Pwd);
-}
+  // Leave -fprofile-dir= an unused argument unless .gcda emission is
+  // enabled. To be polite, with '-fprofile-arcs -fno-profile-arcs' consider
+  // the flag used. There is no -fno-profile-dir, so the user has no
+  // targeted way to suppress the warning.
+  Arg *FProfileDir = nullptr;
+  if (Args.hasArg(options::OPT_fprofile_arcs) ||
+  Args.hasArg(options::OPT_coverage))
+FProfileDir = Args.getLastArg(options::OPT_fprofile_dir);
+
+  // Put the .gcno and .gcda files (if needed) next to the object file or
+  // bitcode file in the case of LTO.
+  // FIXME: There should be a simpler way to find the object file for this
+  // input, and this code probably does the wrong thing for commands that
+  // compile and link all at once.
+  if ((Args.hasArg(options::OPT_c) || Args.hasArg(options::OPT_S)) &&
+  (EmitCovNotes || EmitCovData) && Output.isFilename()) {
+SmallString<128> OutputFilename;
+if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o))
+  OutputFilename = FinalOutput->getValue();
+else
+  OutputFilename = llvm::sys::path::filename(Output.getBaseInput());
+SmallString<128> CoverageFilename = OutputFilename;
+if (llvm::sys::path::is_relative(CoverageFilename)) {
+  SmallString<128> Pwd;
+  if (!llvm::sys::fs::current_path(Pwd)) {
+llvm::sys::path::append(Pwd, CoverageFilename);
+CoverageFilename.swap(Pwd);
   }
-  llvm::sys::path::replace_extension(CoverageFilename, "gcno");
-  CmdArgs.push_back(Args.MakeArgString(CoverageFilename));
+}
+llvm::sys::path::replace_extension(CoverageFilename, "gcno");
 
-  // Leave -fprofile-dir= an unused argument unless .gcda emission is
-  // enabled. To be polite, with '-fprofile-arcs -fno-profile-arcs' 
consider
-  // the flag used. There is no -fno-profile-dir, so the user has no
-  // targeted way to suppress the warning.
-  if (Args.hasArg(options::OPT_fprofile_arcs) ||
-  A

r372999 - Move normalization of `\` in #includes from -fms-compatibility to -fms-extensions

2019-09-26 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Sep 26 10:19:22 2019
New Revision: 372999

URL: http://llvm.org/viewvc/llvm-project?rev=372999&view=rev
Log:
Move normalization of `\` in #includes from -fms-compatibility to 
-fms-extensions

Handling backslashes in include paths in the implementation isn't
non-conforming.

Modified:
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/test/Lexer/cross-windows-on-linux-default.cpp
cfe/trunk/test/Lexer/cross-windows-on-linux.cpp

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=372999&r1=372998&r2=372999&view=diff
==
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Thu Sep 26 10:19:22 2019
@@ -1785,20 +1785,23 @@ Optional Preprocessor::Loo
   return Filename;
 };
 StringRef TypoCorrectionName = CorrectTypoFilename(Filename);
-SmallString<128> NormalizedTypoCorrectionPath;
-if (LangOpts.MSVCCompat) {
-  NormalizedTypoCorrectionPath = TypoCorrectionName.str();
+
 #ifndef _WIN32
+// Normalize slashes when compiling with -fms-extensions on non-Windows.
+// This is unnecessary on Windows since the filesystem there handles
+// backslashes.
+SmallString<128> NormalizedTypoCorrectionPath;
+if (LangOpts.MicrosoftExt) {
+  NormalizedTypoCorrectionPath = TypoCorrectionName;
   llvm::sys::path::native(NormalizedTypoCorrectionPath);
-#endif
+  TypoCorrectionName = NormalizedTypoCorrectionPath;
 }
+#endif
+
 Optional File = LookupFile(
-FilenameLoc,
-LangOpts.MSVCCompat ? NormalizedTypoCorrectionPath.c_str()
-: TypoCorrectionName,
-isAngled, LookupFrom, LookupFromFile, CurDir,
-Callbacks ? &SearchPath : nullptr, Callbacks ? &RelativePath : nullptr,
-&SuggestedModule, &IsMapped,
+FilenameLoc, TypoCorrectionName, isAngled, LookupFrom, LookupFromFile,
+CurDir, Callbacks ? &SearchPath : nullptr,
+Callbacks ? &RelativePath : nullptr, &SuggestedModule, &IsMapped,
 /*IsFrameworkFound=*/nullptr);
 if (File) {
   auto Hint =
@@ -1906,15 +1909,18 @@ Preprocessor::ImportAction Preprocessor:
   // the path.
   ModuleMap::KnownHeader SuggestedModule;
   SourceLocation FilenameLoc = FilenameTok.getLocation();
+  StringRef LookupFilename = Filename;
+
+#ifndef _WIN32
+  // Normalize slashes when compiling with -fms-extensions on non-Windows. This
+  // is unnecessary on Windows since the filesystem there handles backslashes.
   SmallString<128> NormalizedPath;
-  if (LangOpts.MSVCCompat) {
+  if (LangOpts.MicrosoftExt) {
 NormalizedPath = Filename.str();
-#ifndef _WIN32
 llvm::sys::path::native(NormalizedPath);
-#endif
+LookupFilename = NormalizedPath;
   }
-  StringRef LookupFilename =
-  LangOpts.MSVCCompat ? StringRef(NormalizedPath) : Filename;
+#endif
 
   Optional File = LookupHeaderIncludeOrImport(
   CurDir, Filename, FilenameLoc, FilenameRange, FilenameTok,

Modified: cfe/trunk/test/Lexer/cross-windows-on-linux-default.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/cross-windows-on-linux-default.cpp?rev=372999&r1=372998&r2=372999&view=diff
==
--- cfe/trunk/test/Lexer/cross-windows-on-linux-default.cpp (original)
+++ cfe/trunk/test/Lexer/cross-windows-on-linux-default.cpp Thu Sep 26 10:19:22 
2019
@@ -1,4 +1,4 @@
-// RUN: not %clang_cc1 -fsyntax-only -fms-compatibility -triple i686-win32 %s 
2>&1 \
+// RUN: not %clang_cc1 -fsyntax-only -fms-extensions -triple i686-win32 %s 
2>&1 \
 // RUN:   | FileCheck %s
 
 #include "Inputs\success.h"

Modified: cfe/trunk/test/Lexer/cross-windows-on-linux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/cross-windows-on-linux.cpp?rev=372999&r1=372998&r2=372999&view=diff
==
--- cfe/trunk/test/Lexer/cross-windows-on-linux.cpp (original)
+++ cfe/trunk/test/Lexer/cross-windows-on-linux.cpp Thu Sep 26 10:19:22 2019
@@ -6,10 +6,8 @@
 // CHECK: #include "Inputs\success.h"
 // CHECK:  ^
 
-// expected to fail on windows as the inclusion would succeed and the
-// compilation will fail due to the '#error success'.
-// XFAIL: windows-msvc
-
-// This test may or may not fail since 'Inputs\success.h' is passed
-// to Win32 APIs on Windows.
-// REQUIRES: disabled
+// This test is really checking that we *don't* replace backslashes with 
slashes
+// on non-Windows unless -fms-extensions is passed. It won't fail in this way 
on
+// Windows because the filesystem will interpret the backslash as a directory
+// separator.
+// UNSUPPORTED: system-windows


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

[PATCH] D67567: [clang-tidy] New check to warn when storing dispatch_once_t in non-static, non-global storage

2019-09-26 Thread Michael Wyman via Phabricator via cfe-commits
mwyman added a comment.

In D67567#1683905 , @gribozavr wrote:

> Thanks! Do you need me to commit the patch for you?


Yes, thank you. I don't have commit access—and also wasn't sure if anyone else 
had further comment.


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

https://reviews.llvm.org/D67567



___
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-09-26 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan 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


[PATCH] D57829: [HIP] Disable emitting llvm.linker.options in device compilation

2019-09-26 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl abandoned this revision.
yaxunl marked an inline comment as done.
yaxunl added a comment.

no longer needed


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

https://reviews.llvm.org/D57829



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


Re: r371027 - Revert r361885 "[Driver] Fix -working-directory issues"

2019-09-26 Thread Mikael Holmén via cfe-commits
Hi,

As Karl-Johan said I'll be out of office for a few days so please submit a fix 
if you can find the time.

Thanks,
Mikael

Den 26 sep. 2019 15:39 skrev Hans Wennborg :
On Thu, Sep 26, 2019 at 12:55 PM Mikael Holmén via cfe-commits
 wrote:
>
> Hi Hans,
>
> I'm a bit suspicious against the part
>
>  > This also revertes the part of r369938 which checked that
> -working-directory works.
>
> in this revert.
>
> You do:
>
>  > +  SmallString<128> Buf;
>  > +  if (!llvm::sys::fs::current_path(Buf))
>  > +Buf = ".";
>  > +  CDB << "{ \"directory\": \"" << escape(Buf) << "\"";
>
> But if I look at r369938 it seems like before r369938 it looked like
>
> -  SmallString<128> Buf;
> -  if (llvm::sys::fs::current_path(Buf))
> -Buf = ".";
> -  CDB << "{ \"directory\": \"" << escape(Buf) << "\"";
>
> Note the difference in the condition, where you do
>
>   if (!llvm::sys::fs::current_path(Buf))
>
> but before it was
>
>   if (llvm::sys::fs::current_path(Buf))
>
>
> We noticed this since
>
>   clang -MJ test.json -O2 -nostdinc empty.c -S -o - && cat test.json
>
> started to behave differently after this revert. The "directory: " part
> in the output suddenly became ".".

You're right, it definitely looks like I messed up the revert :-(
Looking at the code again, I was probably thrown off by the
current_path returning false on success.

Since you've been investigating, are you set up to land a fix with a
test maybe? Otherwise I can do it, please let me know.

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


r372994 - Un-XFAIL coverage_no_integrated_as.c test on Windows

2019-09-26 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Sep 26 09:56:25 2019
New Revision: 372994

URL: http://llvm.org/viewvc/llvm-project?rev=372994&view=rev
Log:
Un-XFAIL coverage_no_integrated_as.c test on Windows

You can't use -fno-integrated-as for *-msvc triples because no usable
standalone assembler exists. Perhaps we could teach clang to emit a .s
and then reinvoke itself, but that's a bit silly.

Anyway, fix the test by using an Itanium ABI triple, which will become
mingw, which will assume gnu as is a usable assembler.

Modified:
cfe/trunk/test/Driver/coverage_no_integrated_as.c

Modified: cfe/trunk/test/Driver/coverage_no_integrated_as.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/coverage_no_integrated_as.c?rev=372994&r1=372993&r2=372994&view=diff
==
--- cfe/trunk/test/Driver/coverage_no_integrated_as.c (original)
+++ cfe/trunk/test/Driver/coverage_no_integrated_as.c Thu Sep 26 09:56:25 2019
@@ -1,20 +1,19 @@
 // REQUIRES: clang-driver
-// XFAIL: windows-msvc
 
 // RUN: %clang -### -S -fprofile-arcs %s 2>&1 | FileCheck 
-check-prefix=CHECK-GCNO-DEFAULT-LOCATION %s
-// RUN: %clang -### -S -fprofile-arcs -no-integrated-as %s 2>&1 | FileCheck 
-check-prefix=CHECK-GCNO-DEFAULT-LOCATION %s
+// RUN: %clang -### -S -fprofile-arcs --target=%itanium_abi_triple 
-no-integrated-as %s 2>&1 | FileCheck -check-prefix=CHECK-GCNO-DEFAULT-LOCATION 
%s
 // RUN: %clang -### -c -fprofile-arcs %s 2>&1 | FileCheck 
-check-prefix=CHECK-GCNO-DEFAULT-LOCATION %s
-// RUN: %clang -### -c -fprofile-arcs -no-integrated-as %s 2>&1 | FileCheck 
-check-prefix=CHECK-GCNO-DEFAULT-LOCATION %s
+// RUN: %clang -### -c -fprofile-arcs --target=%itanium_abi_triple 
-no-integrated-as %s 2>&1 | FileCheck -check-prefix=CHECK-GCNO-DEFAULT-LOCATION 
%s
 
 // RUN: %clang -### -S -fprofile-arcs %s -o /foo/bar.o 2>&1 | FileCheck 
-check-prefix=CHECK-GCNO-LOCATION %s
-// RUN: %clang -### -S -fprofile-arcs -no-integrated-as %s -o /foo/bar.o 2>&1 
| FileCheck -check-prefix=CHECK-GCNO-LOCATION %s
+// RUN: %clang -### -S -fprofile-arcs --target=%itanium_abi_triple 
-no-integrated-as %s -o /foo/bar.o 2>&1 | FileCheck 
-check-prefix=CHECK-GCNO-LOCATION %s
 // RUN: %clang -### -c -fprofile-arcs %s -o /foo/bar.o 2>&1 | FileCheck 
-check-prefix=CHECK-GCNO-LOCATION %s
-// RUN: %clang -### -c -fprofile-arcs -no-integrated-as %s -o /foo/bar.o 2>&1 
| FileCheck -check-prefix=CHECK-GCNO-LOCATION %s
+// RUN: %clang -### -c -fprofile-arcs --target=%itanium_abi_triple 
-no-integrated-as %s -o /foo/bar.o 2>&1 | FileCheck 
-check-prefix=CHECK-GCNO-LOCATION %s
 
 // RUN: %clang -### -S -fprofile-arcs %s -o foo/bar.o 2>&1 | FileCheck 
-check-prefix=CHECK-GCNO-LOCATION-REL-PATH %s
-// RUN: %clang -### -S -fprofile-arcs -no-integrated-as %s -o foo/bar.o 2>&1 | 
FileCheck -check-prefix=CHECK-GCNO-LOCATION-REL-PATH %s
+// RUN: %clang -### -S -fprofile-arcs --target=%itanium_abi_triple 
-no-integrated-as %s -o foo/bar.o 2>&1 | FileCheck 
-check-prefix=CHECK-GCNO-LOCATION-REL-PATH %s
 // RUN: %clang -### -c -fprofile-arcs %s -o foo/bar.o 2>&1 | FileCheck 
-check-prefix=CHECK-GCNO-LOCATION-REL-PATH %s
-// RUN: %clang -### -c -fprofile-arcs -no-integrated-as %s -o foo/bar.o 2>&1 | 
FileCheck -check-prefix=CHECK-GCNO-LOCATION-REL-PATH %s
+// RUN: %clang -### -c -fprofile-arcs --target=%itanium_abi_triple 
-no-integrated-as %s -o foo/bar.o 2>&1 | FileCheck 
-check-prefix=CHECK-GCNO-LOCATION-REL-PATH %s
 
 
 // CHECK-GCNO-DEFAULT-LOCATION: "-coverage-notes-file" 
"{{.*}}{{/|}}coverage_no_integrated_as.c"


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


[PATCH] D68074: [clang-tidy] Add readability-make-member-function-const

2019-09-26 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp:60
+  template  const T *getParent(const Expr *E) {
+auto Parents = Ctxt.getParents(*E);
+if (Parents.size() != 1)

Return type is not obvious, so auto should not be used.



Comment at: 
clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp:145
+
+if (auto *Cast = dyn_cast_or_null(Parent)) {
+  // A read access to a member is safe when the member either

Is Cast changed, if not, const auto * should be used. Same in other places.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68074



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


[PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

2019-09-26 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev added a comment.

I have uploaded the first part to https://reviews.llvm.org/D68070


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

https://reviews.llvm.org/D64943



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


[PATCH] D66795: [Mips] Use appropriate private label prefix based on Mips ABI

2019-09-26 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

This makes sense to me (although we don't currently need the options parameter 
there).


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

https://reviews.llvm.org/D66795



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


[PATCH] D68076: [AArch64] Enable unwind tables by default for Gnu targets

2019-09-26 Thread David Tellenbach via Phabricator via cfe-commits
tellenbach added a comment.

This would fix PR37240 


Repository:
  rC Clang

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

https://reviews.llvm.org/D68076



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


[PATCH] D67978: [OpenMP 5.0] Fix user-defined mapper lookup in sema for arrays

2019-09-26 Thread Lingda Li via Phabricator via cfe-commits
lildmh added a comment.

In D67978#1684169 , @ABataev wrote:

> In D67978#1684104 , @lildmh wrote:
>
> > In D67978#1683166 , @ABataev wrote:
> >
> > > In D67978#1683146 , @lildmh 
> > > wrote:
> > >
> > > > HI Alexey, the ast print test is already there. Because I didn't check 
> > > > the mapper for array type before, such code will always not report any 
> > > > error, and ast print test is correct. Codegen test belongs to the other 
> > > > patch I released. It fits that patch much better.
> > >
> > >
> > > How is this possible? If we did not have support for the array type, we 
> > > could not have correct handling of such types in successful tests.
> >
> >
> > The ast print for array with mapper was correct because the mapper id is 
> > still with the array type. Without this patch, the problem is it will not 
> > look up the mapper declaration associated with the id, and as a result, the 
> > codegen is not correct. I found this problem when I tested the codegen.
>
>
> Then another one question. Why we don't emit the diagnostics if the original 
> type is not a class, struct or union? We just ignore this situation currently 
> but we should not. The error message must be emitted. I think that's why the 
> ast-print test works correctly though it should not.


We emit such diagnostic when mapper is declared, i.e., you cannot define a 
mapper for a non-class, non-struct, non-union type. It's in function 
`ActOnOpenMPDeclareMapperType` in SemaOpenMP.cpp. But I didn't emit such 
information where mapper is used. I will fix it in this patch. Thanks for 
getting this!


Repository:
  rC Clang

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

https://reviews.llvm.org/D67978



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


[PATCH] D68076: [AArch64] Enable unwind tables by default for Gnu targets

2019-09-26 Thread David Tellenbach via Phabricator via cfe-commits
tellenbach added a comment.

Please also see the ongoing discussion on the mailing list: 
http://lists.llvm.org/pipermail/llvm-dev/2019-September/135433.html 



Repository:
  rC Clang

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

https://reviews.llvm.org/D68076



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


[PATCH] D67980: [WIP][CLANG][BPF] do compile-once run-everywhere relocation for bitfields

2019-09-26 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 221962.
yonghong-song retitled this revision from "[WIP][CLANG][BPF] implement clang 
__builtin_bitfield_info() intrinsic" to "[WIP][CLANG][BPF] do compile-once 
run-everywhere relocation for bitfields".
yonghong-song edited the summary of this revision.
yonghong-song added a comment.
Herald added subscribers: llvm-commits, jdoerfert, hiraditya.
Herald added a project: LLVM.

add BPF backend support


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67980

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaChecking.cpp
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
  llvm/lib/Target/BPF/BTFDebug.cpp
  llvm/lib/Target/BPF/BTFDebug.h

Index: llvm/lib/Target/BPF/BTFDebug.h
===
--- llvm/lib/Target/BPF/BTFDebug.h
+++ llvm/lib/Target/BPF/BTFDebug.h
@@ -254,7 +254,7 @@
   StringMap> FileContent;
   std::map> DataSecEntries;
   std::vector StructTypes;
-  std::map AccessOffsets;
+  std::map PatchImms;
   std::map>>
   FixupDerivedTypes;
 
Index: llvm/lib/Target/BPF/BTFDebug.cpp
===
--- llvm/lib/Target/BPF/BTFDebug.cpp
+++ llvm/lib/Target/BPF/BTFDebug.cpp
@@ -966,14 +966,14 @@
   size_t FirstDollar = AccessPattern.find_first_of('$');
   size_t FirstColon = AccessPattern.find_first_of(':');
   StringRef IndexPattern = AccessPattern.substr(FirstDollar + 1);
-  StringRef OffsetStr = AccessPattern.substr(FirstColon + 1,
+  StringRef PatchImmStr = AccessPattern.substr(FirstColon + 1,
   FirstDollar - FirstColon);
 
   BTFOffsetReloc OffsetReloc;
   OffsetReloc.Label = ORSym;
   OffsetReloc.OffsetNameOff = addString(IndexPattern);
   OffsetReloc.TypeID = RootId;
-  AccessOffsets[AccessPattern.str()] = std::stoi(OffsetStr);
+  PatchImms[AccessPattern.str()] = std::stoull(PatchImmStr);
   OffsetRelocTable[SecNameOff].push_back(OffsetReloc);
 }
 
@@ -1157,10 +1157,13 @@
 MDNode *MDN = GVar->getMetadata(LLVMContext::MD_preserve_access_index);
 DIType *Ty = dyn_cast(MDN);
 std::string TypeName = Ty->getName();
-int64_t Imm = AccessOffsets[GVar->getName().str()];
+uint64_t Imm = PatchImms[GVar->getName().str()];
 
-// Emit "mov ri, " for abstract member accesses.
-OutMI.setOpcode(BPF::MOV_ri);
+// Emit "mov/ld_imm64 ri, " for patched immediate.
+if (Imm > UINT_MAX)
+  OutMI.setOpcode(BPF::LD_imm64);
+else
+  OutMI.setOpcode(BPF::MOV_ri);
 OutMI.addOperand(MCOperand::createReg(MI->getOperand(0).getReg()));
 OutMI.addOperand(MCOperand::createImm(Imm));
 return true;
Index: llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
===
--- llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
+++ llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
@@ -50,6 +50,32 @@
 //   addr = preserve_struct_access_index(base, gep_index, di_index)
 //  !llvm.preserve.access.index 
 //
+// Bitfield member access needs special attention. User cannot take the
+// address of a bitfield access. To avoid generating loads which might
+// have side effects with bpf programs, e.g., verifier may reject it,
+// a new clang intrinsic (__builtin_preserve_bitfield_info()) is added
+// to return bitfield member offset, signness and member size, given
+// a bitfield access. For example,
+//   struct s { int a; int b:3; int b2:4; } arg;
+//   uint64_t __builtin_preserve_bitfield_info(arg->b)
+// The application can then use member offset, signness and member size
+// to perform bit field extraction.
+//
+// A new IR intrinsic:
+//   uint64_t preserve_array_access_index(base)
+// is introduced.
+// The above __builtin_preserve_bitfield_info(arg->b) will generate
+// two preserve_*_access_index() calls like
+//   addr = preserve_struct_access_index(base, 1, 1) !struct s
+//   uint64_t preserve_array_access_index(addr)
+// The above two IR intrinsics will be eventually replaced with
+// a relocatable insn:
+//   bitfield_info = 8ULL << 48 /* member offset */ |
+//   1 << 7 /* signness */ |
+//   3 /* member size */
+// and bitfield_info can be changed by bpf loader based on the
+// types on the host.
+//
 //===--===//
 
 #include "BPF.h"
@@ -95,14 +121,15 @@
 BPFPreserveArrayAI = 1,
 BPFPreserveUnionAI = 2,
 BPFPreserveStructAI = 3,
+BPFPreserveBitFieldAI = 4,
   };
 
   std::map GEPGlobals;
   // A map to link preserve_*_access_index instrinsic calls.
   std::map> AIChain;
   // A 

[PATCH] D65433: [clangd] DefineInline action availability checks

2019-09-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 221947.
kadircet added a comment.

- Use canonical decl when checking visibility


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65433

Files:
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
  clang-tools-extra/clangd/unittests/TweakTesting.cpp
  clang-tools-extra/clangd/unittests/TweakTesting.h
  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
@@ -24,6 +24,7 @@
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -33,6 +34,8 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
+#include 
+#include 
 
 using ::testing::AllOf;
 using ::testing::HasSubstr;
@@ -554,7 +557,6 @@
   EXPECT_THAT(apply(" [[int a = 5;]] a++; "), StartsWith("fail"));
   // Don't extract return
   EXPECT_THAT(apply(" if(true) [[return;]] "), StartsWith("fail"));
-  
 }
 
 TEST_F(ExtractFunctionTest, FileTest) {
@@ -648,6 +650,150 @@
   EXPECT_THAT(apply(" for(;;) { [[while(1) break; break;]] }"),
   StartsWith("fail"));
 }
+
+TWEAK_TEST(DefineInline);
+TEST_F(DefineInlineTest, TriggersOnFunctionDecl) {
+  // Basic check for function body and signature.
+  EXPECT_AVAILABLE(R"cpp(
+  class Bar {
+void baz();
+  };
+
+  [[void [[Bar::[[b^a^z() [[{
+return;
+  }
+
+  void foo();
+  [[void [[f^o^o]]() [[{
+return;
+  }
+  )cpp");
+
+  EXPECT_UNAVAILABLE(R"cpp(
+  // Not a definition
+  vo^i[[d^ ^f]]^oo();
+
+  [[vo^id ]]foo[[()]] {[[
+[[(void)(5+3);
+return;]]
+  }]]
+  )cpp");
+}
+
+TEST_F(DefineInlineTest, NoForwardDecl) {
+  Header = "void bar();";
+  EXPECT_UNAVAILABLE(R"cpp(
+  void bar() {
+return;
+  }
+  // FIXME: Generate a decl in the header.
+  void fo^o() {
+return;
+  })cpp");
+}
+
+TEST_F(DefineInlineTest, ReferencedDecls) {
+  EXPECT_AVAILABLE(R"cpp(
+void bar();
+void foo(int test);
+
+void fo^o(int baz) {
+  int x = 10;
+  bar();
+})cpp");
+
+  // Internal symbol usage.
+  Header = "void foo(int test);";
+  EXPECT_UNAVAILABLE(R"cpp(
+void bar();
+void fo^o(int baz) {
+  int x = 10;
+  bar();
+})cpp");
+
+  // Becomes available after making symbol visible.
+  Header = "void bar();" + Header;
+  EXPECT_AVAILABLE(R"cpp(
+void fo^o(int baz) {
+  int x = 10;
+  bar();
+})cpp");
+
+  // FIXME: Move declaration below bar to make it visible.
+  Header.clear();
+  EXPECT_UNAVAILABLE(R"cpp(
+void foo();
+void bar();
+
+void fo^o() {
+  bar();
+})cpp");
+
+  // Order doesn't matter within a class.
+  EXPECT_AVAILABLE(R"cpp(
+class Bar {
+  void foo();
+  void bar();
+};
+
+void Bar::fo^o() {
+  bar();
+})cpp");
+
+  // FIXME: Perform include insertion to make symbol visible.
+  ExtraFiles["a.h"] = "void bar();";
+  Header = "void foo(int test);";
+  EXPECT_UNAVAILABLE(R"cpp(
+#include "a.h"
+void fo^o(int baz) {
+  int x = 10;
+  bar();
+})cpp");
+}
+
+TEST_F(DefineInlineTest, TemplateSpec) {
+  EXPECT_UNAVAILABLE(R"cpp(
+template  void foo();
+template<> void foo();
+
+template<> void f^oo() {
+})cpp");
+  EXPECT_UNAVAILABLE(R"cpp(
+template  void foo();
+
+template<> void f^oo() {
+})cpp");
+  EXPECT_AVAILABLE(R"cpp(
+template  void foo();
+void bar();
+template <> void foo();
+
+template<> void f^oo() {
+  bar();
+})cpp");
+}
+
+TEST_F(DefineInlineTest, CheckForCanonDecl) {
+  EXPECT_UNAVAILABLE(R"cpp(
+void foo();
+
+void bar() {}
+void f^oo() {
+  // This bar normally refers to the definition just above, but it is not
+  // visible from the forward declaration of foo.
+  bar();
+})cpp");
+  // Make it available with a forward decl.
+  EXPECT_AVAILABLE(R"cpp(
+void bar();
+void foo();
+
+void bar() {}
+void f^oo() {
+  bar();
+})cpp");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/TweakTesting.h
===
--- clang-tools-extra/clangd/unittests/TweakTesting.h
+++ clang-tools-extra/clangd/unittests/TweakTesting.h
@@ -10,8 +10,10 @@
 #define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TWEAKTESTING_H
 
 #include "TestTU.h"
-#include "gtest/gtest.h"
+#include "llvm/ADT/StringMap.h"
 #include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -47

[PATCH] D66647: [clangd] DefineInline action apply logic with fully qualified names

2019-09-26 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D66647#1684046 , @ilya-biryukov 
wrote:

> We also need to rename parameters sometimes, right?
>
>   // Sometimes we need to rename parameters.
>   void usages(int decl_param, int);
>  
>   void usages(int def_param, int now_named) {
> llvm::errs() << def_param + now_named;
>   }
>  
>   // And template parameters! (these are even more interesting)
>   template 
>   struct Foo {
> template 
> void usages();
>   };
>   template 
>   template 
>   void Foo::usages() {
> llvm::errs() << L() + R() + NowNamed();
>   }
>


This is tricky, and there are also cases where the declaration doesn't provide 
the name of parameter, e.g. `llvm::json::Value toJSON(const CodeAction &);`. 
Maybe we  can overwrite the declaration signature with the definition's, or 
just disable the tweak on these cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66647



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


[PATCH] D67978: [OpenMP 5.0] Fix user-defined mapper lookup in sema for arrays

2019-09-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D67978#1684104 , @lildmh wrote:

> In D67978#1683166 , @ABataev wrote:
>
> > In D67978#1683146 , @lildmh wrote:
> >
> > > HI Alexey, the ast print test is already there. Because I didn't check 
> > > the mapper for array type before, such code will always not report any 
> > > error, and ast print test is correct. Codegen test belongs to the other 
> > > patch I released. It fits that patch much better.
> >
> >
> > How is this possible? If we did not have support for the array type, we 
> > could not have correct handling of such types in successful tests.
>
>
> The ast print for array with mapper was correct because the mapper id is 
> still with the array type. Without this patch, the problem is it will not 
> look up the mapper declaration associated with the id, and as a result, the 
> codegen is not correct. I found this problem when I tested the codegen.


Then another one question. Why we don't emit the diagnostics if the original 
type is not a class, struct or union? We just ignore this situation currently 
but we should not. The error message must be emitted. I think that's why the 
ast-print test works correctly though it should not.


Repository:
  rC Clang

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

https://reviews.llvm.org/D67978



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


[PATCH] D68055: Add -fgnuc-version= to control __GNUC__ and other GCC macros

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

This is great, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68055



___
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-09-26 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet updated this revision to Diff 221939.
gchatelet added a comment.

- Checks function name validity and errors when passed 0 argument.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68028

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

Index: clang/test/Sema/no-builtin.c
===
--- /dev/null
+++ clang/test/Sema/no-builtin.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -emit-llvm -o - -verify %s
+
+void foo() __attribute__((no_builtin)) {} // expected-error {{'no_builtin' attribute takes at least 1 argument}}
+
+void bar() __attribute__((no_builtin())) {} // expected-error {{'no_builtin' attribute takes at least 1 argument}}
+
+void invalid_builtin() __attribute__((no_builtin("not_a_builtin"))) {} // expected-error {{use of unknown builtin not_a_builtin}}
+
+int __attribute__((no_builtin("*"))) variable; // expected-warning {{'no_builtin' attribute only applies to functions}}
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.c
===
--- /dev/null
+++ clang/test/CodeGen/no-builtin.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: define void @foo_no_mempcy() #0
+void foo_no_mempcy() __attribute__((no_builtin("memcpy"))) {}
+
+// CHECK-LABEL: define void @foo_no_builtins() #1
+void foo_no_builtins() __attribute__((no_builtin("*"))) {}
+
+// CHECK-LABEL: define void @foo_no_mempcy_memset() #2
+void foo_no_mempcy_memset() __attribute__((no_builtin("memset", "memcpy"))) {}
+
+// CHECK-LABEL: define void @separate_attrs() #2
+void separate_attrs() __attribute__((no_builtin("memset"))) __attribute__((no_builtin("memcpy"))) {}
+
+// CHECK-LABEL: define void @wildcard_wins() #1
+void wildcard_wins() __attribute__((no_builtin("memset"))) __attribute__((no_builtin("*"))) __attribute__((no_builtin("memcpy"))) {}
+
+// CHECK: attributes #0 = {{{.*}}"no-builtin-memcpy"{{.*}}}
+// CHECK: attributes #1 = {{{.*}}"no-builtins"{{.*}}}
+// CHECK: attributes #2 = {{{.*}}"no-builtin-memcpy"{{.*}}"no-builtin-memset"{{.*}}}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -1068,6 +1068,62 @@
   S.Context, AL, Cond, Msg, DiagType, ArgDependent, cast(D)));
 }
 
+NoBuiltinAttr *
+Sema::mergeNoBuiltinAttr(Sema &S, Decl *D, const AttributeCommonInfo &CI,
+ llvm::ArrayRef FunctionNames) {
+  const StringRef Wildcard = "*";
+  llvm::SmallSetVector FunctionNamesSet;
+
+  // Insert previous NoBuiltin attributes.
+  if (D->hasAttr())
+for (StringRef FunctionName : D->getAttr()->functionNames())
+  FunctionNamesSet.insert(FunctionName);
+  // Insert new NoBuiltin attributes.
+  for (StringRef FunctionName : FunctionNames)
+FunctionNamesSet.insert(FunctionName);
+
+  // Wildcard is a superset of all builtins, we keep only this one.
+  if (FunctionNamesSet.count(Wildcard) > 0) {
+FunctionNamesSet.clear();
+FunctionNamesSet.insert(Wildcard);
+  }
+
+  assert((FunctionNamesSet.count(Wildcard) == 0) ||
+ (FunctionNamesSet.size() == 1) && "Wildcard must be on its own");
+
+  llvm::SmallVector UniqFunctionNames =
+  FunctionNamesSet.takeVector();
+  llvm::sort(UniqFunctionNames);
+
+  if (D->hasAttr())
+D->dropAttr();
+
+  return ::new (S.Context) NoBuiltinAttr(
+  S.Context, CI, UniqFunctionNames.data(), UniqFunctionNames.size());
+}
+
+static void handleNoBuiltin(Sema &S, Decl *D, const ParsedAttr &AL) {
+  if (!checkAttributeAtLeastNumArgs(S, AL, 1))
+return;
+
+  llvm::SmallVector FunctionNames;
+  for (unsigned I = 0, E = AL.getNumArgs(); I != E; ++I) {
+StringRef FunctionName;
+SourceLoc

[clang-tools-extra] r372981 - [clangd] Bump vscode-clangd v0.0.18

2019-09-26 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Sep 26 07:11:23 2019
New Revision: 372981

URL: http://llvm.org/viewvc/llvm-project?rev=372981&view=rev
Log:
[clangd] Bump vscode-clangd v0.0.18

CHANGELOG:
- enable semantic highlighting by default
- upgrade the LSP dependencies to pickup the incoming LSP v3.15.0

Modified:
clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json

Modified: clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json?rev=372981&r1=372980&r2=372981&view=diff
==
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json (original)
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json Thu Sep 
26 07:11:23 2019
@@ -2,7 +2,7 @@
 "name": "vscode-clangd",
 "displayName": "vscode-clangd",
 "description": "Clang Language Server",
-"version": "0.0.17",
+"version": "0.0.18",
 "publisher": "llvm-vs-code-extensions",
 "homepage": "https://clang.llvm.org/extra/clangd.html";,
 "engines": {


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


[PATCH] D68080: [clangd][vscode] Add npm helper commands to package/release the extension.

2019-09-26 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372980: [clangd][vscode] Add npm helper commands to 
package/release the extension. (authored by hokein, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68080?vs=221921&id=221938#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68080

Files:
  clang-tools-extra/trunk/clangd/clients/clangd-vscode/DEVELOPING.md
  clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json


Index: clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
@@ -33,7 +33,9 @@
 "compile": "tsc -watch -p ./",
 "postinstall": "node ./node_modules/vscode/bin/install",
 "format": "clang-format --style=LLVM -i --glob=\"{src,test}/*.ts\"",
-"test": "node ./node_modules/vscode/bin/test"
+"test": "node ./node_modules/vscode/bin/test",
+"package": "vsce package --baseImagesUrl 
https://raw.githubusercontent.com/llvm/llvm-project/master/clang-tools-extra/clangd/clients/clangd-vscode/";,
+"publish": "vsce publish --baseImagesUrl 
https://raw.githubusercontent.com/llvm/llvm-project/master/clang-tools-extra/clangd/clients/clangd-vscode/";
 },
 "dependencies": {
 "jsonc-parser": "^2.1.0",
Index: clang-tools-extra/trunk/clangd/clients/clangd-vscode/DEVELOPING.md
===
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/DEVELOPING.md
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/DEVELOPING.md
@@ -48,6 +48,6 @@
   # For the first time, you need to login in the account. vsce will ask you for
 the Personal Access Token, and remember it for future commands.
   $ vsce login llvm-vs-code-extensions
-  # Make sure the screenshots in the readme are rendered in VSCode marketplace.
-  $ vsce publish --baseImagesUrl 
https://raw.githubusercontent.com/llvm/llvm-project/master/clang-tools-extra/clangd/clients/clangd-vscode/
+  # Publish the extension to the VSCode marketplace.
+  $ npm run publish
 ```


Index: clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
@@ -33,7 +33,9 @@
 "compile": "tsc -watch -p ./",
 "postinstall": "node ./node_modules/vscode/bin/install",
 "format": "clang-format --style=LLVM -i --glob=\"{src,test}/*.ts\"",
-"test": "node ./node_modules/vscode/bin/test"
+"test": "node ./node_modules/vscode/bin/test",
+"package": "vsce package --baseImagesUrl https://raw.githubusercontent.com/llvm/llvm-project/master/clang-tools-extra/clangd/clients/clangd-vscode/";,
+"publish": "vsce publish --baseImagesUrl https://raw.githubusercontent.com/llvm/llvm-project/master/clang-tools-extra/clangd/clients/clangd-vscode/";
 },
 "dependencies": {
 "jsonc-parser": "^2.1.0",
Index: clang-tools-extra/trunk/clangd/clients/clangd-vscode/DEVELOPING.md
===
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/DEVELOPING.md
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/DEVELOPING.md
@@ -48,6 +48,6 @@
   # For the first time, you need to login in the account. vsce will ask you for
 the Personal Access Token, and remember it for future commands.
   $ vsce login llvm-vs-code-extensions
-  # Make sure the screenshots in the readme are rendered in VSCode marketplace.
-  $ vsce publish --baseImagesUrl https://raw.githubusercontent.com/llvm/llvm-project/master/clang-tools-extra/clangd/clients/clangd-vscode/
+  # Publish the extension to the VSCode marketplace.
+  $ npm run publish
 ```
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r372980 - [clangd][vscode] Add npm helper commands to package/release the extension.

2019-09-26 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Sep 26 07:04:52 2019
New Revision: 372980

URL: http://llvm.org/viewvc/llvm-project?rev=372980&view=rev
Log:
[clangd][vscode] Add npm helper commands to package/release the extension.

Summary: Help to fix https://github.com/clangd/clangd/issues/159.

Reviewers: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/clients/clangd-vscode/DEVELOPING.md
clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json

Modified: clang-tools-extra/trunk/clangd/clients/clangd-vscode/DEVELOPING.md
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/clients/clangd-vscode/DEVELOPING.md?rev=372980&r1=372979&r2=372980&view=diff
==
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/DEVELOPING.md 
(original)
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/DEVELOPING.md Thu Sep 
26 07:04:52 2019
@@ -48,6 +48,6 @@ please contact clangd-...@lists.llvm.org
   # For the first time, you need to login in the account. vsce will ask you for
 the Personal Access Token, and remember it for future commands.
   $ vsce login llvm-vs-code-extensions
-  # Make sure the screenshots in the readme are rendered in VSCode marketplace.
-  $ vsce publish --baseImagesUrl 
https://raw.githubusercontent.com/llvm/llvm-project/master/clang-tools-extra/clangd/clients/clangd-vscode/
+  # Publish the extension to the VSCode marketplace.
+  $ npm run publish
 ```

Modified: clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json?rev=372980&r1=372979&r2=372980&view=diff
==
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json (original)
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json Thu Sep 
26 07:04:52 2019
@@ -33,7 +33,9 @@
 "compile": "tsc -watch -p ./",
 "postinstall": "node ./node_modules/vscode/bin/install",
 "format": "clang-format --style=LLVM -i --glob=\"{src,test}/*.ts\"",
-"test": "node ./node_modules/vscode/bin/test"
+"test": "node ./node_modules/vscode/bin/test",
+"package": "vsce package --baseImagesUrl 
https://raw.githubusercontent.com/llvm/llvm-project/master/clang-tools-extra/clangd/clients/clangd-vscode/";,
+"publish": "vsce publish --baseImagesUrl 
https://raw.githubusercontent.com/llvm/llvm-project/master/clang-tools-extra/clangd/clients/clangd-vscode/";
 },
 "dependencies": {
 "jsonc-parser": "^2.1.0",


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


[PATCH] D68080: [clangd][vscode] Add npm helper commands to package/release the extension.

2019-09-26 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked an inline comment as done.
hokein added inline comments.



Comment at: clang-tools-extra/clangd/clients/clangd-vscode/package.json:38
+"package": "vsce package --baseImagesUrl 
https://raw.githubusercontent.com/llvm/llvm-project/master/clang-tools-extra/clangd/clients/clangd-vscode/";,
+"publish": "vsce publish --baseImagesUrl 
https://raw.githubusercontent.com/llvm/llvm-project/master/clang-tools-extra/clangd/clients/clangd-vscode/";
 },

ilya-biryukov wrote:
> hokein wrote:
> > ilya-biryukov wrote:
> > > Just to make sure I understand what's going on...
> > > 
> > > Could you explain what `--baseImagesUrl` does? 
> > > The suggested url returns an error code when I try to load it in a 
> > > browser.
> > This is expected, this is a **base** url. it is used to assemble a full url 
> > with the screenshot links in the readme, an example is ` 
> > https://raw.githubusercontent.com/llvm/llvm-project/master/clang-tools-extra/clangd/clients/clangd-vscode/`
> >  + `doc-assets/complete.png`, so that the screenshot can be rendered 
> > correctly in the VSCode market.
> Thanks for the clarification! Surprised we need this for both `package` and 
> `publish`, I'd expect this to be handled in either first or the second step, 
> but not both. I guess I don't fully understand what they do with this URL.
> 
> NIT: could add a comment mentioning that this URL is used to "host images 
> (e.g. screenshots in documentation)"?
> 
> 
> Thanks for the clarification! Surprised we need this for both package and 
> publish, I'd expect this to be handled in either first or the second step, 
> but not both. I guess I don't fully understand what they do with this URL.

Actually, when we make a new release, we use `publish` which includes the 
`package`. The `package` is usually used to build a local package (mainly for 
debugging purpose).

> NIT: could add a comment mentioning that this URL is used to "host images 
> (e.g. screenshots in documentation)"?
Unfortunately, comment is not permitted in the JSON :(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68080



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


[PATCH] D68074: [clang-tidy] Add readability-make-member-function-const

2019-09-26 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

See also PR21981 and D45444 .




Comment at: 
clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp:93
+  bool VisitUser(const ImplicitCastExpr *Cast) {
+
+if (Cast->getCastKind() != CK_NoOp)

Unnecessary empty line.



Comment at: 
clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp:125
+  bool VisitUser(const MemberExpr *Member, bool OnConstObject) {
+
+if (Member->isBoundMemberFunction(Ctxt)) {

Unnecessary empty line.



Comment at: 
clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp:213
+void MakeMemberFunctionConstCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  cxxMethodDecl(

Shouldn't check work only in C++?



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:109
+
+  Finds non-static member functions that can be made ``const``.
+

Please synchronize with first sentence in documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68074



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


[PATCH] D68055: Add -fgnuc-version= to control __GNUC__ and other GCC macros

2019-09-26 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

This looks reasonable to me. Might be worth mentioning in ReleaseNotes too :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68055



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


[PATCH] D68024: [clangd] Implement GetEligiblePoints

2019-09-26 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov marked an inline comment as done.
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/SourceCode.cpp:996
+  std::vector Enclosing = {""};
+  // FIXME: In addition to namespaces try to generate events for function
+  // definitions as well. One might use a closing parantheses(")" followed by 
an

kadircet wrote:
> ilya-biryukov wrote:
> > If we were to do this, I'd rather try matching brace structure and only 
> > report `closing brace that is probably end of the top-level decl(function, 
> > struct, etc)` events.
> > 
> > Everything else seems super hard to get right.
> agreed, my suggestion was also just for figuring out when a `{` might start a 
> definition, and trigger an event at the corresponding `}`
Actually, now I remembered that this should also work just fine.
`) {` is a good marker for start of the function body, I believe clang also 
uses this to detect and skip function bodies for members.

So LG 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68024



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


  1   2   >