Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.

2016-01-07 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 44193.
hokein added a comment.

Address Aaron's comments.


http://reviews.llvm.org/D15710

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/DefinitionsInHeadersCheck.cpp
  clang-tidy/misc/DefinitionsInHeadersCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-definitions-in-headers.rst
  test/clang-tidy/check_clang_tidy.py
  test/clang-tidy/misc-definitions-in-headers.hpp
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -43,7 +43,8 @@
 config.test_format = lit.formats.ShTest(execute_external)
 
 # suffixes: A list of file extensions to treat as test files.
-config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.modularize', '.module-map-checker']
+config.suffixes = ['.c', '.cpp', '.hpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s',
+  '.modularize', '.module-map-checker']
 
 # Test-time dependencies located in directories called 'Inputs' are excluded
 # from test suites; there won't be any lit tests within them.
Index: test/clang-tidy/misc-definitions-in-headers.hpp
===
--- /dev/null
+++ test/clang-tidy/misc-definitions-in-headers.hpp
@@ -0,0 +1,135 @@
+// RUN: %check_clang_tidy %s misc-definitions-in-headers %t
+
+int f() {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function definition is not allowed
+// CHECK-FIXES: inline int f() {
+  return 1;
+}
+
+class CA {
+  void f1() {} // OK: inline class member function definition.
+  void f2();
+  template
+  T f3() {
+T a = 1;
+return a;
+  }
+  template
+  struct CAA {
+struct CAB {
+  void f4();
+};
+  };
+};
+
+void CA::f2() { }
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: function definition is not allowed
+// CHECK-FIXES: inline void CA::f2() {
+
+template <>
+int CA::f3() {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: function definition is not allowed
+  int a = 1;
+  return a;
+}
+
+template 
+void CA::CAA::CAB::f4() {
+// OK: member function definition of a nested template class in a class.
+}
+
+template 
+struct CB {
+  void f1();
+  struct CCA {
+void f2(T a);
+  };
+  struct CCB;  // OK: forward declaration.
+  static int a; // OK: class static data member declaration.
+};
+
+template 
+void CB::f1() { // OK: Member function definition of a class template.
+}
+
+template 
+void CB::CCA::f2(T a) {
+// OK: member function definition of a nested class in a class template.
+}
+
+template 
+struct CB::CCB {
+  void f3();
+};
+
+template 
+void CB::CCB::f3() {
+// OK: member function definition of a nested class in a class template.
+}
+
+template 
+int CB::a = 2; // OK: static data member definition of a class template.
+
+template 
+T tf() { // OK: template function definition.
+  T a;
+  return a;
+}
+
+
+namespace NA {
+  int f() { return 1; }
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: function definition is not allowed
+// CHECK-FIXES: inline int f() { return 1; }
+}
+
+template 
+T f3() {
+  T a = 1;
+  return a;
+}
+
+template <>
+// CHECK-MESSAGES: :[[@LINE+1]]:5: warning: function definition is not allowed
+int f3() {
+  int a = 1;
+  return a;
+}
+
+int f5(); // OK: function declaration.
+inline int f6() { return 1; } // OK: inline function definition.
+namespace {
+  int f7() { return 1; }
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: function definition is not allowed
+}
+
+int a = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable definition is not allowed
+CA a1;
+// CHECK-MESSAGES: :[[@LINE-1]]:4: warning: variable definition is not allowed
+
+namespace NB {
+  int b = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable definition is not allowed
+  const int c = 1; // OK: internal linkage variable definition.
+}
+
+class CC {
+  static int d; // OK: class static data member declaration.
+};
+
+int CC::d = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: variable definition is not allowed
+
+const char* ca = "foo";
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: variable definition is not allowed
+
+namespace {
+  int e = 2;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable definition is not allowed
+}
+
+const char* const g = "foo"; // OK: internal linkage variable definition.
+static int h = 1; // OK: internal linkage variable definition.
+const int i = 1; // OK: internal linkage variable definition.
+extern int j; // OK: internal linkage variable definition.
Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -52,6 +52,8 @@
   extension = '.cpp'
   if (input_file_name.endswith('.c')):
 extension = '.c'
+  if (input_file_name.endswith('.hpp')):
+extension = '.hpp'
   temp_file_name = temp_file_name + extension
 
   clang_tidy_extra_args = extra_args
Index: docs/clang-tidy/checks/m

r257043 - [libclang] Handle AutoType in clang_getTypeDeclaration

2016-01-07 Thread Sergey Kalinichev via cfe-commits
Author: skalinichev
Date: Thu Jan  7 03:20:40 2016
New Revision: 257043

URL: http://llvm.org/viewvc/llvm-project?rev=257043&view=rev
Log:
[libclang] Handle AutoType in clang_getTypeDeclaration

Differential Revision: http://reviews.llvm.org/D13001

Added:
cfe/trunk/test/Index/print-type-declaration.cpp
Modified:
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CXType.cpp

Added: cfe/trunk/test/Index/print-type-declaration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type-declaration.cpp?rev=257043&view=auto
==
--- cfe/trunk/test/Index/print-type-declaration.cpp (added)
+++ cfe/trunk/test/Index/print-type-declaration.cpp Thu Jan  7 03:20:40 2016
@@ -0,0 +1,12 @@
+
+class Test{};
+
+int main()
+{
+  auto a = Test();
+  auto b = a;
+}
+
+// RUN: c-index-test -test-print-type-declaration -std=c++11 %s | FileCheck %s
+// CHECK: VarDecl=a:6:8 (Definition) [typedeclaration=Test] [typekind=Record]
+// CHECK: VarDecl=b:7:8 (Definition) [typedeclaration=Test] [typekind=Record]

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=257043&r1=257042&r2=257043&view=diff
==
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Thu Jan  7 03:20:40 2016
@@ -1508,6 +1508,22 @@ static enum CXChildVisitResult PrintBitW
 }
 
 
/**/
+/* Type declaration testing   
*/
+/**/
+
+static enum CXChildVisitResult PrintTypeDeclaration(CXCursor cursor, CXCursor 
p,
+ CXClientData d) {
+  CXCursor typeDeclaration = 
clang_getTypeDeclaration(clang_getCursorType(cursor));
+
+  if (clang_isDeclaration(typeDeclaration.kind)) {
+PrintCursor(cursor, NULL);
+PrintTypeAndTypeKind(clang_getCursorType(typeDeclaration), " 
[typedeclaration=%s] [typekind=%s]\n");
+  }
+
+  return CXChildVisit_Recurse;
+}
+
+/**/
 /* Loading ASTs/source.   
*/
 
/**/
 
@@ -4137,6 +4153,7 @@ static void print_usage(void) {
 "   c-index-test -test-print-type {}*\n"
 "   c-index-test -test-print-type-size {}*\n"
 "   c-index-test -test-print-bitwidth {}*\n"
+"   c-index-test -test-print-type-declaration {}*\n"
 "   c-index-test -print-usr [ {}]*\n"
 "   c-index-test -print-usr-file \n"
 "   c-index-test -write-pch  \n");
@@ -4230,6 +4247,9 @@ int cindextest_main(int argc, const char
   else if (argc > 2 && strcmp(argv[1], "-test-print-type-size") == 0)
 return perform_test_load_source(argc - 2, argv + 2, "all",
 PrintTypeSize, 0);
+  else if (argc > 2 && strcmp(argv[1], "-test-print-type-declaration") == 0)
+return perform_test_load_source(argc - 2, argv + 2, "all",
+PrintTypeDeclaration, 0);
   else if (argc > 2 && strcmp(argv[1], "-test-print-bitwidth") == 0)
 return perform_test_load_source(argc - 2, argv + 2, "all",
 PrintBitWidth, 0);

Modified: cfe/trunk/tools/libclang/CXType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXType.cpp?rev=257043&r1=257042&r2=257043&view=diff
==
--- cfe/trunk/tools/libclang/CXType.cpp (original)
+++ cfe/trunk/tools/libclang/CXType.cpp Thu Jan  7 03:20:40 2016
@@ -412,6 +412,12 @@ try_again:
  .getAsTemplateDecl();
 break;
 
+  case Type::Auto:
+TP = cast(TP)->getDeducedType().getTypePtrOrNull();
+if (TP)
+  goto try_again;
+break;
+
   case Type::InjectedClassName:
 D = cast(TP)->getDecl();
 break;


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


Re: [PATCH] D15823: Support virtual-near-miss check.

2016-01-07 Thread Cong Liu via cfe-commits
congliu updated this revision to Diff 44197.
congliu added a comment.

- Corrected naming styles; Used clang-format; Add doc to .h
- Removed useless parentheses, braces around one-line ifs.
- Added doc; Corrected style and typos for test.
- Implemented c++ [class.virtual]p7. But has bug.
- Support ambiguity checking.
- Completed virtual covarient check. Updated test.


http://reviews.llvm.org/D15823

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/VirtualNearMissCheck.cpp
  clang-tidy/misc/VirtualNearMissCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-virtual-near-miss.rst
  test/clang-tidy/misc-virtual-near-miss.cpp

Index: test/clang-tidy/misc-virtual-near-miss.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-virtual-near-miss.cpp
@@ -0,0 +1,65 @@
+// RUN: %check_clang_tidy %s misc-virtual-near-miss %t
+
+struct Base {
+  virtual void func();
+  virtual void gunk();
+};
+
+struct Derived : Base {
+  // Should not warn "do you want to override 'gunk'?", becuase gunk is already
+  // overriden by this class.
+  virtual void funk();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do you want to override 'func'? [misc-virtual-near-miss]
+
+  void func2();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do you want to override 'func'?
+
+  void func22(); // Should not warn.
+
+  void gunk(); // Should not warn, because gunk is override.
+
+  void fun();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do you want to override 'func'?
+};
+
+class Father {
+public:
+  Father();
+  virtual void func();
+  virtual Father *create(int i);
+  virtual Base &&generate();
+};
+
+class Mother {
+public:
+  Mother();
+  static void method();
+  virtual int method(int argc, const char **argv);
+  virtual int method(int argc) const;
+};
+
+class Child : Father, Mother {
+public:
+  Child();
+
+  virtual void func2();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do you want to override 'func'?
+
+  int methoe(int x, char **strs); // Should not warn, because param type missmatch.
+
+  int methoe(int x); // Should not warn, because const type missmatch.
+
+  void methof(int x, const char **strs); // Should not warn, because return type missmatch.
+
+  int methoh(int x, const char **strs);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do you want to override 'method'?
+
+  virtual Child *creat(int i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do you want to override 'create'?
+
+  virtual Derived &&generat();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do you want to override 'generate'?
+
+private:
+  void funk(); //Should not warn, because access missmatch.
+};
Index: docs/clang-tidy/checks/misc-virtual-near-miss.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-virtual-near-miss.rst
@@ -0,0 +1,17 @@
+misc-virtual-near-miss
+==
+
+Warn if a function is a near miss (ie. short edit distance) to a virtual function from a base class.
+
+Example:
+
+.. code-block:: c++
+
+  struct Base {
+virtual void func();
+  };
+
+  struct Derived : Base {
+virtual funk();
+// warning: Do you want to override 'func'?
+  };
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -56,6 +56,7 @@
misc-unused-alias-decls
misc-unused-parameters
misc-unused-raii
+   misc-virtual-near-miss
modernize-loop-convert
modernize-make-unique
modernize-pass-by-value
Index: clang-tidy/misc/VirtualNearMissCheck.h
===
--- /dev/null
+++ clang-tidy/misc/VirtualNearMissCheck.h
@@ -0,0 +1,94 @@
+//===--- VirtualNearMissCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_VIRTUAL_NEAR_MISS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_VIRTUAL_NEAR_MISS_H
+
+#include "../ClangTidy.h"
+#include 
+#include 
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+/// Generate warning if an method in derived class is a near miss to some virtual
+/// to base class:
+/// \code
+///   struct Base{
+/// virtual void func();
+///   };
+///   struct Derived:Base{
+/// virtual void funk(); // warning: do you want to override 'func'?
+///   };
+/// \endcode
+class VirtualNearMissCheck : public ClangTidyCheck {
+public:
+  VirtualNearMissCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void c

r257057 - Add missing -no-canonical-prefixes.

2016-01-07 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Thu Jan  7 06:53:59 2016
New Revision: 257057

URL: http://llvm.org/viewvc/llvm-project?rev=257057&view=rev
Log:
Add missing -no-canonical-prefixes.

Modified:
cfe/trunk/test/Driver/wasm-toolchain.c

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=257057&r1=257056&r2=257057&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Thu Jan  7 06:53:59 2016
@@ -2,7 +2,7 @@
 // enabling -ffunction-sections, -fdata-sections, and -fvisibility=hidden by
 // default.
 
-// RUN: %clang %s -### -target wasm32-unknown-unknown 2>&1 | FileCheck 
-check-prefix=CC1 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
2>&1 | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "wasm32-unknown-unknown" {{.*}} 
"-fvisibility" "hidden" {{.*}} "-ffunction-sections" "-fdata-sections"
 
 // Ditto, but ensure that a user -fno-function-sections disables the


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


Proposing a fix for revision 256933

2016-01-07 Thread Aboud, Amjad via cfe-commits
Hi Samuel,
I noticed that the two tests you added in the below commit have a minor issue.
"target_codegen_registration_naming.cpp" is failing on my local machine (Win32).
"target_codegen_registration.cpp" is not failing, but it contain "CHECK..." 
lines with wrong syntax that make FileCheck ignore them.

Please, see the attach patch I suggest for fixing these test.

Thanks,
Amjad


Author: sfantao

Date: Wed Jan  6 07:42:12 2016

New Revision: 256933



URL: http://llvm.org/viewvc/llvm-project?rev=256933&view=rev

Log:

[OpenMP] Reapply rL256842: [OpenMP] Offloading descriptor registration and 
device codegen.



This patch attempts to fix the regressions identified when the patch was 
committed initially.



Thanks to Michael Liao for identifying the fix in the offloading metadata 
generation

related with side effects in evaluation of function arguments.





Added:

cfe/trunk/test/OpenMP/target_codegen_registration.cpp

cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp

Modified:

cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td

cfe/trunk/include/clang/Basic/LangOptions.def

cfe/trunk/include/clang/Basic/LangOptions.h

cfe/trunk/include/clang/Driver/CC1Options.td

cfe/trunk/include/clang/Driver/Options.td

cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp

cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h

cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp

cfe/trunk/lib/CodeGen/CodeGenModule.cpp

cfe/trunk/lib/Frontend/CompilerInvocation.cpp

cfe/trunk/lib/Serialization/ASTReader.cpp

cfe/trunk/lib/Serialization/ASTWriter.cpp

cfe/trunk/test/OpenMP/target_codegen.cpp

cfe/trunk/test/OpenMP/target_codegen_global_capture.cpp

cfe/trunk/test/OpenMP/target_map_codegen.cpp

cfe/trunk/test/OpenMP/target_messages.cpp

-
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


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


r257062 - clang-format: Support weird lambda macros.

2016-01-07 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Thu Jan  7 08:36:11 2016
New Revision: 257062

URL: http://llvm.org/viewvc/llvm-project?rev=257062&view=rev
Log:
clang-format: Support weird lambda macros.

Before:
  MACRO((AA & a) { return 1; });

After:
  MACRO((AA &a) { return 1; });

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=257062&r1=257061&r2=257062&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Jan  7 08:36:11 2016
@@ -199,6 +199,18 @@ private:
 Left->MatchingParen = CurrentToken;
 CurrentToken->MatchingParen = Left;
 
+if (CurrentToken->Next && CurrentToken->Next->is(tok::l_brace) &&
+Left->Previous && Left->Previous->is(tok::l_paren)) {
+  // Detect the case where macros are used to generate lambdas or
+  // function bodies, e.g.:
+  //   auto my_lambda = MARCO((Type *type, int i) { .. body .. });
+  for (FormatToken *Tok = Left; Tok != CurrentToken; Tok = Tok->Next) {
+if (Tok->is(TT_BinaryOperator) &&
+Tok->isOneOf(tok::star, tok::amp, tok::ampamp))
+  Tok->Type = TT_PointerOrReference;
+  }
+}
+
 if (StartsObjCMethodExpr) {
   CurrentToken->Type = TT_ObjCMethodExpr;
   if (Contexts.back().FirstObjCSelectorName) {

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=257062&r1=257061&r2=257062&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Jan  7 08:36:11 2016
@@ -10630,6 +10630,7 @@ TEST_F(FormatTest, FormatsLambdas) {
   // Lambdas created through weird macros.
   verifyFormat("void f() {\n"
"  MACRO((const AA &a) { return 1; });\n"
+   "  MACRO((AA &a) { return 1; });\n"
"}");
 
   verifyFormat("if (blah_blah(whatever, whatever, [] {\n"


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


r257065 - [OpenMP] Fix issue in the offloading metadata testing.

2016-01-07 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Thu Jan  7 08:58:16 2016
New Revision: 257065

URL: http://llvm.org/viewvc/llvm-project?rev=257065&view=rev
Log:
[OpenMP] Fix issue in the offloading metadata testing.

 - Allow device ID to be signed.
 - Add missing semicolon to some of the CHECK directives.

Thanks to Amjad Aboud for detecting the issue.


Modified:
cfe/trunk/test/OpenMP/target_codegen_registration.cpp
cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp

Modified: cfe/trunk/test/OpenMP/target_codegen_registration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_codegen_registration.cpp?rev=257065&r1=257064&r2=257065&view=diff
==
--- cfe/trunk/test/OpenMP/target_codegen_registration.cpp (original)
+++ cfe/trunk/test/OpenMP/target_codegen_registration.cpp Thu Jan  7 08:58:16 
2016
@@ -407,31 +407,31 @@ int bar(int a){
 
 // Check metadata is properly generated:
 // CHECK: !omp_offload.info = !{!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 
!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 
!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}}
-// CHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32 [[FILEID:-?[0-9]+]], 
!"_ZN2SB3fooEv", i32 160, i32 13, i32 {{[0-9]}}+}
-// CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SDD2Ev", i32 210, 
i32 13, i32 {{[0-9]}}+}
-// CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SEC2Ev", i32 226, 
i32 13, i32 {{[0-9]}}+}
-// CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SED2Ev", i32 232, 
i32 13, i32 {{[0-9]}}+}
-// CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] 
!"_ZN2STILi1000EE3fooEv", i32 243, i32 13, i32 {{[0-9]}}+}
-// CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2STILi100EEC2Ev", 
i32 249, i32 13, i32 {{[0-9]}}+}
-// CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_Z3bari", i32 352, i32 
11, i32 {{[0-9]}}+}
-// CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2STILi100EED2Ev", 
i32 255, i32 13, i32 {{[0-9]}}+}
-// CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2STILi1000EEC2Ev", 
i32 249, i32 13, i32 {{[0-9]}}+}
-// CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2STILi1000EED2Ev", 
i32 255, i32 13, i32 {{[0-9]}}+}
-// CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2STILi100EE3fooEv", 
i32 243, i32 13, i32 {{[0-9]}}+}
-// CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SCC2Ev", i32 185, 
i32 13, i32 {{[0-9]}}+}
+// CHECK-DAG: = !{i32 0, i32 [[DEVID:-?[0-9]+]], i32 [[FILEID:-?[0-9]+]], 
!"_ZN2SB3fooEv", i32 193, i32 13, i32 {{[0-9]+}}}
+// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2SDD1Ev", i32 
243, i32 13, i32 {{[0-9]+}}}
+// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2SEC1Ev", i32 
259, i32 13, i32 {{[0-9]+}}}
+// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2SED1Ev", i32 
265, i32 13, i32 {{[0-9]+}}}
+// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], 
!"_ZN2STILi1000EE3fooEv", i32 276, i32 13, i32 {{[0-9]+}}}
+// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi100EEC1Ev", 
i32 282, i32 13, i32 {{[0-9]+}}}
+// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_Z3bari", i32 402, 
i32 11, i32 {{[0-9]+}}}
+// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi100EED1Ev", 
i32 288, i32 13, i32 {{[0-9]+}}}
+// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], 
!"_ZN2STILi1000EEC1Ev", i32 282, i32 13, i32 {{[0-9]+}}}
+// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], 
!"_ZN2STILi1000EED1Ev", i32 288, i32 13, i32 {{[0-9]+}}}
+// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], 
!"_ZN2STILi100EE3fooEv", i32 276, i32 13, i32 {{[0-9]+}}}
+// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2SCC1Ev", i32 
218, i32 13, i32 {{[0-9]+}}}
 
 // TCHECK: !omp_offload.info = !{!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 
!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 
!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}}
-// TCHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32 [[FILEID:-?[0-9]+]], 
!"_ZN2SB3fooEv", i32 160, i32 13, i32 {{[0-9]}}+}
-// TCHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SDD2Ev", i32 210, 
i32 13, i32 {{[0-9]}}+}
-// TCHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SEC2Ev", i32 226, 
i32 13, i32 {{[0-9]}}+}
-// TCHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SED2Ev", i32 232, 
i32 13, i32 {{[0-9]}}+}
-// TCHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] 
!"_ZN2STILi1000EE3fooEv", i32 243, i32 13, i32 {{[0-9]}}+}
-// TCHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2STILi100EEC2Ev", 
i32 249, i32 13, i32 {{[0-9]}}+}
-// TCHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_Z3bari", i32 352, 
i32 11, i32 {{[0-9]}}+}
-// TCHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2STILi100EED2Ev", 
i32 255, i32 13, i32 {{[0-9]}}+}
-// TCHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2STILi1000EEC2Ev",

Re: [PATCH] D15914: [OpenCL] Pipe builtin functions

2016-01-07 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: include/clang/Basic/Builtins.def:1255
@@ -1254,1 +1254,3 @@
 
+// OpenCL 2.0 Pipe functions.
+// We need the variadic prototype, since the packet type could be anything.

Could we put reference to spec section?


Comment at: include/clang/Basic/Builtins.def:1256
@@ +1255,3 @@
+// OpenCL 2.0 Pipe functions.
+// We need the variadic prototype, since the packet type could be anything.
+BUILTIN(read_pipe, "i.", "tn")

Is variadic right here? Should be generic perhaps? 


Comment at: include/clang/Basic/Builtins.def:1257
@@ +1256,3 @@
+// We need the variadic prototype, since the packet type could be anything.
+BUILTIN(read_pipe, "i.", "tn")
+BUILTIN(write_pipe, "i.", "tn")

I think it would make sense to have this as LANGBUILTIN as it's only available 
in OpenCL.


Comment at: include/clang/Basic/Builtins.def:1260
@@ +1259,3 @@
+
+BUILTIN(reserve_read_pipe, "i.", "tn")
+BUILTIN(reserve_write_pipe, "i.", "tn")

From reserve_read_pipe onwards the builtins have a fixed number of arguments, 
and don't need to be variadic.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7643
@@ -7642,1 +7642,3 @@
   "pipes packet types cannot be of reference type">;
+// Builtin pipe
+def err_builtin_pipe_first_arg : Error<

add OpenCL v2.0


Comment at: lib/CodeGen/CGBuiltin.cpp:2028
@@ +2027,3 @@
+  Value *BCast = Builder.CreatePointerCast(Arg3, I8PTy);
+  // We know the third argument is an integer type (Verified by Sema, but
+  // we may need to cast it.

Closing ) is missing.


Comment at: lib/CodeGen/CGBuiltin.cpp:2033
@@ +2032,3 @@
+  return RValue::get(
+  Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name),
+ {Arg0, Arg1, Arg2, BCast, PacketSize}));

So why do we need to mangle at all since the generated function signature will 
always have the same parameter types?


Comment at: lib/CodeGen/CGBuiltin.cpp:2081
@@ +2080,3 @@
+  Arg1 = Builder.CreateZExtOrTrunc(Arg1, Int32Ty);
+return RValue::get(Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name),
+  {Arg0, Arg1, PacketSize}));

So why do we need to mangle at all since the generated function signatures will 
always have the same parameter types?


Comment at: lib/CodeGen/CGOpenCLRuntime.h:55
@@ -50,1 +54,3 @@
 };
+class Ocl20Mangler {
+public:

I am not very convinced on this solution of implementing a separate mangler. 
Also how would it play together with existing mangling schemes?

Additionally how would definitions of builtin with user defined types appear in 
the BIF libraries? I am not clear at the moment.

One approach would be to just generate calls that would always use generic 
types:  opaque type for pipe and void* for a packet and avoid the mangling 
completely. That's what I think is done already (see previous comment), just 
not clear why mangling is added too.


Comment at: lib/Sema/SemaChecking.cpp:267
@@ +266,3 @@
+/// Returns OpenCL access qual.
+static OpenCLImageAccessAttr *getOpenCLImageAcces(const Decl *D) {
+  if (D->hasAttr())

Not sure why we have an image access here?


Comment at: lib/Sema/SemaChecking.cpp:268
@@ +267,3 @@
+static OpenCLImageAccessAttr *getOpenCLImageAcces(const Decl *D) {
+  if (D->hasAttr())
+return D->getAttr();

What happens if access qualifier is not provided?

According to spec it should default to read_only!


Comment at: lib/Sema/SemaChecking.cpp:274
@@ +273,3 @@
+/// Returns true if pipe element type is different from the pointer.
+static bool checkOpenCLPipeArg(Sema &S, CallExpr *call) {
+  const Expr *Arg0 = call->getArg(0);

Should we also be checking that read_write is not used with pipe?


Comment at: lib/Sema/SemaChecking.cpp:282
@@ +281,3 @@
+  }
+  OpenCLImageAccessAttr *AccessQual =
+  getOpenCLImageAcces(cast(Arg0)->getDecl());

Should be a generic name rather than image!


Comment at: lib/Sema/SemaChecking.cpp:291
@@ +290,3 @@
+  if (getFunctionName(call).find("read") != StringRef::npos)
+// if (getFunctionName(call).startswith("read"))
+isValid = AccessQual == nullptr || AccessQual->isReadOnly();

Remove this commented code


Comment at: lib/Sema/SemaChecking.cpp:296
@@ +295,3 @@
+  if (!isValid) {
+bool ReadOnly = getFunctionName(call).startswith("read");
+const char *AM = ReadOnly ? "read_only" : "write_only";

Should you be checking find() instead of startwith()? 


Comment at: lib/Sema/SemaChecking.cpp:297
@@ +296,3 @@
+bool ReadOnl

Re: [PATCH] D15456: [PATCH] New diagnostic for non-idiomatic copy or move operations (v2)

2016-01-07 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D15456#320946, @rsmith wrote:

> I'm unconvinced this meets the bar for an on-by-default warning. Your 
> suggested workaround for correct-but-diagnosed code doesn't seem to work: if 
> I have
>
>   struct X {
> X(const volatile X&);
>   };
>   
>
> ... adding
>
>   X(const X&) = delete;
>   
>
> or a private "normal" copy constructor will break clients of my code that 
> happen to have a non-volatile `X` object.


That's a good point. You could use delegating constructors to silence the 
warning, but that is a bit intrusive (and non-functional for coding targeting 
older versions of the standard).

> This will also diagnose the pre-C++11 idiom of:

> 

>   struct noncopyable {

> noncopyable(noncopyable&);

> void operator=(noncopyable&);

>   };

>

> 

> ... where the references are deliberately references to non-const in order to 
> allow more bugs to be caught at compile time.


This was intentional, based on discussion. The thought was that (1) these are 
still copy constructible/assignable (within the context of the class type 
itself), and (2) they're still not idiomatic. However, I do think that's a bit 
of a weak argument and would be fine allowing those cases.

> I'd also expect that if the user wrote more tokens than would be present in 
> the idiomatic declaration, they probably know what they're doing (so don't 
> reject extra cv-qualifiers and ref-qualifiers).


It would be oddly inconsistent to warn on some non-idiomatic operations, but 
then fail to warn on other non-idiomatic operations though. However, it may 
make sense

> Can you provide a list of the things this found in Qt and rethinkdb? Is there 
> some pattern in them? Are they bugs?


The Qt issues are things like: 
http://code.qt.io/cgit/qt/qtbase.git/tree/src/tools/uic/ui4.h?h=dev#n379 
However, there are also plenty like:

dom/QualifiedName.h:70:11: warning: non-idiomatic copy assignment operator 
declaration; consider returning 'T&' instead [-Wnon-idiomatic-copy-move]

  const QualifiedName& operator=(const QualifiedName& other) { other.ref(); 
deref(); m_impl = other.m_impl; return *this; }

Rethink's look more like:


http://reviews.llvm.org/D15456



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


Re: [PATCH] D15456: [PATCH] New diagnostic for non-idiomatic copy or move operations (v2)

2016-01-07 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

(Sorry, fat fingered the original response.)

In http://reviews.llvm.org/D15456#320946, @rsmith wrote:

> I'm unconvinced this meets the bar for an on-by-default warning. Your 
> suggested workaround for correct-but-diagnosed code doesn't seem to work: if 
> I have
>
>   struct X {
> X(const volatile X&);
>   };
>   
>
> ... adding
>
>   X(const X&) = delete;
>   
>
> or a private "normal" copy constructor will break clients of my code that 
> happen to have a non-volatile `X` object.


That's a good point. You could use delegating constructors to silence the 
warning, but that is a bit intrusive (and non-functional for coding targeting 
older versions of the standard).

> This will also diagnose the pre-C++11 idiom of:

> 

>   struct noncopyable {

> noncopyable(noncopyable&);

> void operator=(noncopyable&);

>   };

>

> 

> ... where the references are deliberately references to non-const in order to 
> allow more bugs to be caught at compile time.


This was intentional, based on discussion. The thought was that (1) these are 
still copy constructible/assignable (within the context of the class type 
itself), and (2) they're still not idiomatic. However, I do think that's a bit 
of a weak argument and would be fine allowing those cases.

> I'd also expect that if the user wrote more tokens than would be present in 
> the idiomatic declaration, they probably know what they're doing (so don't 
> reject extra cv-qualifiers and ref-qualifiers).


It would be oddly inconsistent to warn on some non-idiomatic operations, but 
then fail to warn on other non-idiomatic operations though. However, it may 
make sense

> Can you provide a list of the things this found in Qt and rethinkdb? Is there 
> some pattern in them? Are they bugs?


The Qt issues are things like: 
http://code.qt.io/cgit/qt/qtbase.git/tree/src/tools/uic/ui4.h?h=dev#n379 
However, there are also plenty like:

dom/QualifiedName.h:70:11: warning: non-idiomatic copy assignment operator 
declaration; consider returning 'T&' instead [-Wnon-idiomatic-copy-move]

  const QualifiedName& operator=(const QualifiedName& other) { other.ref(); 
deref(); m_impl = other.m_impl; return *this; }

Rethink's look more like:
./src/rapidjson/document.h:329:5: error: non-idiomatic copy assignment operator 
declaration; consider returning 'T&' instead [-Werror,-Wnon-idiomatic-copy-move]

  GenericStringRef operator=(const GenericStringRef&);
  ^

./src/rapidjson/document.h:595:43: error: non-idiomatic copy assignment 
operator declaration; consider 'const T&' instead 
[-Werror,-Wnon-idiomatic-copy-move]

  GenericValue& operator=(GenericValue& rhs) RAPIDJSON_NOEXCEPT {
^

Whether the issues pointed out are bugs or not is a bit more subjective as it 
depends on the usage. Some seems like they aren't (such as Qt's stuff in ui4.h 
which are old-style "deleted" functions). Others seem like they definitely are, 
such as what I pointed out from rethinkdb (though rethink also had some 
old-style deleted functions as well). And others seem questionable, such as 
Qt's QualifiedName, where it could go either way.


http://reviews.llvm.org/D15456



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


Re: r257005 - [WebAssembly] Enable -ffunction-sections and -fdata-sections by default.

2016-01-07 Thread JF Bastien via cfe-commits
It looks like that's just wasmate. I'll accelerate its deletion.

On Wed, Jan 6, 2016 at 6:41 PM, JF Bastien  wrote:

> Hi Dan,
>
> I think this change (or one of the surrounding ones) broken compiling C
> code with WebAssembly.
>
> Errors look like:  error at line 3: unknown section: .text.foobar
>
> See:
> https://build.chromium.org/p/client.wasm.llvm/builders/linux/builds/1507/steps/Link%20LLVM%20Torture%20with%20wasmate/logs/stdio
>
> Could you look into it?
>
> Thanks,
>
> JF
>
> On Wed, Jan 6, 2016 at 4:50 PM, Dan Gohman via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: djg
>> Date: Wed Jan  6 18:50:27 2016
>> New Revision: 257005
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=257005&view=rev
>> Log:
>> [WebAssembly] Enable -ffunction-sections and -fdata-sections by default.
>>
>> These remain user-overridable with -fno-function-sections and
>> -fno-data-sections.
>>
>> Modified:
>> cfe/trunk/lib/Driver/Tools.cpp
>> cfe/trunk/test/Driver/wasm-toolchain.c
>>
>> Modified: cfe/trunk/lib/Driver/Tools.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=257005&r1=257004&r2=257005&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Driver/Tools.cpp (original)
>> +++ cfe/trunk/lib/Driver/Tools.cpp Wed Jan  6 18:50:27 2016
>> @@ -4176,8 +4176,11 @@ void Clang::ConstructJob(Compilation &C,
>>  CmdArgs.push_back("-generate-type-units");
>>}
>>
>> -  // CloudABI uses -ffunction-sections and -fdata-sections by default.
>> -  bool UseSeparateSections = Triple.getOS() == llvm::Triple::CloudABI;
>> +  // CloudABI and WebAssembly use -ffunction-sections and
>> -fdata-sections by
>> +  // default.
>> +  bool UseSeparateSections = Triple.getOS() == llvm::Triple::CloudABI ||
>> + Triple.getArch() == llvm::Triple::wasm32 ||
>> + Triple.getArch() == llvm::Triple::wasm64;
>>
>>if (Args.hasFlag(options::OPT_ffunction_sections,
>> options::OPT_fno_function_sections,
>> UseSeparateSections)) {
>> @@ -6536,7 +6539,9 @@ void wasm::Linker::ConstructJob(Compilat
>>CmdArgs.push_back("ld");
>>
>>// Enable garbage collection of unused input sections by default,
>> since code
>> -  // size is of particular importance.
>> +  // size is of particular importance. This is significantly facilitated
>> by
>> +  // the enabling of -ffunction-sections and -fdata-sections in
>> +  // Clang::ConstructJob.
>>if (areOptimizationsEnabled(Args))
>>  CmdArgs.push_back("--gc-sections");
>>
>>
>> Modified: cfe/trunk/test/Driver/wasm-toolchain.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=257005&r1=257004&r2=257005&view=diff
>>
>> ==
>> --- cfe/trunk/test/Driver/wasm-toolchain.c (original)
>> +++ cfe/trunk/test/Driver/wasm-toolchain.c Wed Jan  6 18:50:27 2016
>> @@ -1,7 +1,19 @@
>>  // A basic clang -cc1 command-line.
>>
>>  // RUN: %clang %s -### -target wasm32-unknown-unknown 2>&1 | FileCheck
>> -check-prefix=CC1 %s
>> -// CC1: clang{{.*}} "-cc1" "-triple" "wasm32-unknown-unknown" {{.*}}
>> +// CC1: clang{{.*}} "-cc1" "-triple" "wasm32-unknown-unknown" {{.*}}
>> "-ffunction-sections" "-fdata-sections"
>> +
>> +// Ditto, but ensure that a user -fno-function-sections disables the
>> +// default -ffunction-sections.
>> +
>> +// RUN: %clang %s -### -target wasm32-unknown-unknown
>> -fno-function-sections 2>&1 | FileCheck -check-prefix=NO_FUNCTION_SECTIONS
>> %s
>> +// NO_FUNCTION_SECTIONS-NOT: function-sections
>> +
>> +// Ditto, but ensure that a user -fno-data-sections disables the
>> +// default -fdata-sections.
>> +
>> +// RUN: %clang %s -### -target wasm32-unknown-unknown -fno-data-sections
>> 2>&1 | FileCheck -check-prefix=NO_DATA_SECTIONS %s
>> +// NO_DATA_SECTIONS-NOT: data-sections
>>
>>  // A basic C link command-line.
>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15862: A possible direction for fixing https://llvm.org/bugs/show_bug.cgi?id=25973.

2016-01-07 Thread Marshall Clow via cfe-commits
mclow.lists updated this revision to Diff 44220.
mclow.lists added a comment.

Fixed a problem in the `__is_exactly_input_iterator` trait where it would fail 
to compile if `<_Iter>` was not an iterator.

Added the cases for `append`, `insert`, and `replace`.

I have updated the tests (not included in this diff)


http://reviews.llvm.org/D15862

Files:
  include/algorithm
  include/iterator
  include/string

Index: include/string
===
--- include/string
+++ include/string
@@ -1201,6 +1201,25 @@
 #pragma warning( pop )
 #endif // _LIBCPP_MSVC
 
+#ifdef _LIBCPP_HAS_NO_NOEXCEPT
+template 
+struct __libcpp_string_gets_noexcept_iterator_impl : public _LIBCPP_BOOL_CONSTANT(false) {};
+#else
+template 
+struct __libcpp_string_gets_noexcept_iterator_impl : public _LIBCPP_BOOL_CONSTANT((
+__is_forward_iterator<_Iter>::value && 
+noexcept(++(declval<_Iter&>())) && 
+is_nothrow_assignable<_Iter&, _Iter>::value && 
+noexcept(declval<_Iter>() == declval<_Iter>()) && 
+noexcept(*declval<_Iter>())
+)) {};
+#endif
+
+
+template 
+struct __libcpp_string_gets_noexcept_iterator
+: public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value || __libcpp_string_gets_noexcept_iterator_impl<_Iter>::value) {};
+
 #ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
 
 template 
@@ -1495,15 +1514,16 @@
 template
 typename enable_if
 <
- __is_input_iterator  <_InputIterator>::value &&
-!__is_forward_iterator<_InputIterator>::value,
+__is_exactly_input_iterator<_InputIterator>::value
+|| !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
 basic_string&
 >::type
 append(_InputIterator __first, _InputIterator __last);
 template
 typename enable_if
 <
-__is_forward_iterator<_ForwardIterator>::value,
+__is_forward_iterator<_ForwardIterator>::value
+&& __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,
 basic_string&
 >::type
 append(_ForwardIterator __first, _ForwardIterator __last);
@@ -1535,15 +1555,16 @@
 template
 typename enable_if
 <
- __is_input_iterator  <_InputIterator>::value &&
-!__is_forward_iterator<_InputIterator>::value,
+   __is_exactly_input_iterator<_InputIterator>::value
+|| !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
 basic_string&
 >::type
 assign(_InputIterator __first, _InputIterator __last);
 template
 typename enable_if
 <
-__is_forward_iterator<_ForwardIterator>::value,
+__is_forward_iterator<_ForwardIterator>::value
+ && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,
 basic_string&
 >::type
 assign(_ForwardIterator __first, _ForwardIterator __last);
@@ -1564,15 +1585,16 @@
 template
 typename enable_if
 <
- __is_input_iterator  <_InputIterator>::value &&
-!__is_forward_iterator<_InputIterator>::value,
+   __is_exactly_input_iterator<_InputIterator>::value
+|| !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
 iterator
 >::type
 insert(const_iterator __pos, _InputIterator __first, _InputIterator __last);
 template
 typename enable_if
 <
-__is_forward_iterator<_ForwardIterator>::value,
+__is_forward_iterator<_ForwardIterator>::value
+ && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,
 iterator
 >::type
 insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last);
@@ -1817,8 +1839,7 @@
 template 
 typename enable_if
 <
- __is_input_iterator  <_InputIterator>::value &&
-!__is_forward_iterator<_InputIterator>::value,
+__is_exactly_input_iterator<_InputIterator>::value,
 void
 >::type
 __init(_InputIterator __first, _InputIterator __last);
@@ -2195,8 +2216,7 @@
 template 
 typename enable_if
 <
- __is_input_iterator  <_InputIterator>::value &&
-!__is_forward_iterator<_InputIterator>::value,
+__is_exactly_input_iterator<_InputIterator>::value,
 void
 >::type
 basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _InputIterator __last)
@@ -2494,15 +2514,14 @@
 template
 typename enable_if
 <
- __is_input_iterator  <_InputIterator>::value &&
-!__is_forward_iterator<_InputIterator>::value,
+ __is_exactly_input_iterator <_InputIterator>::value
+  || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
 basic_string<_CharT, _Traits, _Allocator>&
 >::type
 basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
 {
-

Re: [PATCH] D15862: A possible direction for fixing https://llvm.org/bugs/show_bug.cgi?id=25973.

2016-01-07 Thread Marshall Clow via cfe-commits
mclow.lists marked an inline comment as done.
mclow.lists added a comment.

http://reviews.llvm.org/D15862



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


Re: [PATCH] D15953: Driver: Pass -flavor gnu to lld for AMDGPU rather than -flavor gnu-old

2016-01-07 Thread Rui Ueyama via cfe-commits
ruiu added a comment.

You can use "ld.lld" which is a symlink to lld instead of "lld -flavor gnu".


http://reviews.llvm.org/D15953



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


Re: [PATCH] D15862: A possible direction for fixing https://llvm.org/bugs/show_bug.cgi?id=25973.

2016-01-07 Thread Tim Song via cfe-commits
tcanens added inline comments.


Comment at: include/string:2677-2678
@@ +2676,4 @@
+#endif
+for (; __first != __last; ++__first)
+push_back(*__first);
+

If an exception is thrown after a `push_back()` causes reallocation, existing 
iterators/pointers/references would have been invalidated, and the `catch` 
block can't do anything about it.

It looks like a temporary string is also needed here.


http://reviews.llvm.org/D15862



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


Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.

2016-01-07 Thread Haojian Wu via cfe-commits
hokein added a comment.

In http://reviews.llvm.org/D15710#321198, @aaron.ballman wrote:

> LGTM, thank you for working on this!


Ping @Alexfh. After the patch gets merged, I will work on the configuration of 
header file extension.


http://reviews.llvm.org/D15710



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


Re: [PATCH] D15506: [ASTMatchers] Allow hasName() to look through inline namespaces

2016-01-07 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

It'll be great to finalize fix before 3.8 branching (planned at January 13).


http://reviews.llvm.org/D15506



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


Re: [PATCH] D15823: Support virtual-near-miss check.

2016-01-07 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

A few more comments.



Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:22
@@ +21,3 @@
+
+bool VirtualNearMissCheck::isOverrideMethod(const CXXMethodDecl *MD) {
+  return MD->size_overridden_methods() > 0 || MD->hasAttr();

This should be a free-standing function.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:48
@@ +47,3 @@
+
+bool VirtualNearMissCheck::checkOverridingFunctionReturnType(
+const ASTContext *Context, const CXXMethodDecl *BaseMD,

IIUC, this can be a free-standing function instead of a method, since it 
doesn't use any class members.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:110
@@ +109,3 @@
+// of D, or D is the same class which DerivedMD is in.
+bool IsIteself = DRD == DerivedMD->getParent();
+bool HasPublicAccess = false;

nit: typo: s/IsIteself/IsItself/


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:112
@@ +111,3 @@
+bool HasPublicAccess = false;
+for (CXXBasePaths::paths_iterator Path = Paths.begin(); Path != 
Paths.end();
+ ++Path) {

Why not a range-for loop?


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:118
@@ +117,3 @@
+}
+if (!(HasPublicAccess || IsIteself))
+  return false;

Please propagate the negation inside parentheses: `!HasPublicAccess && 
!IsItself`.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:129
@@ +128,3 @@
+  // The class type D should have the same cv-qualification as or less
+  // cv-qualification than the class type B
+  if (DTy.isMoreQualifiedThan(BTy))

nit: Please add a trailing period.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:136
@@ +135,3 @@
+
+bool VirtualNearMissCheck::checkParamType(const CXXMethodDecl *BaseMD,
+  const CXXMethodDecl *DerivedMD) {

This should be `checkParamTypes`, note the plural form.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:136
@@ +135,3 @@
+
+bool VirtualNearMissCheck::checkParamType(const CXXMethodDecl *BaseMD,
+  const CXXMethodDecl *DerivedMD) {

alexfh wrote:
> This should be `checkParamTypes`, note the plural form.
This can be a free-standing function, since it doesn't use any class members.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:138
@@ +137,3 @@
+  const CXXMethodDecl *DerivedMD) {
+  unsigned int NumParamA = BaseMD->getNumParams();
+  unsigned int NumParamB = DerivedMD->getNumParams();

I'd slightly prefer `unsigned` over `unsigned int`.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:163
@@ +162,3 @@
+
+std::string VirtualNearMissCheck::generateMethodId(const CXXMethodDecl *MD) {
+  std::string Id =

This should be a free-standing function.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:164
@@ +163,3 @@
+std::string VirtualNearMissCheck::generateMethodId(const CXXMethodDecl *MD) {
+  std::string Id =
+  MD->getQualifiedNameAsString() + " " + MD->getType().getAsString();

The variable is not needed here, just return the expression.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:169
@@ +168,3 @@
+
+bool VirtualNearMissCheck::isPossibleToBeOverriden(
+const CXXMethodDecl *BaseMD) {

s/Overriden/Overridden/


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:175
@@ +174,3 @@
+  if (Iter != PossibleMap.end()) {
+IsPossible = Iter->second;
+  } else {

I'd just `return Iter->second;` and remove `else`. Same below in the 
`isOverridenByDerivedClass` method.


http://reviews.llvm.org/D15823



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


Re: [PATCH] D15881: [DWARF] Omitting the explicit import of an anonymous namespace is a debugger-tuning decision, not a target decision.

2016-01-07 Thread Paul Robinson via cfe-commits
probinson added a comment.

Ping. I did want to get this finished off (moving all triple-based decisions to 
tuning-based decisions) before 3.8 branches.


http://reviews.llvm.org/D15881



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


Re: [PATCH] D15599: [CodeGen] Fix a crash that occurs when attribute "naked" is attached to a c++ member function

2016-01-07 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

ping


http://reviews.llvm.org/D15599



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


r257085 - Correcting the comment in a header file; NFC.

2016-01-07 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Jan  7 13:00:54 2016
New Revision: 257085

URL: http://llvm.org/viewvc/llvm-project?rev=257085&view=rev
Log:
Correcting the comment in a header file; NFC.

Modified:
cfe/trunk/include/clang/AST/BuiltinTypes.def

Modified: cfe/trunk/include/clang/AST/BuiltinTypes.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/BuiltinTypes.def?rev=257085&r1=257084&r2=257085&view=diff
==
--- cfe/trunk/include/clang/AST/BuiltinTypes.def (original)
+++ cfe/trunk/include/clang/AST/BuiltinTypes.def Thu Jan  7 13:00:54 2016
@@ -1,4 +1,4 @@
-//===-- BuiltinTypeNodes.def - Metadata about BuiltinTypes --*- C++ 
-*-===//
+//===-- BuiltinTypes.def - Metadata about BuiltinTypes --*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //


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


Re: [PATCH] D15173: [Preprocessor] Fix assertion in AnnotatePreviousCachedTokens

2016-01-07 Thread Richard Smith via cfe-commits
On Wed, Jan 6, 2016 at 4:22 PM, Bruno Cardoso Lopes  wrote:

> bruno updated this revision to Diff 44180.
> bruno added a comment.
>
> Hi Richard,
>
> Thanks for the comments. Updated the patch!
>
> In http://reviews.llvm.org/D15173#313235, @rsmith wrote:
>
> > I think that this will leave us with a broken token stream. In your
> example, the cached token stream starts as
> >
> >   `NSArray` `<` `id` `<` `PB` `>>` `*` [...]
> >
> >
> > ... and we try to annotate the `id` with our `CachedLexPos` pointing
> at the `*` token. That leaves `CachedTokens` containing:
> >
> >   `NSArray` `<` `(type annotation)` `*` [...]
> >
> >
> > ... which is wrong. We need to actually convert the
> `tok::greatergreater` in `CachedTokens` into a `tok::greater` and update
> its location and length in order for the cached token stream to be
> correctly updated. Otherwise if the parser backtracks it will see the wrong
> token stream.
>
>
> I don't think this happens, the type annotation starts at 7:11 and ends at
> 7:24:
> identifier 'NSArray'Loc=
> greatergreater '>>' Loc=
>
> The code that follows the assert then patches the CachedTokens the correct
> way, see the CachedTokens before and after:
>

This example doesn't show the above problem, because it's annotating the
NSArray<...> type, not the id<...> type. On reflection, the problem that
I'm concerned about won't actually trigger the assertion here (except in
weird and rare cases like annotating the middle > in a >>> token), but it's
really caused by the same underlying bug. In practice, things will go wrong
in two ways when we want to annotate half of a split token such as `>>`:

1) If the annotation ends in the middle of a split token, we'll currently
annotate the entire token and lose the second half if we backtrack
2) If the annotation ends at the end of a split token, we'll assert because
the start of the final token is not on a token boundary in the cached token
stream

The underlying bug is that splitting a token is not properly updating the
token cache. Assuming we never want to split a token, then backtrack over
the token, then choose to not split it, the best fix would seem to be to
update the cached token stream at the point when we perform the split
(replace the tok::greatergreater with two tok::greaters in CachedTokens).
And I think that's a correct assumption, as we only consider splitting when
we know we're parsing a template argument list, and in that context the
token is always split.


> - Before:
>
> (clang::Preprocessor::CachedTokensTy) $32 = {
>
>   [0] = (Loc = 89, UintData = 1, PtrData = 0x, Kind =
> l_paren, Flags = 0)
>   [1] = (Loc = 90, UintData = 7, PtrData = 0x00010d82fba0, Kind =
> identifier, Flags = 0)
>   [2] = (Loc = 97, UintData = 1, PtrData = 0x, Kind =
> less, Flags = 0)
>   [3] = (Loc = 98, UintData = 2, PtrData = 0x00010d01da58, Kind =
> identifier, Flags = 0)
>   [4] = (Loc = 100, UintData = 1, PtrData = 0x, Kind =
> less, Flags = 0)
>   [5] = (Loc = 101, UintData = 2, PtrData = 0x00010d82fb70, Kind =
> identifier, Flags = 0)
>   [6] = (Loc = 103, UintData = 2, PtrData = 0x, Kind =
> greatergreater, Flags = 0)
>   [7] = (Loc = 106, UintData = 1, PtrData = 0x, Kind =
> star, Flags = 2)
>
> }
>
> - After:
>
> (clang::Preprocessor::CachedTokensTy) $34 = {
>
>   [0] = (Loc = 89, UintData = 1, PtrData = 0x, Kind =
> l_paren, Flags = 0)
>   [1] = (Loc = 90, UintData = 104, PtrData = 0x00010d820660, Kind =
> annot_typename, Flags = 0)
>   [2] = (Loc = 106, UintData = 1, PtrData = 0x, Kind =
> star, Flags = 2)
>
> }
>
>
> http://reviews.llvm.org/D15173
>
> Files:
>   lib/Lex/PPCaching.cpp
>   test/Parser/objcxx11-protocol-in-template.mm
>
> Index: test/Parser/objcxx11-protocol-in-template.mm
> ===
> --- test/Parser/objcxx11-protocol-in-template.mm
> +++ test/Parser/objcxx11-protocol-in-template.mm
> @@ -8,3 +8,11 @@
>
>  vector> v;
>  vector>> v2;
> +
> +@protocol PA;
> +@protocol PB;
> +
> +@class NSArray;
> +typedef int some_t;
> +
> +id FA(NSArray> *h, some_t group);
> Index: lib/Lex/PPCaching.cpp
> ===
> --- lib/Lex/PPCaching.cpp
> +++ lib/Lex/PPCaching.cpp
> @@ -97,13 +97,33 @@
>  void Preprocessor::AnnotatePreviousCachedTokens(const Token &Tok) {
>assert(Tok.isAnnotation() && "Expected annotation token");
>assert(CachedLexPos != 0 && "Expected to have some cached tokens");
> -  assert(CachedTokens[CachedLexPos-1].getLastLoc() ==
> Tok.getAnnotationEndLoc()
> - && "The annotation should be until the most recent cached
> token");
> +
> +#ifndef NDEBUG
> +  {
> +Token CachedLastTok = CachedTokens[CachedLexPos - 1];
> +SourceLocation CachedLastTokLoc = CachedLastTok.getLastLoc();
> +SourceLocation TokAnnEndLoc = Tok.getAnnotationEndLoc();

Re: [PATCH] D15958: u8 character literals

2016-01-07 Thread Richard Smith via cfe-commits
rsmith added a comment.

Thanks!

You also need to update ASTWriterDecl.cpp's construction of 
`CharacterLiteralAbbrev` to allow three bits of `Kind` rather than two. (You 
should be able to repro this with a PCH test pretty-printing a `U'x'` literal.)



Comment at: lib/Sema/SemaTemplate.cpp:5507
@@ -5506,1 +5506,3 @@
+// This does not need to handle u8 character literals because those are
+// of type char, and so can also be covered by an Ascii character literal.
 CharacterLiteral::CharacterKind Kind;

Ascii -> ASCII


http://reviews.llvm.org/D15958



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


r257090 - Remove extraneous "Note t" in comment.

2016-01-07 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Jan  7 13:38:29 2016
New Revision: 257090

URL: http://llvm.org/viewvc/llvm-project?rev=257090&view=rev
Log:
Remove extraneous "Note t" in comment.

Added in r167571.

Modified:
cfe/trunk/include/clang/Driver/ToolChain.h

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=257090&r1=257089&r2=257090&view=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Thu Jan  7 13:38:29 2016
@@ -134,7 +134,7 @@ public:
   StringRef getOS() const { return Triple.getOSName(); }
 
   /// \brief Provide the default architecture name (as expected by -arch) for
-  /// this toolchain. Note t
+  /// this toolchain.
   StringRef getDefaultUniversalArchName() const;
 
   std::string getTripleString() const {


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


Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2016-01-07 Thread Nathan Wilson via cfe-commits
nwilson added a comment.

Ping. Now that the holidays are over-ish, as Aaron said in one of his Patches.


http://reviews.llvm.org/D13357



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


Re: [PATCH] D15861: Support fully-qualified names for all QualTypes

2016-01-07 Thread Sterling Augustine via cfe-commits
saugustine updated this revision to Diff 44245.
saugustine marked 4 inline comments as done.
saugustine added a comment.

- Update docs. Handle keywords and anonymous namespaces.


http://reviews.llvm.org/D15861

Files:
  include/clang/Tooling/Core/QualTypeNames.h
  lib/Tooling/Core/CMakeLists.txt
  lib/Tooling/Core/QualTypeNames.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/QualTypeNamesTest.cpp

Index: unittests/Tooling/QualTypeNamesTest.cpp
===
--- /dev/null
+++ unittests/Tooling/QualTypeNamesTest.cpp
@@ -0,0 +1,135 @@
+//===- unittest/Tooling/QualTypeNameTest.cpp --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Tooling/Core/QualTypeNames.h"
+#include "TestVisitor.h"
+using namespace clang;
+
+namespace {
+struct TypeNameVisitor : TestVisitor {
+  llvm::StringMap ExpectedQualTypeNames;
+
+  // ValueDecls are the least-derived decl with both a qualtype and a
+  // name.
+  bool traverseDecl(Decl *D) {
+return true;  // Always continue
+  }
+
+  bool VisitValueDecl(const ValueDecl *VD) {
+std::string ExpectedName =
+ExpectedQualTypeNames.lookup(VD->getNameAsString());
+if (ExpectedName != "") {
+  std::string ActualName =
+  TypeName::getFullyQualifiedName(VD->getType(), *Context);
+  if (ExpectedName != ActualName) {
+// A custom message makes it much easier to see what declaration
+// failed compared to EXPECT_EQ.
+EXPECT_TRUE(false) << "Typename::getFullyQualifiedName failed for "
+   << VD->getQualifiedNameAsString() << std::endl
+   << "   Actual: " << ActualName << std::endl
+   << " Exepcted: " << ExpectedName;
+  }
+}
+return true;
+  }
+};
+
+TEST(QualTypeNameTest, getFullyQualifiedName) {
+  TypeNameVisitor Visitor;
+  // Simple case to test the test framework itself.
+  Visitor.ExpectedQualTypeNames["CheckInt"] = "int";
+
+  // Keeping the names of the variables whose types we check unique
+  // within the entire test--regardless of their own scope--makes it
+  // easier to diagnose test failures.
+
+  // Simple namespace qualifier
+  Visitor.ExpectedQualTypeNames["CheckA"] = "A::B::Class0";
+  // Lookup up the enclosing scopes, then down another one. (These
+  // appear as elaborated type in the AST. In that case--even if
+  // policy.SuppressScope = 0--qual_type.getAsString(policy) only
+  // gives the name as it appears in the source, not the full name.
+  Visitor.ExpectedQualTypeNames["CheckB"] = "A::B::C::Class1";
+  // Template parameter expansion.
+  Visitor.ExpectedQualTypeNames["CheckC"] =
+  "A::B::Template0";
+  // Recursive template parameter expansion.
+  Visitor.ExpectedQualTypeNames["CheckD"] =
+  "A::B::Template0, "
+  "A::B::Template0 >";
+  // Variadic Template expansion.
+  Visitor.ExpectedQualTypeNames["CheckE"] =
+  "A::Variadic, "
+  "A::B::Template1, A::B::C::MyInt>";
+  // Using declarations should be fully expanded.
+  Visitor.ExpectedQualTypeNames["CheckF"] = "A::B::Class0";
+  // Elements found within "using namespace foo;" should be fully
+  // expanded.
+  Visitor.ExpectedQualTypeNames["CheckG"] = "A::B::C::MyInt";
+  // Type inside function
+  Visitor.ExpectedQualTypeNames["CheckH"] = "struct X";
+  // Anonymous Namespaces
+  Visitor.ExpectedQualTypeNames["CheckI"] = "aClass";
+  // Keyword inclusion with namespaces
+  Visitor.ExpectedQualTypeNames["CheckJ"] = "struct A::aStruct";
+  Visitor.runOver(
+  "int CheckInt;\n"
+  "namespace A {\n"
+  " namespace B {\n"
+  "   class Class0 { };\n"
+  "   namespace C {\n"
+  " typedef int MyInt;"
+  "   }\n"
+  "   template class Template0;"
+  "   template class Template1;"
+  "   typedef B::Class0 AnotherClass;\n"
+  "   void Function1(Template0 CheckC);\n"
+  "   void Function2(Template0,\n"
+  "Template0 > CheckD);\n"
+  "  }\n"
+  "template class Variadic {};\n"
+  "Variadic, "
+  " B::Template1, "
+  " B::C::MyInt > CheckE;\n"
+  "}\n"
+  "using A::B::Class0;\n"
+  "void Function(Class0 CheckF);\n"
+  "using namespace A::B::C;\n"
+  "void Function(MyInt CheckG);\n"
+  "void f() {\n"
+  "  struct X {} CheckH;\n"
+  "}\n"
+  "namespace {\n"
+  "  class aClass {};\n"
+  "   aClass CheckI;\n"
+  "}\n"
+  "namespace A {\n"
+  "  struct aStruct {} CheckJ;\n"
+  "}\n");
+
+  TypeNameVisitor Complex;
+  Complex.ExpectedQualTypeNames["CheckTX"] = "B::TX";
+  Complex.runOver(
+  "namespace A {"
+  "  struct X {};"
+  "}"
+  "using

Re: [PATCH] D15862: A possible direction for fixing https://llvm.org/bugs/show_bug.cgi?id=25973.

2016-01-07 Thread Tim Song via cfe-commits
tcanens added inline comments.


Comment at: include/string:2673
@@ -2654,1 +2672,3 @@
+   basic_string __temp (__first, __last, __alloc());
+   append(__temp.begin(), __temp.end());
 return *this;

Likewise - should probably be `append(__temp.data(), __temp.size());`.


http://reviews.llvm.org/D15862



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


Re: [PATCH] D15862: A possible direction for fixing https://llvm.org/bugs/show_bug.cgi?id=25973.

2016-01-07 Thread Tim Song via cfe-commits
tcanens added inline comments.


Comment at: include/string:2826-2827
@@ -2787,13 +2825,4 @@
 #endif
-size_type __old_sz = size();
-difference_type __ip = __pos - begin();
-for (; __first != __last; ++__first)
-push_back(*__first);
-pointer __p = __get_pointer();
-_VSTD::rotate(__p + __ip, __p + __old_sz, __p + size());
-#if _LIBCPP_DEBUG_LEVEL >= 2
-return iterator(this, __p + __ip);
-#else
-return iterator(__p + __ip);
-#endif
+basic_string __temp(__first, __last, __alloc());
+return insert(__pos, __temp.begin(), __temp.end());
 }

This may cause infinite recursion if the allocator uses a fancy pointer (so 
that `__libcpp_string_gets_noexcept_iterator` returns `false`). 

Perhaps `return insert(__pos, __temp.data(), __temp.data()+__temp.size());`?


http://reviews.llvm.org/D15862



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


Re: [PATCH] D15953: Driver: Pass -flavor gnu to lld for AMDGPU rather than -flavor gnu-old

2016-01-07 Thread Tom Stellard via cfe-commits
tstellarAMD updated this revision to Diff 44249.
tstellarAMD added a comment.

Use ld.lld alias instead of '-flavor gnu'


http://reviews.llvm.org/D15953

Files:
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  test/Driver/amdgpu-toolchain.c

Index: test/Driver/amdgpu-toolchain.c
===
--- test/Driver/amdgpu-toolchain.c
+++ test/Driver/amdgpu-toolchain.c
@@ -1,3 +1,3 @@
 // RUN: %clang -### -target amdgcn--amdhsa -x assembler -mcpu=kaveri %s 2>&1 | 
FileCheck -check-prefix=AS_LINK %s
 // AS_LINK: clang{{.*}} "-cc1as"
-// AS_LINK: lld{{.*}} "-flavor" "old-gnu" "-target" "amdgcn--amdhsa"
+// AS_LINK: ld.lld{{.*}}
Index: lib/Driver/Tools.h
===
--- lib/Driver/Tools.h
+++ lib/Driver/Tools.h
@@ -240,7 +240,7 @@
 
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  Linker(const ToolChain &TC) : GnuTool("amdgpu::Linker", "lld", TC) {}
+  Linker(const ToolChain &TC) : GnuTool("amdgpu::Linker", "ld.lld", TC) {}
   bool isLinkJob() const override { return true; }
   bool hasIntegratedCPP() const override { return false; }
   void ConstructJob(Compilation &C, const JobAction &JA,
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -6520,10 +6520,6 @@
 
   std::string Linker = getToolChain().GetProgramPath(getShortName());
   ArgStringList CmdArgs;
-  CmdArgs.push_back("-flavor");
-  CmdArgs.push_back("old-gnu");
-  CmdArgs.push_back("-target");
-  CmdArgs.push_back(Args.MakeArgString(getToolChain().getTripleString()));
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());


Index: test/Driver/amdgpu-toolchain.c
===
--- test/Driver/amdgpu-toolchain.c
+++ test/Driver/amdgpu-toolchain.c
@@ -1,3 +1,3 @@
 // RUN: %clang -### -target amdgcn--amdhsa -x assembler -mcpu=kaveri %s 2>&1 | FileCheck -check-prefix=AS_LINK %s
 // AS_LINK: clang{{.*}} "-cc1as"
-// AS_LINK: lld{{.*}} "-flavor" "old-gnu" "-target" "amdgcn--amdhsa"
+// AS_LINK: ld.lld{{.*}}
Index: lib/Driver/Tools.h
===
--- lib/Driver/Tools.h
+++ lib/Driver/Tools.h
@@ -240,7 +240,7 @@
 
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  Linker(const ToolChain &TC) : GnuTool("amdgpu::Linker", "lld", TC) {}
+  Linker(const ToolChain &TC) : GnuTool("amdgpu::Linker", "ld.lld", TC) {}
   bool isLinkJob() const override { return true; }
   bool hasIntegratedCPP() const override { return false; }
   void ConstructJob(Compilation &C, const JobAction &JA,
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -6520,10 +6520,6 @@
 
   std::string Linker = getToolChain().GetProgramPath(getShortName());
   ArgStringList CmdArgs;
-  CmdArgs.push_back("-flavor");
-  CmdArgs.push_back("old-gnu");
-  CmdArgs.push_back("-target");
-  CmdArgs.push_back(Args.MakeArgString(getToolChain().getTripleString()));
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15953: Driver: Pass -flavor gnu to lld for AMDGPU rather than -flavor gnu-old

2016-01-07 Thread Rui Ueyama via cfe-commits
ruiu accepted this revision.
ruiu added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D15953



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


r257097 - Properly track that a character literal is UTF-8, and pretty print the prefix properly.

2016-01-07 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Jan  7 14:59:26 2016
New Revision: 257097

URL: http://llvm.org/viewvc/llvm-project?rev=257097&view=rev
Log:
Properly track that a character literal is UTF-8, and pretty print the prefix 
properly.

Added:
cfe/trunk/test/Misc/ast-print-char-literal.cpp
cfe/trunk/test/PCH/cxx-char-literal.cpp
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/Lex/LiteralSupport.h
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/Lex/LiteralSupport.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=257097&r1=257096&r2=257097&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Thu Jan  7 14:59:26 2016
@@ -1292,6 +1292,7 @@ public:
   enum CharacterKind {
 Ascii,
 Wide,
+UTF8,
 UTF16,
 UTF32
   };

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=257097&r1=257096&r2=257097&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Thu Jan  7 14:59:26 2016
@@ -130,7 +130,7 @@ protected:
 friend class CharacterLiteral;
 unsigned : NumExprBits;
 
-unsigned Kind : 2;
+unsigned Kind : 3;
   };
 
   enum APFloatSemantics {

Modified: cfe/trunk/include/clang/Lex/LiteralSupport.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/LiteralSupport.h?rev=257097&r1=257096&r2=257097&view=diff
==
--- cfe/trunk/include/clang/Lex/LiteralSupport.h (original)
+++ cfe/trunk/include/clang/Lex/LiteralSupport.h Thu Jan  7 14:59:26 2016
@@ -166,6 +166,7 @@ public:
   bool hadError() const { return HadError; }
   bool isAscii() const { return Kind == tok::char_constant; }
   bool isWide() const { return Kind == tok::wide_char_constant; }
+  bool isUTF8() const { return Kind == tok::utf8_char_constant; }
   bool isUTF16() const { return Kind == tok::utf16_char_constant; }
   bool isUTF32() const { return Kind == tok::utf32_char_constant; }
   bool isMultiChar() const { return IsMultiChar; }

Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=257097&r1=257096&r2=257097&view=diff
==
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Thu Jan  7 14:59:26 2016
@@ -1165,6 +1165,7 @@ void StmtPrinter::VisitCharacterLiteral(
   switch (Node->getKind()) {
   case CharacterLiteral::Ascii: break; // no prefix.
   case CharacterLiteral::Wide:  OS << 'L'; break;
+  case CharacterLiteral::UTF8:  OS << "u8"; break;
   case CharacterLiteral::UTF16: OS << 'u'; break;
   case CharacterLiteral::UTF32: OS << 'U'; break;
   }

Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=257097&r1=257096&r2=257097&view=diff
==
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Thu Jan  7 14:59:26 2016
@@ -983,6 +983,7 @@ NumericLiteralParser::GetFloatValue(llvm
 /// u' c-char-sequence '
 /// U' c-char-sequence '
 /// L' c-char-sequence '
+/// u8' c-char-sequence ' [C++1z lex.ccon]
 ///   c-char-sequence:
 /// c-char
 /// c-char-sequence c-char

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=257097&r1=257096&r2=257097&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Jan  7 14:59:26 2016
@@ -3084,6 +3084,8 @@ ExprResult Sema::ActOnCharacterConstant(
 Kind = CharacterLiteral::UTF16;
   else if (Literal.isUTF32())
 Kind = CharacterLiteral::UTF32;
+  else if (Literal.isUTF8())
+Kind = CharacterLiteral::UTF8;
 
   Expr *Lit = new (Context) CharacterLiteral(Literal.getValue(), Kind, Ty,
  Tok.getLocation());

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=257097&r1=257096&r2=257097&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema

Re: [PATCH] D15958: u8 character literals

2016-01-07 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

Good catches! I've fixed those issues, and commit in r257097 (I thought I had 
the LG, but now notice I don't -- if this is a problem, I will revert).


http://reviews.llvm.org/D15958



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


[PATCH] D15967: Turn off lldb debug tuning by default for FreeBSD

2016-01-07 Thread Dimitry Andric via cfe-commits
dim created this revision.
dim added reviewers: emaste, probinson.
dim added a subscriber: cfe-commits.
Herald added a subscriber: emaste.

This is the clang part of D15966.  In rL256104, debugger tuning was
added to the clang driver, and again the default for FreeBSD was set to
lldb.  The default needs to be gdb instead.

http://reviews.llvm.org/D15967

Files:
  lib/Driver/ToolChains.h
  test/Driver/debug-options.c

Index: test/Driver/debug-options.c
===
--- test/Driver/debug-options.c
+++ test/Driver/debug-options.c
@@ -32,7 +32,7 @@
 // RUN: | FileCheck -check-prefix=G_DARWIN %s
 
 // RUN: %clang -### -c -g %s -target x86_64-pc-freebsd10.0 2>&1 \
-// RUN: | FileCheck -check-prefix=G_LLDB %s
+// RUN: | FileCheck -check-prefix=G_GDB %s
 
 // On the PS4, -g defaults to -gno-column-info, and we always generate the
 // arange section.
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -730,9 +730,6 @@
   // Until dtrace (via CTF) and LLDB can deal with distributed debug info,
   // FreeBSD defaults to standalone/full debug info.
   bool GetDefaultStandaloneDebug() const override { return true; }
-  llvm::DebuggerKind getDefaultDebuggerTuning() const override {
-return llvm::DebuggerKind::LLDB;
-  }
 
 protected:
   Tool *buildAssembler() const override;


Index: test/Driver/debug-options.c
===
--- test/Driver/debug-options.c
+++ test/Driver/debug-options.c
@@ -32,7 +32,7 @@
 // RUN: | FileCheck -check-prefix=G_DARWIN %s
 
 // RUN: %clang -### -c -g %s -target x86_64-pc-freebsd10.0 2>&1 \
-// RUN: | FileCheck -check-prefix=G_LLDB %s
+// RUN: | FileCheck -check-prefix=G_GDB %s
 
 // On the PS4, -g defaults to -gno-column-info, and we always generate the
 // arange section.
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -730,9 +730,6 @@
   // Until dtrace (via CTF) and LLDB can deal with distributed debug info,
   // FreeBSD defaults to standalone/full debug info.
   bool GetDefaultStandaloneDebug() const override { return true; }
-  llvm::DebuggerKind getDefaultDebuggerTuning() const override {
-return llvm::DebuggerKind::LLDB;
-  }
 
 protected:
   Tool *buildAssembler() const override;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15967: Turn off lldb debug tuning by default for FreeBSD

2016-01-07 Thread Ed Maste via cfe-commits
emaste accepted this revision.
emaste added a comment.
This revision is now accepted and ready to land.

I advocated for the lldb tuning by default on FreeBSD originally, but I didn't 
fully understand the implications. It turns out we're just not ready yet. So, 
LGTM.


http://reviews.llvm.org/D15967



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


Re: [PATCH] D15967: Turn off lldb debug tuning by default for FreeBSD

2016-01-07 Thread Paul Robinson via cfe-commits
probinson added a comment.

Sure, I was just making it the same as LLVM's default.
Now that it's wired up through clang, people who want LLDB can use -glldb to 
get the same effect.


http://reviews.llvm.org/D15967



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


r257104 - Turn off lldb debug tuning by default for FreeBSD

2016-01-07 Thread Dimitry Andric via cfe-commits
Author: dim
Date: Thu Jan  7 16:09:47 2016
New Revision: 257104

URL: http://llvm.org/viewvc/llvm-project?rev=257104&view=rev
Log:
Turn off lldb debug tuning by default for FreeBSD

Summary:
This is the clang part of D15966.  In rL256104, debugger tuning was
added to the clang driver, and again the default for FreeBSD was set to
lldb.  The default needs to be gdb instead.

Reviewers: emaste, probinson

Subscribers: cfe-commits, emaste

Differential Revision: http://reviews.llvm.org/D15967

Modified:
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/test/Driver/debug-options.c

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=257104&r1=257103&r2=257104&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Thu Jan  7 16:09:47 2016
@@ -730,9 +730,6 @@ public:
   // Until dtrace (via CTF) and LLDB can deal with distributed debug info,
   // FreeBSD defaults to standalone/full debug info.
   bool GetDefaultStandaloneDebug() const override { return true; }
-  llvm::DebuggerKind getDefaultDebuggerTuning() const override {
-return llvm::DebuggerKind::LLDB;
-  }
 
 protected:
   Tool *buildAssembler() const override;

Modified: cfe/trunk/test/Driver/debug-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=257104&r1=257103&r2=257104&view=diff
==
--- cfe/trunk/test/Driver/debug-options.c (original)
+++ cfe/trunk/test/Driver/debug-options.c Thu Jan  7 16:09:47 2016
@@ -32,7 +32,7 @@
 // RUN: | FileCheck -check-prefix=G_DARWIN %s
 
 // RUN: %clang -### -c -g %s -target x86_64-pc-freebsd10.0 2>&1 \
-// RUN: | FileCheck -check-prefix=G_LLDB %s
+// RUN: | FileCheck -check-prefix=G_GDB %s
 
 // On the PS4, -g defaults to -gno-column-info, and we always generate the
 // arange section.


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


Re: [PATCH] D15967: Turn off lldb debug tuning by default for FreeBSD

2016-01-07 Thread Ed Maste via cfe-commits
emaste added a comment.

> Sure, I was just making it the same as LLVM's default.


Yeah, the defaults ought to be the same; it turns out this change was just 
premature.


http://reviews.llvm.org/D15967



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


Re: [PATCH] D15958: u8 character literals

2016-01-07 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

For posterity :)


http://reviews.llvm.org/D15958



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


Re: [PATCH] D15958: u8 character literals

2016-01-07 Thread Aaron Ballman via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

For cleanliness. ;-)


http://reviews.llvm.org/D15958



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


Re: [PATCH] D15881: [DWARF] Omitting the explicit import of an anonymous namespace is a debugger-tuning decision, not a target decision.

2016-01-07 Thread Eric Christopher via cfe-commits
echristo added inline comments.


Comment at: lib/Frontend/CompilerInvocation.cpp:363-370
@@ -362,2 +362,10 @@
 
+// Convenience functions for debugger tuning.
+static bool tuneForGDB(CodeGenOptions &Opts) {
+  return Opts.getDebuggerTuning() == CodeGenOptions::DebuggerKindGDB;
+}
+static bool tuneForLLDB(CodeGenOptions &Opts) {
+  return Opts.getDebuggerTuning() == CodeGenOptions::DebuggerKindLLDB;
+}
+
 static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,

This seems like overkill for a single case.


http://reviews.llvm.org/D15881



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


[PATCH] D15974: [CUDA] Split out tests for unused-arg warnings from cuda-options.cu.

2016-01-07 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added a subscriber: cfe-commits.

Trying to make this test a bit more manageable.

http://reviews.llvm.org/D15974

Files:
  test/Driver/cuda-options.cu
  test/Driver/cuda-unused-arg-warning.cu

Index: test/Driver/cuda-unused-arg-warning.cu
===
--- /dev/null
+++ test/Driver/cuda-unused-arg-warning.cu
@@ -0,0 +1,23 @@
+// Tests that we trigger unused-arg warnings on CUDA flags appropriately.
+
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// --cuda-host-only should never trigger unused arg warning.
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -c %s 2>&1 | \
+// RUN:FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -x c -c %s 2>&1 
| \
+// RUN:FileCheck %s
+
+// --cuda-device-only should warn during non-CUDA compilation.
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -x c -c %s 
2>&1 | \
+// RUN:FileCheck -check-prefix UNUSED-CDO %s
+
+// --cuda-device-only should not produce warning compiling CUDA files
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -c %s 2>&1 | \
+// RUN:FileCheck -check-prefix NO-UNUSED-CDO %s
+
+// CHECK-NOT: warning: argument unused during compilation: '--cuda-host-only'
+// UNUSED-CDO: warning: argument unused during compilation: 
'--cuda-device-only'
+// NO-UNUSED-CDO-NOT: warning: argument unused during compilation: 
'--cuda-device-only'
Index: test/Driver/cuda-options.cu
===
--- test/Driver/cuda-options.cu
+++ test/Driver/cuda-options.cu
@@ -111,20 +111,6 @@
 // Make sure we don't link anything.
 // RUN:   -check-prefix CUDA-NL %s
 
-// --cuda-host-only should never trigger unused arg warning.
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -c %s 2>&1 | \
-// RUN:FileCheck -check-prefix CUDA-NO-UNUSED-CHO %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -x c -c %s 2>&1 
| \
-// RUN:FileCheck -check-prefix CUDA-NO-UNUSED-CHO %s
-
-// --cuda-device-only should not produce warning compiling CUDA files
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -c %s 2>&1 | \
-// RUN:FileCheck -check-prefix CUDA-NO-UNUSED-CDO %s
-
-// --cuda-device-only should warn during non-CUDA compilation.
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -x c -c %s 
2>&1 | \
-// RUN:FileCheck -check-prefix CUDA-UNUSED-CDO %s
-
 // Match device-side preprocessor, and compiler phases with -save-temps
 // CUDA-D1S: "-cc1" "-triple" "nvptx64-nvidia-cuda"
 // CUDA-D1S-SAME: "-aux-triple" "x86_64--linux-gnu"
@@ -189,7 +175,3 @@
 
 // Match no linker
 // CUDA-NL-NOT: "{{.*}}{{ld|link}}{{(.exe)?}}"
-
-// CUDA-NO-UNUSED-CHO-NOT: warning: argument unused during compilation: 
'--cuda-host-only'
-// CUDA-UNUSED-CDO: warning: argument unused during compilation: 
'--cuda-device-only'
-// CUDA-NO-UNUSED-CDO-NOT: warning: argument unused during compilation: 
'--cuda-device-only'


Index: test/Driver/cuda-unused-arg-warning.cu
===
--- /dev/null
+++ test/Driver/cuda-unused-arg-warning.cu
@@ -0,0 +1,23 @@
+// Tests that we trigger unused-arg warnings on CUDA flags appropriately.
+
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// --cuda-host-only should never trigger unused arg warning.
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -c %s 2>&1 | \
+// RUN:FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -x c -c %s 2>&1 | \
+// RUN:FileCheck %s
+
+// --cuda-device-only should warn during non-CUDA compilation.
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -x c -c %s 2>&1 | \
+// RUN:FileCheck -check-prefix UNUSED-CDO %s
+
+// --cuda-device-only should not produce warning compiling CUDA files
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -c %s 2>&1 | \
+// RUN:FileCheck -check-prefix NO-UNUSED-CDO %s
+
+// CHECK-NOT: warning: argument unused during compilation: '--cuda-host-only'
+// UNUSED-CDO: warning: argument unused during compilation: '--cuda-device-only'
+// NO-UNUSED-CDO-NOT: warning: argument unused during compilation: '--cuda-device-only'
Index: test/Driver/cuda-options.cu
===
--- test/Driver/cuda-options.cu
+++ test/Driver/cuda-options.cu
@@ -111,20 +111,6 @@
 // Make sure we don't link anything.
 // RUN:   -check-prefix CUDA-NL %s
 
-// --cuda-host-only should never trigger unused arg warning.
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -c %s 2>&1 | \
-// RUN:FileCheck -check-prefix CUDA-NO-UNUSED-CHO %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -x c -c %s 2>&1 | \
-// RUN:File

Re: [PATCH] D15911: Switch Action and ActionList over to using std::shared_ptr.

2016-01-07 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 44272.
jlebar marked 2 inline comments as done.
jlebar added a comment.

Address review comments.


http://reviews.llvm.org/D15911

Files:
  include/clang/Driver/Action.h
  include/clang/Driver/Driver.h
  include/clang/Driver/Util.h
  lib/Driver/Action.cpp
  lib/Driver/Compilation.cpp
  lib/Driver/Driver.cpp
  lib/Driver/Tools.cpp
  lib/Tooling/CompilationDatabase.cpp

Index: lib/Tooling/CompilationDatabase.cpp
===
--- lib/Tooling/CompilationDatabase.cpp
+++ lib/Tooling/CompilationDatabase.cpp
@@ -141,7 +141,7 @@
 
 for (driver::ActionList::const_iterator I = A->begin(), E = A->end();
  I != E; ++I)
-  runImpl(*I, CollectChildren);
+  runImpl(I->get(), CollectChildren);
   }
 };
 
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2465,7 +2465,7 @@
 return true;
 
   for (const auto &Act : *A)
-if (ContainsCompileAction(Act))
+if (ContainsCompileAction(Act.get()))
   return true;
 
   return false;
@@ -2482,7 +2482,7 @@
   if (RelaxDefault) {
 RelaxDefault = false;
 for (const auto &Act : C.getActions()) {
-  if (ContainsCompileAction(Act)) {
+  if (ContainsCompileAction(Act.get())) {
 RelaxDefault = true;
 break;
   }
@@ -5969,7 +5969,7 @@
   const Action *SourceAction = &JA;
   while (SourceAction->getKind() != Action::InputClass) {
 assert(!SourceAction->getInputs().empty() && "unexpected root action!");
-SourceAction = SourceAction->getInputs()[0];
+SourceAction = SourceAction->getInputs()[0].get();
   }
 
   // Forward -g and handle debug info related flags, assuming we are dealing
@@ -6893,7 +6893,7 @@
   const Action *SourceAction = &JA;
   while (SourceAction->getKind() != Action::InputClass) {
 assert(!SourceAction->getInputs().empty() && "unexpected root action!");
-SourceAction = SourceAction->getInputs()[0];
+SourceAction = SourceAction->getInputs()[0].get();
   }
 
   // If -fno-integrated-as is used add -Q to the darwin assember driver to make
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -934,36 +934,36 @@
 // Display an action graph human-readably.  Action A is the "sink" node
 // and latest-occuring action. Traversal is in pre-order, visiting the
 // inputs to each action before printing the action itself.
-static unsigned PrintActions1(const Compilation &C, Action *A,
-  std::map &Ids) {
+static unsigned PrintActions1(const Compilation &C, const Action *A,
+  std::map &Ids) {
   if (Ids.count(A)) // A was already visited.
 return Ids[A];
 
   std::string str;
   llvm::raw_string_ostream os(str);
 
   os << Action::getClassName(A->getKind()) << ", ";
-  if (InputAction *IA = dyn_cast(A)) {
+  if (const InputAction *IA = dyn_cast(A)) {
 os << "\"" << IA->getInputArg().getValue() << "\"";
-  } else if (BindArchAction *BIA = dyn_cast(A)) {
+  } else if (const BindArchAction *BIA = dyn_cast(A)) {
 os << '"' << BIA->getArchName() << '"' << ", {"
-   << PrintActions1(C, *BIA->begin(), Ids) << "}";
-  } else if (CudaDeviceAction *CDA = dyn_cast(A)) {
+   << PrintActions1(C, BIA->begin()->get(), Ids) << "}";
+  } else if (const CudaDeviceAction *CDA = dyn_cast(A)) {
 os << '"' << CDA->getGpuArchName() << '"' << ", {"
-   << PrintActions1(C, *CDA->begin(), Ids) << "}";
+   << PrintActions1(C, CDA->begin()->get(), Ids) << "}";
   } else {
 const ActionList *AL;
-if (CudaHostAction *CHA = dyn_cast(A)) {
-  os << "{" << PrintActions1(C, *CHA->begin(), Ids) << "}"
+if (const CudaHostAction *CHA = dyn_cast(A)) {
+  os << "{" << PrintActions1(C, CHA->begin()->get(), Ids) << "}"
  << ", gpu binaries ";
   AL = &CHA->getDeviceActions();
 } else
   AL = &A->getInputs();
 
 if (AL->size()) {
   const char *Prefix = "{";
-  for (Action *PreRequisite : *AL) {
-os << Prefix << PrintActions1(C, PreRequisite, Ids);
+  for (const std::shared_ptr &PreRequisite : *AL) {
+os << Prefix << PrintActions1(C, PreRequisite.get(), Ids);
 Prefix = ", ";
   }
   os << "}";
@@ -982,9 +982,9 @@
 // Print the action graphs in a compilation C.
 // For example "clang -c file1.c file2.c" is composed of two subgraphs.
 void Driver::PrintActions(const Compilation &C) const {
-  std::map Ids;
-  for (Action *A : C.getActions())
-PrintActions1(C, A, Ids);
+  std::map Ids;
+  for (const std::shared_ptr &A : C.getActions())
+PrintActions1(C, A.get(), Ids);
 }
 
 /// \brief Check whether the given input tree contains any compilation or
@@ -994,8 +994,8 @@
   isa(A))
 return true;
 
-  for (const Action *Input : *A)
-if (ContainsCompileOrAssembleAction(

[PATCH] D15977: [Clang] Supporting all entities declared in lexical scope in LLVM debug info

2016-01-07 Thread Amjad Aboud via cfe-commits
aaboud created this revision.
aaboud added reviewers: probinson, aprantl, echristo, dblaikie.
aaboud added a subscriber: cfe-commits.

This is the full implementation in Clang of the proposal:
http://lists.llvm.org/pipermail/llvm-dev/2015-December/093313.html

http://reviews.llvm.org/D15977

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CGDecl.cpp
  test/CodeGenCXX/debug-info-lb-class.cpp
  test/CodeGenCXX/debug-info-lb-static.cpp
  test/CodeGenCXX/debug-info-lb-static2.cpp
  test/CodeGenCXX/debug-info-lb-typedef.cpp

Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -83,26 +83,30 @@
   case Decl::UsingShadow:
   case Decl::ObjCTypeParam:
 llvm_unreachable("Declaration should not be in declstmts!");
-  case Decl::Function:  // void X();
-  case Decl::Record:// struct/union/class X;
-  case Decl::Enum:  // enum X;
-  case Decl::EnumConstant: // enum ? { X = ? }
-  case Decl::CXXRecord: // struct/union/class X; [C++]
+  case Decl::Function: // void X();
   case Decl::StaticAssert: // static_assert(X, ""); [C++0x]
   case Decl::Label:// __label__ x;
   case Decl::Import:
   case Decl::OMPThreadPrivate:
   case Decl::Empty:
 // None of these decls require codegen support.
 return;
 
+  case Decl::Record:   // struct/union/class X;
+  case Decl::Enum: // enum X;
+  case Decl::EnumConstant: // enum ? { X = ? }
+  case Decl::CXXRecord:// struct/union/class X; [C++]
+if (CGDebugInfo *DI = getDebugInfo())
+  DI->recordDeclarationLexicalScope(D);
+return;
+
   case Decl::NamespaceAlias:
 if (CGDebugInfo *DI = getDebugInfo())
-DI->EmitNamespaceAlias(cast(D));
+  DI->EmitNamespaceAlias(cast(D));
 return;
   case Decl::Using:  // using X; [C++]
 if (CGDebugInfo *DI = getDebugInfo())
-DI->EmitUsingDecl(cast(D));
+  DI->EmitUsingDecl(cast(D));
 return;
   case Decl::UsingDirective: // using namespace X; [C++]
 if (CGDebugInfo *DI = getDebugInfo())
@@ -120,6 +124,9 @@
 const TypedefNameDecl &TD = cast(D);
 QualType Ty = TD.getUnderlyingType();
 
+if (CGDebugInfo *DI = getDebugInfo())
+  DI->recordDeclarationLexicalScope(D);
+
 if (Ty->isVariablyModifiedType())
   EmitVariablyModifiedType(Ty);
   }
Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -114,6 +114,11 @@
 
   /// Keep track of our current nested lexical block.
   std::vector> LexicalBlockStack;
+
+  /// Map of AST declaration to its lexical block scope.
+  llvm::DenseMap>
+  LexicalBlockMap;
+
   llvm::DenseMap RegionMap;
   /// Keep track of LexicalBlockStack counter at the beginning of a
   /// function. This is used to pop unbalanced regions at the end of a
@@ -365,6 +370,12 @@
   /// Emit an Objective-C interface type standalone debug info.
   llvm::DIType *getOrCreateInterfaceType(QualType Ty, SourceLocation Loc);
 
+  /// Map AST declaration to its lexical block scope if available.
+  void recordDeclarationLexicalScope(const Decl &D);
+
+  /// Get lexical scope of AST declaration.
+  llvm::DIScope *getDeclarationLexicalScope(const Decl &D, QualType Ty);
+
   /// Emit standalone debug info for a type.
   llvm::DIType *getOrCreateStandaloneType(QualType Ty, SourceLocation Loc);
 
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -831,15 +831,18 @@
 
 llvm::DIType *CGDebugInfo::CreateType(const TypedefType *Ty,
   llvm::DIFile *Unit) {
+  TypedefNameDecl *TD = Ty->getDecl();
   // We don't set size information, but do specify where the typedef was
   // declared.
-  SourceLocation Loc = Ty->getDecl()->getLocation();
+  SourceLocation Loc = TD->getLocation();
+
+  llvm::DIScope *TDContext = getDeclarationLexicalScope(*TD, QualType(Ty, 0));
 
   // Typedefs are derived from some other type.
   return DBuilder.createTypedef(
   getOrCreateType(Ty->getDecl()->getUnderlyingType(), Unit),
   Ty->getDecl()->getName(), getOrCreateFile(Loc), getLineNumber(Loc),
-  getDeclContextDescriptor(Ty->getDecl()));
+  TDContext);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const FunctionType *Ty,
@@ -1472,6 +1475,23 @@
   return T;
 }
 
+void CGDebugInfo::recordDeclarationLexicalScope(const Decl &D) {
+  assert(LexicalBlockMap.find(&D) == LexicalBlockMap.end() &&
+ "D is already mapped to lexical block scope");
+  if (!LexicalBlockStack.empty())
+LexicalBlockMap[&D] = LexicalBlockStack.back();
+}
+
+llvm::DIScope *CGDebugInfo::getDeclarationLexicalScope(const Decl &D,
+   QualType Ty) {
+  auto I = LexicalBlockMap.find(&D);
+  if (I != LexicalBlockMap.end()) {
+

Re: [PATCH] D15881: [DWARF] Omitting the explicit import of an anonymous namespace is a debugger-tuning decision, not a target decision.

2016-01-07 Thread Paul Robinson via cfe-commits
probinson updated this revision to Diff 44278.
probinson marked an inline comment as done.

http://reviews.llvm.org/D15881

Files:
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/debug-info-anon-namespace.cpp

Index: test/CodeGenCXX/debug-info-anon-namespace.cpp
===
--- test/CodeGenCXX/debug-info-anon-namespace.cpp
+++ test/CodeGenCXX/debug-info-anon-namespace.cpp
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-scei-ps4 
-O0 %s -o - | FileCheck --check-prefix=PS4 %s
-// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple 
x86_64-unknown-linux-gnu -O0 %s -o - | FileCheck --check-prefix=NON-PS4 %s
+// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple 
-debug-info-kind=limited -debugger-tuning=gdb -O0 %s -o - | FileCheck 
--check-prefix=NOIMPORT %s
+// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple 
-debug-info-kind=limited -debugger-tuning=lldb -O0 %s -o - | FileCheck 
--check-prefix=NOIMPORT %s
+// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple 
-debug-info-kind=limited -debugger-tuning=sce -O0 %s -o - | FileCheck 
--check-prefix=IMPORT %s
+// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple 
-debug-info-kind=limited -O0 %s -o - | FileCheck --check-prefix=IMPORT %s
 
 namespace
 {
@@ -18,9 +20,9 @@
 int *b2 = &a2;
 
 
-// PS4:  [[NS:![0-9]+]] = !DINamespace
-// PS4:  [[NS2:![0-9]+]] = !DINamespace
-// PS4: !DIImportedEntity(tag: DW_TAG_imported_module, scope: !0, entity: 
[[NS]])
-// PS4: !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[NS]], entity: 
[[NS2]], line: {{[0-9]+}})
-// NON-PS4-NOT: !DIImportedEntity
+// IMPORT:  [[NS:![0-9]+]] = !DINamespace
+// IMPORT:  [[NS2:![0-9]+]] = !DINamespace
+// IMPORT: !DIImportedEntity(tag: DW_TAG_imported_module, scope: !0, entity: 
[[NS]])
+// IMPORT: !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[NS]], 
entity: [[NS2]], line: {{[0-9]+}})
+// NOIMPORT-NOT: !DIImportedEntity
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -443,7 +443,9 @@
   Opts.EmitCodeView = Args.hasArg(OPT_gcodeview);
   Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file);
   Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs);
-  Opts.DebugExplicitImport = Triple.isPS4CPU(); 
+  Opts.DebugExplicitImport =
+  Opts.getDebuggerTuning() != CodeGenOptions::DebuggerKindGDB &&
+  Opts.getDebuggerTuning() != CodeGenOptions::DebuggerKindLLDB;
 
   for (const auto &Arg : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ))
 Opts.DebugPrefixMap.insert(StringRef(Arg).split('='));


Index: test/CodeGenCXX/debug-info-anon-namespace.cpp
===
--- test/CodeGenCXX/debug-info-anon-namespace.cpp
+++ test/CodeGenCXX/debug-info-anon-namespace.cpp
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-scei-ps4 -O0 %s -o - | FileCheck --check-prefix=PS4 %s
-// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-unknown-linux-gnu -O0 %s -o - | FileCheck --check-prefix=NON-PS4 %s
+// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -debug-info-kind=limited -debugger-tuning=gdb -O0 %s -o - | FileCheck --check-prefix=NOIMPORT %s
+// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -debug-info-kind=limited -debugger-tuning=lldb -O0 %s -o - | FileCheck --check-prefix=NOIMPORT %s
+// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -debug-info-kind=limited -debugger-tuning=sce -O0 %s -o - | FileCheck --check-prefix=IMPORT %s
+// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -debug-info-kind=limited -O0 %s -o - | FileCheck --check-prefix=IMPORT %s
 
 namespace
 {
@@ -18,9 +20,9 @@
 int *b2 = &a2;
 
 
-// PS4:  [[NS:![0-9]+]] = !DINamespace
-// PS4:  [[NS2:![0-9]+]] = !DINamespace
-// PS4: !DIImportedEntity(tag: DW_TAG_imported_module, scope: !0, entity: [[NS]])
-// PS4: !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[NS]], entity: [[NS2]], line: {{[0-9]+}})
-// NON-PS4-NOT: !DIImportedEntity
+// IMPORT:  [[NS:![0-9]+]] = !DINamespace
+// IMPORT:  [[NS2:![0-9]+]] = !DINamespace
+// IMPORT: !DIImportedEntity(tag: DW_TAG_imported_module, scope: !0, entity: [[NS]])
+// IMPORT: !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[NS]], entity: [[NS2]], line: {{[0-9]+}})
+// NOIMPORT-NOT: !DIImportedEntity
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -443,7 +443,9 @@
   Opts.EmitCodeView = Args.hasArg(OPT_gcodeview);
   Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file);
   Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs);
-  Opts.DebugExplicitImport = Triple.isPS4CPU(); 
+  Opts.DebugExpl

Re: [PATCH] D15881: [DWARF] Omitting the explicit import of an anonymous namespace is a debugger-tuning decision, not a target decision.

2016-01-07 Thread Eric Christopher via cfe-commits
echristo added inline comments.


Comment at: lib/Frontend/CompilerInvocation.cpp:446-448
@@ -445,3 +445,5 @@
   Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs);
-  Opts.DebugExplicitImport = Triple.isPS4CPU(); 
+  Opts.DebugExplicitImport =
+  Opts.getDebuggerTuning() != CodeGenOptions::DebuggerKindGDB &&
+  Opts.getDebuggerTuning() != CodeGenOptions::DebuggerKindLLDB;
 

Why not just a positive for debugger tuning SCE?


http://reviews.llvm.org/D15881



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


Re: [PATCH] D15589: [PPC] Add long long/double support for vec_cts, vec_ctu and vec_ctf.

2016-01-07 Thread Kit Barton via cfe-commits
kbarton accepted this revision.
kbarton added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D15589



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


Re: [PATCH] D15881: [DWARF] Omitting the explicit import of an anonymous namespace is a debugger-tuning decision, not a target decision.

2016-01-07 Thread Paul Robinson via cfe-commits
probinson added inline comments.


Comment at: lib/Frontend/CompilerInvocation.cpp:363-370
@@ -362,2 +362,10 @@
 
+// Convenience functions for debugger tuning.
+static bool tuneForGDB(CodeGenOptions &Opts) {
+  return Opts.getDebuggerTuning() == CodeGenOptions::DebuggerKindGDB;
+}
+static bool tuneForLLDB(CodeGenOptions &Opts) {
+  return Opts.getDebuggerTuning() == CodeGenOptions::DebuggerKindLLDB;
+}
+
 static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,

echristo wrote:
> This seems like overkill for a single case.
I suppose... having the big hairy test inline isn't *that* unreadable.


Comment at: lib/Frontend/CompilerInvocation.cpp:446-448
@@ -445,3 +445,5 @@
   Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs);
-  Opts.DebugExplicitImport = Triple.isPS4CPU(); 
+  Opts.DebugExplicitImport =
+  Opts.getDebuggerTuning() != CodeGenOptions::DebuggerKindGDB &&
+  Opts.getDebuggerTuning() != CodeGenOptions::DebuggerKindLLDB;
 

echristo wrote:
> Why not just a positive for debugger tuning SCE?
Because the default (i.e., no tuning specified) behavior should be to conform 
to the DWARF spec, which basically says you need the explicit import.  There's 
a new extra RUN line in the test, with no tuning specified, to verify this.
GDB and LLDB are the oddballs here, they implement a special case for 
namespaces whose name meets certain criteria, and do something beyond what 
DWARF says to do.  So, the condition is written to express that.



http://reviews.llvm.org/D15881



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


Re: [PATCH] D15881: [DWARF] Omitting the explicit import of an anonymous namespace is a debugger-tuning decision, not a target decision.

2016-01-07 Thread Paul Robinson via cfe-commits
probinson added a comment.

FTR, the previous wiring-up-thru-Clang patches put the there-must-be-a-tuning 
decision in the driver; CC1 does not assume or require a non-default tuning.


http://reviews.llvm.org/D15881



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


Re: [PATCH] D15974: [CUDA] Split out tests for unused-arg warnings from cuda-options.cu.

2016-01-07 Thread Artem Belevich via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM.


http://reviews.llvm.org/D15974



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


Re: [PATCH] D15363: [UBSan] Implement runtime suppressions (PR25066).

2016-01-07 Thread Alexey Samsonov via cfe-commits
Interesting. Do we run test/asan/TestCases/suppressions-interceptor.cc on
Windows? Seems so: I don't see an XFAIL there, and it also uses
suppressions, but with single quote, followed by double quote:

%env_asan_opts=suppressions='"%t.supp"'

Why does it work there?

On Tue, Dec 22, 2015 at 4:35 PM, Nico Weber  wrote:

> thakis added a comment.
>
> I've looked at it some, and couldn't find a way of escaping quotes that
> lit doesn't strip but that ubsan accepts.
>
> '"c:\foo"' gets its quotes stripped by lit, so does """c:\foo""".
> \"c:\foo\" confuses lit enough that it tries to call lit.util.warning()
> which doesn't exist.
>
> I've XFAIL'd the test on win32 in 256307 for now. Please take a look when
> you're back. Maybe teaching lit about \" escaping is the best fix.
>
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D15363
>
>
>
>


-- 
Alexey Samsonov
vonos...@gmail.com
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15881: [DWARF] Omitting the explicit import of an anonymous namespace is a debugger-tuning decision, not a target decision.

2016-01-07 Thread Eric Christopher via cfe-commits
echristo added inline comments.


Comment at: lib/Frontend/CompilerInvocation.cpp:446-448
@@ -445,3 +445,5 @@
   Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs);
-  Opts.DebugExplicitImport = Triple.isPS4CPU(); 
+  Opts.DebugExplicitImport =
+  Opts.getDebuggerTuning() != CodeGenOptions::DebuggerKindGDB &&
+  Opts.getDebuggerTuning() != CodeGenOptions::DebuggerKindLLDB;
 

probinson wrote:
> echristo wrote:
> > Why not just a positive for debugger tuning SCE?
> Because the default (i.e., no tuning specified) behavior should be to conform 
> to the DWARF spec, which basically says you need the explicit import.  
> There's a new extra RUN line in the test, with no tuning specified, to verify 
> this.
> GDB and LLDB are the oddballs here, they implement a special case for 
> namespaces whose name meets certain criteria, and do something beyond what 
> DWARF says to do.  So, the condition is written to express that.
> 
I don't necessarily agree with that interpretation on the explicit import - I 
did skim the thread, perhaps you could highlight what makes you think this?


http://reviews.llvm.org/D15881



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


Re: [PATCH] D15881: [DWARF] Omitting the explicit import of an anonymous namespace is a debugger-tuning decision, not a target decision.

2016-01-07 Thread Paul Robinson via cfe-commits
probinson added inline comments.


Comment at: lib/Frontend/CompilerInvocation.cpp:446-448
@@ -445,3 +445,5 @@
   Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs);
-  Opts.DebugExplicitImport = Triple.isPS4CPU(); 
+  Opts.DebugExplicitImport =
+  Opts.getDebuggerTuning() != CodeGenOptions::DebuggerKindGDB &&
+  Opts.getDebuggerTuning() != CodeGenOptions::DebuggerKindLLDB;
 

echristo wrote:
> probinson wrote:
> > echristo wrote:
> > > Why not just a positive for debugger tuning SCE?
> > Because the default (i.e., no tuning specified) behavior should be to 
> > conform to the DWARF spec, which basically says you need the explicit 
> > import.  There's a new extra RUN line in the test, with no tuning 
> > specified, to verify this.
> > GDB and LLDB are the oddballs here, they implement a special case for 
> > namespaces whose name meets certain criteria, and do something beyond what 
> > DWARF says to do.  So, the condition is written to express that.
> > 
> I don't necessarily agree with that interpretation on the explicit import - I 
> did skim the thread, perhaps you could highlight what makes you think this?
Basically, a namespace is a "context" for declarations, and the DWARF mechanism 
for making declarations from one context available in another context is with 
DW_TAG_imported_declaration and DW_TAG_imported_module.
The C++ spec describes the behavior "as if" there was an explicit using 
directive, and DW_TAG_imported_module is the DWARF mechanism for describing a 
using directive.

The meaning of DWARF is determined by the DWARF spec, not the C++ spec, and the 
DWARF spec does not say there's anything special about a namespace that has no 
name.  There is a perfectly reasonable DWARF mechanism for getting the desired 
effect, so there's no reason for DWARF to make a special rule for an unnamed 
namespace.  Therefore, an anonymous namespace should be explicitly imported 
into the containing namespace. The explicit import would be marked artificial 
of course.



http://reviews.llvm.org/D15881



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


[PATCH] D15985: AST: Support constant folding of variables of const pointer type.

2016-01-07 Thread Peter Collingbourne via cfe-commits
pcc created this revision.
pcc added a reviewer: rsmith.
pcc added a subscriber: cfe-commits.

http://reviews.llvm.org/D15985

Files:
  lib/AST/ExprConstant.cpp
  test/CodeGenCXX/global-init.cpp

Index: test/CodeGenCXX/global-init.cpp
===
--- test/CodeGenCXX/global-init.cpp
+++ test/CodeGenCXX/global-init.cpp
@@ -18,8 +18,7 @@
 // CHECK: @__dso_handle = external global i8
 // CHECK: @c = global %struct.C zeroinitializer, align 8
 
-// It's okay if we ever implement the IR-generation optimization to remove 
this.
-// CHECK: @_ZN5test3L3varE = internal constant i8* getelementptr inbounds ([7 
x i8], [7 x i8]* 
+// CHECK: @[[STR:.*]] = private unnamed_addr constant [7 x i8] c"string\00"
 
 // PR6205: The casts should not require global initializers
 // CHECK: @_ZN6PR59741cE = external global %"struct.PR5974::C"
@@ -66,10 +65,10 @@
 }
 
 namespace test3 {
-  // Tested at the beginning of the file.
   const char * const var = "string";
   extern const char * const var;
 
+  // CHECK: ret i8* getelementptr inbounds ([7 x i8], [7 x i8]* @[[STR]], i32 
0, i32 0)
   const char *test() { return var; }
 }
 
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -2678,10 +2678,11 @@
   }
   return CompleteObject();
 }
-  } else if (BaseType->isFloatingType() && BaseType.isConstQualified()) {
-// We support folding of const floating-point types, in order to make
-// static const data members of such types (supported as an extension)
-// more useful.
+  } else if ((BaseType->isFloatingType() || BaseType->isPointerType()) &&
+ BaseType.isConstQualified()) {
+// We support folding of const floating-point and pointer types, in
+// order to make static const data members of such types (supported as
+// an extension) more useful.
 if (Info.getLangOpts().CPlusPlus11) {
   Info.CCEDiag(E, diag::note_constexpr_ltor_non_constexpr, 1) << VD;
   Info.Note(VD->getLocation(), diag::note_declared_at);


Index: test/CodeGenCXX/global-init.cpp
===
--- test/CodeGenCXX/global-init.cpp
+++ test/CodeGenCXX/global-init.cpp
@@ -18,8 +18,7 @@
 // CHECK: @__dso_handle = external global i8
 // CHECK: @c = global %struct.C zeroinitializer, align 8
 
-// It's okay if we ever implement the IR-generation optimization to remove this.
-// CHECK: @_ZN5test3L3varE = internal constant i8* getelementptr inbounds ([7 x i8], [7 x i8]* 
+// CHECK: @[[STR:.*]] = private unnamed_addr constant [7 x i8] c"string\00"
 
 // PR6205: The casts should not require global initializers
 // CHECK: @_ZN6PR59741cE = external global %"struct.PR5974::C"
@@ -66,10 +65,10 @@
 }
 
 namespace test3 {
-  // Tested at the beginning of the file.
   const char * const var = "string";
   extern const char * const var;
 
+  // CHECK: ret i8* getelementptr inbounds ([7 x i8], [7 x i8]* @[[STR]], i32 0, i32 0)
   const char *test() { return var; }
 }
 
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -2678,10 +2678,11 @@
   }
   return CompleteObject();
 }
-  } else if (BaseType->isFloatingType() && BaseType.isConstQualified()) {
-// We support folding of const floating-point types, in order to make
-// static const data members of such types (supported as an extension)
-// more useful.
+  } else if ((BaseType->isFloatingType() || BaseType->isPointerType()) &&
+ BaseType.isConstQualified()) {
+// We support folding of const floating-point and pointer types, in
+// order to make static const data members of such types (supported as
+// an extension) more useful.
 if (Info.getLangOpts().CPlusPlus11) {
   Info.CCEDiag(E, diag::note_constexpr_ltor_non_constexpr, 1) << VD;
   Info.Note(VD->getLocation(), diag::note_declared_at);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D5023: [analyzer] Fix ObjC Dealloc Checker to operate only on classes with retained properties

2016-01-07 Thread Devin Coughlin via cfe-commits
dcoughlin commandeered this revision.
dcoughlin edited reviewers, added: ddkilzer; removed: dcoughlin.
dcoughlin added a comment.

I am commandeering this revision!


http://reviews.llvm.org/D5023



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


Re: r256012 - Add a defensive check for a nullptr.

2016-01-07 Thread David Blaikie via cfe-commits
Test case?

On Fri, Dec 18, 2015 at 11:44 AM, Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: adrian
> Date: Fri Dec 18 13:44:31 2015
> New Revision: 256012
>
> URL: http://llvm.org/viewvc/llvm-project?rev=256012&view=rev
> Log:
> Add a defensive check for a nullptr.
>
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=256012&r1=256011&r2=256012&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Dec 18 13:44:31 2015
> @@ -3443,11 +3443,13 @@ void CGDebugInfo::EmitUsingDecl(const Us
>  }
>
>  void CGDebugInfo::EmitImportDecl(const ImportDecl &ID) {
> -  auto Info =
> ExternalASTSource::ASTSourceDescriptor(*ID.getImportedModule());
> -  DBuilder.createImportedDeclaration(
> -  getCurrentContextDescriptor(cast(ID.getDeclContext())),
> -  getOrCreateModuleRef(Info, DebugTypeExtRefs),
> -  getLineNumber(ID.getLocation()));
> +  if (Module *M = ID.getImportedModule()) {
> +auto Info =
> ExternalASTSource::ASTSourceDescriptor(*ID.getImportedModule());
> +DBuilder.createImportedDeclaration(
> +getCurrentContextDescriptor(cast(ID.getDeclContext())),
> +getOrCreateModuleRef(Info, DebugTypeExtRefs),
> +getLineNumber(ID.getLocation()));
> +  }
>  }
>
>  llvm::DIImportedEntity *
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r256049 - Split RequireCompleteType into a function that actually requires that the type

2016-01-07 Thread David Blaikie via cfe-commits
On Fri, Dec 18, 2015 at 2:40 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Fri Dec 18 16:40:25 2015
> New Revision: 256049
>
> URL: http://llvm.org/viewvc/llvm-project?rev=256049&view=rev
> Log:
> Split RequireCompleteType into a function that actually requires that the
> type
> is complete (with an error produced if not) and a function that merely
> queries
> whether the type is complete. Either way we'll trigger instantiation if
> necessary, but only the former will diagnose and recover from missing
> module
> imports.
>
> The intent of this change is to prevent a class of bugs where code would
> call
> RequireCompleteType(..., 0) and then ignore the result. With modules, we
> must
> check the return value and use it to determine whether the definition of
> the
> type is visible.
>
> This also fixes a debug info quality issue: calls to isCompleteType do not
> trigger the emission of debug information for a type in limited-debug-info
> mode. This allows us to avoid emitting debug information for type
> definitions
> in more cases where we believe it is safe to do so.
>

Thanks for mentioning - I was wondering if that was the case.

Do you have a canonical example where we previously required the type to be
complete, but we now only query it?


>
> Modified:
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/Sema/SemaCast.cpp
> cfe/trunk/lib/Sema/SemaCodeComplete.cpp
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/lib/Sema/SemaExprCXX.cpp
> cfe/trunk/lib/Sema/SemaExprObjC.cpp
> cfe/trunk/lib/Sema/SemaInit.cpp
> cfe/trunk/lib/Sema/SemaLookup.cpp
> cfe/trunk/lib/Sema/SemaOverload.cpp
> cfe/trunk/lib/Sema/SemaStmt.cpp
> cfe/trunk/lib/Sema/SemaStmtAsm.cpp
> cfe/trunk/lib/Sema/SemaTemplate.cpp
> cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
> cfe/trunk/lib/Sema/SemaType.cpp
> cfe/trunk/test/CodeGenCXX/debug-info-limited.cpp
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=256049&r1=256048&r2=256049&view=diff
>
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Fri Dec 18 16:40:25 2015
> @@ -1316,9 +1316,7 @@ public:
>
>/// \brief Abstract class used to diagnose incomplete types.
>struct TypeDiagnoser {
> -bool Suppressed;
> -
> -TypeDiagnoser(bool Suppressed = false) : Suppressed(Suppressed) { }
> +TypeDiagnoser() {}
>
>  virtual void diagnose(Sema &S, SourceLocation Loc, QualType T) = 0;
>  virtual ~TypeDiagnoser() {}
> @@ -1354,11 +1352,11 @@ public:
>
>public:
>  BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
> -: TypeDiagnoser(DiagID == 0), DiagID(DiagID), Args(Args...) {}
> +: TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
> +  assert(DiagID != 0 && "no diagnostic for type diagnoser");
> +}
>
>  void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
> -  if (Suppressed)
> -return;
>const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
>emit(DB, llvm::index_sequence_for());
>DB << T;
> @@ -1367,7 +1365,7 @@ public:
>
>  private:
>bool RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
> -   TypeDiagnoser &Diagnoser);
> +   TypeDiagnoser *Diagnoser);
>
>VisibleModuleSet VisibleModules;
>llvm::SmallVector VisibleModulesStack;
> @@ -1413,6 +1411,9 @@ public:
>SourceLocation Loc, const NamedDecl *D,
>ArrayRef Equiv);
>
> +  bool isCompleteType(SourceLocation Loc, QualType T) {
> +return !RequireCompleteTypeImpl(Loc, T, nullptr);
> +  }
>bool RequireCompleteType(SourceLocation Loc, QualType T,
> TypeDiagnoser &Diagnoser);
>bool RequireCompleteType(SourceLocation Loc, QualType T,
> @@ -5502,6 +5503,7 @@ public:
>  AbstractArrayType
>};
>
> +  bool isAbstractType(SourceLocation Loc, QualType T);
>bool RequireNonAbstractType(SourceLocation Loc, QualType T,
>TypeDiagnoser &Diagnoser);
>template 
> @@ -5513,9 +5515,6 @@ public:
>
>void DiagnoseAbstractType(const CXXRecordDecl *RD);
>
> -  bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned
> DiagID,
> -  AbstractDiagSelID SelID = AbstractNone);
> -
>
>  
> //======//
>// C++ Overloaded Operators [C++ 13.5]
>//
>
> Modified: cfe/trunk/lib/Sema/SemaCast.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=256049&r1=256048&r2=256049&view=diff
>
> ==
> ---

Re: [PATCH] D15305: [CUDA] Do not allow dynamic initialization of global device side variables.

2016-01-07 Thread Richard Smith via cfe-commits
rsmith added a comment.

This should be checked and diagnosed in Sema, not in CodeGen.



Comment at: lib/CodeGen/CGDeclCXX.cpp:323-324
@@ +322,4 @@
+
+  // The constructor function has no parameters,
+  if (CD->getNumParams() != 0)
+return false;

What if the constructor is a C-style varargs function:

  struct X { X(...) {} };

?


Comment at: lib/CodeGen/CGDeclCXX.cpp:329
@@ +328,3 @@
+  for (const CXXCtorInitializer *CI: CD->inits())
+if (CI->isAnyMemberInitializer() && CI->isWritten())
+  return false;

tra wrote:
> @rsmith: is this a good way to find member initializer list items?
> 
> ```
> struct S {
> int a,b,c;
> S() : a(1),b(2),c(3) {}
> };
> ```
> I'm looking for a(),b(),c() which is what I think CUDA spec wants to check 
> for, but CD->inits() appears to have other initializers on the list as well.
You shouldn't need to check `isAnyMemberInitializer`: if there's any written 
inits, the constructor violates the rules.


Comment at: lib/CodeGen/CGDeclCXX.cpp:333
@@ +332,3 @@
+  // and the function body is an empty compound statement.
+  // That does not always work.
+  if (!CD->hasTrivialBody())

What doesn't always work?


Comment at: lib/CodeGen/CGDeclCXX.cpp:347-367
@@ +346,23 @@
+
+  // The default constructors of all base classes of its class can be
+  // considered empty.
+  for (auto &Base : RD->bases())
+if (hasNonEmptyDefaultConstructors(*this,
+   Base.getType()->getAsCXXRecordDecl()))
+  return false;
+
+  // For all the nonstatic data members of its class that are of class type
+  // (or array thereof), the default constructors can be considered empty.
+  for (const auto *I : RD->decls())
+if (const FieldDecl *V = dyn_cast(I)) {
+  QualType T = V->getType();
+
+  if (const ArrayType *Ty = dyn_cast(T))
+while ((Ty = dyn_cast(T)))
+  T = Ty->getElementType();
+
+  if (const CXXRecordDecl *R = T->getAsCXXRecordDecl())
+if (hasNonEmptyDefaultConstructors(*this, R))
+  return false;
+}
+

Rather than checking these properties this way, I'd suggest you check the 
initialization expression in each `CXXCtorInitializer` only contains 
`CXXConstructExpr`s for empty constructors (or any other whitelisted 
constructs). Your current approach will miss a couple of cases which the CUDA 
spec misses but presumably meant to exclude:

1) Default member initializers

  int f();
  struct X { int n = f(); X() {} };

2) Cases where a constructor other than a default constructor is implicitly 
invoked

  struct A { template A(T...); };
  struct B : A { B() {} };


Comment at: lib/CodeGen/CodeGenModule.cpp:1347-1351
@@ -1346,2 +1346,7 @@
 return false;
+  // Delay codegen for device-side CUDA variables. We need to have all
+  // constructor definitions available before we can determine whether
+  // we can skip them or produce an error.
+  if (LangOpts.CUDA && LangOpts.CUDAIsDevice && isa(Global))
+return false;
 

According to the quoted specification, you're supposed to check whether the 
constructor can be considered empty at the point in the translation unit where 
the definition of the variable occurs, so I don't think you need to delay 
anything.


http://reviews.llvm.org/D15305



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


[PATCH] D15989: [OpenMP] Parsing + sema for "target enter data" and "target exit data" directives.

2016-01-07 Thread Arpith Jacob via cfe-commits
arpith-jacob created this revision.
arpith-jacob added reviewers: kkwli0, sfantao, fraggamuffin, hfinkel, ABataev, 
carlo.bertolli.
arpith-jacob added a subscriber: cfe-commits.

This patch adds parsing and sema support for "#pragma omp target enter data" 
and "#pragma omp target exit data" directives.

http://reviews.llvm.org/D15989

Files:
  include/clang-c/Index.h
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/StmtOpenMP.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenMPKinds.def
  include/clang/Basic/StmtNodes.td
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/OpenMPClause.cpp
  lib/AST/StmtOpenMP.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/OpenMP/target_enter_data_ast_print.cpp
  test/OpenMP/target_enter_data_device_messages.cpp
  test/OpenMP/target_enter_data_if_messages.cpp
  test/OpenMP/target_enter_data_map_messages.c
  test/OpenMP/target_exit_data_ast_print.cpp
  test/OpenMP/target_exit_data_device_messages.cpp
  test/OpenMP/target_exit_data_if_messages.cpp
  test/OpenMP/target_exit_data_map_messages.c
  tools/libclang/CIndex.cpp
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -600,6 +600,12 @@
   case Stmt::OMPTargetDataDirectiveClass:
 K = CXCursor_OMPTargetDataDirective;
 break;
+  case Stmt::OMPTargetEnterDataDirectiveClass:
+K = CXCursor_OMPTargetEnterDataDirective;
+break;
+  case Stmt::OMPTargetExitDataDirectiveClass:
+K = CXCursor_OMPTargetExitDataDirective;
+break;
   case Stmt::OMPTeamsDirectiveClass:
 K = CXCursor_OMPTeamsDirective;
 break;
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1949,6 +1949,8 @@
   void VisitOMPAtomicDirective(const OMPAtomicDirective *D);
   void VisitOMPTargetDirective(const OMPTargetDirective *D);
   void VisitOMPTargetDataDirective(const OMPTargetDataDirective *D);
+  void VisitOMPTargetEnterDataDirective(const OMPTargetEnterDataDirective *D);
+  void VisitOMPTargetExitDataDirective(const OMPTargetExitDataDirective *D);
   void VisitOMPTeamsDirective(const OMPTeamsDirective *D);
   void VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *D);
   void VisitOMPTaskLoopSimdDirective(const OMPTaskLoopSimdDirective *D);
@@ -2624,6 +2626,16 @@
   VisitOMPExecutableDirective(D);
 }
 
+void EnqueueVisitor::VisitOMPTargetEnterDataDirective(
+const OMPTargetEnterDataDirective *D) {
+  VisitOMPExecutableDirective(D);
+}
+
+void EnqueueVisitor::VisitOMPTargetExitDataDirective(
+const OMPTargetExitDataDirective *D) {
+  VisitOMPExecutableDirective(D);
+}
+
 void EnqueueVisitor::VisitOMPTeamsDirective(const OMPTeamsDirective *D) {
   VisitOMPExecutableDirective(D);
 }
@@ -4506,6 +4518,10 @@
 return cxstring::createRef("OMPTargetDirective");
   case CXCursor_OMPTargetDataDirective:
 return cxstring::createRef("OMPTargetDataDirective");
+  case CXCursor_OMPTargetEnterDataDirective:
+return cxstring::createRef("OMPTargetEnterDataDirective");
+  case CXCursor_OMPTargetExitDataDirective:
+return cxstring::createRef("OMPTargetExitDataDirective");
   case CXCursor_OMPTeamsDirective:
 return cxstring::createRef("OMPTeamsDirective");
   case CXCursor_OMPCancellationPointDirective:
Index: test/OpenMP/target_exit_data_map_messages.c
===
--- /dev/null
+++ test/OpenMP/target_exit_data_map_messages.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+
+int main(int argc, char **argv) {
+
+  int r;
+  #pragma omp target exit data map(r) // expected-error {{map type must be specified for '#pragma omp target exit data'}}
+
+  #pragma omp target exit data // expected-error {{expected at least one map clause for '#pragma omp target exit data'}}
+
+  #pragma omp target exit data map(tofrom: r) // expected-error {{map type 'tofrom' is not allowed for '#pragma omp target exit data'}}
+
+  #pragma omp target exit data map(always, from: r)
+  #pragma omp target exit data map(delete: r)
+  #pragma omp target exit data map(release: r)
+  #pragma omp target exit data map(always, alloc: r) // expected-error {{map type 'alloc' is not allowed for '#pragma omp target exit data'}}
+  #pragma omp target exit data map(to: r) // expected-error {{map type 'to' is not allowed for '#pragma omp target exit data'}}
+
+  retur

Re: [PATCH] D15989: [OpenMP] Parsing + sema for "target enter data" and "target exit data" directives.

2016-01-07 Thread Arpith Jacob via cfe-commits
arpith-jacob added inline comments.


Comment at: lib/Parse/ParseOpenMP.cpp:42
@@ -37,1 +41,3 @@
+  {OMPD_unknown /*target exit*/, OMPD_unknown /*data*/,
+   OMPD_target_exit_data},
   {OMPD_for, OMPD_simd, OMPD_for_simd},

I have written this code based on the comments in the 'target data' patch and 
also the approach to parsing 'cancellation'.  This requires hard coded array 
index numbers below (see diff with cancellation and point tokens).  If anyone 
can suggest better alternatives I will be happy to rework the code.


Comment at: lib/Sema/SemaOpenMP.cpp:5918
@@ -5866,1 +5917,3 @@
+}
+
 OMPClause *Sema::ActOnOpenMPSafelenClause(Expr *Len, SourceLocation StartLoc,

This method is required to ensure that target enter/exit directives always have 
a map clause.  It can be reused by other directives such as target data.


Comment at: lib/Sema/SemaOpenMP.cpp:8507
@@ +8506,3 @@
+  Diag(StartLoc, diag::err_omp_invalid_map_type_for_directive) <<
+  static_cast(IsMapTypeImplicit) <<
+  getOpenMPSimpleClauseTypeName(OMPC_map, MapType) <<

I have to capture 'IsMapTypeImplicit' from the parser for more informative 
error messages.  This helps me support the following case:

#pragma omp target enter data map(r) // expected-error {{map type must be 
specified for '#pragma omp target enter data'}}

and distinguish it from:

#pragma omp target enter data map(tofrom: r) // expected-error {{map type 
'tofrom' is not allowed for '#pragma omp target enter data'}}


Comment at: lib/Sema/SemaOpenMP.cpp:8510
@@ +8509,3 @@
+  getOpenMPDirectiveName(DKind);
+  // Proceed to add the variable in a map clause anyway, to prevent
+  // further spurious messages

This error occurs when the user specifies an invalid map type.  After reporting 
the error I proceed to retain the clause so that it doesn't trigger the 'map 
clause not present' error.


http://reviews.llvm.org/D15989



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


Re: r256287 - Document that we recommend to turn off -gmodules when building a static

2016-01-07 Thread David Blaikie via cfe-commits
Presumably this only applies when using implicit modules builds, not when
using explicit modules builds. (though I'm not sure what the current
behavior of -gmodules is with explicit modules, maybe it's
untested/broken/etc anyway)

On Tue, Dec 22, 2015 at 2:37 PM, Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: adrian
> Date: Tue Dec 22 16:37:22 2015
> New Revision: 256287
>
> URL: http://llvm.org/viewvc/llvm-project?rev=256287&view=rev
> Log:
> Document that we recommend to turn off -gmodules when building a static
> library for distribution to other machines on the clang man page.
>
> Modified:
> cfe/trunk/docs/CommandGuide/clang.rst
>
> Modified: cfe/trunk/docs/CommandGuide/clang.rst
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CommandGuide/clang.rst?rev=256287&r1=256286&r2=256287&view=diff
>
> ==
> --- cfe/trunk/docs/CommandGuide/clang.rst (original)
> +++ cfe/trunk/docs/CommandGuide/clang.rst Tue Dec 22 16:37:22 2015
> @@ -262,7 +262,12 @@ Code Generation Options
>Generate debug information that contains external references to
>types defined in clang modules or precompiled headers instead of
>emitting redundant debug type information into every object file.
> -  This option implies `-fmodule-format=obj`.
> +  This option implies :option:`-fmodule-format=obj`.
> +
> +  This option should not be used when building static libraries for
> +  distribution to other machines because the debug info will contain
> +  references to the module cache on the machine the object files in
> +  the library were built on.
>
>  .. option:: -fstandalone-debug -fno-standalone-debug
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r256403 - Revert r256399 "[Sema] ArrayRef-ize ActOnBaseSpecifiers. NFC"

2016-01-07 Thread David Blaikie via cfe-commits
On Thu, Dec 24, 2015 at 4:36 PM, Craig Topper via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ctopper
> Date: Thu Dec 24 18:36:02 2015
> New Revision: 256403
>
> URL: http://llvm.org/viewvc/llvm-project?rev=256403&view=rev
> Log:
> Revert r256399 "[Sema] ArrayRef-ize ActOnBaseSpecifiers. NFC"
>
> It broke lldb build.
>

Any idea why?


>
> Modified:
> cfe/trunk/include/clang/AST/DeclCXX.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/AST/ASTImporter.cpp
> cfe/trunk/lib/AST/DeclCXX.cpp
> cfe/trunk/lib/Parse/ParseDeclCXX.cpp
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
>
> Modified: cfe/trunk/include/clang/AST/DeclCXX.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=256403&r1=256402&r2=256403&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
> +++ cfe/trunk/include/clang/AST/DeclCXX.h Thu Dec 24 18:36:02 2015
> @@ -701,7 +701,7 @@ public:
>}
>
>/// \brief Sets the base classes of this struct or class.
> -  void setBases(ArrayRef Bases);
> +  void setBases(CXXBaseSpecifier const * const *Bases, unsigned NumBases);
>
>/// \brief Retrieves the number of base classes of this class.
>unsigned getNumBases() const { return data().NumBases; }
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=256403&r1=256402&r2=256403&view=diff
>
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Thu Dec 24 18:36:02 2015
> @@ -5365,10 +5365,10 @@ public:
>  SourceLocation BaseLoc,
>  SourceLocation EllipsisLoc);
>
> -  bool AttachBaseSpecifiers(CXXRecordDecl *Class,
> -MutableArrayRef Bases);
> -  void ActOnBaseSpecifiers(Decl *ClassDecl,
> -   MutableArrayRef Bases);
> +  bool AttachBaseSpecifiers(CXXRecordDecl *Class, CXXBaseSpecifier
> **Bases,
> +unsigned NumBases);
> +  void ActOnBaseSpecifiers(Decl *ClassDecl, CXXBaseSpecifier **Bases,
> +   unsigned NumBases);
>
>bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base);
>bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base,
>
> Modified: cfe/trunk/lib/AST/ASTImporter.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=256403&r1=256402&r2=256403&view=diff
>
> ==
> --- cfe/trunk/lib/AST/ASTImporter.cpp (original)
> +++ cfe/trunk/lib/AST/ASTImporter.cpp Thu Dec 24 18:36:02 2015
> @@ -2073,7 +2073,7 @@ bool ASTNodeImporter::ImportDefinition(R
> EllipsisLoc));
>  }
>  if (!Bases.empty())
> -  ToCXX->setBases(Bases);
> +  ToCXX->setBases(Bases.data(), Bases.size());
>}
>
>if (shouldForceImportDeclContext(Kind))
>
> Modified: cfe/trunk/lib/AST/DeclCXX.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=256403&r1=256402&r2=256403&view=diff
>
> ==
> --- cfe/trunk/lib/AST/DeclCXX.cpp (original)
> +++ cfe/trunk/lib/AST/DeclCXX.cpp Thu Dec 24 18:36:02 2015
> @@ -135,13 +135,14 @@ CXXRecordDecl::CreateDeserialized(const
>  }
>
>  void
> -CXXRecordDecl::setBases(ArrayRef Bases) {
> +CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases,
> +unsigned NumBases) {
>ASTContext &C = getASTContext();
>
>if (!data().Bases.isOffset() && data().NumBases > 0)
>  C.Deallocate(data().getBases());
>
> -  if (!Bases.empty()) {
> +  if (NumBases) {
>  // C++ [dcl.init.aggr]p1:
>  //   An aggregate is [...] a class with [...] no base classes [...].
>  data().Aggregate = false;
> @@ -157,9 +158,9 @@ CXXRecordDecl::setBases(ArrayRef// The virtual bases of this class.
>SmallVector VBases;
>
> -  data().Bases = new(C) CXXBaseSpecifier [Bases.size()];
> -  data().NumBases = Bases.size();
> -  for (unsigned i = 0; i < Bases.size(); ++i) {
> +  data().Bases = new(C) CXXBaseSpecifier [NumBases];
> +  data().NumBases = NumBases;
> +  for (unsigned i = 0; i < NumBases; ++i) {
>  data().getBases()[i] = *Bases[i];
>  // Keep track of inherited vbases for this base class.
>  const CXXBaseSpecifier *Base = Bases[i];
>
> Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=256403&r1=256402&r2=256403&view=diff
>
> ==
> --- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (orig

Re: [PATCH] D15173: [Preprocessor] Fix assertion in AnnotatePreviousCachedTokens

2016-01-07 Thread Bruno Cardoso Lopes via cfe-commits
bruno updated this revision to Diff 44306.
bruno added a comment.

Hi Richard,

Thanks for the detailed explanation, it now makes sense to me. I updated the 
patch with another approach! Let me know if it's the right direction.


http://reviews.llvm.org/D15173

Files:
  include/clang/Lex/Preprocessor.h
  lib/Lex/PPCaching.cpp
  lib/Parse/ParseTemplate.cpp
  test/Parser/objcxx11-protocol-in-template.mm

Index: test/Parser/objcxx11-protocol-in-template.mm
===
--- test/Parser/objcxx11-protocol-in-template.mm
+++ test/Parser/objcxx11-protocol-in-template.mm
@@ -8,3 +8,11 @@
 
 vector> v;
 vector>> v2;
+
+@protocol PA;
+@protocol PB;
+
+@class NSArray;
+typedef int some_t;
+
+id FA(NSArray> *h, some_t group);
Index: lib/Parse/ParseTemplate.cpp
===
--- lib/Parse/ParseTemplate.cpp
+++ lib/Parse/ParseTemplate.cpp
@@ -827,6 +827,7 @@
   }
 
   // Strip the initial '>' from the token.
+  Token PrevTok = Tok;
   if (RemainingToken == tok::equal && Next.is(tok::equal) &&
   areTokensAdjacent(Tok, Next)) {
 // Join two adjacent '=' tokens into one, for cases like:
@@ -843,6 +844,20 @@
  PP.getSourceManager(),
  getLangOpts()));
 
+  // The advance from '>>' to '>' in a ObjectiveC template argument list needs
+  // to be properly reflected in the token cache to allow correct interaction
+  // between annotation and backtracking.
+  if (ObjCGenericList && PrevTok.getKind() == tok::greatergreater &&
+  RemainingToken == tok::greater &&
+  PrevTok.getLocation().getRawEncoding() <=
+  PP.getLastCachedTokenLocation().getRawEncoding()) {
+Token ReplTok = PrevTok;
+PrevTok.setKind(RemainingToken);
+PrevTok.setLength(1);
+SmallVector NewToks = {PrevTok, Tok};
+PP.ReplaceCachedToken(ReplTok, NewToks);
+  }
+
   if (!ConsumeLastToken) {
 // Since we're not supposed to consume the '>' token, we need to push
 // this token and revert the current token back to the '>'.
Index: lib/Lex/PPCaching.cpp
===
--- lib/Lex/PPCaching.cpp
+++ lib/Lex/PPCaching.cpp
@@ -116,3 +116,19 @@
 }
   }
 }
+
+void Preprocessor::ReplaceCachedToken(const Token &Tok,
+  SmallVectorImpl &NewToks) {
+  assert(CachedLexPos != 0 && "Expected to have some cached tokens");
+  for (auto i = CachedLexPos - 1; i != 0; --i) {
+const Token CurrCachedTok = CachedTokens[i];
+if (CurrCachedTok.getKind() == Tok.getKind() &&
+CurrCachedTok.getLocation() == Tok.getLocation()) {
+  CachedTokens.insert(CachedTokens.begin() + i, NewToks.begin(),
+  NewToks.end());
+  CachedTokens.erase(CachedTokens.begin() + i + NewToks.size());
+  CachedLexPos += NewToks.size() - 1;
+  return;
+}
+  }
+}
Index: include/clang/Lex/Preprocessor.h
===
--- include/clang/Lex/Preprocessor.h
+++ include/clang/Lex/Preprocessor.h
@@ -1185,6 +1185,12 @@
 return CachedTokens[CachedLexPos-1].getLastLoc();
   }
 
+  /// \brief Replace token \p Tok in CachedTokens by the tokens in \p NewToks.
+  ///
+  /// Useful when a token needs to be split in smaller ones and CachedTokens
+  /// must to be updated to reflect that.
+  void ReplaceCachedToken(const Token &Tok, SmallVectorImpl &NewToks);
+
   /// \brief Replace the last token with an annotation token.
   ///
   /// Like AnnotateCachedTokens(), this routine replaces an


Index: test/Parser/objcxx11-protocol-in-template.mm
===
--- test/Parser/objcxx11-protocol-in-template.mm
+++ test/Parser/objcxx11-protocol-in-template.mm
@@ -8,3 +8,11 @@
 
 vector> v;
 vector>> v2;
+
+@protocol PA;
+@protocol PB;
+
+@class NSArray;
+typedef int some_t;
+
+id FA(NSArray> *h, some_t group);
Index: lib/Parse/ParseTemplate.cpp
===
--- lib/Parse/ParseTemplate.cpp
+++ lib/Parse/ParseTemplate.cpp
@@ -827,6 +827,7 @@
   }
 
   // Strip the initial '>' from the token.
+  Token PrevTok = Tok;
   if (RemainingToken == tok::equal && Next.is(tok::equal) &&
   areTokensAdjacent(Tok, Next)) {
 // Join two adjacent '=' tokens into one, for cases like:
@@ -843,6 +844,20 @@
  PP.getSourceManager(),
  getLangOpts()));
 
+  // The advance from '>>' to '>' in a ObjectiveC template argument list needs
+  // to be properly reflected in the token cache to allow correct interaction
+  // between annotation and backtracking.
+  if (ObjCGenericList && PrevTok.getKind() == tok::greatergreater &&
+  RemainingToken == tok::greater &&
+  PrevTok.getLocation().getRawEncod

Re: [PATCH] D15911: Switch Action and ActionList over to using std::shared_ptr.

2016-01-07 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 44307.
jlebar added a comment.

Switch to maintaining ownership of the Actions within the Compilation.


http://reviews.llvm.org/D15911

Files:
  include/clang/Driver/Action.h
  include/clang/Driver/Compilation.h
  include/clang/Driver/Driver.h
  lib/Driver/Action.cpp
  lib/Driver/Compilation.cpp
  lib/Driver/Driver.cpp

Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1049,19 +1049,15 @@
   << types::getTypeName(Act->getType());
 
 ActionList Inputs;
-for (unsigned i = 0, e = Archs.size(); i != e; ++i) {
-  Inputs.push_back(
-  new BindArchAction(std::unique_ptr(Act), Archs[i]));
-  if (i != 0)
-Inputs.back()->setOwnsInputs(false);
-}
+for (unsigned i = 0, e = Archs.size(); i != e; ++i)
+  Inputs.push_back(C.MakeAction(Act, Archs[i]));
 
 // Lipo if necessary, we do it this way because we need to set the arch flag
 // so that -Xarch_ gets overwritten.
 if (Inputs.size() == 1 || Act->getType() == types::TY_Nothing)
   Actions.append(Inputs.begin(), Inputs.end());
 else
-  Actions.push_back(new LipoJobAction(Inputs, Act->getType()));
+  Actions.push_back(C.MakeAction(Inputs, Act->getType()));
 
 // Handle debug info queries.
 Arg *A = Args.getLastArg(options::OPT_g_Group);
@@ -1077,15 +1073,16 @@
 ActionList Inputs;
 Inputs.push_back(Actions.back());
 Actions.pop_back();
-Actions.push_back(new DsymutilJobAction(Inputs, types::TY_dSYM));
+Actions.push_back(
+C.MakeAction(Inputs, types::TY_dSYM));
   }
 
   // Verify the debug info output.
   if (Args.hasArg(options::OPT_verify_debug_info)) {
-std::unique_ptr VerifyInput(Actions.back());
+Action* LastAction = Actions.back();
 Actions.pop_back();
-Actions.push_back(new VerifyDebugInfoJobAction(std::move(VerifyInput),
-   types::TY_Nothing));
+Actions.push_back(C.MakeAction(
+LastAction, types::TY_Nothing));
   }
 }
   }
@@ -1283,16 +1280,15 @@
 // Actions and /p Current is released. Otherwise the function creates
 // and returns a new CudaHostAction which wraps /p Current and device
 // side actions.
-static std::unique_ptr
-buildCudaActions(Compilation &C, DerivedArgList &Args, const Arg *InputArg,
- std::unique_ptr HostAction, ActionList &Actions) {
+static Action *buildCudaActions(Compilation &C, DerivedArgList &Args,
+const Arg *InputArg, Action *HostAction,
+ActionList &Actions) {
   Arg *PartialCompilationArg = Args.getLastArg(options::OPT_cuda_host_only,
options::OPT_cuda_device_only);
   // Host-only compilation case.
   if (PartialCompilationArg &&
   PartialCompilationArg->getOption().matches(options::OPT_cuda_host_only))
-return std::unique_ptr(
-new CudaHostAction(std::move(HostAction), {}));
+return C.MakeAction(HostAction, ActionList());
 
   // Collect all cuda_gpu_arch parameters, removing duplicates.
   SmallVector GpuArchList;
@@ -1350,26 +1346,25 @@
 }
 
 for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I)
-  Actions.push_back(new CudaDeviceAction(
-  std::unique_ptr(CudaDeviceActions[I]), GpuArchList[I],
-  /* AtTopLevel */ true));
+  Actions.push_back(C.MakeAction(CudaDeviceActions[I],
+   GpuArchList[I],
+   /* AtTopLevel */ true));
 // Kill host action in case of device-only compilation.
 if (DeviceOnlyCompilation)
-  HostAction.reset(nullptr);
+  return nullptr;
 return HostAction;
   }
 
   // Outputs of device actions during complete CUDA compilation get created
   // with AtTopLevel=false and become inputs for the host action.
   ActionList DeviceActions;
   for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I)
-DeviceActions.push_back(new CudaDeviceAction(
-std::unique_ptr(CudaDeviceActions[I]), GpuArchList[I],
-/* AtTopLevel */ false));
+DeviceActions.push_back(
+C.MakeAction(CudaDeviceActions[I], GpuArchList[I],
+   /* AtTopLevel */ false));
   // Return a new host action that incorporates original host action and all
   // device actions.
-  return std::unique_ptr(
-  new CudaHostAction(std::move(HostAction), DeviceActions));
+  return C.MakeAction(HostAction, DeviceActions);
 }
 
 void Driver::BuildActions(Compilation &C, const ToolChain &TC,
@@ -1478,7 +1473,7 @@
   }
 
 // Build the pipeline for this file.
-std::unique_ptr Current(new InputAction(*InputArg, InputType));
+Action *Current = C.MakeAction(*InputArg, InputType);
 for (S

Re: [PATCH] D15911: Move ownership of Action objects into Compilation.

2016-01-07 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 44308.
jlebar retitled this revision from "Move ownership of Action objects into 
Compilation.
" to "Move ownership of Action objects into Compilation.".
jlebar added a comment.

Clear both Actions and OwningActions in 
Compilation::initCompilationForDiagnostics().


http://reviews.llvm.org/D15911

Files:
  include/clang/Driver/Action.h
  include/clang/Driver/Compilation.h
  include/clang/Driver/Driver.h
  lib/Driver/Action.cpp
  lib/Driver/Compilation.cpp
  lib/Driver/Driver.cpp

Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1049,19 +1049,15 @@
   << types::getTypeName(Act->getType());
 
 ActionList Inputs;
-for (unsigned i = 0, e = Archs.size(); i != e; ++i) {
-  Inputs.push_back(
-  new BindArchAction(std::unique_ptr(Act), Archs[i]));
-  if (i != 0)
-Inputs.back()->setOwnsInputs(false);
-}
+for (unsigned i = 0, e = Archs.size(); i != e; ++i)
+  Inputs.push_back(C.MakeAction(Act, Archs[i]));
 
 // Lipo if necessary, we do it this way because we need to set the arch flag
 // so that -Xarch_ gets overwritten.
 if (Inputs.size() == 1 || Act->getType() == types::TY_Nothing)
   Actions.append(Inputs.begin(), Inputs.end());
 else
-  Actions.push_back(new LipoJobAction(Inputs, Act->getType()));
+  Actions.push_back(C.MakeAction(Inputs, Act->getType()));
 
 // Handle debug info queries.
 Arg *A = Args.getLastArg(options::OPT_g_Group);
@@ -1077,15 +1073,16 @@
 ActionList Inputs;
 Inputs.push_back(Actions.back());
 Actions.pop_back();
-Actions.push_back(new DsymutilJobAction(Inputs, types::TY_dSYM));
+Actions.push_back(
+C.MakeAction(Inputs, types::TY_dSYM));
   }
 
   // Verify the debug info output.
   if (Args.hasArg(options::OPT_verify_debug_info)) {
-std::unique_ptr VerifyInput(Actions.back());
+Action* LastAction = Actions.back();
 Actions.pop_back();
-Actions.push_back(new VerifyDebugInfoJobAction(std::move(VerifyInput),
-   types::TY_Nothing));
+Actions.push_back(C.MakeAction(
+LastAction, types::TY_Nothing));
   }
 }
   }
@@ -1283,16 +1280,15 @@
 // Actions and /p Current is released. Otherwise the function creates
 // and returns a new CudaHostAction which wraps /p Current and device
 // side actions.
-static std::unique_ptr
-buildCudaActions(Compilation &C, DerivedArgList &Args, const Arg *InputArg,
- std::unique_ptr HostAction, ActionList &Actions) {
+static Action *buildCudaActions(Compilation &C, DerivedArgList &Args,
+const Arg *InputArg, Action *HostAction,
+ActionList &Actions) {
   Arg *PartialCompilationArg = Args.getLastArg(options::OPT_cuda_host_only,
options::OPT_cuda_device_only);
   // Host-only compilation case.
   if (PartialCompilationArg &&
   PartialCompilationArg->getOption().matches(options::OPT_cuda_host_only))
-return std::unique_ptr(
-new CudaHostAction(std::move(HostAction), {}));
+return C.MakeAction(HostAction, ActionList());
 
   // Collect all cuda_gpu_arch parameters, removing duplicates.
   SmallVector GpuArchList;
@@ -1350,26 +1346,25 @@
 }
 
 for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I)
-  Actions.push_back(new CudaDeviceAction(
-  std::unique_ptr(CudaDeviceActions[I]), GpuArchList[I],
-  /* AtTopLevel */ true));
+  Actions.push_back(C.MakeAction(CudaDeviceActions[I],
+   GpuArchList[I],
+   /* AtTopLevel */ true));
 // Kill host action in case of device-only compilation.
 if (DeviceOnlyCompilation)
-  HostAction.reset(nullptr);
+  return nullptr;
 return HostAction;
   }
 
   // Outputs of device actions during complete CUDA compilation get created
   // with AtTopLevel=false and become inputs for the host action.
   ActionList DeviceActions;
   for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I)
-DeviceActions.push_back(new CudaDeviceAction(
-std::unique_ptr(CudaDeviceActions[I]), GpuArchList[I],
-/* AtTopLevel */ false));
+DeviceActions.push_back(
+C.MakeAction(CudaDeviceActions[I], GpuArchList[I],
+   /* AtTopLevel */ false));
   // Return a new host action that incorporates original host action and all
   // device actions.
-  return std::unique_ptr(
-  new CudaHostAction(std::move(HostAction), DeviceActions));
+  return C.MakeAction(HostAction, DeviceActions);
 }
 
 void Driver::BuildActions(Compilation &C, const ToolChain &TC,
@@ -1478,7 +1473,7 @@
   }
 
 // Build the 

Re: [PATCH] D15911: Move ownership of Action objects into Compilation.

2016-01-07 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Changed to move ownership into Compilation, as discussed earlier today.  Please 
have a look.


http://reviews.llvm.org/D15911



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


Re: [PATCH] D15960: Don't build jobs for the same Action + ToolChain twice.

2016-01-07 Thread Justin Lebar via cfe-commits
jlebar added a comment.

This actually has a subtle issue not found with existing unit tests: 
BuildJobsForAction has an outparam and we don't set it on cache hit.

Please hold off reviewing this until I fix the problem.


http://reviews.llvm.org/D15960



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


r257142 - [CUDA] Split out tests for unused-arg warnings from cuda-options.cu.

2016-01-07 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Jan  7 21:33:04 2016
New Revision: 257142

URL: http://llvm.org/viewvc/llvm-project?rev=257142&view=rev
Log:
[CUDA] Split out tests for unused-arg warnings from cuda-options.cu.

Summary: Trying to make this test a bit more manageable.

Reviewers: tra

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D15974

Added:
cfe/trunk/test/Driver/cuda-unused-arg-warning.cu
Modified:
cfe/trunk/test/Driver/cuda-options.cu

Modified: cfe/trunk/test/Driver/cuda-options.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-options.cu?rev=257142&r1=257141&r2=257142&view=diff
==
--- cfe/trunk/test/Driver/cuda-options.cu (original)
+++ cfe/trunk/test/Driver/cuda-options.cu Thu Jan  7 21:33:04 2016
@@ -111,20 +111,6 @@
 // Make sure we don't link anything.
 // RUN:   -check-prefix CUDA-NL %s
 
-// --cuda-host-only should never trigger unused arg warning.
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -c %s 2>&1 | \
-// RUN:FileCheck -check-prefix CUDA-NO-UNUSED-CHO %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -x c -c %s 2>&1 
| \
-// RUN:FileCheck -check-prefix CUDA-NO-UNUSED-CHO %s
-
-// --cuda-device-only should not produce warning compiling CUDA files
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -c %s 2>&1 | \
-// RUN:FileCheck -check-prefix CUDA-NO-UNUSED-CDO %s
-
-// --cuda-device-only should warn during non-CUDA compilation.
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -x c -c %s 
2>&1 | \
-// RUN:FileCheck -check-prefix CUDA-UNUSED-CDO %s
-
 // Match device-side preprocessor, and compiler phases with -save-temps
 // CUDA-D1S: "-cc1" "-triple" "nvptx64-nvidia-cuda"
 // CUDA-D1S-SAME: "-aux-triple" "x86_64--linux-gnu"
@@ -189,7 +175,3 @@
 
 // Match no linker
 // CUDA-NL-NOT: "{{.*}}{{ld|link}}{{(.exe)?}}"
-
-// CUDA-NO-UNUSED-CHO-NOT: warning: argument unused during compilation: 
'--cuda-host-only'
-// CUDA-UNUSED-CDO: warning: argument unused during compilation: 
'--cuda-device-only'
-// CUDA-NO-UNUSED-CDO-NOT: warning: argument unused during compilation: 
'--cuda-device-only'

Added: cfe/trunk/test/Driver/cuda-unused-arg-warning.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-unused-arg-warning.cu?rev=257142&view=auto
==
--- cfe/trunk/test/Driver/cuda-unused-arg-warning.cu (added)
+++ cfe/trunk/test/Driver/cuda-unused-arg-warning.cu Thu Jan  7 21:33:04 2016
@@ -0,0 +1,23 @@
+// Tests that we trigger unused-arg warnings on CUDA flags appropriately.
+
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// --cuda-host-only should never trigger unused arg warning.
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -c %s 2>&1 | \
+// RUN:FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -x c -c %s 2>&1 
| \
+// RUN:FileCheck %s
+
+// --cuda-device-only should warn during non-CUDA compilation.
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -x c -c %s 
2>&1 | \
+// RUN:FileCheck -check-prefix UNUSED-CDO %s
+
+// --cuda-device-only should not produce warning compiling CUDA files
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -c %s 2>&1 | \
+// RUN:FileCheck -check-prefix NO-UNUSED-CDO %s
+
+// CHECK-NOT: warning: argument unused during compilation: '--cuda-host-only'
+// UNUSED-CDO: warning: argument unused during compilation: 
'--cuda-device-only'
+// NO-UNUSED-CDO-NOT: warning: argument unused during compilation: 
'--cuda-device-only'


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


Re: [PATCH] D15974: [CUDA] Split out tests for unused-arg warnings from cuda-options.cu.

2016-01-07 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL257142: [CUDA] Split out tests for unused-arg warnings from 
cuda-options.cu. (authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D15974?vs=44270&id=44309#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15974

Files:
  cfe/trunk/test/Driver/cuda-options.cu
  cfe/trunk/test/Driver/cuda-unused-arg-warning.cu

Index: cfe/trunk/test/Driver/cuda-options.cu
===
--- cfe/trunk/test/Driver/cuda-options.cu
+++ cfe/trunk/test/Driver/cuda-options.cu
@@ -111,20 +111,6 @@
 // Make sure we don't link anything.
 // RUN:   -check-prefix CUDA-NL %s
 
-// --cuda-host-only should never trigger unused arg warning.
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -c %s 2>&1 | \
-// RUN:FileCheck -check-prefix CUDA-NO-UNUSED-CHO %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -x c -c %s 2>&1 
| \
-// RUN:FileCheck -check-prefix CUDA-NO-UNUSED-CHO %s
-
-// --cuda-device-only should not produce warning compiling CUDA files
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -c %s 2>&1 | \
-// RUN:FileCheck -check-prefix CUDA-NO-UNUSED-CDO %s
-
-// --cuda-device-only should warn during non-CUDA compilation.
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -x c -c %s 
2>&1 | \
-// RUN:FileCheck -check-prefix CUDA-UNUSED-CDO %s
-
 // Match device-side preprocessor, and compiler phases with -save-temps
 // CUDA-D1S: "-cc1" "-triple" "nvptx64-nvidia-cuda"
 // CUDA-D1S-SAME: "-aux-triple" "x86_64--linux-gnu"
@@ -189,7 +175,3 @@
 
 // Match no linker
 // CUDA-NL-NOT: "{{.*}}{{ld|link}}{{(.exe)?}}"
-
-// CUDA-NO-UNUSED-CHO-NOT: warning: argument unused during compilation: 
'--cuda-host-only'
-// CUDA-UNUSED-CDO: warning: argument unused during compilation: 
'--cuda-device-only'
-// CUDA-NO-UNUSED-CDO-NOT: warning: argument unused during compilation: 
'--cuda-device-only'
Index: cfe/trunk/test/Driver/cuda-unused-arg-warning.cu
===
--- cfe/trunk/test/Driver/cuda-unused-arg-warning.cu
+++ cfe/trunk/test/Driver/cuda-unused-arg-warning.cu
@@ -0,0 +1,23 @@
+// Tests that we trigger unused-arg warnings on CUDA flags appropriately.
+
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// --cuda-host-only should never trigger unused arg warning.
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -c %s 2>&1 | \
+// RUN:FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -x c -c %s 2>&1 
| \
+// RUN:FileCheck %s
+
+// --cuda-device-only should warn during non-CUDA compilation.
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -x c -c %s 
2>&1 | \
+// RUN:FileCheck -check-prefix UNUSED-CDO %s
+
+// --cuda-device-only should not produce warning compiling CUDA files
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -c %s 2>&1 | \
+// RUN:FileCheck -check-prefix NO-UNUSED-CDO %s
+
+// CHECK-NOT: warning: argument unused during compilation: '--cuda-host-only'
+// UNUSED-CDO: warning: argument unused during compilation: 
'--cuda-device-only'
+// NO-UNUSED-CDO-NOT: warning: argument unused during compilation: 
'--cuda-device-only'


Index: cfe/trunk/test/Driver/cuda-options.cu
===
--- cfe/trunk/test/Driver/cuda-options.cu
+++ cfe/trunk/test/Driver/cuda-options.cu
@@ -111,20 +111,6 @@
 // Make sure we don't link anything.
 // RUN:   -check-prefix CUDA-NL %s
 
-// --cuda-host-only should never trigger unused arg warning.
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -c %s 2>&1 | \
-// RUN:FileCheck -check-prefix CUDA-NO-UNUSED-CHO %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -x c -c %s 2>&1 | \
-// RUN:FileCheck -check-prefix CUDA-NO-UNUSED-CHO %s
-
-// --cuda-device-only should not produce warning compiling CUDA files
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -c %s 2>&1 | \
-// RUN:FileCheck -check-prefix CUDA-NO-UNUSED-CDO %s
-
-// --cuda-device-only should warn during non-CUDA compilation.
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -x c -c %s 2>&1 | \
-// RUN:FileCheck -check-prefix CUDA-UNUSED-CDO %s
-
 // Match device-side preprocessor, and compiler phases with -save-temps
 // CUDA-D1S: "-cc1" "-triple" "nvptx64-nvidia-cuda"
 // CUDA-D1S-SAME: "-aux-triple" "x86_64--linux-gnu"
@@ -189,7 +175,3 @@
 
 // Match no linker
 // CUDA-NL-NOT: "{{.*}}{{ld|link}}{{(.exe)?}}"
-
-// CUDA-NO-UNUSED-CHO-NOT: warning: argument unused during compilation: '--cuda-host-only'
-// CUDA-UNUSED-CDO: warning: argument unused during compilation: '--cuda-device-only'
-// CUDA-NO-UNUSED-CDO-NOT: warning: argument unused during compilation: '--cuda-device-only'
Index: c

Re: r256403 - Revert r256399 "[Sema] ArrayRef-ize ActOnBaseSpecifiers. NFC"

2016-01-07 Thread Craig Topper via cfe-commits
I think lldb was calling the setBases method. It could probably be easily
fixed, but I don't normally contribute to lldb and thus don't have a local
copy to commit with.

On Thu, Jan 7, 2016 at 6:58 PM, David Blaikie  wrote:

>
>
> On Thu, Dec 24, 2015 at 4:36 PM, Craig Topper via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ctopper
>> Date: Thu Dec 24 18:36:02 2015
>> New Revision: 256403
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=256403&view=rev
>> Log:
>> Revert r256399 "[Sema] ArrayRef-ize ActOnBaseSpecifiers. NFC"
>>
>> It broke lldb build.
>>
>
> Any idea why?
>
>
>>
>> Modified:
>> cfe/trunk/include/clang/AST/DeclCXX.h
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/lib/AST/ASTImporter.cpp
>> cfe/trunk/lib/AST/DeclCXX.cpp
>> cfe/trunk/lib/Parse/ParseDeclCXX.cpp
>> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/DeclCXX.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=256403&r1=256402&r2=256403&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
>> +++ cfe/trunk/include/clang/AST/DeclCXX.h Thu Dec 24 18:36:02 2015
>> @@ -701,7 +701,7 @@ public:
>>}
>>
>>/// \brief Sets the base classes of this struct or class.
>> -  void setBases(ArrayRef Bases);
>> +  void setBases(CXXBaseSpecifier const * const *Bases, unsigned
>> NumBases);
>>
>>/// \brief Retrieves the number of base classes of this class.
>>unsigned getNumBases() const { return data().NumBases; }
>>
>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=256403&r1=256402&r2=256403&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>> +++ cfe/trunk/include/clang/Sema/Sema.h Thu Dec 24 18:36:02 2015
>> @@ -5365,10 +5365,10 @@ public:
>>  SourceLocation BaseLoc,
>>  SourceLocation EllipsisLoc);
>>
>> -  bool AttachBaseSpecifiers(CXXRecordDecl *Class,
>> -MutableArrayRef Bases);
>> -  void ActOnBaseSpecifiers(Decl *ClassDecl,
>> -   MutableArrayRef Bases);
>> +  bool AttachBaseSpecifiers(CXXRecordDecl *Class, CXXBaseSpecifier
>> **Bases,
>> +unsigned NumBases);
>> +  void ActOnBaseSpecifiers(Decl *ClassDecl, CXXBaseSpecifier **Bases,
>> +   unsigned NumBases);
>>
>>bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType
>> Base);
>>bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base,
>>
>> Modified: cfe/trunk/lib/AST/ASTImporter.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=256403&r1=256402&r2=256403&view=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/ASTImporter.cpp (original)
>> +++ cfe/trunk/lib/AST/ASTImporter.cpp Thu Dec 24 18:36:02 2015
>> @@ -2073,7 +2073,7 @@ bool ASTNodeImporter::ImportDefinition(R
>> EllipsisLoc));
>>  }
>>  if (!Bases.empty())
>> -  ToCXX->setBases(Bases);
>> +  ToCXX->setBases(Bases.data(), Bases.size());
>>}
>>
>>if (shouldForceImportDeclContext(Kind))
>>
>> Modified: cfe/trunk/lib/AST/DeclCXX.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=256403&r1=256402&r2=256403&view=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/DeclCXX.cpp (original)
>> +++ cfe/trunk/lib/AST/DeclCXX.cpp Thu Dec 24 18:36:02 2015
>> @@ -135,13 +135,14 @@ CXXRecordDecl::CreateDeserialized(const
>>  }
>>
>>  void
>> -CXXRecordDecl::setBases(ArrayRef Bases) {
>> +CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases,
>> +unsigned NumBases) {
>>ASTContext &C = getASTContext();
>>
>>if (!data().Bases.isOffset() && data().NumBases > 0)
>>  C.Deallocate(data().getBases());
>>
>> -  if (!Bases.empty()) {
>> +  if (NumBases) {
>>  // C++ [dcl.init.aggr]p1:
>>  //   An aggregate is [...] a class with [...] no base classes [...].
>>  data().Aggregate = false;
>> @@ -157,9 +158,9 @@ CXXRecordDecl::setBases(ArrayRef>// The virtual bases of this class.
>>SmallVector VBases;
>>
>> -  data().Bases = new(C) CXXBaseSpecifier [Bases.size()];
>> -  data().NumBases = Bases.size();
>> -  for (unsigned i = 0; i < Bases.size(); ++i) {
>> +  data().Bases = new(C) CXXBaseSpecifier [NumBases];
>> +  data().NumBases = NumBases;
>> +  for (unsigned i = 0; i < NumBases; ++i) {
>>  data().getBases()[i] = *Bases[i];
>>  // Keep track of inherited vbases for this base 

Re: [PATCH] D15914: [OpenCL] Pipe builtin functions

2016-01-07 Thread Xiuli PAN via cfe-commits
pxli168 added a comment.

So here is the summary about the inline comments:

1. What kind of prototype should codegen output for these functions?
2. What function names should these builtins have in llvm ir?
3. Access for pipe use image's for now, and will be refined.
4. What rules should we follow to check the access for the group functions, 
since specification does not tell?



Comment at: include/clang/Basic/Builtins.def:1255
@@ -1254,1 +1254,3 @@
 
+// OpenCL 2.0 Pipe functions.
+// We need the variadic prototype, since the packet type could be anything.

Anastasia wrote:
> Could we put reference to spec section?
OK, I will add a reference.


Comment at: include/clang/Basic/Builtins.def:1256
@@ +1255,3 @@
+// OpenCL 2.0 Pipe functions.
+// We need the variadic prototype, since the packet type could be anything.
+BUILTIN(read_pipe, "i.", "tn")

Anastasia wrote:
> Is variadic right here? Should be generic perhaps? 
That sounds better.


Comment at: include/clang/Basic/Builtins.def:1257
@@ +1256,3 @@
+// We need the variadic prototype, since the packet type could be anything.
+BUILTIN(read_pipe, "i.", "tn")
+BUILTIN(write_pipe, "i.", "tn")

Anastasia wrote:
> I think it would make sense to have this as LANGBUILTIN as it's only 
> available in OpenCL.
Good idea.


Comment at: include/clang/Basic/Builtins.def:1260
@@ +1259,3 @@
+
+BUILTIN(reserve_read_pipe, "i.", "tn")
+BUILTIN(reserve_write_pipe, "i.", "tn")

Anastasia wrote:
> From reserve_read_pipe onwards the builtins have a fixed number of arguments, 
> and don't need to be variadic.
I think the pipe and reserve_id_t does not have a macro here, and that is why 
there is a full semacheck for all arguments.


Comment at: lib/CodeGen/CGBuiltin.cpp:2033
@@ +2032,3 @@
+  return RValue::get(
+  Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name),
+ {Arg0, Arg1, Arg2, BCast, PacketSize}));

Anastasia wrote:
> So why do we need to mangle at all since the generated function signature 
> will always have the same parameter types?
That's one thing I want to discuss about, do you think it is good to have the 
builtin functions have the same parameter?
Actually I have another version without mangle and the last size, and the other 
thing is that if we need to pass the packet size here if we know that the 
packet type is the same with the pointer form the semacheck. I think the packet 
size can be got from the pipe as we can get it with metadata of pipe.

Hope we can make some consensus about this that can make backend easier!


Comment at: lib/CodeGen/CGOpenCLRuntime.h:55
@@ -50,1 +54,3 @@
 };
+class Ocl20Mangler {
+public:

Anastasia wrote:
> I am not very convinced on this solution of implementing a separate mangler. 
> Also how would it play together with existing mangling schemes?
> 
> Additionally how would definitions of builtin with user defined types appear 
> in the BIF libraries? I am not clear at the moment.
> 
> One approach would be to just generate calls that would always use generic 
> types:  opaque type for pipe and void* for a packet and avoid the mangling 
> completely. That's what I think is done already (see previous comment), just 
> not clear why mangling is added too.
Here is some code for the generic types you can see, it is just hard coded the 
function mangle for the void*.
Also this is part of the experiment code from bader, as you asked that we can 
discuss about it in patch, I just update them to see if this hard code can be 
accepted.

The builtin codegen part of this patch is only a draft, I actually have no idea 
about how to output these builtin,
if you think the opaque type and generic type could works, could you give some 
advice about the function name?
Should we follow the spir specification?


Comment at: lib/Sema/SemaChecking.cpp:267
@@ +266,3 @@
+/// Returns OpenCL access qual.
+static OpenCLImageAccessAttr *getOpenCLImageAcces(const Decl *D) {
+  if (D->hasAttr())

Anastasia wrote:
> Not sure why we have an image access here?
That was a fixme in last commit about the read_only write_only and read_write. 
Since pipe use the access that used to be image only, I think we'd better still 
use it and refine it to something like OpenCLTypeAcces after this patch to make 
it more clearer in commit. 


Comment at: lib/Sema/SemaChecking.cpp:268
@@ +267,3 @@
+static OpenCLImageAccessAttr *getOpenCLImageAcces(const Decl *D) {
+  if (D->hasAttr())
+return D->getAttr();

Anastasia wrote:
> What happens if access qualifier is not provided?
> 
> According to spec it should default to read_only!
Yes, this was handled later when get a null.
We can refine it to a better form later.


Comment at: lib/Sema/SemaChecking.cpp:274
@@ 

r257154 - clang-format: [JS] Support more ES6 classes.

2016-01-07 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Fri Jan  8 01:06:07 2016
New Revision: 257154

URL: http://llvm.org/viewvc/llvm-project?rev=257154&view=rev
Log:
clang-format: [JS] Support more ES6 classes.

Before:
  foo = class {
  constructor() {}
  }
  ;

After:
  foo = class {
  constructor() {}
  };

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=257154&r1=257153&r2=257154&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Fri Jan  8 01:06:07 2016
@@ -841,6 +841,8 @@ void UnwrappedLineParser::parseStructura
   // This does not apply for Java and JavaScript.
   if (Style.Language == FormatStyle::LK_Java ||
   Style.Language == FormatStyle::LK_JavaScript) {
+if (FormatTok->is(tok::semi))
+  nextToken();
 addUnwrappedLine();
 return;
   }

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=257154&r1=257153&r2=257154&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Fri Jan  8 01:06:07 2016
@@ -755,6 +755,12 @@ TEST_F(FormatTestJS, ClassDeclarations)
"  (aaa: ):\n"
"  aa {}\n"
"}");
+  verifyFormat("foo = class Name {\n"
+   "  constructor() {}\n"
+   "};");
+  verifyFormat("foo = class {\n"
+   "  constructor() {}\n"
+   "};");
 
   // ':' is not a type declaration here.
   verifyFormat("class X {\n"


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


Re: [PATCH] D15914: [OpenCL] Pipe builtin functions

2016-01-07 Thread Xiuli PAN via cfe-commits
pxli168 updated this revision to Diff 44312.
pxli168 added a comment.

1. Refine the def of BUILTIN with LANGBUITIN with new OCLC_LANG
2. Remove mangler for the hard coded builtin function name
3. Fix some bugs.


http://reviews.llvm.org/D15914

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/Builtins.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Basic/Builtins.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CGOpenCLRuntime.h
  lib/Sema/SemaChecking.cpp

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -258,6 +258,191 @@
   return false;
 }
 
+/// Returns readable name for a call.
+static StringRef getFunctionName(CallExpr *Call) {
+  return cast(Call->getCalleeDecl())->getName();
+}
+
+/// Returns OpenCL access qual.
+static OpenCLImageAccessAttr *getOpenCLImageAcces(const Decl *D) {
+  if (D->hasAttr())
+return D->getAttr();
+  return nullptr;
+}
+
+/// Returns true if pipe element type is different from the pointer.
+static bool checkOpenCLPipeArg(Sema &S, CallExpr *Call) {
+  const Expr *Arg0 = Call->getArg(0);
+  // First argument type should always be pipe.
+  if (!Arg0->getType()->isPipeType()) {
+S.Diag(Call->getLocStart(), diag::err_opencl_builtin_pipe_first_arg)
+<< getFunctionName(Call) << Arg0->getSourceRange();
+return true;
+  }
+  OpenCLImageAccessAttr *AccessQual =
+  getOpenCLImageAcces(cast(Arg0)->getDecl());
+  // Validates the access modifier is compatible with the call.
+  // From OpenCL C Specification 6.13.16 the access qualifiers for
+  // pipe should only be read_only and write_only, and assumed to
+  // be read_only if no qualifier is specified.
+  bool isValid = true;
+  // TODO: For all pipe built-in read is for read_only?
+  bool ReadOnly = getFunctionName(Call).find("read") != StringRef::npos;
+  if (ReadOnly)
+isValid = AccessQual == nullptr || AccessQual->isReadOnly();
+  else
+isValid = AccessQual != nullptr && AccessQual->isWriteOnly();
+  if (!isValid) {
+const char *AM = ReadOnly ? "read_only" : "write_only";
+S.Diag(Arg0->getLocStart(),
+   diag::err_opencl_builtin_pipe_invalid_access_modifier)
+<< AM << Arg0->getSourceRange();
+return true;
+  }
+
+  return false;
+}
+
+/// Returns true if pipe element type is different from the pointer.
+static bool checkOpenCLPipePacketType(Sema &S, CallExpr *Call, unsigned Idx) {
+  const Expr *Arg0 = Call->getArg(0);
+  const Expr *ArgIdx = Call->getArg(Idx);
+  const PipeType *PipeTy = cast(Arg0->getType());
+  const Type *EltTy = PipeTy->getElementType().getTypePtr();
+  const PointerType *ArgTy =
+  dyn_cast(ArgIdx->getType().getTypePtr());
+  // The Idx argument should be a pointer and the type of the pointer and
+  // the type of pipe element should also be the same.
+  if (!ArgTy || EltTy != ArgTy->getPointeeType().getTypePtr()) {
+S.Diag(Call->getLocStart(), diag::err_opencl_builtin_pipe_invalid_arg)
+<< getFunctionName(Call)
+<< S.Context.getPointerType(PipeTy->getElementType())
+<< ArgIdx->getSourceRange();
+return true;
+  }
+  return false;
+}
+
+// \brief Performs semantic analysis for the read/write_pipe call.
+// \param S Reference to the semantic analyzer.
+// \param Call A pointer to the builtin call.
+// \return True if a semantic error has been found, false otherwise.
+static bool SemaBuiltinRWPipe(Sema &S, CallExpr *Call) {
+
+  if (checkOpenCLPipeArg(S, Call))
+return true;
+
+  // Two kinds of read/write pipe
+  // From OpenCL C Specification 6.13.16.2 the built-in read/write
+  // functions have following forms.
+  switch (Call->getNumArgs()) {
+  case 2: {
+// The call with 2 arguments should be
+// read/write_pipe(pipe T, T*)
+// check packet type T
+if (checkOpenCLPipePacketType(S, Call, 1))
+  return true;
+  } break;
+
+  case 4: {
+// The call with 4 arguments should be
+// read/write_pipe(pipe T, reserve_id_t, uint, T*)
+// check reserve_id_t
+if (!Call->getArg(1)->getType()->isReserveIDT()) {
+  S.Diag(Call->getLocStart(), diag::err_opencl_builtin_pipe_invalid_arg)
+  << getFunctionName(Call) << S.Context.OCLReserveIDTy
+  << Call->getArg(1)->getSourceRange();
+  return true;
+}
+
+// check the index
+const Expr *Arg2 = Call->getArg(2);
+if (!Arg2->getType()->isIntegerType() &&
+!Arg2->getType()->isUnsignedIntegerType()) {
+  S.Diag(Call->getLocStart(), diag::err_opencl_builtin_pipe_invalid_arg)
+  << getFunctionName(Call) << S.Context.UnsignedIntTy
+  << Arg2->getSourceRange();
+  return true;
+}
+
+// check packet type T
+if (checkOpenCLPipePacketType(S, Call, 3))
+  return true;
+  } break;
+  default:
+S.Diag(Call->getLocStart(), diag::err_opencl_builtin_pipe_arg_num)
+<< getFunctionName(Call) << Cal