Re: [PATCH] D16215: ASTMatchers: enable hasBody() matcher for FunctionDecls

2016-01-19 Thread Aleksei Sidorin via cfe-commits
a.sidorin updated this revision to Diff 45232.
a.sidorin added a comment.

Match only FunctionDecls which are definitions and ignore redeclarations 
without bodies.


http://reviews.llvm.org/D16215

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  include/clang/ASTMatchers/ASTMatchersInternal.h
  lib/ASTMatchers/ASTMatchersInternal.cpp
  unittests/ASTMatchers/ASTMatchersTest.cpp
  unittests/ASTMatchers/Dynamic/ParserTest.cpp

Index: unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -263,7 +263,7 @@
 "1:1: Matcher does not support binding.",
 ParseWithError("isArrow().bind(\"foo\")"));
   EXPECT_EQ("Input value has unresolved overloaded type: "
-"Matcher",
+"Matcher",
 ParseMatcherWithError("hasBody(stmt())"));
 }
 
Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -2858,7 +2858,7 @@
   compoundStmt()));
 }
 
-TEST(HasBody, FindsBodyOfForWhileDoLoops) {
+TEST(HasBody, FindsBodyOfForWhileDoLoopsAndFunctions) {
   EXPECT_TRUE(matches("void f() { for(;;) {} }",
   forStmt(hasBody(compoundStmt();
   EXPECT_TRUE(notMatches("void f() { for(;;); }",
@@ -2869,6 +2869,10 @@
   doStmt(hasBody(compoundStmt();
   EXPECT_TRUE(matches("void f() { int p[2]; for (auto x : p) {} }",
   cxxForRangeStmt(hasBody(compoundStmt();
+  EXPECT_TRUE(matches("void f() {}", functionDecl(hasBody(compoundStmt();
+  EXPECT_TRUE(notMatches("void f();", functionDecl(hasBody(compoundStmt();
+  EXPECT_TRUE(matches("void f(); void f() {}",
+ functionDecl(hasBody(compoundStmt();
 }
 
 TEST(HasAnySubstatement, MatchesForTopLevelCompoundStatement) {
Index: lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- lib/ASTMatchers/ASTMatchersInternal.cpp
+++ lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -339,6 +339,11 @@
   return matchesNodeFull(Node);
 }
 
+template <>
+const Stmt *GetBodyMatcher::get(const FunctionDecl ) {
+  return Node.isThisDeclarationADefinition() ? Node.getBody() : NULL;
+}
+
 } // end namespace internal
 } // end namespace ast_matchers
 } // end namespace clang
Index: include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- include/clang/ASTMatchers/ASTMatchersInternal.h
+++ include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1584,6 +1584,14 @@
   ast_type_traits::DynTypedNode Node;
 };
 
+
+template 
+struct GetBodyMatcher {
+static const Stmt *get(const Ty ) {
+  return Node.getBody();
+}
+};
+
 } // end namespace internal
 } // end namespace ast_matchers
 } // end namespace clang
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3114,8 +3114,8 @@
   return false;
 }
 
-/// \brief Matches a 'for', 'while', or 'do while' statement that has
-/// a given body.
+/// \brief Matches a 'for', 'while', 'do while' statement or a function
+/// declaration that has a given body.
 ///
 /// Given
 /// \code
@@ -3128,9 +3128,10 @@
 AST_POLYMORPHIC_MATCHER_P(hasBody,
   AST_POLYMORPHIC_SUPPORTED_TYPES(DoStmt, ForStmt,
   WhileStmt,
-  CXXForRangeStmt),
+  CXXForRangeStmt,
+  FunctionDecl),
   internal::Matcher, InnerMatcher) {
-  const Stmt *const Statement = Node.getBody();
+  const Stmt *const Statement = internal::GetBodyMatcher::get(Node);
   return (Statement != nullptr &&
   InnerMatcher.matches(*Statement, Finder, Builder));
 }
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -3400,8 +3400,8 @@
 
 
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html;>CXXForRangeStmthasBodyMatcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>Stmt InnerMatcher
-Matches a 'for', 'while', or 'do while' statement that has
-a given body.
+Matches a 'for', 'while', 'do while' statement or a function
+declaration that has a given body.
 
 Given
   for (;;) {}
@@ -3825,8 +3825,8 @@
 
 
 

[PATCH] D16310: new clang-tidy checker misc-long-cast

2016-01-19 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki created this revision.
danielmarjamaki added subscribers: cfe-commits, alexfh.

This is a new checker for clang-tidy.

This checker will warn when there is a explicit redundant cast of a calculation
result to a bigger type. If the intention of the cast is to avoid loss of
precision then the cast is misplaced, and there can be loss of precision.
Otherwise the cast is ineffective.

No warning is written when it is seen that the cast is ineffective.

I tested this on debian projects.. and I see quite little noise. in 1212 
projects I got 76 warnings. The cast is either ineffective or there is loss of 
precision in all these cases. I don't see warnings where I think the warning is 
wrong. But I don't want to warn when it can be determined that the cast is just 
ineffective, I think that the perfect checker would be better at determining 
this.


http://reviews.llvm.org/D16310

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/LongCastCheck.cpp
  clang-tidy/misc/LongCastCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-long-cast.rst
  test/clang-tidy/misc-long-cast.cpp

Index: test/clang-tidy/misc-long-cast.cpp
===
--- test/clang-tidy/misc-long-cast.cpp
+++ test/clang-tidy/misc-long-cast.cpp
@@ -0,0 +1,48 @@
+// RUN: %check_clang_tidy %s misc-long-cast %t
+
+void assign(int a, int b) {
+  long l;
+
+  l = a * b;
+  l = (long)(a * b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long' is ineffective, or there is loss of precision before the conversion
+  l = (long)a * b;
+
+  l = (long)(a << 8);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long'
+  l = (long)b << 8;
+}
+
+void init(unsigned int n) {
+  long l = (long)(n << 8);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: either cast from 'int' to 'long'
+}
+
+long ret(int a) {
+  return (long)(a * 1000);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: either cast from 'int' to 'long'
+}
+
+void dontwarn1(unsigned char a, int i, unsigned char *p) {
+  long l;
+  // the result is a 9 bit value, there is no truncation in the implicit cast
+  l = (long)(a + 15);
+  // the result is a 12 bit value, there is no truncation in the implicit cast
+  l = (long)(a << 4);
+  // the result is a 3 bit value, there is no truncation in the implicit cast
+  l = (long)((i%5)+1);
+  // the result is a 16 bit value, there is no truncation in the implicit cast
+  l = (long)(((*p)<<8) + *(p+1));
+}
+
+// Cast is not suspicious when casting macro
+#define A  (X<<2)
+long macro1(int X) {
+  return (long)A;
+}
+
+// Don't warn about cast in macro
+#define B(X,Y)   (long)(X*Y)
+long macro2(int x, int y) {
+  return B(x,y);
+}
Index: docs/clang-tidy/checks/misc-long-cast.rst
===
--- docs/clang-tidy/checks/misc-long-cast.rst
+++ docs/clang-tidy/checks/misc-long-cast.rst
@@ -0,0 +1,29 @@
+.. title:: clang-tidy - misc-long-cast
+
+misc-long-cast
+==
+
+This checker will warn when there is a explicit redundant cast of a calculation
+result to a bigger type. If the intention of the cast is to avoid loss of
+precision then the cast is misplaced, and there can be loss of precision.
+Otherwise the cast is ineffective.
+
+Example code::
+
+long f(int x) {
+return (long)(x*1000);
+}
+
+The result x*1000 is first calculated using int precision. If the result
+exceeds int precision there is loss of precision. Then the result is casted to
+long.
+
+If there is no loss of precision then the cast can be removed or you can
+explicitly cast to int instead.
+
+If you want to avoid loss of precision then put the cast in a proper location,
+for instance::
+
+long f(int x) {
+return (long)x * 1000;
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -49,6 +49,7 @@
misc-definitions-in-headers
misc-inaccurate-erase
misc-inefficient-algorithm
+   misc-long-cast
misc-macro-parentheses
misc-macro-repeated-side-effects
misc-move-constructor-init
Index: clang-tidy/misc/MiscTidyModule.cpp
===
--- clang-tidy/misc/MiscTidyModule.cpp
+++ clang-tidy/misc/MiscTidyModule.cpp
@@ -17,6 +17,7 @@
 #include "DefinitionsInHeadersCheck.h"
 #include "InaccurateEraseCheck.h"
 #include "InefficientAlgorithmCheck.h"
+#include "LongCastCheck.h"
 #include "MacroParenthesesCheck.h"
 #include "MacroRepeatedSideEffectsCheck.h"
 #include "MoveConstantArgumentCheck.h"
@@ -56,6 +57,8 @@
 "misc-inaccurate-erase");
 CheckFactories.registerCheck(
 "misc-inefficient-algorithm");
+CheckFactories.registerCheck(
+"misc-long-cast");
 CheckFactories.registerCheck(
 

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

2016-01-19 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Could you please remove the line with printf before committing (see 
comment above)?



Comment at: lib/CodeGen/CGBuiltin.cpp:1976
@@ +1975,3 @@
+getContext().getTargetAddressSpace(LangAS::opencl_generic);
+if(GenericAS != 4U) printf("Generic AS is %d\n",GenericAS);
+llvm::Type *I8PTy = llvm::PointerType::get(

Could you remove this line with printf please?


http://reviews.llvm.org/D15914



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


Re: [PATCH] D16044: getVariableName() for MemRegion

2016-01-19 Thread Alexander Droste via cfe-commits
Alexander_Droste updated this revision to Diff 45239.
Alexander_Droste added a comment.

- reduce copying
- differentiate ER->getIndex().getAs<> cases

How about this?


http://reviews.llvm.org/D16044

Files:
  tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp

Index: tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
===
--- tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -149,6 +149,14 @@
   template const RegionTy* getAs() const;
 
   virtual bool isBoundable() const { return false; }
+
+  /// Get variable name for memory region. The name is obtained from
+  /// the variable/field declaration retrieved from the memory region.
+  /// Regions that point to an element of an array are returned as: "arr[0]".
+  /// Regions that point to a struct are returned as: "st.var".
+  ///
+  /// \returns variable name for memory region
+  std::string getVariableName() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";
Index: tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -639,6 +639,55 @@
   superRegion->printPrettyAsExpr(os);
 }
 
+std::string MemRegion::getVariableName() const {
+  std::string VariableName{""};
+  std::string ArrayIndices{""};
+
+  const clang::ento::MemRegion *R = this;
+  llvm::SmallString<50> buf;
+  llvm::raw_svector_ostream os(buf);
+
+  // Obtain array indices to add them to the variable name.
+  const clang::ento::ElementRegion *ER = nullptr;
+  while ((ER = R->getAs())) {
+
+std::string idx{""};
+if (auto CI = ER->getIndex().getAs()) {
+  llvm::SmallString<2> intValAsString;
+  CI->getValue().toString(intValAsString);
+  idx = {intValAsString.begin(), intValAsString.end()};
+}
+
+else if (auto SV =
+ER->getIndex().getAs()) {
+llvm::SmallString<8> buf;
+llvm::raw_svector_ostream os(buf);
+os << SV->getSymbol();
+idx = os.str();
+}
+
+ArrayIndices += "]" + idx + "[";
+R = ER->getSuperRegion();
+  }
+
+  std::reverse(ArrayIndices.begin(), ArrayIndices.end());
+
+  // Get variable name.
+  if (R && R->canPrintPretty()) {
+R->printPretty(os);
+VariableName += os.str();
+  }
+
+  // Combine variable name with indices.
+  if (VariableName.size() && VariableName.back() == '\'') {
+VariableName.insert(VariableName.size() - 1, ArrayIndices);
+  } else {
+VariableName += ArrayIndices;
+  }
+
+  return VariableName;
+}
+
 
//===--===//
 // MemRegionManager methods.
 
//===--===//


Index: tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
===
--- tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -149,6 +149,14 @@
   template const RegionTy* getAs() const;
 
   virtual bool isBoundable() const { return false; }
+
+  /// Get variable name for memory region. The name is obtained from
+  /// the variable/field declaration retrieved from the memory region.
+  /// Regions that point to an element of an array are returned as: "arr[0]".
+  /// Regions that point to a struct are returned as: "st.var".
+  ///
+  /// \returns variable name for memory region
+  std::string getVariableName() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";
Index: tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -639,6 +639,55 @@
   superRegion->printPrettyAsExpr(os);
 }
 
+std::string MemRegion::getVariableName() const {
+  std::string VariableName{""};
+  std::string ArrayIndices{""};
+
+  const clang::ento::MemRegion *R = this;
+  llvm::SmallString<50> buf;
+  llvm::raw_svector_ostream os(buf);
+
+  // Obtain array indices to add them to the variable name.
+  const clang::ento::ElementRegion *ER = nullptr;
+  while ((ER = R->getAs())) {
+
+std::string idx{""};
+if (auto CI = ER->getIndex().getAs()) {
+  llvm::SmallString<2> intValAsString;
+  CI->getValue().toString(intValAsString);
+  idx = {intValAsString.begin(), intValAsString.end()};
+}
+
+else if (auto SV =
+ER->getIndex().getAs()) {
+llvm::SmallString<8> buf;
+llvm::raw_svector_ostream os(buf);
+os << SV->getSymbol();
+ 

Re: [PATCH] D16295: Change of UserLabelPrefix default value from "_" to ""

2016-01-19 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

@rafael, all these changes are driven by tests.

It seems you mean OS targeting, which is handled in other TargetInfo classes 
(LinuxTargetInfo in Linux case).



Comment at: lib/Basic/Targets.cpp:801
@@ -818,2 +800,3 @@
 LongDoubleFormat = ::APFloat::PPCDoubleDouble;
+UserLabelPrefix = "_";
   }

rafael wrote:
> This looks wrong, we produce a "f:" not an "_f:" when targeting 
> powerpc-linux-gnu.
> 
Is this commented out, tools/clang/test/Preprocessor/init.c:5216 fails. As can 
be seen in the test, PPC603E target expects UserLabelPrefix to be equal to "_" 
in freestanding mode.

As for powerpc-linux-gnu target, UserLabelPrefix is set to "" at 
lib/Basic/Target.cpp:416 (LinuxTargetInfo constructor).


Comment at: lib/Basic/Targets.cpp:1617
@@ -1633,2 +1616,3 @@
 GPU = GK_SM20;
+UserLabelPrefix = "_";
   }

rafael wrote:
> This also looks wrong.
Same as above -- NVPTX target expects UserLabelPrefix to be "_" in freestanding 
mode (tools/clang/test/Preprocessor/init.c:4853). Linux target is covered in 
LinuxTargetInfo constructor.


http://reviews.llvm.org/D16295



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


Re: [libcxx] r258107 - Fix PR#26175. Thanks to Josh Petrie for the report and the patch. Reviewed as http://reviews.llvm.org/D16262

2016-01-19 Thread Dimitry Andric via cfe-commits
On 19 Jan 2016, at 01:50, Marshall Clow via cfe-commits 
 wrote:
> 
> Author: marshall
> Date: Mon Jan 18 18:50:37 2016
> New Revision: 258107
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=258107=rev
> Log:
> Fix PR#26175. Thanks to Josh Petrie for the report and the patch. Reviewed as 
> http://reviews.llvm.org/D16262

This looks like a good candidate for the 3.8 branch, do you agree?

-Dimitry



signature.asc
Description: Message signed with OpenPGP using GPGMail
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11035: trivial patch, improve constness

2016-01-19 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added a subscriber: rsmith.
danielmarjamaki added a comment.

ping.. can somebody review.


http://reviews.llvm.org/D11035



___
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-19 Thread Xiuli PAN via cfe-commits
pxli168 updated the summary for this revision.
pxli168 updated this revision to Diff 45234.
pxli168 marked 9 inline comments as done.
pxli168 added a comment.

Fix some small comments problems.


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/Sema/SemaChecking.cpp
  test/CodeGenOpenCL/pipe_builtin.cl
  test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl

Index: test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
===
--- /dev/null
+++ test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+
+void test1(read_only pipe int p, global int* ptr){
+  int tmp;
+  reserve_id_t rid;
+
+  // read/write_pipe
+  read_pipe(tmp, p);// expected-error {{first argument to read_pipe must be a pipe type}}
+  read_pipe(p);   // expected-error {{invalid number of arguments to function: read_pipe}}
+  read_pipe(p, tmp, tmp, ptr);   // expected-error {{invalid argument type to function read_pipe (expecting 'reserve_id_t')}}
+  read_pipe(p, rid, rid, ptr);   // expected-error {{invalid argument type to function read_pipe (expecting 'unsigned int')}}
+  read_pipe(p, tmp);   // expected-error {{invalid argument type to function read_pipe (expecting 'int *')}}
+  write_pipe(p, ptr);// expected-error {{invalid pipe access modifier (expecting write_only)}}
+  write_pipe(p, rid, tmp, ptr);// expected-error {{invalid pipe access modifier (expecting write_only)}}
+
+  // reserve_read/write_pipe
+  reserve_read_pipe(p, ptr);// expected-error{{invalid argument type to function reserve_read_pipe (expecting 'unsigned int')}}
+  work_group_reserve_read_pipe(tmp, tmp);// expected-error{{first argument to work_group_reserve_read_pipe must be a pipe type}}
+  sub_group_reserve_write_pipe(p, tmp);// expected-error{{invalid pipe access modifier (expecting write_only)}}
+
+  // commit_read/write_pipe
+  commit_read_pipe(tmp, rid);// expected-error{{first argument to commit_read_pipe must be a pipe type}}
+  work_group_commit_read_pipe(p, tmp);// expected-error{{invalid argument type to function work_group_commit_read_pipe (expecting 'reserve_id_t')}}
+  sub_group_commit_write_pipe(p, tmp);// expected-error{{nvalid pipe access modifier (expecting write_only)}}
+}
+
+void test2(write_only pipe int p, global int* ptr){
+  int tmp;
+  reserve_id_t rid;
+
+  // read/write_pipe
+  write_pipe(tmp, p);// expected-error {{first argument to write_pipe must be a pipe type}}
+  write_pipe(p);   // expected-error {{invalid number of arguments to function: write_pipe}}
+  write_pipe(p, tmp, tmp, ptr);   // expected-error {{invalid argument type to function write_pipe (expecting 'reserve_id_t')}}
+  write_pipe(p, rid, rid, ptr);   // expected-error {{invalid argument type to function write_pipe (expecting 'unsigned int')}}
+  write_pipe(p, tmp);   // expected-error {{invalid argument type to function write_pipe (expecting 'int *')}}
+  read_pipe(p, ptr);// expected-error {{invalid pipe access modifier (expecting read_only)}}
+  read_pipe(p, rid, tmp, ptr);// expected-error {{invalid pipe access modifier (expecting read_only)}}
+
+  // reserve_read/write_pipe
+  reserve_write_pipe(p, ptr);// expected-error{{invalid argument type to function reserve_write_pipe (expecting 'unsigned int')}}
+  work_group_reserve_write_pipe(tmp, tmp);// expected-error{{first argument to work_group_reserve_write_pipe must be a pipe type}}
+  sub_group_reserve_read_pipe(p, tmp);// expected-error{{invalid pipe access modifier (expecting read_only)}}
+
+  // commit_read/write_pipe
+  commit_write_pipe(tmp, rid);// expected-error{{first argument to commit_write_pipe must be a pipe type}}
+  work_group_commit_write_pipe(p, tmp);// expected-error{{invalid argument type to function work_group_commit_write_pipe (expecting 'reserve_id_t')}}
+  sub_group_commit_read_pipe(p, tmp);// expected-error{{nvalid pipe access modifier (expecting read_only)}}
+}
+
+void test3(){
+  int tmp;
+  get_pipe_num_packets(tmp);// expected-error {{first argument to get_pipe_num_packets must be a pipe type}}
+  get_pipe_max_packets(tmp);// expected-error {{first argument to get_pipe_max_packets must be a pipe type}}
+}
Index: test/CodeGenOpenCL/pipe_builtin.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/pipe_builtin.cl
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+
+// CHECK: %opencl.pipe_t = type opaque
+// CHECK: %opencl.reserve_id_t = type opaque
+
+void test1(read_only pipe int p, global int *ptr) {
+  // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}})
+  read_pipe(p, ptr);
+  // CHECK: call %opencl.reserve_id_t* 

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

2016-01-19 Thread Xiuli PAN via cfe-commits
pxli168 added inline comments.


Comment at: lib/CodeGen/CGBuiltin.cpp:1974
@@ +1973,3 @@
+// Type of the generic packet parameter.
+unsigned GenericAS =
+getContext().getTargetAddressSpace(LangAS::opencl_generic);

Good idea! This can fit different target.


http://reviews.llvm.org/D15914



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


Re: [PATCH] D16261: [CUDA] Only allow __global__ on free functions and static member functions.

2016-01-19 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 45297.
jlebar marked an inline comment as done.
jlebar added a comment.

Address tra's review.


http://reviews.llvm.org/D16261

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaCUDA.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/SemaCUDA/bad-attributes.cu

Index: test/SemaCUDA/bad-attributes.cu
===
--- test/SemaCUDA/bad-attributes.cu
+++ test/SemaCUDA/bad-attributes.cu
@@ -4,8 +4,8 @@
 //
 // You should be able to run this file through nvcc for compatibility testing.
 //
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fcuda-is-device -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wcuda-compat -verify %s
+// RUN: %clang_cc1 -fcuda-is-device -fsyntax-only -Wcuda-compat -verify %s
 
 #include "Inputs/cuda.h"
 
@@ -47,3 +47,12 @@
 // expected-note@-1 {{conflicting attribute is here}}
 __global__ __host__ void z12();  // expected-error {{attributes are not 
compatible}}
 // expected-note@-1 {{conflicting attribute is here}}
+
+struct S {
+  __global__ void foo() {};  // expected-error {{must be a free function or 
static member function}}
+  __global__ static void bar(); // expected-warning {{kernel function 'bar' is 
a member function}}
+  // Although this is implicitly inline, we shouldn't warn.
+  __global__ static void baz() {}; // expected-warning {{kernel function 'baz' 
is a member function}}
+};
+
+__global__ static inline void foobar() {};  // expected-warning {{ignored 
'inline' attribute on kernel function 'foobar'}}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3617,11 +3617,20 @@
   : FixItHint());
 return;
   }
+  if (const auto *Method = dyn_cast(FD)) {
+if (Method->isInstance()) {
+  S.Diag(Method->getLocStart(), diag::err_kern_is_nonstatic_method)
+  << Method;
+  return;
+}
+S.Diag(Method->getLocStart(), diag::warn_kern_is_method) << Method;
+  }
+  if (FD->isInlineSpecified())
+S.Diag(FD->getLocStart(), diag::warn_kern_is_inline) << FD;
 
   D->addAttr(::new (S.Context)
   CUDAGlobalAttr(Attr.getRange(), S.Context,
  Attr.getAttributeSpellingListIndex()));
-
 }
 
 static void handleGNUInlineAttr(Sema , Decl *D, const AttributeList ) {
Index: lib/Sema/SemaCUDA.cpp
===
--- lib/Sema/SemaCUDA.cpp
+++ lib/Sema/SemaCUDA.cpp
@@ -273,12 +273,9 @@
 resolveCalleeCUDATargetConflict(Sema::CUDAFunctionTarget Target1,
 Sema::CUDAFunctionTarget Target2,
 Sema::CUDAFunctionTarget *ResolvedTarget) {
-  if (Target1 == Sema::CFT_Global && Target2 == Sema::CFT_Global) {
-// TODO: this shouldn't happen, really. Methods cannot be marked 
__global__.
-// Clang should detect this earlier and produce an error. Then this
-// condition can be changed to an assertion.
-return true;
-  }
+  // Only free functions and static member functions may be global.
+  assert(Target1 != Sema::CFT_Global);
+  assert(Target2 != Sema::CFT_Global);
 
   if (Target1 == Sema::CFT_HostDevice) {
 *ResolvedTarget = Target2;
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -6402,6 +6402,8 @@
 
 def err_kern_type_not_void_return : Error<
   "kernel function type %0 must have void return type">;
+def err_kern_is_nonstatic_method : Error<
+  "kernel function %0 must be a free function or static member function">;
 def err_config_scalar_return : Error<
   "CUDA special function 'cudaConfigureCall' must have scalar return type">;
 def err_kern_call_not_global_function : Error<
@@ -6414,6 +6416,12 @@
 def warn_host_calls_from_host_device : Warning<
   "calling __host__ function %0 from __host__ __device__ function %1 can lead 
to runtime errors">,
   InGroup;
+def warn_kern_is_method : Extension<
+  "kernel function %0 is a member function; this may not be accepted by nvcc">,
+  InGroup;
+def warn_kern_is_inline : Warning<
+  "ignored 'inline' attribute on kernel function %0">,
+  InGroup;
 
 def warn_non_pod_vararg_with_format_string : Warning<
   "cannot pass %select{non-POD|non-trivial}0 object of type %1 to variadic "


Index: test/SemaCUDA/bad-attributes.cu
===
--- test/SemaCUDA/bad-attributes.cu
+++ test/SemaCUDA/bad-attributes.cu
@@ -4,8 +4,8 @@
 //
 // You should be able to run this file through nvcc for compatibility testing.
 //
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fcuda-is-device -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wcuda-compat -verify %s
+// RUN: 

Re: [PATCH] D16261: [CUDA] Only allow __global__ on free functions and static member functions.

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

Thank you for the review.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6418
@@ +6417,3 @@
+def warn_nvcc_compat_kern_is_method : Warning<
+  "kernel function %0 is a member function; this may not be accepted by nvcc">,
+  InGroup;

tra wrote:
> There's an Extension<> tablegen class used to report various C and C++ 
> extensions.
> This looks like a good use case for it.
I'll also check that the rest of the CudaCompat warnings here shouldn't be 
Extension<>s.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6421
@@ +6420,3 @@
+def warn_nvcc_compat_kern_is_inlined : Warning<
+  "kernel function %0 is inlined; this may not be accepted by nvcc">,
+  InGroup;

tra wrote:
> Perhaps we should use the same message as nvcc here:
> 'inline qualifier ignored for "global" function'
Ah, yes, given that it's not an nvcc error, we should just warn.  (Or even not 
say anything at all; it seems like a silly warning.)


http://reviews.llvm.org/D16261



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


[libcxx] r258198 - Add more missing license headers

2016-01-19 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Jan 19 15:58:49 2016
New Revision: 258198

URL: http://llvm.org/viewvc/llvm-project?rev=258198=rev
Log:
Add more missing license headers

Modified:
libcxx/trunk/src/include/atomic_support.h
libcxx/trunk/utils/gen_link_script/gen_link_script.py
libcxx/trunk/utils/not/not.py
libcxx/trunk/utils/sym_check/sym_check/__init__.py
libcxx/trunk/utils/sym_check/sym_check/diff.py
libcxx/trunk/utils/sym_check/sym_check/extract.py
libcxx/trunk/utils/sym_check/sym_check/match.py
libcxx/trunk/utils/sym_check/sym_check/util.py
libcxx/trunk/utils/sym_check/sym_diff.py
libcxx/trunk/utils/sym_check/sym_extract.py
libcxx/trunk/utils/sym_check/sym_match.py

Modified: libcxx/trunk/src/include/atomic_support.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/include/atomic_support.h?rev=258198=258197=258198=diff
==
--- libcxx/trunk/src/include/atomic_support.h (original)
+++ libcxx/trunk/src/include/atomic_support.h Tue Jan 19 15:58:49 2016
@@ -1,3 +1,12 @@
+//===--===
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===
+
 #ifndef ATOMIC_SUPPORT_H
 #define ATOMIC_SUPPORT_H
 

Modified: libcxx/trunk/utils/gen_link_script/gen_link_script.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/gen_link_script/gen_link_script.py?rev=258198=258197=258198=diff
==
--- libcxx/trunk/utils/gen_link_script/gen_link_script.py (original)
+++ libcxx/trunk/utils/gen_link_script/gen_link_script.py Tue Jan 19 15:58:49 
2016
@@ -1,4 +1,13 @@
 #!/usr/bin/env python
+#===--===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is dual licensed under the MIT and the University of Illinois Open
+# Source Licenses. See LICENSE.TXT for details.
+#
+#===--===##
+
 import os
 import sys
 

Modified: libcxx/trunk/utils/not/not.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/not/not.py?rev=258198=258197=258198=diff
==
--- libcxx/trunk/utils/not/not.py (original)
+++ libcxx/trunk/utils/not/not.py Tue Jan 19 15:58:49 2016
@@ -1,3 +1,12 @@
+#===--===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is dual licensed under the MIT and the University of Illinois Open
+# Source Licenses. See LICENSE.TXT for details.
+#
+#===--===##
+
 """not.py is a utility for inverting the return code of commands.
 It acts similar to llvm/utils/not.
 ex: python /path/to/not.py ' echo hello

Modified: libcxx/trunk/utils/sym_check/sym_check/__init__.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/sym_check/sym_check/__init__.py?rev=258198=258197=258198=diff
==
--- libcxx/trunk/utils/sym_check/sym_check/__init__.py (original)
+++ libcxx/trunk/utils/sym_check/sym_check/__init__.py Tue Jan 19 15:58:49 2016
@@ -1,3 +1,12 @@
+#===--===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is dual licensed under the MIT and the University of Illinois Open
+# Source Licenses. See LICENSE.TXT for details.
+#
+#===--===##
+
 """libcxx abi symbol checker"""
 
 __author__ = 'Eric Fiselier'

Modified: libcxx/trunk/utils/sym_check/sym_check/diff.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/sym_check/sym_check/diff.py?rev=258198=258197=258198=diff
==
--- libcxx/trunk/utils/sym_check/sym_check/diff.py (original)
+++ libcxx/trunk/utils/sym_check/sym_check/diff.py Tue Jan 19 15:58:49 2016
@@ -1,4 +1,12 @@
 # -*- Python -*- vim: set syntax=python tabstop=4 expandtab cc=80:
+#===--===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is dual licensed under the MIT and the University of Illinois Open
+# Source Licenses. See LICENSE.TXT for details.
+#
+#===--===##
 """
 diff - A set of functions for diff-ing two symbol lists.
 """

Modified: 

r258214 - [CMake] Don't apply Export set to clang tools

2016-01-19 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Tue Jan 19 17:01:38 2016
New Revision: 258214

URL: http://llvm.org/viewvc/llvm-project?rev=258214=rev
Log:
[CMake] Don't apply Export set to clang tools

I can't apply export to tools without getting some strange CMake spew. The 
behavior here is a bit unexpected. CMake is complaining about static link 
dependencies not being in the same export set, which shouldn't matter.

In the short term it is easier to just remove the export set (which was just 
added in r258209) while I sort this out.

Modified:
cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=258214=258213=258214=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Tue Jan 19 17:01:38 2016
@@ -447,7 +447,6 @@ endmacro(add_clang_executable)
 macro(add_clang_tool name)
   add_clang_executable(${name} ${ARGN})
   install(TARGETS ${name}
-EXPORT ClangTargets
 RUNTIME DESTINATION bin
 COMPONENT ${name})
 


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


Re: r258128 - Add -Wexpansion-to-undefined: warn when using `defined` in a macro definition.

2016-01-19 Thread Diego Novillo via cfe-commits
On Tue, Jan 19, 2016 at 3:43 PM, Nico Weber  wrote:

> I mean you could pass a -Wno flag. It's undefined behavior that's actually
> causing bugs in practice; it should probably be on by default.
>

But then you need to fix all the warnings it's producing in an llvm build.
That is currently blocking several folks (us included).
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r258179 - [OpenMP] Detect implicit map type to report unspecified map type for target enter/exit data directives.

2016-01-19 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Tue Jan 19 14:40:49 2016
New Revision: 258179

URL: http://llvm.org/viewvc/llvm-project?rev=258179=rev
Log:
[OpenMP] Detect implicit map type to report unspecified map type for target 
enter/exit data directives.

Support for the following OpenMP 4.5 restriction on 'target enter data' and 
'target exit data':

  - A map-type must be specified in all map clauses.

I have to save 'IsMapTypeImplicit' when parsing a map clause to support this 
constraint and 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'}}

Patch by Arpith Jacob. Thanks!


Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/OpenMP/target_enter_data_map_messages.c
cfe/trunk/test/OpenMP/target_exit_data_map_messages.c

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=258179=258178=258179=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Tue Jan 19 14:40:49 2016
@@ -2741,6 +2741,8 @@ class OMPMapClause final : public OMPVar
   OpenMPMapClauseKind MapTypeModifier;
   /// \brief Map type for the 'map' clause.
   OpenMPMapClauseKind MapType;
+  /// \brief Is this an implicit map type or not.
+  bool MapTypeIsImplicit;
   /// \brief Location of the map type.
   SourceLocation MapLoc;
   /// \brief Colon location.
@@ -2771,17 +2773,21 @@ class OMPMapClause final : public OMPVar
   ///
   /// \param MapTypeModifier Map type modifier.
   /// \param MapType Map type.
+  /// \param MapTypeIsImplicit Map type is inferred implicitly.
   /// \param MapLoc Location of the map type.
   /// \param StartLoc Starting location of the clause.
   /// \param EndLoc Ending location of the clause.
   /// \param N Number of the variables in the clause.
   ///
   explicit OMPMapClause(OpenMPMapClauseKind MapTypeModifier,
-OpenMPMapClauseKind MapType, SourceLocation MapLoc,
-SourceLocation StartLoc, SourceLocation LParenLoc,
-SourceLocation EndLoc, unsigned N)
-: OMPVarListClause(OMPC_map, StartLoc, LParenLoc, EndLoc, N),
-  MapTypeModifier(MapTypeModifier), MapType(MapType), MapLoc(MapLoc) {}
+OpenMPMapClauseKind MapType, bool MapTypeIsImplicit,
+SourceLocation MapLoc, SourceLocation StartLoc,
+SourceLocation LParenLoc, SourceLocation EndLoc,
+unsigned N)
+  : OMPVarListClause(OMPC_map, StartLoc, LParenLoc, EndLoc,
+   N),
+MapTypeModifier(MapTypeModifier), MapType(MapType),
+MapTypeIsImplicit(MapTypeIsImplicit), MapLoc(MapLoc) {}
 
   /// \brief Build an empty clause.
   ///
@@ -2790,7 +2796,8 @@ class OMPMapClause final : public OMPVar
   explicit OMPMapClause(unsigned N)
   : OMPVarListClause(OMPC_map, SourceLocation(),
SourceLocation(), SourceLocation(), N),
-MapTypeModifier(OMPC_MAP_unknown), MapType(OMPC_MAP_unknown), MapLoc() 
{}
+MapTypeModifier(OMPC_MAP_unknown), MapType(OMPC_MAP_unknown),
+MapTypeIsImplicit(false), MapLoc() {}
 
 public:
   /// \brief Creates clause with a list of variables \a VL.
@@ -2801,13 +2808,15 @@ public:
   /// \param VL List of references to the variables.
   /// \param TypeModifier Map type modifier.
   /// \param Type Map type.
+  /// \param TypeIsImplicit Map type is inferred implicitly.
   /// \param TypeLoc Location of the map type.
   ///
   static OMPMapClause *Create(const ASTContext , SourceLocation StartLoc,
-  SourceLocation LParenLoc,
-  SourceLocation EndLoc, ArrayRef VL,
+  SourceLocation LParenLoc, SourceLocation EndLoc,
+  ArrayRef VL,
   OpenMPMapClauseKind TypeModifier,
-  OpenMPMapClauseKind Type, SourceLocation 
TypeLoc);
+  OpenMPMapClauseKind Type, bool TypeIsImplicit,
+  SourceLocation TypeLoc);
   /// \brief Creates an empty clause with the place for \a N variables.
   ///
   /// \param C AST context.
@@ -2818,6 +2827,13 @@ public:
   /// \brief Fetches mapping kind for the clause.
   OpenMPMapClauseKind 

Re: [PATCH] D16280: [OpenMP] Detect implicit map type to report unspecified map type for target enter/exit data directives.

2016-01-19 Thread Samuel Antao via cfe-commits
sfantao closed this revision.
sfantao added a comment.

Committed revision 258179.

Thanks,
Samuel


http://reviews.llvm.org/D16280



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


Re: [libcxxabi] r257896 - Revert r256322 (and follow-up 256323), the test it added does not pass on OS X.

2016-01-19 Thread Hans Wennborg via cfe-commits
Merged to 3.8 in r258186. (See discussion on the r256323 commit).

On Fri, Jan 15, 2016 at 7:44 AM, Nico Weber via cfe-commits
 wrote:
> Author: nico
> Date: Fri Jan 15 09:44:14 2016
> New Revision: 257896
>
> URL: http://llvm.org/viewvc/llvm-project?rev=257896=rev
> Log:
> Revert r256322 (and follow-up 256323), the test it added does not pass on OS 
> X.
>
> Removed:
> libcxxabi/trunk/test/incomplete_type.sh.cpp
> Modified:
> libcxxabi/trunk/src/private_typeinfo.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16115: [test-suite] Add ClangAnalyzerBenchmarks directory to test-suite repository

2016-01-19 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

Ping.

Any objections to adding a new 'ClangAnalyzer' directory to test-suite?


http://reviews.llvm.org/D16115



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


r258213 - Allow __attribute__((mode)) to appertain to field declarations again. Corrects compile issues with LibreOffice.

2016-01-19 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue Jan 19 16:54:26 2016
New Revision: 258213

URL: http://llvm.org/viewvc/llvm-project?rev=258213=rev
Log:
Allow __attribute__((mode)) to appertain to field declarations again. Corrects 
compile issues with LibreOffice.

Patch by Stephan Bergmann

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/AttributeList.h
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/attr-mode.c

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=258213=258212=258213=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Jan 19 16:54:26 2016
@@ -879,8 +879,8 @@ def MipsInterrupt : InheritableAttr, Tar
 
 def Mode : Attr {
   let Spellings = [GCC<"mode">];
-  let Subjects = SubjectList<[Var, TypedefName], ErrorDiag,
- "ExpectedVariableOrTypedef">;
+  let Subjects = SubjectList<[Var, TypedefName, Field], ErrorDiag,
+ "ExpectedVariableFieldOrTypedef">;
   let Args = [IdentifierArgument<"Mode">];
   let Documentation = [Undocumented];
 }

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=258213=258212=258213=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Jan 19 16:54:26 
2016
@@ -2441,7 +2441,8 @@ def warn_attribute_wrong_decl_type : War
   "Objective-C instance methods|init methods of interface or class extension 
declarations|"
   "variables, functions and classes|Objective-C protocols|"
   "functions and global variables|structs, unions, and typedefs|structs and 
typedefs|"
-  "interface or protocol declarations|kernel functions|non-K 
functions}1">,
+  "interface or protocol declarations|kernel functions|non-K 
functions|"
+  "variables, fields and typedefs}1">,
   InGroup;
 def err_attribute_wrong_decl_type : Error;
 def warn_type_attribute_wrong_type : Warning<

Modified: cfe/trunk/include/clang/Sema/AttributeList.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=258213=258212=258213=diff
==
--- cfe/trunk/include/clang/Sema/AttributeList.h (original)
+++ cfe/trunk/include/clang/Sema/AttributeList.h Tue Jan 19 16:54:26 2016
@@ -855,7 +855,8 @@ enum AttributeDeclKind {
   ExpectedStructOrTypedef,
   ExpectedObjectiveCInterfaceOrProtocol,
   ExpectedKernelFunction,
-  ExpectedFunctionWithProtoType
+  ExpectedFunctionWithProtoType,
+  ExpectedVariableFieldOrTypedef
 };
 
 }  // end namespace clang

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=258213=258212=258213=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Jan 19 16:54:26 2016
@@ -3392,7 +3392,7 @@ static void handleModeAttr(Sema , Decl
   if (TypedefNameDecl *TD = dyn_cast(D))
 OldTy = TD->getUnderlyingType();
   else
-OldTy = cast(D)->getType();
+OldTy = cast(D)->getType();
 
   // Base type can also be a vector type (see PR17453).
   // Distinguish between base type and base element type.
@@ -3465,7 +3465,7 @@ static void handleModeAttr(Sema , Decl
   if (TypedefNameDecl *TD = dyn_cast(D))
 TD->setModedTypeSourceInfo(TD->getTypeSourceInfo(), NewTy);
   else
-cast(D)->setType(NewTy);
+cast(D)->setType(NewTy);
 
   D->addAttr(::new (S.Context)
  ModeAttr(Attr.getRange(), S.Context, Name,

Modified: cfe/trunk/test/Sema/attr-mode.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-mode.c?rev=258213=258212=258213=diff
==
--- cfe/trunk/test/Sema/attr-mode.c (original)
+++ cfe/trunk/test/Sema/attr-mode.c Tue Jan 19 16:54:26 2016
@@ -24,8 +24,8 @@ typedef unsigned unwind_word __attribute
 
 int **__attribute((mode(QI)))* i32;  // expected-error{{mode attribute}}
 
-__attribute__((mode(QI))) int invalid_func() { return 1; } // 
expected-error{{'mode' attribute only applies to variables and typedefs}}
-enum invalid_enum { A1 __attribute__((mode(QI))) }; // expected-error{{'mode' 
attribute only applies to variables and typedefs}}
+__attribute__((mode(QI))) int invalid_func() { return 1; } // 
expected-error{{'mode' attribute only applies to variables, fields and 
typedefs}}
+enum invalid_enum { A1 __attribute__((mode(QI))) }; // expected-error{{'mode' 
attribute 

Re: [PATCH] D16301: Allow mode attribute for member variables again

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

Thanks! I've commit in r258213.


http://reviews.llvm.org/D16301



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


Re: r258128 - Add -Wexpansion-to-undefined: warn when using `defined` in a macro definition.

2016-01-19 Thread Diego Novillo via cfe-commits
On Tue, Jan 19, 2016 at 3:30 PM, Nico Weber  wrote:

> I'll take a look. If it's urgent it's also possible to disable this
> warning.
>

Yeah.  I think disabling it by default may be the better choice.  Thanks.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r258128 - Add -Wexpansion-to-undefined: warn when using `defined` in a macro definition.

2016-01-19 Thread Nico Weber via cfe-commits
Back at my desk now, looking.

On Tue, Jan 19, 2016 at 3:44 PM, Diego Novillo  wrote:

>
>
> On Tue, Jan 19, 2016 at 3:43 PM, Nico Weber  wrote:
>
>> I mean you could pass a -Wno flag. It's undefined behavior that's
>> actually causing bugs in practice; it should probably be on by default.
>>
>
> But then you need to fix all the warnings it's producing in an llvm
> build.  That is currently blocking several folks (us included).
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r258128 - Add -Wexpansion-to-undefined: warn when using `defined` in a macro definition.

2016-01-19 Thread Nico Weber via cfe-commits
r258181 should stop the bleeding. I'll look at fixing the warnings now.

On Tue, Jan 19, 2016 at 3:46 PM, Nico Weber  wrote:

> Back at my desk now, looking.
>
> On Tue, Jan 19, 2016 at 3:44 PM, Diego Novillo 
> wrote:
>
>>
>>
>> On Tue, Jan 19, 2016 at 3:43 PM, Nico Weber  wrote:
>>
>>> I mean you could pass a -Wno flag. It's undefined behavior that's
>>> actually causing bugs in practice; it should probably be on by default.
>>>
>>
>> But then you need to fix all the warnings it's producing in an llvm
>> build.  That is currently blocking several folks (us included).
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16261: [CUDA] Only allow __global__ on free functions and static member functions.

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

Checked Thrust as we discussed.  It doesn't seem to be getting hung up here.


http://reviews.llvm.org/D16261



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


Re: [PATCH] D16301: Allow mode attribute for member variables again

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

Can you please rebase this off ToT and upload the latest diff? This is not 
applying cleanly for me.


http://reviews.llvm.org/D16301



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


Re: r258128 - Add -Wexpansion-to-undefined: warn when using `defined` in a macro definition.

2016-01-19 Thread Nico Weber via cfe-commits
I'll take a look. If it's urgent it's also possible to disable this warning.
On Jan 19, 2016 2:29 PM, "Diego Novillo via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

> Nico, this is producing tons of warnings on an LLVM build and is actually
> breaking our internal builds (we build with -Werror).
>
> I fixed one file that was producing this, but there are several that have
> the same problem (e.g., gtest-port.h).  Could you fix them or rollback?
>
>
> Thanks.  Diego.
>
> On Tue, Jan 19, 2016 at 10:15 AM, Nico Weber via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: nico
>> Date: Tue Jan 19 09:15:31 2016
>> New Revision: 258128
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=258128=rev
>> Log:
>> Add -Wexpansion-to-undefined: warn when using `defined` in a macro
>> definition.
>>
>> [cpp.cond]p4:
>>   Prior to evaluation, macro invocations in the list of preprocessing
>>   tokens that will become the controlling constant expression are replaced
>>   (except for those macro names modified by the 'defined' unary operator),
>>   just as in normal text. If the token 'defined' is generated as a result
>>   of this replacement process or use of the 'defined' unary operator does
>>   not match one of the two specified forms prior to macro replacement, the
>>   behavior is undefined.
>>
>> This isn't an idle threat, consider this program:
>>   #define FOO
>>   #define BAR defined(FOO)
>>   #if BAR
>>   ...
>>   #else
>>   ...
>>   #endif
>> clang and gcc will pick the #if branch while Visual Studio will take the
>> #else branch.  Emit a warning about this undefined behavior.
>>
>> One problem is that this also applies to function-like macros. While the
>> example above can be written like
>>
>> #if defined(FOO) && defined(BAR)
>> #defined HAVE_FOO 1
>> #else
>> #define HAVE_FOO 0
>> #endif
>>
>> there is no easy way to rewrite a function-like macro like `#define FOO(x)
>> (defined __foo_##x && __foo_##x)`.  Function-like macros like this are
>> used in
>> practice, and compilers seem to not have differing behavior in that case.
>> So
>> this a default-on warning only for object-like macros. For function-like
>> macros, it is an extension warning that only shows up with `-pedantic`.
>> (But it's undefined behavior in both cases.)
>>
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>> cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>> cfe/trunk/lib/Lex/PPExpressions.cpp
>> cfe/trunk/test/Lexer/cxx-features.cpp
>> cfe/trunk/test/Preprocessor/expr_define_expansion.c
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=258128=258127=258128=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Jan 19 09:15:31
>> 2016
>> @@ -204,6 +204,7 @@ def OverloadedShiftOpParentheses: DiagGr
>>  def DanglingElse: DiagGroup<"dangling-else">;
>>  def DanglingField : DiagGroup<"dangling-field">;
>>  def DistributedObjectModifiers :
>> DiagGroup<"distributed-object-modifiers">;
>> +def ExpansionToUndefined : DiagGroup<"expansion-to-undefined">;
>>  def FlagEnum : DiagGroup<"flag-enum">;
>>  def IncrementBool : DiagGroup<"increment-bool",
>> [DeprecatedIncrementBool]>;
>>  def InfiniteRecursion : DiagGroup<"infinite-recursion">;
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=258128=258127=258128=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue Jan 19
>> 09:15:31 2016
>> @@ -658,6 +658,13 @@ def warn_header_guard : Warning<
>>  def note_header_guard : Note<
>>"%0 is defined here; did you mean %1?">;
>>
>> +def warn_defined_in_object_type_macro : Warning<
>> +  "macro expansion producing 'defined' has undefined behavior">,
>> +  InGroup;
>> +def warn_defined_in_function_type_macro : Extension<
>> +  "macro expansion producing 'defined' has undefined behavior">,
>> +  InGroup;
>> +
>>  let CategoryName = "Nullability Issue" in {
>>
>>  def err_pp_assume_nonnull_syntax : Error<"expected 'begin' or 'end'">;
>>
>> Modified: cfe/trunk/lib/Lex/PPExpressions.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPExpressions.cpp?rev=258128=258127=258128=diff
>>
>> ==
>> --- cfe/trunk/lib/Lex/PPExpressions.cpp (original)
>> +++ cfe/trunk/lib/Lex/PPExpressions.cpp Tue Jan 19 09:15:31 2016
>> @@ -140,6 +140,51 @@ static bool EvaluateDefined(PPValue 
>>  PP.LexNonComment(PeekTok);
>>}
>>
>> +  // 

[libcxxabi] r258186 - Merging r257896:

2016-01-19 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue Jan 19 15:06:49 2016
New Revision: 258186

URL: http://llvm.org/viewvc/llvm-project?rev=258186=rev
Log:
Merging r257896:

r257896 | nico | 2016-01-15 07:44:14 -0800 (Fri, 15 Jan 2016) | 1 line

Revert r256322 (and follow-up 256323), the test it added does not pass on OS X.


Removed:
libcxxabi/branches/release_38/test/incomplete_type.sh.cpp
Modified:
libcxxabi/branches/release_38/   (props changed)
libcxxabi/branches/release_38/src/private_typeinfo.cpp

Propchange: libcxxabi/branches/release_38/
--
svn:mergeinfo = /libcxxabi/trunk:257896

Modified: libcxxabi/branches/release_38/src/private_typeinfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/branches/release_38/src/private_typeinfo.cpp?rev=258186=258185=258186=diff
==
--- libcxxabi/branches/release_38/src/private_typeinfo.cpp (original)
+++ libcxxabi/branches/release_38/src/private_typeinfo.cpp Tue Jan 19 15:06:49 
2016
@@ -34,12 +34,9 @@
 // 
 // _LIBCXX_DYNAMIC_FALLBACK is currently off by default.
 
-
-#include 
-
-
 #ifdef _LIBCXX_DYNAMIC_FALLBACK
 #include "abort_message.h"
+#include 
 #include 
 #endif
 
@@ -60,19 +57,31 @@ namespace __cxxabiv1
 
 #pragma GCC visibility push(hidden)
 
+#ifdef _LIBCXX_DYNAMIC_FALLBACK
+
 inline
 bool
 is_equal(const std::type_info* x, const std::type_info* y, bool use_strcmp)
 {
-#ifndef _WIN32
 if (!use_strcmp)
 return x == y;
 return strcmp(x->name(), y->name()) == 0;
+}
+
+#else  // !_LIBCXX_DYNAMIC_FALLBACK
+
+inline
+bool
+is_equal(const std::type_info* x, const std::type_info* y, bool)
+{
+#ifndef _WIN32
+return x == y;
 #else
 return (x == y) || (strcmp(x->name(), y->name()) == 0);
-#endif
+#endif
 }
 
+#endif  // _LIBCXX_DYNAMIC_FALLBACK
 
 // __shim_type_info
 
@@ -342,17 +351,8 @@ bool
 __pbase_type_info::can_catch(const __shim_type_info* thrown_type,
  void*&) const
 {
-if (is_equal(thrown_type, (std::nullptr_t), false)) return true;
-bool use_strcmp = this->__flags & (__incomplete_class_mask |
-   __incomplete_mask);
-if (!use_strcmp) {
-const __pbase_type_info* thrown_pbase = dynamic_cast(
-thrown_type);
-if (!thrown_pbase) return false;
-use_strcmp = thrown_pbase->__flags & (__incomplete_class_mask |
-  __incomplete_mask);
-}
-return is_equal(this, thrown_type, use_strcmp);
+return is_equal(this, thrown_type, false) ||
+   is_equal(thrown_type, (std::nullptr_t), false);
 }
 
 #ifdef __clang__

Removed: libcxxabi/branches/release_38/test/incomplete_type.sh.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/branches/release_38/test/incomplete_type.sh.cpp?rev=258185=auto
==
--- libcxxabi/branches/release_38/test/incomplete_type.sh.cpp (original)
+++ libcxxabi/branches/release_38/test/incomplete_type.sh.cpp (removed)
@@ -1,162 +0,0 @@
-//===- incomplete_type.cpp 
--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-// http://mentorembedded.github.io/cxx-abi/abi.html#rtti-layout
-
-// Two abi::__pbase_type_info objects can always be compared for equality
-// (i.e. of the types represented) or ordering by comparison of their name
-// NTBS addresses. In addition, unless either or both have either of the
-// incomplete flags set, equality can be tested by comparing the type_info
-// addresses.
-
-// RUN: %cxx %flags %compile_flags -c %s -o %t.one.o
-// RUN: %cxx %flags %compile_flags -c %s -o %t.two.o -DTU_ONE
-// RUN: %cxx %flags %link_flags -o %t.exe %t.one.o %t.two.o
-// RUN: %t.exe
-
-#include 
-#include 
-#include 
-
-struct NeverDefined;
-void ThrowNeverDefinedMP();
-
-struct IncompleteAtThrow;
-void ThrowIncompleteMP();
-void ThrowIncompletePP();
-void ThrowIncompletePMP();
-std::type_info const& ReturnTypeInfoIncompleteMP();
-std::type_info const& ReturnTypeInfoIncompletePP();
-
-struct CompleteAtThrow;
-void ThrowCompleteMP();
-void ThrowCompletePP();
-void ThrowCompletePMP();
-std::type_info const& ReturnTypeInfoCompleteMP();
-std::type_info const& ReturnTypeInfoCompletePP();
-
-void ThrowNullptr();
-
-#ifndef TU_ONE
-
-void ThrowNeverDefinedMP() { throw (int NeverDefined::*)nullptr; }
-
-void ThrowIncompleteMP() { throw (int IncompleteAtThrow::*)nullptr; }
-void ThrowIncompletePP() { throw 

Re: [libcxxabi] r256323 - Add new tests for throwing incomplete pointer types

2016-01-19 Thread Eric Fiselier via cfe-commits
Equally as good. Thanks.

On Tue, Jan 19, 2016 at 2:09 PM, Hans Wennborg  wrote:

> Actually, I'll go ahead and merge Nico's revert to 3.8 for now to
> unbreak the build there, and then I'll be happy to merge fixes when
> you've looked into it. Sorry for the double messaging.
>
> On Tue, Jan 19, 2016 at 9:43 AM, Hans Wennborg  wrote:
> > That sounds great. Thanks!
> >
> > On Tue, Jan 19, 2016 at 9:33 AM, Eric Fiselier  wrote:
> >> Hi Hans,
> >>
> >> Can I have today to work on this? If I can't come up with a fix we can
> >> revert tommorow.
> >> I'll ping you tommorow with the result.
> >>
> >> Does that work?
> >>
> >> /Eric
> >>
> >> On Tue, Jan 19, 2016 at 10:30 AM, Hans Wennborg 
> wrote:
> >>>
> >>> Nico pointed out his revert should probably be merged to 3.8.
> >>>
> >>> Has there been any follow-up here, e.g. fixes, that I should be aware
> of?
> >>>
> >>> Thanks,
> >>> Hans
> >>>
> >>> On Fri, Jan 15, 2016 at 7:48 AM, Nico Weber via cfe-commits
> >>>  wrote:
> >>> > I reverted this and 322 for now in 257896.
> >>> >
> >>> > On Fri, Jan 15, 2016 at 10:36 AM, Nico Weber 
> >>> > wrote:
> >>> >>
> >>> >> This test fails on OS X for me:
> >>> >>
> >>> >>
> >>> >> Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
> >>> >> FAIL: libc++abi :: incomplete_type.sh.cpp (29529 of 29545)
> >>> >>  TEST 'libc++abi :: incomplete_type.sh.cpp'
> FAILED
> >>> >> 
> >>> >> Script:
> >>> >> --
> >>> >>
> >>> >>
> >>> >>
> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
> >>> >> -v -DLIBCXXABI_NO_TIMER -funwind-tables -std=c++1z -nostdinc++
> >>> >>
> -I/Users/thakis/src/chrome/src/third_party/llvm/projects/libcxx/include
> >>> >>
> >>> >>
> -I/Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/include
> >>> >> -isysroot
> >>> >>
> >>> >>
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
> >>> >> -c
> >>> >>
> >>> >>
> /Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/test/incomplete_type.sh.cpp
> >>> >> -o
> >>> >>
> >>> >>
> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.one.o
> >>> >>
> >>> >>
> >>> >>
> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
> >>> >> -v -DLIBCXXABI_NO_TIMER -funwind-tables -std=c++1z -nostdinc++
> >>> >>
> -I/Users/thakis/src/chrome/src/third_party/llvm/projects/libcxx/include
> >>> >>
> >>> >>
> -I/Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/include
> >>> >> -isysroot
> >>> >>
> >>> >>
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
> >>> >> -c
> >>> >>
> >>> >>
> /Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/test/incomplete_type.sh.cpp
> >>> >> -o
> >>> >>
> >>> >>
> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.two.o
> >>> >> -DTU_ONE
> >>> >>
> >>> >>
> >>> >>
> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
> >>> >> -v -nodefaultlibs
> >>> >> -L/Users/thakis/src/chrome/src/third_party/llvm-bootstrap/lib
> >>> >>
> -Wl,-rpath,/Users/thakis/src/chrome/src/third_party/llvm-bootstrap/lib
> >>> >> -lc++
> >>> >> -lc++abi -lSystem -o
> >>> >>
> >>> >>
> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.exe
> >>> >>
> >>> >>
> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.one.o
> >>> >>
> >>> >>
> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.two.o
> >>> >>
> >>> >>
> >>> >>
> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.exe
> >>> >> --
> >>> >> Exit Code: 134
> >>> >>
> >>> >> Command Output (stderr):
> >>> >> --
> >>> >> Apple LLVM version 7.0.0 (clang-700.1.76)
> >>> >> Target: x86_64-apple-darwin15.0.0
> >>> >> Thread model: posix
> >>> >>
> >>> >>
> >>> >>
> "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
> >>> >> -cc1 -triple x86_64-apple-macosx10.11.0 -Wdeprecated-objc-isa-usage
> >>> >> -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all
> -disable-free
> >>> >> -disable-llvm-verifier -main-file-name incomplete_type.sh.cpp
> >>> >> -mrelocation-model pic -pic-level 2 -mthread-model posix
> >>> >> -mdisable-fp-elim
> >>> >> -masm-verbose -munwind-tables -target-cpu core2
> -target-linker-version
> >>> >> 253.6
> >>> >> -v -dwarf-column-info -coverage-file
> >>> >>
> >>> >>
> 

[libcxxabi] r258201 - Add missing license headers

2016-01-19 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Jan 19 16:07:10 2016
New Revision: 258201

URL: http://llvm.org/viewvc/llvm-project?rev=258201=rev
Log:
Add missing license headers

Modified:
libcxxabi/trunk/test/libcxxabi/test/config.py
libcxxabi/trunk/test/support/timer.hpp

Modified: libcxxabi/trunk/test/libcxxabi/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/libcxxabi/test/config.py?rev=258201=258200=258201=diff
==
--- libcxxabi/trunk/test/libcxxabi/test/config.py (original)
+++ libcxxabi/trunk/test/libcxxabi/test/config.py Tue Jan 19 16:07:10 2016
@@ -1,3 +1,11 @@
+#===--===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is dual licensed under the MIT and the University of Illinois Open
+# Source Licenses. See LICENSE.TXT for details.
+#
+#===--===##
 import os
 import sys
 

Modified: libcxxabi/trunk/test/support/timer.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/support/timer.hpp?rev=258201=258200=258201=diff
==
--- libcxxabi/trunk/test/support/timer.hpp (original)
+++ libcxxabi/trunk/test/support/timer.hpp Tue Jan 19 16:07:10 2016
@@ -1,3 +1,12 @@
+//===--===
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===
+
 #ifndef TIMER_HPP
 #define TIMER_HPP
 
@@ -43,4 +52,4 @@ public:
 
 #endif /* LIBCXXABI_NO_TIMER */
 
-#endif /* TIMER_HPP */
\ No newline at end of file
+#endif /* TIMER_HPP */


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


Re: [PATCH] D16216: Fix infinite loop when ::new or ::delete are found in member initializer list

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

LGTM, thanks! Do you need someone to commit for you?


http://reviews.llvm.org/D16216



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


Re: [PATCH] D16115: [test-suite] Add ClangAnalyzerBenchmarks directory to test-suite repository

2016-01-19 Thread Chris Matthews via cfe-commits
LGTM too.

> On Jan 19, 2016, at 1:30 PM, Devin Coughlin  wrote:
> 
> dcoughlin added a comment.
> 
> Ping.
> 
> Any objections to adding a new 'ClangAnalyzer' directory to test-suite?
> 
> 
> http://reviews.llvm.org/D16115
> 
> 
> 

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


Re: [PATCH] D16115: [test-suite] Add ClangAnalyzerBenchmarks directory to test-suite repository

2016-01-19 Thread Chris Matthews via cfe-commits
cmatthews added a subscriber: cmatthews.
cmatthews added a comment.

LGTM too.


http://reviews.llvm.org/D16115



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


Re: [PATCH] D16216: Fix infinite loop when ::new or ::delete are found in member initializer list

2016-01-19 Thread Denis Zobnin via cfe-commits
d.zobnin.bugzilla updated this revision to Diff 45295.
d.zobnin.bugzilla added a comment.

Thank you for the review! Updated the patch: parser now skips the rest of the 
initializers if the previous one was invalid, added several checks to the test.


http://reviews.llvm.org/D16216

Files:
  lib/Parse/ParseDeclCXX.cpp
  test/Parser/cxx-invalid-function-decl.cpp

Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -3187,28 +3187,30 @@
   Actions.CodeCompleteConstructorInitializer(ConstructorDecl,
  MemInitializers);
   return cutOffParsing();
-} else {
-  MemInitResult MemInit = ParseMemInitializer(ConstructorDecl);
-  if (!MemInit.isInvalid())
-MemInitializers.push_back(MemInit.get());
-  else
-AnyErrors = true;
 }
-
+
+MemInitResult MemInit = ParseMemInitializer(ConstructorDecl);
+if (!MemInit.isInvalid())
+  MemInitializers.push_back(MemInit.get());
+else
+  AnyErrors = true;
+
 if (Tok.is(tok::comma))
   ConsumeToken();
 else if (Tok.is(tok::l_brace))
   break;
-// If the next token looks like a base or member initializer, assume that
-// we're just missing a comma.
-else if (Tok.isOneOf(tok::identifier, tok::coloncolon)) {
+// If the previous initializer was valid and the next token looks like a
+// base or member initializer, assume that we're just missing a comma.
+else if (!MemInit.isInvalid() &&
+ Tok.isOneOf(tok::identifier, tok::coloncolon)) {
   SourceLocation Loc = PP.getLocForEndOfToken(PrevTokLocation);
   Diag(Loc, diag::err_ctor_init_missing_comma)
 << FixItHint::CreateInsertion(Loc, ", ");
 } else {
   // Skip over garbage, until we get to '{'.  Don't eat the '{'.
-  Diag(Tok.getLocation(), diag::err_expected_either) << tok::l_brace
- << tok::comma;
+  if (!MemInit.isInvalid())
+Diag(Tok.getLocation(), diag::err_expected_either) << tok::l_brace
+   << tok::comma;
   SkipUntil(tok::l_brace, StopAtSemi | StopBeforeMatch);
   break;
 }
Index: test/Parser/cxx-invalid-function-decl.cpp
===
--- test/Parser/cxx-invalid-function-decl.cpp
+++ test/Parser/cxx-invalid-function-decl.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Check that "::new" and "::delete" in member initializer list are diagnosed
+// correctly and don't lead to infinite loop on parsing.
+
+// Error: X() (initializer on non-constructor), "::new" is skipped.
+void f1() : X() ::new{}; // expected-error{{only constructors take base 
initializers}}
+
+// Errors: first "::delete" and initializer on non-constructor, others skipped.
+void f2() : ::delete, ::new, X() ::new ::delete{} // expected-error{{expected 
class member or base class name}}
+  // expected-error@-1{{only 
constructors take base initializers}}
+
+// Errors: the '::' token, "::delete" and initializer on non-constructor, 
others skipped.
+void f3() : ::, ::delete X(), ::new {}; // expected-error2{{expected class 
member or base class name}}
+// expected-error@-1{{only 
constructors take base initializers}}
+
+template 
+struct Base1 {
+  T x1;
+  Base1(T a1) : x1(a1) {}
+};
+
+template 
+struct Base2 {
+  T x2;
+  Base2(T a2) : x2(a2) {}
+};
+
+struct S : public Base1, public Base2 {
+  int x;
+
+  // 1-st initializer is correct (just missing ','), 2-nd incorrect, skip 
other.
+  S() : ::Base1(0) ::new, ::Base2(1.0) ::delete x(2) {} // 
expected-error{{expected class member or base class name}}
+// 
expected-error@-1{{missing ',' between base or member initializers}}
+
+  // 1-st and 2-nd are correct, errors: '::' and "::new", others skipped.
+  S(int a) : Base1(a), ::Base2(1.0), ::, // 
expected-error{{expected class member or base class name}}
+ ::new, ! ::delete, ::Base2<() x(3) {}   // 
expected-error{{expected class member or base class name}}
+
+  // All initializers are correct, nothing to skip, diagnose 2 missing commas.
+  S(const S &) : Base1(0) ::Base2(1.0) x(2) {} // 
expected-error2{{missing ',' between base or member initializers}}
+};


Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -3187,28 +3187,30 @@
   Actions.CodeCompleteConstructorInitializer(ConstructorDecl,
  MemInitializers);
   return cutOffParsing();
-} else {
-  MemInitResult MemInit = 

Re: [PATCH] D12664: Fixed comparison.

2016-01-19 Thread Akira Hatanaka via cfe-commits
ahatanak added a subscriber: ahatanak.
ahatanak added a comment.

This looks LGTM.


http://reviews.llvm.org/D12664



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


[PATCH] D16331: [CUDA] Bail, rather than crash, on va_arg in device code.

2016-01-19 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added subscribers: cfe-commits, jhen, echristo.

http://reviews.llvm.org/D16331

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExpr.cpp
  test/SemaCUDA/vararg.cu

Index: test/SemaCUDA/vararg.cu
===
--- /dev/null
+++ test/SemaCUDA/vararg.cu
@@ -0,0 +1,28 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -fsyntax-only \
+// RUN:   -verify -DEXPECT_ERR %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only %s
+
+#include 
+#include "Inputs/cuda.h"
+
+__device__ void foo() {
+  va_list list;
+  va_arg(list, int);
+#ifdef EXPECT_ERR
+  // expected-error@-2 {{CUDA device code does not support va_arg}}
+#endif
+}
+
+void bar() {
+  va_list list;
+  va_arg(list, int);  // OK: host-only
+}
+
+__device__ void baz() {
+#if !defined(__CUDA_ARCH__)
+  va_list list;
+  va_arg(list, int);  // OK: only seen when compiling for host
+#endif
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -11715,9 +11715,8 @@
   return Result;
 }
 
-ExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc,
-Expr *E, ParsedType Ty,
-SourceLocation RPLoc) {
+ExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty,
+SourceLocation RPLoc) {
   TypeSourceInfo *TInfo;
   GetTypeFromParser(Ty, );
   return BuildVAArgExpr(BuiltinLoc, E, TInfo, RPLoc);
@@ -11729,6 +11728,16 @@
   Expr *OrigExpr = E;
   bool IsMS = false;
 
+  // CUDA device code does not support varargs.
+  if (getLangOpts().CUDAIsDevice) {
+if (const FunctionDecl *F = dyn_cast(CurContext)) {
+  CUDAFunctionTarget T = IdentifyCUDATarget(F);
+  if (T == CFT_Global || T == CFT_Device || T == CFT_HostDevice) {
+return ExprError(Diag(E->getLocStart(), diag::err_va_arg_in_device));
+  }
+}
+  }
+
   // It might be a __builtin_ms_va_list. (But don't ever mark a va_arg()
   // as Microsoft ABI on an actual Microsoft platform, where
   // __builtin_ms_va_list and __builtin_va_list are the same.)
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -6422,6 +6422,8 @@
 def warn_kern_is_inline : Warning<
   "ignored 'inline' attribute on kernel function %0">,
   InGroup;
+def err_va_arg_in_device : Error<
+  "CUDA device code does not support va_arg">;
 
 def warn_non_pod_vararg_with_format_string : Warning<
   "cannot pass %select{non-POD|non-trivial}0 object of type %1 to variadic "


Index: test/SemaCUDA/vararg.cu
===
--- /dev/null
+++ test/SemaCUDA/vararg.cu
@@ -0,0 +1,28 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -fsyntax-only \
+// RUN:   -verify -DEXPECT_ERR %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only %s
+
+#include 
+#include "Inputs/cuda.h"
+
+__device__ void foo() {
+  va_list list;
+  va_arg(list, int);
+#ifdef EXPECT_ERR
+  // expected-error@-2 {{CUDA device code does not support va_arg}}
+#endif
+}
+
+void bar() {
+  va_list list;
+  va_arg(list, int);  // OK: host-only
+}
+
+__device__ void baz() {
+#if !defined(__CUDA_ARCH__)
+  va_list list;
+  va_arg(list, int);  // OK: only seen when compiling for host
+#endif
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -11715,9 +11715,8 @@
   return Result;
 }
 
-ExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc,
-Expr *E, ParsedType Ty,
-SourceLocation RPLoc) {
+ExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty,
+SourceLocation RPLoc) {
   TypeSourceInfo *TInfo;
   GetTypeFromParser(Ty, );
   return BuildVAArgExpr(BuiltinLoc, E, TInfo, RPLoc);
@@ -11729,6 +11728,16 @@
   Expr *OrigExpr = E;
   bool IsMS = false;
 
+  // CUDA device code does not support varargs.
+  if (getLangOpts().CUDAIsDevice) {
+if (const FunctionDecl *F = dyn_cast(CurContext)) {
+  CUDAFunctionTarget T = IdentifyCUDATarget(F);
+  if (T == CFT_Global || T == CFT_Device || T == CFT_HostDevice) {
+return ExprError(Diag(E->getLocStart(), diag::err_va_arg_in_device));
+  }
+}
+  }
+
   // It might be a __builtin_ms_va_list. (But don't ever mark a va_arg()
   // as Microsoft ABI on an actual Microsoft platform, where
   // __builtin_ms_va_list 

Re: [libcxxabi] r256323 - Add new tests for throwing incomplete pointer types

2016-01-19 Thread Hans Wennborg via cfe-commits
Actually, I'll go ahead and merge Nico's revert to 3.8 for now to
unbreak the build there, and then I'll be happy to merge fixes when
you've looked into it. Sorry for the double messaging.

On Tue, Jan 19, 2016 at 9:43 AM, Hans Wennborg  wrote:
> That sounds great. Thanks!
>
> On Tue, Jan 19, 2016 at 9:33 AM, Eric Fiselier  wrote:
>> Hi Hans,
>>
>> Can I have today to work on this? If I can't come up with a fix we can
>> revert tommorow.
>> I'll ping you tommorow with the result.
>>
>> Does that work?
>>
>> /Eric
>>
>> On Tue, Jan 19, 2016 at 10:30 AM, Hans Wennborg  wrote:
>>>
>>> Nico pointed out his revert should probably be merged to 3.8.
>>>
>>> Has there been any follow-up here, e.g. fixes, that I should be aware of?
>>>
>>> Thanks,
>>> Hans
>>>
>>> On Fri, Jan 15, 2016 at 7:48 AM, Nico Weber via cfe-commits
>>>  wrote:
>>> > I reverted this and 322 for now in 257896.
>>> >
>>> > On Fri, Jan 15, 2016 at 10:36 AM, Nico Weber 
>>> > wrote:
>>> >>
>>> >> This test fails on OS X for me:
>>> >>
>>> >>
>>> >> Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
>>> >> FAIL: libc++abi :: incomplete_type.sh.cpp (29529 of 29545)
>>> >>  TEST 'libc++abi :: incomplete_type.sh.cpp' FAILED
>>> >> 
>>> >> Script:
>>> >> --
>>> >>
>>> >>
>>> >> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
>>> >> -v -DLIBCXXABI_NO_TIMER -funwind-tables -std=c++1z -nostdinc++
>>> >> -I/Users/thakis/src/chrome/src/third_party/llvm/projects/libcxx/include
>>> >>
>>> >> -I/Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/include
>>> >> -isysroot
>>> >>
>>> >> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
>>> >> -c
>>> >>
>>> >> /Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/test/incomplete_type.sh.cpp
>>> >> -o
>>> >>
>>> >> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.one.o
>>> >>
>>> >>
>>> >> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
>>> >> -v -DLIBCXXABI_NO_TIMER -funwind-tables -std=c++1z -nostdinc++
>>> >> -I/Users/thakis/src/chrome/src/third_party/llvm/projects/libcxx/include
>>> >>
>>> >> -I/Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/include
>>> >> -isysroot
>>> >>
>>> >> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
>>> >> -c
>>> >>
>>> >> /Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/test/incomplete_type.sh.cpp
>>> >> -o
>>> >>
>>> >> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.two.o
>>> >> -DTU_ONE
>>> >>
>>> >>
>>> >> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
>>> >> -v -nodefaultlibs
>>> >> -L/Users/thakis/src/chrome/src/third_party/llvm-bootstrap/lib
>>> >> -Wl,-rpath,/Users/thakis/src/chrome/src/third_party/llvm-bootstrap/lib
>>> >> -lc++
>>> >> -lc++abi -lSystem -o
>>> >>
>>> >> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.exe
>>> >>
>>> >> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.one.o
>>> >>
>>> >> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.two.o
>>> >>
>>> >>
>>> >> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.exe
>>> >> --
>>> >> Exit Code: 134
>>> >>
>>> >> Command Output (stderr):
>>> >> --
>>> >> Apple LLVM version 7.0.0 (clang-700.1.76)
>>> >> Target: x86_64-apple-darwin15.0.0
>>> >> Thread model: posix
>>> >>
>>> >>
>>> >> "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
>>> >> -cc1 -triple x86_64-apple-macosx10.11.0 -Wdeprecated-objc-isa-usage
>>> >> -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free
>>> >> -disable-llvm-verifier -main-file-name incomplete_type.sh.cpp
>>> >> -mrelocation-model pic -pic-level 2 -mthread-model posix
>>> >> -mdisable-fp-elim
>>> >> -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version
>>> >> 253.6
>>> >> -v -dwarf-column-info -coverage-file
>>> >>
>>> >> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.one.o
>>> >> -nostdinc++ -resource-dir
>>> >>
>>> >> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.0
>>> >> -isysroot
>>> >>
>>> >> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
>>> >> -D LIBCXXABI_NO_TIMER -I
>>> >> 

r258209 - [CMake] Creating add_clang_tool macro to wrap add_clang_executable and generate install actions and targets.

2016-01-19 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Tue Jan 19 16:41:51 2016
New Revision: 258209

URL: http://llvm.org/viewvc/llvm-project?rev=258209=rev
Log:
[CMake] Creating add_clang_tool macro to wrap add_clang_executable and generate 
install actions and targets.

This change brings forward the LLVM convention that "executables" are just 
runnable binaries, and "tools" are executables that are part of the project's 
install.

Having this abstraction will allow us to simplify some of the tool CMakeLists 
files, and it will standardize some of the install behaviors.

Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/tools/driver/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=258209=258208=258209=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Tue Jan 19 16:41:51 2016
@@ -444,6 +444,22 @@ macro(add_clang_executable name)
   set_clang_windows_version_resource_properties(${name})
 endmacro(add_clang_executable)
 
+macro(add_clang_tool name)
+  add_clang_executable(${name} ${ARGN})
+  install(TARGETS ${name}
+EXPORT ClangTargets
+RUNTIME DESTINATION bin
+COMPONENT ${name})
+
+  if(NOT CMAKE_CONFIGURATION_TYPES)
+add_custom_target(install-${name}
+  DEPENDS ${name}
+  COMMAND "${CMAKE_COMMAND}"
+  -DCMAKE_INSTALL_COMPONENT=${name}
+  -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  endif()
+endmacro()
+
 macro(add_clang_symlink name dest)
   add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE)
   # Always generate install targets

Modified: cfe/trunk/tools/driver/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/CMakeLists.txt?rev=258209=258208=258209=diff
==
--- cfe/trunk/tools/driver/CMakeLists.txt (original)
+++ cfe/trunk/tools/driver/CMakeLists.txt Tue Jan 19 16:41:51 2016
@@ -24,7 +24,7 @@ if(CLANG_PLUGIN_SUPPORT)
   set(LLVM_NO_DEAD_STRIP 1)
 endif()
 
-add_clang_executable(clang
+add_clang_tool(clang
   driver.cpp
   cc1_main.cpp
   cc1as_main.cpp
@@ -51,18 +51,6 @@ endif()
 
 add_dependencies(clang clang-headers)
 
-install(TARGETS clang
-  RUNTIME DESTINATION bin
-  COMPONENT clang)
-
-if(NOT CMAKE_CONFIGURATION_TYPES)
-  add_custom_target(install-clang
-DEPENDS clang
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=clang
--P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
-endif()
-
 if(NOT CLANG_LINKS_TO_CREATE)
   set(CLANG_LINKS_TO_CREATE clang++ clang-cl)
 


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


Re: r258128 - Add -Wexpansion-to-undefined: warn when using `defined` in a macro definition.

2016-01-19 Thread Nico Weber via cfe-commits
I mean you could pass a -Wno flag. It's undefined behavior that's actually
causing bugs in practice; it should probably be on by default.
On Jan 19, 2016 3:38 PM, "Diego Novillo"  wrote:

>
>
> On Tue, Jan 19, 2016 at 3:30 PM, Nico Weber  wrote:
>
>> I'll take a look. If it's urgent it's also possible to disable this
>> warning.
>>
>
> Yeah.  I think disabling it by default may be the better choice.  Thanks.
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r258195 - Mark slow ASAN/MSAN tests as XFAIL for now.

2016-01-19 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Jan 19 15:51:07 2016
New Revision: 258195

URL: http://llvm.org/viewvc/llvm-project?rev=258195=rev
Log:
Mark slow ASAN/MSAN tests as XFAIL for now.

Modified:

libcxx/trunk/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp
libcxx/trunk/test/std/re/re.traits/isctype.pass.cpp

Modified: 
libcxx/trunk/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpp?rev=258195=258194=258195=diff
==
--- 
libcxx/trunk/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpp
 Tue Jan 19 15:51:07 2016
@@ -13,6 +13,9 @@
 
 // iter_type put(iter_type s, ios_base& iob, char_type fill, double v) const;
 
+// TODO(EricWF): This test takes 40+ minutes to build with Clang 3.8 under 
ASAN or MSAN.
+// UNSUPPORTED: asan, msan
+
 #include 
 #include 
 #include 

Modified: 
libcxx/trunk/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp?rev=258195=258194=258195=diff
==
--- 
libcxx/trunk/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp
 Tue Jan 19 15:51:07 2016
@@ -13,6 +13,9 @@
 
 // iter_type put(iter_type s, ios_base& iob, char_type fill, long double v) 
const;
 
+// TODO(EricWF): This test takes 40+ minutes to build with Clang 3.8 under 
ASAN or MSAN.
+// UNSUPPORTED: asan, msan
+
 // TODO GLIBC uses a different string for positive and negative NAN numbers.
 // XFAIL: linux-gnu
 

Modified: libcxx/trunk/test/std/re/re.traits/isctype.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.traits/isctype.pass.cpp?rev=258195=258194=258195=diff
==
--- libcxx/trunk/test/std/re/re.traits/isctype.pass.cpp (original)
+++ libcxx/trunk/test/std/re/re.traits/isctype.pass.cpp Tue Jan 19 15:51:07 2016
@@ -13,6 +13,10 @@
 
 // bool isctype(charT c, char_class_type f) const;
 
+// TODO(EricWF): This test takes 40+ minutes to build with Clang 3.8 under 
ASAN or MSAN.
+// UNSUPPORTED: asan, msan
+
+
 #include 
 #include 
 


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


Re: [PATCH] D16331: [CUDA] Bail, rather than crash, on va_arg in device code.

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

Rename test file.


http://reviews.llvm.org/D16331

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExpr.cpp
  test/SemaCUDA/va-arg.cu

Index: test/SemaCUDA/va-arg.cu
===
--- /dev/null
+++ test/SemaCUDA/va-arg.cu
@@ -0,0 +1,28 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -fsyntax-only \
+// RUN:   -verify -DEXPECT_ERR %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only %s
+
+#include 
+#include "Inputs/cuda.h"
+
+__device__ void foo() {
+  va_list list;
+  va_arg(list, int);
+#ifdef EXPECT_ERR
+  // expected-error@-2 {{CUDA device code does not support va_arg}}
+#endif
+}
+
+void bar() {
+  va_list list;
+  va_arg(list, int);  // OK: host-only
+}
+
+__device__ void baz() {
+#if !defined(__CUDA_ARCH__)
+  va_list list;
+  va_arg(list, int);  // OK: only seen when compiling for host
+#endif
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -11715,9 +11715,8 @@
   return Result;
 }
 
-ExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc,
-Expr *E, ParsedType Ty,
-SourceLocation RPLoc) {
+ExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty,
+SourceLocation RPLoc) {
   TypeSourceInfo *TInfo;
   GetTypeFromParser(Ty, );
   return BuildVAArgExpr(BuiltinLoc, E, TInfo, RPLoc);
@@ -11729,6 +11728,16 @@
   Expr *OrigExpr = E;
   bool IsMS = false;
 
+  // CUDA device code does not support varargs.
+  if (getLangOpts().CUDAIsDevice) {
+if (const FunctionDecl *F = dyn_cast(CurContext)) {
+  CUDAFunctionTarget T = IdentifyCUDATarget(F);
+  if (T == CFT_Global || T == CFT_Device || T == CFT_HostDevice) {
+return ExprError(Diag(E->getLocStart(), diag::err_va_arg_in_device));
+  }
+}
+  }
+
   // It might be a __builtin_ms_va_list. (But don't ever mark a va_arg()
   // as Microsoft ABI on an actual Microsoft platform, where
   // __builtin_ms_va_list and __builtin_va_list are the same.)
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -6422,6 +6422,8 @@
 def warn_kern_is_inline : Warning<
   "ignored 'inline' attribute on kernel function %0">,
   InGroup;
+def err_va_arg_in_device : Error<
+  "CUDA device code does not support va_arg">;
 
 def warn_non_pod_vararg_with_format_string : Warning<
   "cannot pass %select{non-POD|non-trivial}0 object of type %1 to variadic "


Index: test/SemaCUDA/va-arg.cu
===
--- /dev/null
+++ test/SemaCUDA/va-arg.cu
@@ -0,0 +1,28 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -fsyntax-only \
+// RUN:   -verify -DEXPECT_ERR %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only %s
+
+#include 
+#include "Inputs/cuda.h"
+
+__device__ void foo() {
+  va_list list;
+  va_arg(list, int);
+#ifdef EXPECT_ERR
+  // expected-error@-2 {{CUDA device code does not support va_arg}}
+#endif
+}
+
+void bar() {
+  va_list list;
+  va_arg(list, int);  // OK: host-only
+}
+
+__device__ void baz() {
+#if !defined(__CUDA_ARCH__)
+  va_list list;
+  va_arg(list, int);  // OK: only seen when compiling for host
+#endif
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -11715,9 +11715,8 @@
   return Result;
 }
 
-ExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc,
-Expr *E, ParsedType Ty,
-SourceLocation RPLoc) {
+ExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty,
+SourceLocation RPLoc) {
   TypeSourceInfo *TInfo;
   GetTypeFromParser(Ty, );
   return BuildVAArgExpr(BuiltinLoc, E, TInfo, RPLoc);
@@ -11729,6 +11728,16 @@
   Expr *OrigExpr = E;
   bool IsMS = false;
 
+  // CUDA device code does not support varargs.
+  if (getLangOpts().CUDAIsDevice) {
+if (const FunctionDecl *F = dyn_cast(CurContext)) {
+  CUDAFunctionTarget T = IdentifyCUDATarget(F);
+  if (T == CFT_Global || T == CFT_Device || T == CFT_HostDevice) {
+return ExprError(Diag(E->getLocStart(), diag::err_va_arg_in_device));
+  }
+}
+  }
+
   // It might be a __builtin_ms_va_list. (But don't ever mark a va_arg()
   // as Microsoft ABI on an actual Microsoft platform, where
   // __builtin_ms_va_list and __builtin_va_list are the 

Re: [PATCH] D9929: Add missing modules/header - stage 1

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

Looks like this was never committed?


http://reviews.llvm.org/D9929



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


[libcxx] r258196 - Add missing license headers

2016-01-19 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Jan 19 15:52:04 2016
New Revision: 258196

URL: http://llvm.org/viewvc/llvm-project?rev=258196=rev
Log:
Add missing license headers

Modified:
libcxx/trunk/test/libcxx/compiler.py
libcxx/trunk/test/libcxx/test/config.py
libcxx/trunk/test/libcxx/test/executor.py
libcxx/trunk/test/libcxx/test/format.py
libcxx/trunk/test/libcxx/test/target_info.py
libcxx/trunk/test/libcxx/test/tracing.py
libcxx/trunk/test/libcxx/util.py

libcxx/trunk/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_helpers.h

libcxx/trunk/test/std/utilities/function.objects/func.require/invoke_helpers.h

libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/function_types.h
libcxx/trunk/test/support/any_helpers.h
libcxx/trunk/test/support/cmpxchg_loop.h
libcxx/trunk/test/support/count_new.hpp
libcxx/trunk/test/support/disable_missing_braces_warning.h
libcxx/trunk/test/support/nasty_macros.hpp
libcxx/trunk/test/support/tracked_value.h
libcxx/trunk/test/support/user_defined_integral.hpp

Modified: libcxx/trunk/test/libcxx/compiler.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/compiler.py?rev=258196=258195=258196=diff
==
--- libcxx/trunk/test/libcxx/compiler.py (original)
+++ libcxx/trunk/test/libcxx/compiler.py Tue Jan 19 15:52:04 2016
@@ -1,3 +1,12 @@
+#===--===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is dual licensed under the MIT and the University of Illinois Open
+# Source Licenses. See LICENSE.TXT for details.
+#
+#===--===##
+
 import os
 import lit.util
 import libcxx.util

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=258196=258195=258196=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Tue Jan 19 15:52:04 2016
@@ -1,3 +1,12 @@
+#===--===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is dual licensed under the MIT and the University of Illinois Open
+# Source Licenses. See LICENSE.TXT for details.
+#
+#===--===##
+
 import locale
 import os
 import platform

Modified: libcxx/trunk/test/libcxx/test/executor.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/executor.py?rev=258196=258195=258196=diff
==
--- libcxx/trunk/test/libcxx/test/executor.py (original)
+++ libcxx/trunk/test/libcxx/test/executor.py Tue Jan 19 15:52:04 2016
@@ -1,3 +1,12 @@
+#===--===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is dual licensed under the MIT and the University of Illinois Open
+# Source Licenses. See LICENSE.TXT for details.
+#
+#===--===##
+
 import os
 
 from libcxx.test import tracing

Modified: libcxx/trunk/test/libcxx/test/format.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/format.py?rev=258196=258195=258196=diff
==
--- libcxx/trunk/test/libcxx/test/format.py (original)
+++ libcxx/trunk/test/libcxx/test/format.py Tue Jan 19 15:52:04 2016
@@ -1,3 +1,12 @@
+#===--===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is dual licensed under the MIT and the University of Illinois Open
+# Source Licenses. See LICENSE.TXT for details.
+#
+#===--===##
+
 import errno
 import os
 import time

Modified: libcxx/trunk/test/libcxx/test/target_info.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/target_info.py?rev=258196=258195=258196=diff
==
--- libcxx/trunk/test/libcxx/test/target_info.py (original)
+++ libcxx/trunk/test/libcxx/test/target_info.py Tue Jan 19 15:52:04 2016
@@ -1,3 +1,12 @@
+#===--===//
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is dual licensed under the MIT and the University of Illinois Open
+# Source Licenses. See LICENSE.TXT for details.
+#
+#===--===//

Re: [PATCH] D16301: Allow mode attribute for member variables again

2016-01-19 Thread Stephan Bergmann via cfe-commits
sberg added a comment.

Please somebody push this for me; I don't have commit access. Thanks


http://reviews.llvm.org/D16301



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


Re: [PATCH] D16301: Allow mode attribute for member variables again

2016-01-19 Thread Stephan Bergmann via cfe-commits
sberg updated this revision to Diff 45310.
sberg added a comment.

oops, had erroneously based it on some other local patch; rebased now


http://reviews.llvm.org/D16301

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/AttributeList.h
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/attr-mode.c

Index: test/Sema/attr-mode.c
===
--- test/Sema/attr-mode.c
+++ test/Sema/attr-mode.c
@@ -24,8 +24,8 @@
 
 int **__attribute((mode(QI)))* i32;  // expected-error{{mode attribute}}
 
-__attribute__((mode(QI))) int invalid_func() { return 1; } // 
expected-error{{'mode' attribute only applies to variables and typedefs}}
-enum invalid_enum { A1 __attribute__((mode(QI))) }; // expected-error{{'mode' 
attribute only applies to variables and typedefs}}
+__attribute__((mode(QI))) int invalid_func() { return 1; } // 
expected-error{{'mode' attribute only applies to variables, fields and 
typedefs}}
+enum invalid_enum { A1 __attribute__((mode(QI))) }; // expected-error{{'mode' 
attribute only applies to variables, fields and typedefs}}
 
 typedef _Complex double c32 __attribute((mode(SC)));
 int c32_test[sizeof(c32) == 8 ? 1 : -1];
@@ -76,3 +76,7 @@
 #else
 #error Unknown test architecture.
 #endif
+
+struct S {
+  int n __attribute((mode(HI)));
+};
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3392,7 +3392,7 @@
   if (TypedefNameDecl *TD = dyn_cast(D))
 OldTy = TD->getUnderlyingType();
   else
-OldTy = cast(D)->getType();
+OldTy = cast(D)->getType();
 
   // Base type can also be a vector type (see PR17453).
   // Distinguish between base type and base element type.
@@ -3465,7 +3465,7 @@
   if (TypedefNameDecl *TD = dyn_cast(D))
 TD->setModedTypeSourceInfo(TD->getTypeSourceInfo(), NewTy);
   else
-cast(D)->setType(NewTy);
+cast(D)->setType(NewTy);
 
   D->addAttr(::new (S.Context)
  ModeAttr(Attr.getRange(), S.Context, Name,
Index: include/clang/Sema/AttributeList.h
===
--- include/clang/Sema/AttributeList.h
+++ include/clang/Sema/AttributeList.h
@@ -855,7 +855,8 @@
   ExpectedStructOrTypedef,
   ExpectedObjectiveCInterfaceOrProtocol,
   ExpectedKernelFunction,
-  ExpectedFunctionWithProtoType
+  ExpectedFunctionWithProtoType,
+  ExpectedVariableFieldOrTypedef
 };
 
 }  // end namespace clang
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2441,7 +2441,8 @@
   "Objective-C instance methods|init methods of interface or class extension 
declarations|"
   "variables, functions and classes|Objective-C protocols|"
   "functions and global variables|structs, unions, and typedefs|structs and 
typedefs|"
-  "interface or protocol declarations|kernel functions|non-K 
functions}1">,
+  "interface or protocol declarations|kernel functions|non-K 
functions|"
+  "variables, fields and typedefs}1">,
   InGroup;
 def err_attribute_wrong_decl_type : Error;
 def warn_type_attribute_wrong_type : Warning<
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -879,8 +879,8 @@
 
 def Mode : Attr {
   let Spellings = [GCC<"mode">];
-  let Subjects = SubjectList<[Var, TypedefName], ErrorDiag,
- "ExpectedVariableOrTypedef">;
+  let Subjects = SubjectList<[Var, TypedefName, Field], ErrorDiag,
+ "ExpectedVariableFieldOrTypedef">;
   let Args = [IdentifierArgument<"Mode">];
   let Documentation = [Undocumented];
 }


Index: test/Sema/attr-mode.c
===
--- test/Sema/attr-mode.c
+++ test/Sema/attr-mode.c
@@ -24,8 +24,8 @@
 
 int **__attribute((mode(QI)))* i32;  // expected-error{{mode attribute}}
 
-__attribute__((mode(QI))) int invalid_func() { return 1; } // expected-error{{'mode' attribute only applies to variables and typedefs}}
-enum invalid_enum { A1 __attribute__((mode(QI))) }; // expected-error{{'mode' attribute only applies to variables and typedefs}}
+__attribute__((mode(QI))) int invalid_func() { return 1; } // expected-error{{'mode' attribute only applies to variables, fields and typedefs}}
+enum invalid_enum { A1 __attribute__((mode(QI))) }; // expected-error{{'mode' attribute only applies to variables, fields and typedefs}}
 
 typedef _Complex double c32 __attribute((mode(SC)));
 int c32_test[sizeof(c32) == 8 ? 1 : -1];
@@ -76,3 +76,7 @@
 #else
 #error Unknown test architecture.
 #endif
+
+struct S {
+  int n __attribute((mode(HI)));
+};
Index: lib/Sema/SemaDeclAttr.cpp

Re: [libcxxabi] r256323 - Add new tests for throwing incomplete pointer types

2016-01-19 Thread Hans Wennborg via cfe-commits
That sounds great. Thanks!

On Tue, Jan 19, 2016 at 9:33 AM, Eric Fiselier  wrote:
> Hi Hans,
>
> Can I have today to work on this? If I can't come up with a fix we can
> revert tommorow.
> I'll ping you tommorow with the result.
>
> Does that work?
>
> /Eric
>
> On Tue, Jan 19, 2016 at 10:30 AM, Hans Wennborg  wrote:
>>
>> Nico pointed out his revert should probably be merged to 3.8.
>>
>> Has there been any follow-up here, e.g. fixes, that I should be aware of?
>>
>> Thanks,
>> Hans
>>
>> On Fri, Jan 15, 2016 at 7:48 AM, Nico Weber via cfe-commits
>>  wrote:
>> > I reverted this and 322 for now in 257896.
>> >
>> > On Fri, Jan 15, 2016 at 10:36 AM, Nico Weber 
>> > wrote:
>> >>
>> >> This test fails on OS X for me:
>> >>
>> >>
>> >> Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
>> >> FAIL: libc++abi :: incomplete_type.sh.cpp (29529 of 29545)
>> >>  TEST 'libc++abi :: incomplete_type.sh.cpp' FAILED
>> >> 
>> >> Script:
>> >> --
>> >>
>> >>
>> >> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
>> >> -v -DLIBCXXABI_NO_TIMER -funwind-tables -std=c++1z -nostdinc++
>> >> -I/Users/thakis/src/chrome/src/third_party/llvm/projects/libcxx/include
>> >>
>> >> -I/Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/include
>> >> -isysroot
>> >>
>> >> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
>> >> -c
>> >>
>> >> /Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/test/incomplete_type.sh.cpp
>> >> -o
>> >>
>> >> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.one.o
>> >>
>> >>
>> >> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
>> >> -v -DLIBCXXABI_NO_TIMER -funwind-tables -std=c++1z -nostdinc++
>> >> -I/Users/thakis/src/chrome/src/third_party/llvm/projects/libcxx/include
>> >>
>> >> -I/Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/include
>> >> -isysroot
>> >>
>> >> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
>> >> -c
>> >>
>> >> /Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/test/incomplete_type.sh.cpp
>> >> -o
>> >>
>> >> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.two.o
>> >> -DTU_ONE
>> >>
>> >>
>> >> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
>> >> -v -nodefaultlibs
>> >> -L/Users/thakis/src/chrome/src/third_party/llvm-bootstrap/lib
>> >> -Wl,-rpath,/Users/thakis/src/chrome/src/third_party/llvm-bootstrap/lib
>> >> -lc++
>> >> -lc++abi -lSystem -o
>> >>
>> >> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.exe
>> >>
>> >> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.one.o
>> >>
>> >> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.two.o
>> >>
>> >>
>> >> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.exe
>> >> --
>> >> Exit Code: 134
>> >>
>> >> Command Output (stderr):
>> >> --
>> >> Apple LLVM version 7.0.0 (clang-700.1.76)
>> >> Target: x86_64-apple-darwin15.0.0
>> >> Thread model: posix
>> >>
>> >>
>> >> "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
>> >> -cc1 -triple x86_64-apple-macosx10.11.0 -Wdeprecated-objc-isa-usage
>> >> -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free
>> >> -disable-llvm-verifier -main-file-name incomplete_type.sh.cpp
>> >> -mrelocation-model pic -pic-level 2 -mthread-model posix
>> >> -mdisable-fp-elim
>> >> -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version
>> >> 253.6
>> >> -v -dwarf-column-info -coverage-file
>> >>
>> >> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test/Output/incomplete_type.sh.cpp.tmp.one.o
>> >> -nostdinc++ -resource-dir
>> >>
>> >> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.0
>> >> -isysroot
>> >>
>> >> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
>> >> -D LIBCXXABI_NO_TIMER -I
>> >> /Users/thakis/src/chrome/src/third_party/llvm/projects/libcxx/include
>> >> -I
>> >>
>> >> /Users/thakis/src/chrome/src/third_party/llvm/projects/libcxxabi/include
>> >> -stdlib=libc++ -std=c++1z -fdeprecated-macro -fdebug-compilation-dir
>> >>
>> >> /Users/thakis/src/chrome/src/third_party/llvm-bootstrap/projects/libcxxabi/test
>> >> -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -mstackrealign
>> >> 

Re: [PATCH] D16158: [CMake] Add clang's targets to LLVM's export set when not building standalone

2016-01-19 Thread don hinton via cfe-commits
hintonda added a comment.

Ah, great.  That is simpler.


http://reviews.llvm.org/D16158



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


Re: [PATCH] D16259: Add clang-tidy readability-redundant-return check

2016-01-19 Thread Kim Gräsman via cfe-commits
kimgr added inline comments.


Comment at: test/clang-tidy/readability-redundant-return.cpp:21-24
@@ +20,6 @@
+
+void g(int i) {
+  if (i < 0) {
+return;
+  }
+  if (i < 10) {

LegalizeAdulthood wrote:
> kimgr wrote:
> > What happens to guard clauses invoking void functions?
> > 
> > void h() {
> > }
> > 
> > void g(int i) {
> >   if(i < 0) {
> > return h();
> >   }
> > }
> > 
> Nothing because the last statement of the `compoundStmt` that is the function 
> body is an `if` statement and not a `return` statement.
> 
> That is exactly why lines 21-24 are in the test suite :).
Ah, I hadn't understood the mechanics of the check. I read the docs, and now I 
do! Don't mind me :-)


http://reviews.llvm.org/D16259



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


Re: [PATCH] D16279: [OpenMP] Parsing + sema for "target exit data" directive.

2016-01-19 Thread Samuel Antao via cfe-commits
sfantao closed this revision.
sfantao added a comment.

Committed revision 258177.

Thanks,
Samuel


http://reviews.llvm.org/D16279



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


Re: [PATCH] D16308: clang-tidy Enhance readability-simplify-boolean-expr check to handle implicit conversions of integral types to bool and member pointers

2016-01-19 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.h:50
@@ -49,3 +49,3 @@
 ///  opposite condition.
 ///   4. Implicit conversions of pointer to `bool` are replaced with explicit
 ///  comparisons to `nullptr`.

LegalizeAdulthood wrote:
> aaron.ballman wrote:
> > Can you also update for member pointers?
> I can explicitly state that; to me "pointers" is a term that includes member 
> pointers.
Hmm, perhaps I am being too pedantic. I'm used to thinking of member pointers 
as different from pointers because it's that way in standardese.


Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.h:77
@@ -74,3 +76,3 @@
 ///  implicit conversion of `i & 1` to `bool` and becomes
-///  `bool b = static_cast(i & 1);`.
+///  `bool b = i & 1 != 0;`.
 ///

LegalizeAdulthood wrote:
> aaron.ballman wrote:
> > To me, this does not improve readability -- I now have to think much harder 
> > about operator precedence. Including parens would help significantly, IMO, 
> > so that it becomes `(i & 1) != 0`.
> To clarify: You'd like to see parens around the expression when it is a 
> binary operator, correct?
> 
> When it is a variable, there's no need to add parentheses.
Correct; if it's just a DeclRefExpr or unary operator then parens aren't 
useful; but if it's a binary operator, I think parens may help clarify.


http://reviews.llvm.org/D16308



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


r258165 - [OpenMP] Parsing + sema for "target enter data" directive.

2016-01-19 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Tue Jan 19 13:15:56 2016
New Revision: 258165

URL: http://llvm.org/viewvc/llvm-project?rev=258165=rev
Log:
[OpenMP] Parsing + sema for "target enter data" directive.

Patch by Arpith Jacob. Thanks!


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

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=258165=258164=258165=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Tue Jan 19 13:15:56 2016
@@ -2274,7 +2274,11 @@ enum CXCursorKind {
*/
   CXCursor_OMPDistributeDirective= 260,
 
-  CXCursor_LastStmt  = CXCursor_OMPDistributeDirective,
+  /** \brief OpenMP target enter data directive.
+   */
+  CXCursor_OMPTargetEnterDataDirective   = 261,
+
+  CXCursor_LastStmt  = 
CXCursor_OMPTargetEnterDataDirective,
 
   /**
* \brief Cursor that represents the translation unit itself.

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=258165=258164=258165=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Tue Jan 19 13:15:56 2016
@@ -2433,6 +2433,9 @@ DEF_TRAVERSE_STMT(OMPTargetDirective,
 DEF_TRAVERSE_STMT(OMPTargetDataDirective,
   { TRY_TO(TraverseOMPExecutableDirective(S)); })
 
+DEF_TRAVERSE_STMT(OMPTargetEnterDataDirective,
+  { TRY_TO(TraverseOMPExecutableDirective(S)); })
+
 DEF_TRAVERSE_STMT(OMPTeamsDirective,
   { TRY_TO(TraverseOMPExecutableDirective(S)); })
 

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=258165=258164=258165=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Tue Jan 19 13:15:56 2016
@@ -2038,6 +2038,66 @@ public:
   }
 };
 
+/// \brief This represents '#pragma omp target enter data' directive.
+///
+/// \code
+/// #pragma omp target enter data device(0) if(a) map(b[:])
+/// \endcode
+/// In this example directive '#pragma omp target enter data' has clauses
+/// 'device' with the value '0', 'if' with condition 'a' and 'map' with array
+/// section 'b[:]'.
+///
+class OMPTargetEnterDataDirective : public OMPExecutableDirective {
+  friend class ASTStmtReader;
+  /// \brief Build directive with the given start and end location.
+  ///
+  /// \param StartLoc Starting location of the directive kind.
+  /// \param EndLoc Ending Location of the directive.
+  /// \param NumClauses The number of clauses.
+  ///
+  OMPTargetEnterDataDirective(SourceLocation StartLoc, SourceLocation EndLoc,
+  unsigned NumClauses)
+  : OMPExecutableDirective(this, OMPTargetEnterDataDirectiveClass,
+   OMPD_target_enter_data, StartLoc, EndLoc,
+   NumClauses, /*NumChildren=*/0) {}
+
+  /// \brief Build an empty directive.
+  ///
+  /// \param NumClauses Number of clauses.
+  ///
+  explicit OMPTargetEnterDataDirective(unsigned NumClauses)
+  : OMPExecutableDirective(this, OMPTargetEnterDataDirectiveClass,
+   OMPD_target_enter_data, SourceLocation(),
+   SourceLocation(), NumClauses,
+   

Re: [PATCH] D16307: [CUDA] Handle -O options (more) correctly.

2016-01-19 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/D16307



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


Re: [PATCH] D16261: [CUDA] Only allow __global__ on free functions and static member functions.

2016-01-19 Thread Artem Belevich via cfe-commits
tra added inline comments.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6418
@@ +6417,3 @@
+def warn_nvcc_compat_kern_is_method : Warning<
+  "kernel function %0 is a member function; this may not be accepted by nvcc">,
+  InGroup;

There's an Extension<> tablegen class used to report various C and C++ 
extensions.
This looks like a good use case for it.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6421
@@ +6420,3 @@
+def warn_nvcc_compat_kern_is_inlined : Warning<
+  "kernel function %0 is inlined; this may not be accepted by nvcc">,
+  InGroup;

Perhaps we should use the same message as nvcc here:
'inline qualifier ignored for "global" function'


http://reviews.llvm.org/D16261



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


Re: [PATCH] D16310: new clang-tidy checker misc-long-cast

2016-01-19 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a comment.

Clang-tidy has 6 cast related checks. May be this is good time to introduce 
dedicated category for them?


Repository:
  rL LLVM

http://reviews.llvm.org/D16310



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


Re: [PATCH] D16259: Add clang-tidy readability-redundant-return check

2016-01-19 Thread Kim Gräsman via cfe-commits
kimgr added a subscriber: kimgr.
kimgr added a comment.

Came up with another test case.



Comment at: test/clang-tidy/readability-redundant-return.cpp:21-24
@@ +20,6 @@
+
+void g(int i) {
+  if (i < 0) {
+return;
+  }
+  if (i < 10) {

What happens to guard clauses invoking void functions?

void h() {
}

void g(int i) {
  if(i < 0) {
return h();
  }
}



http://reviews.llvm.org/D16259



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


Re: r258128 - Add -Wexpansion-to-undefined: warn when using `defined` in a macro definition.

2016-01-19 Thread Evgenii Stepanov via cfe-commits
This broke all WERROR bots. Sounds like this warning should be
disabled by default.

On Tue, Jan 19, 2016 at 8:15 AM, Krzysztof Parzyszek via cfe-commits
 wrote:
> This generates hundreds of warnings when doing check-all.
>
> Here's the offending code:
>
>
> utils/unittest/googletest/include/gtest/internal/gtest-port.h
>
> // Cygwin 1.7 and below doesn't support ::std::wstring.
> // Solaris' libc++ doesn't support it either.  Android has
> // no support for it at least as recent as Froyo (2.2).
> // Minix currently doesn't support it either.
> # define GTEST_HAS_STD_WSTRING \
> (!(GTEST_OS_LINUX_ANDROID || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS ||
> GTEST_OS_HAIKU || defined(_MINIX)))
>
>
> -Krzysztof
>
>
>
>
> On 1/19/2016 9:15 AM, Nico Weber via cfe-commits wrote:
>>
>> Author: nico
>> Date: Tue Jan 19 09:15:31 2016
>> New Revision: 258128
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=258128=rev
>> Log:
>> Add -Wexpansion-to-undefined: warn when using `defined` in a macro
>> definition.
>>
>> [cpp.cond]p4:
>>Prior to evaluation, macro invocations in the list of preprocessing
>>tokens that will become the controlling constant expression are
>> replaced
>>(except for those macro names modified by the 'defined' unary
>> operator),
>>just as in normal text. If the token 'defined' is generated as a result
>>of this replacement process or use of the 'defined' unary operator does
>>not match one of the two specified forms prior to macro replacement,
>> the
>>behavior is undefined.
>>
>> This isn't an idle threat, consider this program:
>>#define FOO
>>#define BAR defined(FOO)
>>#if BAR
>>...
>>#else
>>...
>>#endif
>> clang and gcc will pick the #if branch while Visual Studio will take the
>> #else branch.  Emit a warning about this undefined behavior.
>>
>> One problem is that this also applies to function-like macros. While the
>> example above can be written like
>>
>>  #if defined(FOO) && defined(BAR)
>>  #defined HAVE_FOO 1
>>  #else
>>  #define HAVE_FOO 0
>>  #endif
>>
>> there is no easy way to rewrite a function-like macro like `#define FOO(x)
>> (defined __foo_##x && __foo_##x)`.  Function-like macros like this are
>> used in
>> practice, and compilers seem to not have differing behavior in that case.
>> So
>> this a default-on warning only for object-like macros. For function-like
>> macros, it is an extension warning that only shows up with `-pedantic`.
>> (But it's undefined behavior in both cases.)
>>
>> Modified:
>>  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>>  cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>>  cfe/trunk/lib/Lex/PPExpressions.cpp
>>  cfe/trunk/test/Lexer/cxx-features.cpp
>>  cfe/trunk/test/Preprocessor/expr_define_expansion.c
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=258128=258127=258128=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Jan 19 09:15:31
>> 2016
>> @@ -204,6 +204,7 @@ def OverloadedShiftOpParentheses: DiagGr
>>   def DanglingElse: DiagGroup<"dangling-else">;
>>   def DanglingField : DiagGroup<"dangling-field">;
>>   def DistributedObjectModifiers :
>> DiagGroup<"distributed-object-modifiers">;
>> +def ExpansionToUndefined : DiagGroup<"expansion-to-undefined">;
>>   def FlagEnum : DiagGroup<"flag-enum">;
>>   def IncrementBool : DiagGroup<"increment-bool",
>> [DeprecatedIncrementBool]>;
>>   def InfiniteRecursion : DiagGroup<"infinite-recursion">;
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=258128=258127=258128=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue Jan 19
>> 09:15:31 2016
>> @@ -658,6 +658,13 @@ def warn_header_guard : Warning<
>>   def note_header_guard : Note<
>> "%0 is defined here; did you mean %1?">;
>>
>> +def warn_defined_in_object_type_macro : Warning<
>> +  "macro expansion producing 'defined' has undefined behavior">,
>> +  InGroup;
>> +def warn_defined_in_function_type_macro : Extension<
>> +  "macro expansion producing 'defined' has undefined behavior">,
>> +  InGroup;
>> +
>>   let CategoryName = "Nullability Issue" in {
>>
>>   def err_pp_assume_nonnull_syntax : Error<"expected 'begin' or 'end'">;
>>
>> Modified: cfe/trunk/lib/Lex/PPExpressions.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPExpressions.cpp?rev=258128=258127=258128=diff
>>
>> 

Re: [PATCH] D16286: [clang-tidy] Readability check for redundant parenthesis in return expression.

2016-01-19 Thread Richard via cfe-commits
LegalizeAdulthood added a comment.

@alexfh: The check and the bug report 
 originate in the preferences of 
the google style guide.


http://reviews.llvm.org/D16286



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


Re: [PATCH] D16310: new clang-tidy checker misc-long-cast

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


Comment at: docs/clang-tidy/checks/misc-long-cast.rst:6
@@ +5,3 @@
+
+This checker will warn when there is a explicit redundant cast of a calculation
+result to a bigger type. If the intention of the cast is to avoid loss of

Please use //check// instead of //checker// for documentation consistency.


http://reviews.llvm.org/D16310



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


Re: [PATCH] D16259: Add clang-tidy readability-redundant-return check

2016-01-19 Thread Richard via cfe-commits
LegalizeAdulthood added inline comments.


Comment at: test/clang-tidy/readability-redundant-return.cpp:21-24
@@ +20,6 @@
+
+void g(int i) {
+  if (i < 0) {
+return;
+  }
+  if (i < 10) {

kimgr wrote:
> What happens to guard clauses invoking void functions?
> 
> void h() {
> }
> 
> void g(int i) {
>   if(i < 0) {
> return h();
>   }
> }
> 
Nothing because the last statement of the `compoundStmt` that is the function 
body is an `if` statement and not a `return` statement.

That is exactly why lines 21-24 are in the test suite :).


http://reviews.llvm.org/D16259



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


Re: [PATCH] D16286: [clang-tidy] Readability check for redundant parenthesis in return expression.

2016-01-19 Thread Richard via cfe-commits
LegalizeAdulthood added a comment.

With readability checks, there are always people who disagree about what makes 
for more readable code.  I think I have seen this back-and-forth discussion 
with **every** readability check since I've been paying attention.  It simply 
isn't possible to make everyone happy and we shouldn't even try.

As I stated earlier on this review, IMO the way to deal with complex 
expressions is not to shotgun blast extra parentheses into the expression, but 
to extract variables or functions with intention revealing names that break out 
meaningful subexpressions.

For checks relating to readability or style, I think it is fair to simply 
assume that the results are subjective.  At the risk of sounding tautological, 
those who don't want the transformation shouldn't ask clang-tidy to perform the 
transformation.

There are already tons of transformations that clang-tidy performs that aren't 
to my personal taste, but are there because of a particular style guide (LLVM, 
google, etc.) or because the author of the check desires the transformation 
that is implemented.

I don't think such transformations should be denied from clang-tidy simply 
because of a difference of opinion.

One could argue that this check should be part of the google module.  The 
google style guide specifically forbids writing return with extra parenthesis.


http://reviews.llvm.org/D16286



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


LLVM buildmaster will be restarted tonight

2016-01-19 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be updated and restarted after 7 PM Pacific time
today.

Thanks

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


Re: [PATCH] D16301: Allow mode attribute for member variables again

2016-01-19 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you for fixing this!


http://reviews.llvm.org/D16301



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


Re: [PATCH] D16248: [Clang-tidy] rename misc-inefficient-algorithm to performance-inefficient-algorithm

2016-01-19 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added inline comments.


Comment at: docs/clang-tidy/checks/performance-inefficient-algorithm.rst:3
@@ -2,3 +2,3 @@
 
-misc-inefficient-algorithm
+performance-inefficient-algorithm
 ==

alexfh wrote:
> After reading this check name a few times, I found it too generic (one may 
> think that this is a generic algorithm-level code profiler ;). I think, we 
> need to rename it to `performance-inefficient-lookup-algorithm` or 
> `performance-inefficient-search-algorithm`, since we're changing the name 
> anyway.
I think will be better to keep generic name, since other algorithms could be 
added later.


http://reviews.llvm.org/D16248



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


Re: [PATCH] D16310: new clang-tidy checker misc-long-cast

2016-01-19 Thread Richard via cfe-commits
LegalizeAdulthood added a subscriber: LegalizeAdulthood.
LegalizeAdulthood added a comment.

Why not supply a fixit that removes the cast?


Repository:
  rL LLVM

http://reviews.llvm.org/D16310



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


Re: r258128 - Add -Wexpansion-to-undefined: warn when using `defined` in a macro definition.

2016-01-19 Thread Diego Novillo via cfe-commits
Nico, this is producing tons of warnings on an LLVM build and is actually
breaking our internal builds (we build with -Werror).

I fixed one file that was producing this, but there are several that have
the same problem (e.g., gtest-port.h).  Could you fix them or rollback?


Thanks.  Diego.

On Tue, Jan 19, 2016 at 10:15 AM, Nico Weber via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: nico
> Date: Tue Jan 19 09:15:31 2016
> New Revision: 258128
>
> URL: http://llvm.org/viewvc/llvm-project?rev=258128=rev
> Log:
> Add -Wexpansion-to-undefined: warn when using `defined` in a macro
> definition.
>
> [cpp.cond]p4:
>   Prior to evaluation, macro invocations in the list of preprocessing
>   tokens that will become the controlling constant expression are replaced
>   (except for those macro names modified by the 'defined' unary operator),
>   just as in normal text. If the token 'defined' is generated as a result
>   of this replacement process or use of the 'defined' unary operator does
>   not match one of the two specified forms prior to macro replacement, the
>   behavior is undefined.
>
> This isn't an idle threat, consider this program:
>   #define FOO
>   #define BAR defined(FOO)
>   #if BAR
>   ...
>   #else
>   ...
>   #endif
> clang and gcc will pick the #if branch while Visual Studio will take the
> #else branch.  Emit a warning about this undefined behavior.
>
> One problem is that this also applies to function-like macros. While the
> example above can be written like
>
> #if defined(FOO) && defined(BAR)
> #defined HAVE_FOO 1
> #else
> #define HAVE_FOO 0
> #endif
>
> there is no easy way to rewrite a function-like macro like `#define FOO(x)
> (defined __foo_##x && __foo_##x)`.  Function-like macros like this are
> used in
> practice, and compilers seem to not have differing behavior in that case.
> So
> this a default-on warning only for object-like macros. For function-like
> macros, it is an extension warning that only shows up with `-pedantic`.
> (But it's undefined behavior in both cases.)
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> cfe/trunk/lib/Lex/PPExpressions.cpp
> cfe/trunk/test/Lexer/cxx-features.cpp
> cfe/trunk/test/Preprocessor/expr_define_expansion.c
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=258128=258127=258128=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Jan 19 09:15:31
> 2016
> @@ -204,6 +204,7 @@ def OverloadedShiftOpParentheses: DiagGr
>  def DanglingElse: DiagGroup<"dangling-else">;
>  def DanglingField : DiagGroup<"dangling-field">;
>  def DistributedObjectModifiers :
> DiagGroup<"distributed-object-modifiers">;
> +def ExpansionToUndefined : DiagGroup<"expansion-to-undefined">;
>  def FlagEnum : DiagGroup<"flag-enum">;
>  def IncrementBool : DiagGroup<"increment-bool",
> [DeprecatedIncrementBool]>;
>  def InfiniteRecursion : DiagGroup<"infinite-recursion">;
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=258128=258127=258128=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue Jan 19
> 09:15:31 2016
> @@ -658,6 +658,13 @@ def warn_header_guard : Warning<
>  def note_header_guard : Note<
>"%0 is defined here; did you mean %1?">;
>
> +def warn_defined_in_object_type_macro : Warning<
> +  "macro expansion producing 'defined' has undefined behavior">,
> +  InGroup;
> +def warn_defined_in_function_type_macro : Extension<
> +  "macro expansion producing 'defined' has undefined behavior">,
> +  InGroup;
> +
>  let CategoryName = "Nullability Issue" in {
>
>  def err_pp_assume_nonnull_syntax : Error<"expected 'begin' or 'end'">;
>
> Modified: cfe/trunk/lib/Lex/PPExpressions.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPExpressions.cpp?rev=258128=258127=258128=diff
>
> ==
> --- cfe/trunk/lib/Lex/PPExpressions.cpp (original)
> +++ cfe/trunk/lib/Lex/PPExpressions.cpp Tue Jan 19 09:15:31 2016
> @@ -140,6 +140,51 @@ static bool EvaluateDefined(PPValue 
>  PP.LexNonComment(PeekTok);
>}
>
> +  // [cpp.cond]p4:
> +  //   Prior to evaluation, macro invocations in the list of preprocessing
> +  //   tokens that will become the controlling constant expression are
> replaced
> +  //   (except for those macro names modified by the 'defined' unary
> operator),
> +  //   just as in normal text. If 

r258177 - [OpenMP] Parsing + sema for "target exit data" directive.

2016-01-19 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Tue Jan 19 14:04:50 2016
New Revision: 258177

URL: http://llvm.org/viewvc/llvm-project?rev=258177=rev
Log:
[OpenMP] Parsing + sema for "target exit data" directive.

Patch by Arpith Jacob. Thanks!

Added:
cfe/trunk/test/OpenMP/target_exit_data_ast_print.cpp
cfe/trunk/test/OpenMP/target_exit_data_device_messages.cpp
cfe/trunk/test/OpenMP/target_exit_data_if_messages.cpp
cfe/trunk/test/OpenMP/target_exit_data_map_messages.c
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/AST/StmtOpenMP.h
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Basic/StmtNodes.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/StmtOpenMP.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/OpenMP/nesting_of_regions.cpp
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CXCursor.cpp

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=258177=258176=258177=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Tue Jan 19 14:04:50 2016
@@ -2278,7 +2278,11 @@ enum CXCursorKind {
*/
   CXCursor_OMPTargetEnterDataDirective   = 261,
 
-  CXCursor_LastStmt  = 
CXCursor_OMPTargetEnterDataDirective,
+  /** \brief OpenMP target exit data directive.
+   */
+  CXCursor_OMPTargetExitDataDirective= 262,
+
+  CXCursor_LastStmt  = CXCursor_OMPTargetExitDataDirective,
 
   /**
* \brief Cursor that represents the translation unit itself.

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=258177=258176=258177=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Tue Jan 19 14:04:50 2016
@@ -2436,6 +2436,9 @@ DEF_TRAVERSE_STMT(OMPTargetDataDirective
 DEF_TRAVERSE_STMT(OMPTargetEnterDataDirective,
   { TRY_TO(TraverseOMPExecutableDirective(S)); })
 
+DEF_TRAVERSE_STMT(OMPTargetExitDataDirective,
+  { TRY_TO(TraverseOMPExecutableDirective(S)); })
+
 DEF_TRAVERSE_STMT(OMPTeamsDirective,
   { TRY_TO(TraverseOMPExecutableDirective(S)); })
 

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=258177=258176=258177=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Tue Jan 19 14:04:50 2016
@@ -2098,6 +2098,66 @@ public:
   }
 };
 
+/// \brief This represents '#pragma omp target exit data' directive.
+///
+/// \code
+/// #pragma omp target exit data device(0) if(a) map(b[:])
+/// \endcode
+/// In this example directive '#pragma omp target exit data' has clauses
+/// 'device' with the value '0', 'if' with condition 'a' and 'map' with array
+/// section 'b[:]'.
+///
+class OMPTargetExitDataDirective : public OMPExecutableDirective {
+  friend class ASTStmtReader;
+  /// \brief Build directive with the given start and end location.
+  ///
+  /// \param StartLoc Starting location of the directive kind.
+  /// \param EndLoc Ending Location of the directive.
+  /// \param NumClauses The number of clauses.
+  ///
+  OMPTargetExitDataDirective(SourceLocation StartLoc, SourceLocation EndLoc,
+ unsigned NumClauses)
+  : OMPExecutableDirective(this, OMPTargetExitDataDirectiveClass,
+   OMPD_target_exit_data, StartLoc, EndLoc,
+   NumClauses, /*NumChildren=*/0) {}
+
+  /// \brief Build an empty directive.
+  ///
+  /// \param NumClauses Number of clauses.
+  ///
+  explicit OMPTargetExitDataDirective(unsigned NumClauses)
+  : OMPExecutableDirective(this, OMPTargetExitDataDirectiveClass,
+   OMPD_target_exit_data, SourceLocation(),
+   SourceLocation(), NumClauses,
+   /*NumChildren=*/0) {}
+
+public:
+  /// \brief Creates directive with a list of 

Re: [PATCH] D15699: [cfi] Cross-DSO CFI diagnostic mode (clang part)

2016-01-19 Thread Evgeniy Stepanov via cfe-commits
eugenis updated this revision to Diff 45292.

Repository:
  rL LLVM

http://reviews.llvm.org/D15699

Files:
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/Driver/Tools.cpp
  test/CodeGen/cfi-check-fail.c
  test/CodeGen/cfi-icall-cross-dso.c
  test/CodeGenCXX/cfi-cross-dso.cpp
  test/CodeGenCXX/cfi-vcall.cpp

Index: test/CodeGenCXX/cfi-vcall.cpp
===
--- test/CodeGenCXX/cfi-vcall.cpp
+++ test/CodeGenCXX/cfi-vcall.cpp
@@ -55,7 +55,7 @@
 
 // DIAG: @[[SRC:.*]] = private unnamed_addr constant [{{.*}} x i8] c"{{.*}}cfi-vcall.cpp\00", align 1
 // DIAG: @[[TYPE:.*]] = private unnamed_addr constant { i16, i16, [4 x i8] } { i16 -1, i16 0, [4 x i8] c"'A'\00" }
-// DIAG: @[[BADTYPESTATIC:.*]] = private unnamed_addr global { { [{{.*}} x i8]*, i32, i32 }, { i16, i16, [4 x i8] }*, i8 } { { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 [[@LINE+21]], i32 3 }, { i16, i16, [4 x i8] }* @[[TYPE]], i8 0 }
+// DIAG: @[[BADTYPESTATIC:.*]] = private unnamed_addr global { i8, { [{{.*}} x i8]*, i32, i32 }, { i16, i16, [4 x i8] }* } { i8 0, { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 [[@LINE+21]], i32 3 }, { i16, i16, [4 x i8] }* @[[TYPE]] }
 
 // ITANIUM: define void @_Z2afP1A
 // MS: define void @"\01?af@@YAXPEAUA@@@Z"
@@ -69,9 +69,9 @@
   // NDIAG-NEXT: call void @llvm.trap()
   // NDIAG-NEXT: unreachable
   // DIAG-NEXT: [[VTINT:%[^ ]*]] = ptrtoint i8* [[VT]] to i64
-  // DIAG-ABORT-NEXT: call void @__ubsan_handle_cfi_bad_type_abort(i8* bitcast ({{.*}} @[[BADTYPESTATIC]] to i8*), i64 [[VTINT]])
+  // DIAG-ABORT-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(i8* getelementptr inbounds ({{.*}} @[[BADTYPESTATIC]], i32 0, i32 0), i64 [[VTINT]])
   // DIAG-ABORT-NEXT: unreachable
-  // DIAG-RECOVER-NEXT: call void @__ubsan_handle_cfi_bad_type(i8* bitcast ({{.*}} @[[BADTYPESTATIC]] to i8*), i64 [[VTINT]])
+  // DIAG-RECOVER-NEXT: call void @__ubsan_handle_cfi_check_fail(i8* getelementptr inbounds ({{.*}} @[[BADTYPESTATIC]], i32 0, i32 0), i64 [[VTINT]])
   // DIAG-RECOVER-NEXT: br label %[[CONTBB]]
 
   // CHECK: [[CONTBB]]
Index: test/CodeGenCXX/cfi-cross-dso.cpp
===
--- test/CodeGenCXX/cfi-cross-dso.cpp
+++ test/CodeGenCXX/cfi-cross-dso.cpp
@@ -34,8 +34,8 @@
 // MS:   %[[TEST:.*]] = call i1 @llvm.bitset.test(i8* %[[VT2]], metadata !"?AUA@@"), !nosanitize
 // CHECK:   br i1 %[[TEST]], label %[[CONT:.*]], label %[[SLOW:.*]], {{.*}} !nosanitize
 // CHECK: [[SLOW]]
-// ITANIUM:   call void @__cfi_slowpath(i64 7004155349499253778, i8* %[[VT2]]) {{.*}} !nosanitize
-// MS:   call void @__cfi_slowpath(i64 -8005289897957287421, i8* %[[VT2]]) {{.*}} !nosanitize
+// ITANIUM:   call void @__cfi_slowpath_diag(i64 7004155349499253778, i8* %[[VT2]], {{.*}}) {{.*}} !nosanitize
+// MS:   call void @__cfi_slowpath_diag(i64 -8005289897957287421, i8* %[[VT2]], {{.*}}) {{.*}} !nosanitize
 // CHECK:   br label %[[CONT]], !nosanitize
 // CHECK: [[CONT]]
 // CHECK:   call void %{{.*}}(%struct.A* %{{.*}})
Index: test/CodeGen/cfi-icall-cross-dso.c
===
--- test/CodeGen/cfi-icall-cross-dso.c
+++ test/CodeGen/cfi-icall-cross-dso.c
@@ -1,5 +1,30 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux -O1 -fsanitize=cfi-icall -fsanitize-cfi-cross-dso -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=ITANIUM %s
-// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -O1 -fsanitize=cfi-icall  -fsanitize-cfi-cross-dso -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=MS %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -O1 \
+// RUN:   -fsanitize=cfi-icall -fsanitize-cfi-cross-dso \
+// RUN:   -emit-llvm -o - %s | FileCheck \
+// RUN:   --check-prefix=CHECK --check-prefix=CHECK-DIAG \
+// RUN:   --check-prefix=ITANIUM --check-prefix=ITANIUM-DIAG \
+// RUN:   %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -O1 \
+// RUN:   -fsanitize=cfi-icall -fsanitize-cfi-cross-dso -fsanitize-trap=cfi-icall \
+// RUN:   -emit-llvm -o - %s | FileCheck \
+// RUN:   --check-prefix=CHECK \
+// RUN:   --check-prefix=ITANIUM --check-prefix=ITANIUM-TRAP \
+// RUN:   %s
+
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -O1 \
+// RUN:   -fsanitize=cfi-icall -fsanitize-cfi-cross-dso \
+// RUN:   -emit-llvm -o - %s | FileCheck \
+// RUN:   --check-prefix=CHECK --check-prefix=CHECK-DIAG \
+// RUN:   --check-prefix=MS --check-prefix=MS-DIAG \
+// RUN:   %s
+
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -O1 \
+// RUN:   -fsanitize=cfi-icall -fsanitize-cfi-cross-dso -fsanitize-trap=cfi-icall \
+// RUN:   -emit-llvm -o - %s | FileCheck \
+// RUN:   --check-prefix=CHECK \
+// RUN:   --check-prefix=MS --check-prefix=MS-TRAP \
+// RUN:   %s
 
 void caller(void (*f)()) {
   f();
@@ -19,11 +44,18 @@
 inline void foo() 

Re: [PATCH] D16215: ASTMatchers: enable hasBody() matcher for FunctionDecls

2016-01-19 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

With one small nit, LGTM, thanks!



Comment at: include/clang/ASTMatchers/ASTMatchersInternal.h:1596
@@ +1595,3 @@
+inline const Stmt *GetBodyMatcher::get(const FunctionDecl ) 
{
+  return Node.doesThisDeclarationHaveABody() ? Node.getBody() : NULL;
+}

s/NULL/nullptr


http://reviews.llvm.org/D16215



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


r258152 - Module Debugging: Defer the emission of anonymous tag decls

2016-01-19 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue Jan 19 12:02:47 2016
New Revision: 258152

URL: http://llvm.org/viewvc/llvm-project?rev=258152=rev
Log:
Module Debugging: Defer the emission of anonymous tag decls
until we are visiting their declcontext.

This fixes a regression introduced in r256962:
When building debug info for a typdef'd anonymous tag type, we would be
visiting the inner anonymous type first thus creating a "typedef changes
linkage of anonymous type, but linkage was already computed" error.

rdar://problem/24199640

Modified:
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
cfe/trunk/test/Modules/ExtDebugInfo.cpp
cfe/trunk/test/Modules/Inputs/DebugCXX.h
cfe/trunk/test/Modules/ModuleDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=258152=258151=258152=diff
==
--- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
+++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Tue Jan 19 
12:02:47 2016
@@ -190,6 +190,10 @@ public:
 if (D->isFromASTFile())
   return;
 
+// Anonymous tag decls are deferred until we are building their 
declcontext.
+if (D->getName().empty())
+  return;
+
 DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx, false);
 DTV.TraverseDecl(D);
 Builder->UpdateCompletedType(D);

Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=258152=258151=258152=diff
==
--- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Tue Jan 19 12:02:47 2016
@@ -35,6 +35,10 @@ enum {
 auto anon_enum = DebugCXX::e2;
 char _anchor = anon_enum + conflicting_uid;
 
+TypedefUnion tdu;
+TypedefEnum tde;
+TypedefStruct tds;
+
 // CHECK: ![[NS:.*]] = !DINamespace(name: "DebugCXX", scope: ![[MOD:[0-9]+]],
 // CHECK: ![[MOD]] = !DIModule(scope: null, name: {{.*}}DebugCXX
 
@@ -62,6 +66,13 @@ char _anchor = anon_enum + conflicting_u
 // CHECK-SAME: flags: DIFlagFwdDecl,
 // CHECK-SAME: identifier: 
"_ZTSN8DebugCXX8TemplateIfNS_6traitsIf")
 
+// CHECK: !DICompositeType(tag: DW_TAG_union_type,
+// CHECK-SAME: flags: DIFlagFwdDecl, identifier: 
"_ZTS12TypedefUnion")
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
+// CHECK-SAME: flags: DIFlagFwdDecl, identifier: 
"_ZTS11TypedefEnum")
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type,
+// CHECK-SAME: flags: DIFlagFwdDecl, identifier: 
"_ZTS13TypedefStruct")
+
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "static_member",
 // CHECK-SAME:   scope: !"_ZTSN8DebugCXX6StructE"
 

Modified: cfe/trunk/test/Modules/Inputs/DebugCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DebugCXX.h?rev=258152=258151=258152=diff
==
--- cfe/trunk/test/Modules/Inputs/DebugCXX.h (original)
+++ cfe/trunk/test/Modules/Inputs/DebugCXX.h Tue Jan 19 12:02:47 2016
@@ -58,3 +58,7 @@ class FwdVirtual {
 };
 
 struct PureForwardDecl;
+
+typedef union { int i; } TypedefUnion;
+typedef enum { e0 = 0 } TypedefEnum;
+typedef struct { int i; } TypedefStruct;

Modified: cfe/trunk/test/Modules/ModuleDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleDebugInfo.cpp?rev=258152=258151=258152=diff
==
--- cfe/trunk/test/Modules/ModuleDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ModuleDebugInfo.cpp Tue Jan 19 12:02:47 2016
@@ -28,6 +28,10 @@
 // CHECK-SAME: identifier: "_ZTSN8DebugCXX4EnumE")
 // CHECK: !DINamespace(name: "DebugCXX"
 
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
+// CHECK-SAME-NOT: name:
+// CHECK-SAME: identifier: "_ZTS11TypedefEnum")
+
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Struct"
 // CHECK-SAME: identifier: "_ZTSN8DebugCXX6StructE")
 
@@ -47,6 +51,14 @@
 // CHECK-SAME: identifier: "_ZTS10FwdVirtual")
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "_vptr$FwdVirtual"
 
+// CHECK: !DICompositeType(tag: DW_TAG_union_type,
+// CHECK-SAME-NOT: name:
+// CHECK-SAME: identifier: "_ZTS12TypedefUnion")
+
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type,
+// CHECK-SAME-NOT: name:
+// CHECK-SAME: identifier: "_ZTS13TypedefStruct")
+
 // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "FloatInstatiation"
 // no mangled name here yet.
 


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

Re: [PATCH] D8822: Proposed fix for PR23076 (conditional branch debug line info)

2016-01-19 Thread Adrian Prantl via cfe-commits
aprantl added a subscriber: aprantl.
aprantl added a comment.

Reposting dblaikie's example hoping that phabricator doesn't mangle it this 
time:

   1: int main() {
   2: if (
   3: tr()
   4: &&
   5: tr()
   6: )
   7: func();
   8: if (
   9: fa()
  10: &&
  11: tr()
  12: )
  13: func();
  14: }
  15:

G++-4.8:
3, 4, 5, 4, 2, 7
10, 11, 9, 15

Clang before the change:
3, 4, 5, 3, 7
10, 11, 15

Clang after the change:
3, 5, 7
10, 15


http://reviews.llvm.org/D8822



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


Re: r258110 - Fix PR26134: When substituting into default template arguments, keep CurContext unchanged.

2016-01-19 Thread Dimitry Andric via cfe-commits
Hi Richard,

I am unsure if you are specifically the code owner of Sema, but can you please 
approve this change for the 3.8 branch?

-Dimitry

> On 19 Jan 2016, at 04:58, Faisal Vali via cfe-commits 
>  wrote:
> 
> Author: faisalv
> Date: Mon Jan 18 21:58:55 2016
> New Revision: 258110
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=258110=rev
> Log:
> Fix PR26134: When substituting into default template arguments, keep 
> CurContext unchanged.
> 
> Or, do not set Sema's CurContext to the template declaration's when 
> substituting into default template arguments of said template declaration.
> If we do push the template declaration context on to Sema, and the template 
> declaration is at namespace scope, Sema can get confused and try and do odr 
> analysis when substituting into default template arguments, even though the 
> substitution could be occurring within a dependent context.
> I'm not sure why this was being done, perhaps there was concern that if a 
> default template argument referred to a previous template parameter, it might 
> not be found during substitution - but all regression tests pass, and I can't 
> craft a test that would cause it to fails (if some one does, please inform 
> me, and i'll craft a different fix for the PR).
> 
> 
> This patch removes a single line of code, but unfortunately adds more than it 
> removes, because of the tests.  Some day I still hope to commit a patch that 
> removes far more lines than it adds, while leaving clang better for it ;)
> 
> Sorry that r253590 ("Change the expression evaluation context from 
> Unevaluated to ConstantEvaluated while substituting into non-type template 
> argument defaults") caused the PR!
> 
> 
> 
> 
> 
> Modified:
>cfe/trunk/lib/Sema/SemaTemplate.cpp
>cfe/trunk/test/SemaTemplate/default-arguments.cpp
> 
> Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=258110=258109=258110=diff
> ==
> --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Mon Jan 18 21:58:55 2016
> @@ -3281,7 +3281,6 @@ SubstDefaultTemplateArgument(Sema 
>   for (unsigned i = 0, e = Param->getDepth(); i != e; ++i)
> TemplateArgLists.addOuterTemplateArguments(None);
> 
> -  Sema::ContextRAII SavedContext(SemaRef, Template->getDeclContext());
>   EnterExpressionEvaluationContext ConstantEvaluated(SemaRef,
>  Sema::ConstantEvaluated);
>   return SemaRef.SubstExpr(Param->getDefaultArgument(), TemplateArgLists);
> 
> Modified: cfe/trunk/test/SemaTemplate/default-arguments.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-arguments.cpp?rev=258110=258109=258110=diff
> ==
> --- cfe/trunk/test/SemaTemplate/default-arguments.cpp (original)
> +++ cfe/trunk/test/SemaTemplate/default-arguments.cpp Mon Jan 18 21:58:55 2016
> @@ -179,3 +179,31 @@ struct C {
>   C(T t = ); // expected-error {{expected expression}}
> };
> C obj;
> +
> +namespace PR26134 {
> +// Make sure when substituting default template arguments we do it in the 
> current context.
> +template
> +struct X {};
> +
> +template struct Y {
> +  void f() { X xy; }
> +  static const bool value = B;
> +};
> +
> +namespace ns1 {
> +template
> +struct X {
> +  template struct XInner { static const bool value = B; 
> };
> +};
> +template struct S { static const bool value = B; };
> +#if __cplusplus > 199711L
> +template struct Y {
> +  static constexpr bool f() { return typename X::template 
> XInner<>{}.value; }
> +  static_assert(f() == B, "");
> +};
> +Y y;
> +Y y2;
> +#endif
> +
> +} // end ns1
> +} // end ns PR26134
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits



signature.asc
Description: Message signed with OpenPGP using GPGMail
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16259: Add clang-tidy readability-redundant-return check

LegalizeAdulthood added inline comments.


Comment at: test/clang-tidy/readability-redundant-return.cpp:21-24
@@ +20,6 @@
+
+void g(int i) {
+  if (i < 0) {
+return;
+  }
+  if (i < 10) {

kimgr wrote:
> LegalizeAdulthood wrote:
> > kimgr wrote:
> > > What happens to guard clauses invoking void functions?
> > > 
> > > void h() {
> > > }
> > > 
> > > void g(int i) {
> > >   if(i < 0) {
> > > return h();
> > >   }
> > > }
> > > 
> > Nothing because the last statement of the `compoundStmt` that is the 
> > function body is an `if` statement and not a `return` statement.
> > 
> > That is exactly why lines 21-24 are in the test suite :).
> Ah, I hadn't understood the mechanics of the check. I read the docs, and now 
> I do! Don't mind me :-)
I had thought about doing a deeper analysis of the control flow to look for 
such cases, but I will leave that for later.

For instance, the following code may plausibly appear in a code base:

```
void f() {
  do_stuff();
  {
lock l(mutex);
do_locked_stuff();
return;
  }
}
```

I haven't tried this on this patch, but I suspect it would do nothing; I will 
add some examples of these more complicated cases to the test suite to show 
that the implementation doesn't yet handle more advanced flow analysis.

In this case, the `return` is similarly redundant, as well as a `return` as the 
last statement of an `if` as you mentioned.  However, I wanted to start with 
something simple and get feedback on that before attempting to do more advanced 
cases.



http://reviews.llvm.org/D16259



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


Re: [PATCH] D16286: [clang-tidy] Readability check for redundant parenthesis in return expression.

aaron.ballman added a comment.

In http://reviews.llvm.org/D16286#330360, @LegalizeAdulthood wrote:

> With readability checks, there are always people who disagree about what 
> makes for more readable code.  I think I have seen this back-and-forth 
> discussion with **every** readability check since I've been paying attention. 
>  It simply isn't possible to make everyone happy and we shouldn't even try.


It is perfectly reasonable for people to disagree about what makes code more or 
less readable. Some readability issues are more obvious than others, and the 
threshold for "readable" is going to change from check to check. However, that 
is not a reason to not attempt to make a check that makes everyone reasonably 
(un)happy.

> As I stated earlier on this review, IMO the way to deal with complex 
> expressions is not to shotgun blast extra parentheses into the expression, 
> but to extract variables or functions with intention revealing names that 
> break out meaningful subexpressions.


That seems reasonable to me, but this checker is *removing* parens, not adding 
them. The point I was making before is that when a subexpression is 
sufficiently complex, parens are a quick-and-dirty way to reduce cognitive load 
for understanding operator precedence. This is an approach you see relatively 
frequently -- a quick look at the LLVM source base shows that. For a check that 
claims it will make something more readable, removing code the user wrote had 
better have a pretty good chance of improving readability or else the check 
will quickly get disabled.

A good way to empirically test this is to run this check over the LLVM source 
base (and/or a few other large source bases) and see how often the diagnostic 
is triggered, and take a random sampling to see how often the removal of parens 
involves an expression with multiple operators of differing precedence to see 
if perhaps an option or design change is warranted or not. These sort of 
metrics are something we usually look for with any clang-tidy check that may 
have a high false-positive rate. For stylistic checks, I suppose just about 
anything could qualify as a false-positive (unless it's part of a style 
guideline that's being followed).

> For checks relating to readability or style, I think it is fair to simply 
> assume that the results are subjective.


Definitely agreed.

> At the risk of sounding tautological, those who don't want the transformation 
> shouldn't ask clang-tidy to perform the transformation.


That presumes the user knows what transformations this check will apply. If 
this was misc-remove-redundant-parens or 
some-style-guide-remove-redundant-parens, I would agree with your statement. 
However, with readability-* I think the user is likely to ask clang-tidy to 
perform the check and apply changes on a case-by-case basis. So we may want to 
start with the smallest set of cases where the check might increase readability 
and then expand from there to cover more cases as uses are requested.

> There are already tons of transformations that clang-tidy performs that 
> aren't to my personal taste, but are there because of a particular style 
> guide (LLVM, google, etc.) or because the author of the check desires the 
> transformation that is implemented.

> 

> I don't think such transformations should be denied from clang-tidy simply 
> because of a difference of opinion.


No one is recommending denying this transformation; just discussing the 
particulars of it to ensure we have reasonable semantics for the check.

> One could argue that this check should be part of the google module.  The 
> google style guide specifically forbids writing return with extra parenthesis.


If it is meant to work for a particular style guide, then it should absolutely 
go under that style guide. But for something more generally under the 
readability-* umbrella, I think it doesn't hurt to discuss where to draw the 
line, or what options may be valuable.


http://reviews.llvm.org/D16286



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


Re: [PATCH] D16307: [CUDA] Handle -O options (more) correctly.

This revision was automatically updated to reflect the committed changes.
Closed by commit rL258174: [CUDA] Handle -O options (more) correctly. (authored 
by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D16307?vs=45223=45290#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16307

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/cuda-external-tools.cu

Index: cfe/trunk/test/Driver/cuda-external-tools.cu
===
--- cfe/trunk/test/Driver/cuda-external-tools.cu
+++ cfe/trunk/test/Driver/cuda-external-tools.cu
@@ -4,14 +4,31 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
 
-// Regular compile with -O2.
+// Regular compiles with -O{0,1,2,3,4,fast}.  -O4 and -Ofast map to ptxas O3.
+// RUN: %clang -### -target x86_64-linux-gnu -O0 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT0 
%s
+// RUN: %clang -### -target x86_64-linux-gnu -O1 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT1 
%s
 // RUN: %clang -### -target x86_64-linux-gnu -O2 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT2 
%s
+// RUN: %clang -### -target x86_64-linux-gnu -O3 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT3 
%s
+// RUN: %clang -### -target x86_64-linux-gnu -O4 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT3 
%s
+// RUN: %clang -### -target x86_64-linux-gnu -Ofast -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT3 
%s
 
 // Regular compile without -O.  This should result in us passing -O0 to ptxas.
 // RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT0 
%s
 
+// Regular compiles with -Os and -Oz.  For lack of a better option, we map
+// these to ptxas -O3.
+// RUN: %clang -### -target x86_64-linux-gnu -Os -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT2 
%s
+// RUN: %clang -### -target x86_64-linux-gnu -Oz -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT2 
%s
+
 // Regular compile targeting sm_35.
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM35 %s
@@ -42,7 +59,9 @@
 // ARCH64: "-m64"
 // ARCH32: "-m32"
 // OPT0: "-O0"
+// OPT1: "-O1"
 // OPT2: "-O2"
+// OPT3: "-O3"
 // SM20: "--gpu-name" "sm_20"
 // SM35: "--gpu-name" "sm_35"
 // SM20: "--output-file" "[[CUBINFILE:[^"]*]]"
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -10663,10 +10663,35 @@
   ArgStringList CmdArgs;
   CmdArgs.push_back(TC.getTriple().isArch64Bit() ? "-m64" : "-m32");
 
-  // Clang's default optimization level is -O0, but ptxas's default is -O3.
-  CmdArgs.push_back(Args.MakeArgString(
-  llvm::Twine("-O") +
-  Args.getLastArgValue(options::OPT_O_Group, "0").data()));
+  // Map the -O we received to -O{0,1,2,3}.
+  //
+  // TODO: Perhaps we should map host -O2 to ptxas -O3. -O3 is ptxas's default,
+  // so it may correspond more closely to the spirit of clang -O2.
+  if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
+// -O3 seems like the least-bad option when -Osomething is specified to
+// clang but it isn't handled below.
+StringRef OOpt = "3";
+if (A->getOption().matches(options::OPT_O4) ||
+A->getOption().matches(options::OPT_Ofast))
+  OOpt = "3";
+else if (A->getOption().matches(options::OPT_O0))
+  OOpt = "0";
+else if (A->getOption().matches(options::OPT_O)) {
+  // -Os, -Oz, and -O(anything else) map to -O2, for lack of better 
options.
+  OOpt = llvm::StringSwitch(A->getValue())
+ .Case("1", "1")
+ .Case("2", "2")
+ .Case("3", "3")
+ .Case("s", "2")
+ .Case("z", "2")
+ .Default("2");
+}
+CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-O") + OOpt));
+  } else {
+// If no -O was passed, pass -O0 to ptxas -- no opt flag should correspond
+// to no optimizations, but ptxas's default is -O3.
+CmdArgs.push_back("-O0");
+  }
 
   // Don't bother passing -g to ptxas: It's enabled by default at -O0, and
   // not supported at other optimization levels.


Index: cfe/trunk/test/Driver/cuda-external-tools.cu
===
--- cfe/trunk/test/Driver/cuda-external-tools.cu
+++ cfe/trunk/test/Driver/cuda-external-tools.cu
@@ -4,14 +4,31 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
 
-// Regular compile with -O2.
+// Regular compiles with 

r258174 - [CUDA] Handle -O options (more) correctly.

Author: jlebar
Date: Tue Jan 19 13:52:21 2016
New Revision: 258174

URL: http://llvm.org/viewvc/llvm-project?rev=258174=rev
Log:
[CUDA] Handle -O options (more) correctly.

Summary:
Previously we'd crash the driver if you passed -O0.  Now we try to
handle all of clang's various optimization flags in a sane way.

Reviewers: tra

Subscribers: cfe-commits, echristo, jhen

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

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/cuda-external-tools.cu

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=258174=258173=258174=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Jan 19 13:52:21 2016
@@ -10663,10 +10663,35 @@ void NVPTX::Assembler::ConstructJob(Comp
   ArgStringList CmdArgs;
   CmdArgs.push_back(TC.getTriple().isArch64Bit() ? "-m64" : "-m32");
 
-  // Clang's default optimization level is -O0, but ptxas's default is -O3.
-  CmdArgs.push_back(Args.MakeArgString(
-  llvm::Twine("-O") +
-  Args.getLastArgValue(options::OPT_O_Group, "0").data()));
+  // Map the -O we received to -O{0,1,2,3}.
+  //
+  // TODO: Perhaps we should map host -O2 to ptxas -O3. -O3 is ptxas's default,
+  // so it may correspond more closely to the spirit of clang -O2.
+  if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
+// -O3 seems like the least-bad option when -Osomething is specified to
+// clang but it isn't handled below.
+StringRef OOpt = "3";
+if (A->getOption().matches(options::OPT_O4) ||
+A->getOption().matches(options::OPT_Ofast))
+  OOpt = "3";
+else if (A->getOption().matches(options::OPT_O0))
+  OOpt = "0";
+else if (A->getOption().matches(options::OPT_O)) {
+  // -Os, -Oz, and -O(anything else) map to -O2, for lack of better 
options.
+  OOpt = llvm::StringSwitch(A->getValue())
+ .Case("1", "1")
+ .Case("2", "2")
+ .Case("3", "3")
+ .Case("s", "2")
+ .Case("z", "2")
+ .Default("2");
+}
+CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-O") + OOpt));
+  } else {
+// If no -O was passed, pass -O0 to ptxas -- no opt flag should correspond
+// to no optimizations, but ptxas's default is -O3.
+CmdArgs.push_back("-O0");
+  }
 
   // Don't bother passing -g to ptxas: It's enabled by default at -O0, and
   // not supported at other optimization levels.

Modified: cfe/trunk/test/Driver/cuda-external-tools.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-external-tools.cu?rev=258174=258173=258174=diff
==
--- cfe/trunk/test/Driver/cuda-external-tools.cu (original)
+++ cfe/trunk/test/Driver/cuda-external-tools.cu Tue Jan 19 13:52:21 2016
@@ -4,14 +4,31 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
 
-// Regular compile with -O2.
+// Regular compiles with -O{0,1,2,3,4,fast}.  -O4 and -Ofast map to ptxas O3.
+// RUN: %clang -### -target x86_64-linux-gnu -O0 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT0 
%s
+// RUN: %clang -### -target x86_64-linux-gnu -O1 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT1 
%s
 // RUN: %clang -### -target x86_64-linux-gnu -O2 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT2 
%s
+// RUN: %clang -### -target x86_64-linux-gnu -O3 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT3 
%s
+// RUN: %clang -### -target x86_64-linux-gnu -O4 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT3 
%s
+// RUN: %clang -### -target x86_64-linux-gnu -Ofast -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT3 
%s
 
 // Regular compile without -O.  This should result in us passing -O0 to ptxas.
 // RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT0 
%s
 
+// Regular compiles with -Os and -Oz.  For lack of a better option, we map
+// these to ptxas -O3.
+// RUN: %clang -### -target x86_64-linux-gnu -Os -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT2 
%s
+// RUN: %clang -### -target x86_64-linux-gnu -Oz -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT2 
%s
+
 // Regular compile targeting sm_35.
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM35 %s
@@ -42,7 +59,9 @@
 // ARCH64: "-m64"
 // ARCH32: "-m32"
 // OPT0: "-O0"
+// OPT1: "-O1"
 // OPT2: "-O2"
+// 

[libcxxabi] r258235 - Creating release directory for release_380.

Author: hans
Date: Tue Jan 19 17:41:04 2016
New Revision: 258235

URL: http://llvm.org/viewvc/llvm-project?rev=258235=rev
Log:
Creating release directory for release_380.

Added:
libcxxabi/tags/RELEASE_380/

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


[libcxx] r258233 - Creating release directory for release_380.

Author: hans
Date: Tue Jan 19 17:40:59 2016
New Revision: 258233

URL: http://llvm.org/viewvc/llvm-project?rev=258233=rev
Log:
Creating release directory for release_380.

Added:
libcxx/tags/RELEASE_380/

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


[libcxx] r258234 - Creating release candidate rc1 from release_380 branch

Author: hans
Date: Tue Jan 19 17:41:02 2016
New Revision: 258234

URL: http://llvm.org/viewvc/llvm-project?rev=258234=rev
Log:
Creating release candidate rc1 from release_380 branch

Added:
libcxx/tags/RELEASE_380/rc1/   (props changed)
  - copied from r258233, libcxx/branches/release_38/

Propchange: libcxx/tags/RELEASE_380/rc1/
--
--- svn:mergeinfo (added)
+++ svn:mergeinfo Tue Jan 19 17:41:02 2016
@@ -0,0 +1,2 @@
+/libcxx/branches/apple:136569-137939
+/libcxx/trunk:257682,257696,257702


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


Re: [PATCH] D16261: [CUDA] Only allow __global__ on free functions and static member functions.

jlebar added inline comments.


Comment at: lib/Sema/SemaDeclAttr.cpp:3620-3629
@@ -3619,2 +3619,12 @@
   }
+  if (const auto *Method = dyn_cast(FD)) {
+if (Method->isInstance()) {
+  S.Diag(Method->getLocStart(), diag::err_kern_is_nonstatic_method)
+  << Method;
+  return;
+}
+S.Diag(Method->getLocStart(), diag::warn_kern_is_method) << Method;
+  }
+  if (FD->isInlineSpecified())
+S.Diag(FD->getLocStart(), diag::warn_kern_is_inline) << FD;
 

tra wrote:
> Perhaps we should emit diagnostics on device side only.
Hm.  I don't feel strongly, but since we're talking about __global__ functions, 
this seems sort of relevant for both host and device compilation?


http://reviews.llvm.org/D16261



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


Re: r258251 - Module Debugging: Don't emit external type references to anonymous types.


> On Jan 19, 2016, at 3:52 PM, David Blaikie  wrote:
> 
> 
> 
> On Tue, Jan 19, 2016 at 3:42 PM, Adrian Prantl via cfe-commits 
> > wrote:
> Author: adrian
> Date: Tue Jan 19 17:42:53 2016
> New Revision: 258251
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=258251=rev 
> 
> Log:
> Module Debugging: Don't emit external type references to anonymous types.
> Even if they exist in the module, they can't be matched with the forward
> declaration in the object file.
> 
> They can't be matched because they're matched by (non-mangled) name?

Yes, dsymutil and lldb use the (non-mangled) name + DeclContext (which includes 
the qualified module name).

> I thought at least they'd be matched by mangled name (& perhaps we need to 
> emit DW_AT_linkage_name on them to make that possible)?

Emitting the DW_AT_linkage_name and matching/indexing types based on it is 
definitely  interesting for the future (bag of dwarf ...), but currently LLVM 
doesn’t do that.

>  
> 
> 
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/test/Modules/ExtDebugInfo.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=258251=258250=258251=diff
>  
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Jan 19 17:42:53 2016
> @@ -1536,8 +1536,9 @@ static bool shouldOmitDefinition(CodeGen
>   const RecordDecl *RD,
>   const LangOptions ) {
>// Does the type exist in an imported clang module?
> -  if (DebugTypeExtRefs && RD->isFromASTFile() && RD->getDefinition())
> -  return true;
> +  if (DebugTypeExtRefs && RD->isFromASTFile() && RD->getDefinition() &&
> +  RD->isExternallyVisible())
> 
> Not sure if this is the right check. There might be named things that are 
> static (so not externally visible) in headers?

I used isExternallyVisible() because it implies that the type won’t have a 
mangled name, (mostly thinking about the future where this would become more 
relevant), but at the moment we can relax this to RD->getName().isEmpty() and 
worry about nonexisting mangled names later.

-- adrian

>  
> +return true;
> 
>if (DebugKind > CodeGenOptions::LimitedDebugInfo)
>  return false;
> 
> Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=258251=258250=258251=diff
>  
> 
> ==
> --- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original)
> +++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Tue Jan 19 17:42:53 2016
> @@ -84,4 +84,13 @@ void foo() {
>  // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, scope: ![[NS]],
>  // CHECK-SAME: line: 16
> 
> +// CHECK: !DIGlobalVariable(name: "GlobalUnion",
> +// CHECK-SAME:  type: ![[GLOBAL_UNION:[0-9]+]]
> +// CHECK: ![[GLOBAL_UNION]] = !DICompositeType(tag: DW_TAG_union_type,
> +// CHECK-SAME:elements: !{{[0-9]+}})
> +// CHECK: !DIGlobalVariable(name: "GlobalStruct",
> +// CHECK-SAME:  type: ![[GLOBAL_STRUCT:[0-9]+]]
> +// CHECK: ![[GLOBAL_STRUCT]] = !DICompositeType(tag: DW_TAG_structure_type,
> +// CHECK-SAME:elements: !{{[0-9]+}})
> +
>  // CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, 
> entity: !"_ZTSN8DebugCXX6StructE", line: 24)
> 
> 
> ___
> 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: [libcxx] [PATCH] unordered_map: Avoid unnecessary mallocs when no insert occurs

Hey Duncan,

I know this isn't required, but would it be possible to put this on
phabricator?

/Eric

On Mon, Jan 18, 2016 at 4:34 PM, Duncan P. N. Exon Smith <
dexonsm...@apple.com> wrote:

> ping
>
> > On 2016-Jan-11, at 16:23, Duncan P. N. Exon Smith 
> wrote:
> >
> > ping
> >
> >> On 2016-Jan-04, at 12:37, Duncan P. N. Exon Smith 
> wrote:
> >>
> >> ping
> >>
> >>> On 2015-Dec-17, at 13:56, Duncan P. N. Exon Smith <
> dexonsm...@apple.com> wrote:
> >>>
> >>>
>  On 2015-Dec-16, at 14:42, Duncan P. N. Exon Smith <
> dexonsm...@apple.com> wrote:
> 
>  This is a follow-up to r239666: "Fix PR12999 - unordered_set::insert
>  calls operator new when no insert occurs".  That fix didn't apply to
>  `unordered_map` because unordered_map::value_type gets packed inside:
>  --
>  union __value_type {
>  pair __nc;   // Only C++11 or higher.
>  pair __cc; // Always.
>  // Constructors...
>  };
>  --
>  and the underlying __hash_table only knows about __value_type.
> >>>
> >>> Sorry for the quick ping, but I realized this morning that my approach
> >>> was still leaving mallocs on the table.
> >>>
> >>> I've attached a new patch that handles more cases.
> >>>
> >>> This patch should avoid unnecessary mallocs whenever the caller passes
> >>> in a pair such that T is trivially convertible to key_type.
> >>>
> >>> Since __hash_table's value_type is really *never* a pair (for
> >>> unordered_map, it's a union of two pairs) the static dispatch is all in
> >>> unordered_map.  It's doing this:
> >>> - If the argument isn't a pair<>, alloc.
> >>> - If argument.first can be referenced as const key_type&, don't alloc.
> >>> - If argument.first can be trivially converted to key_type, don't
> >>>  alloc.
> >>> - Else alloc.
> >>>
> >>> In the pre-C++11 world the caller has already converted to
> >>> unordered_map::value_type.  We can always avoid the alloc.
> >>>
> >>> To support all of this:
> >>> - In C++03, __unordered_map_equal and __unordered_map_hasher need to
> >>>  handle unordered_map::value_type.
> >>> - In C++03, __hash_table::__insert_unique_value() now takes its
> >>>  argument by template.
> >>> - In C++11, __hash_table::__insert_unique_value() is now a one-liner
> >>>  that forwards to __insert_unique_key_value() for the real work.
> >>> - The versions of __hash_table::__construct_node() that take a
> >>>  pre-computed hash have been renamed to __construct_node_hash(), and
> >>>  these versions use perfect forwarding.
> >>>
> >>> Most of the following still apply:
> >>>
>  This is one of my first patches for libc++, and I'm not sure of a few
>  things:
>  - Did I successfully match the coding style?  (I'm kind of lost
>  without clang-format TBH.)
>  - Should I separate the change to __construct_node_hash() into a
>  separate prep commit?  (I would if this were LLVM, but I'm not sure
>  if the common practice is different for libc++.)
>  - Most of the overloads I added to __unordered_map_hasher and
>  __unordered_map_equal aren't actually used by
>  __hash_table::__insert_unique_value().  Should I omit the unused
>  ones?  (Again, for LLVM I would have omitted them.)
> >>>
> >>> (For the updated patch, I went with the LLVM approach of only adding
> >>> the used API.  It seems more appropriate in this case.)
> >>>
>  After this I'll fix the same performance issue in std::map (and I
>  assume std::set?).
> >>
> >> <0001-unordered_map-Avoid-unnecessary-mallocs-when-no-i-v2.patch>
> >
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16341: [OpenMP] Check for at least one map clause on target data directive.

arpith-jacob created this revision.
arpith-jacob added reviewers: kkwli0, hfinkel, ABataev, sfantao, carlo.bertolli.
arpith-jacob added subscribers: fraggamuffin, caomhin, cfe-commits.

OpenMP [2.10.1, Restrictions, p. 97]
At least one map clause must appear on the directive.

http://reviews.llvm.org/D16341

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/target_data_ast_print.cpp
  test/OpenMP/target_data_device_messages.cpp
  test/OpenMP/target_data_if_messages.cpp
  test/OpenMP/target_data_messages.c

Index: test/OpenMP/target_data_messages.c
===
--- test/OpenMP/target_data_messages.c
+++ test/OpenMP/target_data_messages.c
@@ -3,19 +3,22 @@
 void foo() { }
 
 int main(int argc, char **argv) {
+  int a;
+  #pragma omp target data // expected-error {{expected at least one map clause for '#pragma omp target data'}}
+  {}
   L1:
 foo();
-  #pragma omp target data
+  #pragma omp target data map(a)
   {
 foo();
 goto L1; // expected-error {{use of undeclared label 'L1'}}
   }
   goto L2; // expected-error {{use of undeclared label 'L2'}}
-  #pragma omp target data
+  #pragma omp target data map(a)
   L2:
   foo();
 
-  #pragma omp target data(i) // expected-warning {{extra tokens at the end of '#pragma omp target data' are ignored}}
+  #pragma omp target data map(a)(i) // expected-warning {{extra tokens at the end of '#pragma omp target data' are ignored}}
   {
 foo();
   }
Index: test/OpenMP/target_data_if_messages.cpp
===
--- test/OpenMP/target_data_if_messages.cpp
+++ test/OpenMP/target_data_if_messages.cpp
@@ -10,22 +10,23 @@
 struct S1; // expected-note {{declared here}}
 
 int main(int argc, char **argv) {
-  #pragma omp target data if // expected-error {{expected '(' after 'if'}}
-  #pragma omp target data if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
-  #pragma omp target data if () // expected-error {{expected expression}}
-  #pragma omp target data if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
-  #pragma omp target data if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target data' are ignored}}
-  #pragma omp target data if (argc > 0 ? argv[1] : argv[2])
-  #pragma omp target data if (argc + argc)
-  #pragma omp target data if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target data' cannot contain more than one 'if' clause}}
-  #pragma omp target data if (S1) // expected-error {{'S1' does not refer to a value}}
-  #pragma omp target data if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
-  #pragma omp target data if(target data : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
-  #pragma omp target data if(target data : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
-  #pragma omp target data if(target data : argc)
-  #pragma omp target data if(target data : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp target data'}}
-  #pragma omp target data if(target data : argc) if (target data:argc) // expected-error {{directive '#pragma omp target data' cannot contain more than one 'if' clause with 'target data' name modifier}}
-  #pragma omp target data if(target data : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
+  int a;
+  #pragma omp target data map(to: a) if // expected-error {{expected '(' after 'if'}}
+  #pragma omp target data map(to: a) if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp target data map(to: a) if () // expected-error {{expected expression}}
+  #pragma omp target data map(to: a) if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp target data map(to: a) if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target data' are ignored}}
+  #pragma omp target data map(to: a) if (argc > 0 ? argv[1] : argv[2])
+  #pragma omp target data map(to: a) if (argc + argc)
+  #pragma omp target data map(to: a) if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target data' cannot contain more than one 'if' clause}}
+  #pragma omp target data map(to: a) if (S1) // expected-error {{'S1' does not refer to a value}}
+  #pragma omp target data map(to: a) if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp target data map(to: a) if(target data : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp target data map(to: a) if(target data : argc // 

Re: [libcxx] r258217 - Fix enviroment variables when running shell scripts

Hi Hans,

Please merge this commit into 3.8. I need it in order to un-revert the
libc++abi commit r256323.

Marshall can you OK this?

/Eric

On Tue, Jan 19, 2016 at 4:06 PM, Eric Fiselier via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ericwf
> Date: Tue Jan 19 17:06:29 2016
> New Revision: 258217
>
> URL: http://llvm.org/viewvc/llvm-project?rev=258217=rev
> Log:
> Fix enviroment variables when running shell scripts
>
> Modified:
> libcxx/trunk/test/libcxx/test/config.py
>
> Modified: libcxx/trunk/test/libcxx/test/config.py
> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=258217=258216=258217=diff
>
> ==
> --- libcxx/trunk/test/libcxx/test/config.py (original)
> +++ libcxx/trunk/test/libcxx/test/config.py Tue Jan 19 17:06:29 2016
> @@ -615,7 +615,7 @@ class Configuration(object):
>  for k, v in self.env.items():
>  exec_env_str += ' %s=%s' % (k, v)
>  # Configure run env substitution.
> -exec_str = ''
> +exec_str = exec_env_str
>  if self.lit_config.useValgrind:
>  exec_str = ' '.join(self.lit_config.valgrindArgs) +
> exec_env_str
>  sub.append(('%exec', exec_str))
>
>
> ___
> 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


r258220 - StmtOpenMP.h: Fix a warning in r258177. [-Wdocumentation]

Author: chapuni
Date: Tue Jan 19 17:21:18 2016
New Revision: 258220

URL: http://llvm.org/viewvc/llvm-project?rev=258220=rev
Log:
StmtOpenMP.h: Fix a warning in r258177. [-Wdocumentation]

Modified:
cfe/trunk/include/clang/AST/StmtOpenMP.h

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=258220=258219=258220=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Tue Jan 19 17:21:18 2016
@@ -2137,7 +2137,6 @@ public:
   /// \param StartLoc Starting location of the directive kind.
   /// \param EndLoc Ending Location of the directive.
   /// \param Clauses List of clauses.
-  /// \param AssociatedStmt Statement, associated with the directive.
   ///
   static OMPTargetExitDataDirective *Create(const ASTContext ,
 SourceLocation StartLoc,


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


r258219 - StmtOpenMP.h: Fix a warning in r258165. [-Wdocumentation]

Author: chapuni
Date: Tue Jan 19 17:21:13 2016
New Revision: 258219

URL: http://llvm.org/viewvc/llvm-project?rev=258219=rev
Log:
StmtOpenMP.h: Fix a warning in r258165. [-Wdocumentation]

Modified:
cfe/trunk/include/clang/AST/StmtOpenMP.h

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=258219=258218=258219=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Tue Jan 19 17:21:13 2016
@@ -2078,7 +2078,6 @@ public:
   /// \param StartLoc Starting location of the directive kind.
   /// \param EndLoc Ending Location of the directive.
   /// \param Clauses List of clauses.
-  /// \param AssociatedStmt Statement, associated with the directive.
   ///
   static OMPTargetEnterDataDirective *Create(const ASTContext ,
  SourceLocation StartLoc,


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


Re: [PATCH] D16261: [CUDA] Only allow __global__ on free functions and static member functions.

tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

Small diags not. LGTM otherwise.



Comment at: lib/Sema/SemaDeclAttr.cpp:3620-3629
@@ -3619,2 +3619,12 @@
   }
+  if (const auto *Method = dyn_cast(FD)) {
+if (Method->isInstance()) {
+  S.Diag(Method->getLocStart(), diag::err_kern_is_nonstatic_method)
+  << Method;
+  return;
+}
+S.Diag(Method->getLocStart(), diag::warn_kern_is_method) << Method;
+  }
+  if (FD->isInlineSpecified())
+S.Diag(FD->getLocStart(), diag::warn_kern_is_inline) << FD;
 

Perhaps we should emit diagnostics on device side only.


http://reviews.llvm.org/D16261



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


Re: [Diffusion] rL257984: [Cygwin] Use -femulated-tls by default since r257718 introduced the new pass.

On Tue, Jan 19, 2016 at 3:43 PM, NAKAMURA Takumi  wrote:
> May I push it (llvm and clang) into release_38?
> It depends on r257718.

r257718 was committed after the branch. Are you suggesting we merge that too?

This looks like a pretty significant change. Can't it wait until 3.9?


> 2016-01-16 12:48 GMT+09:00 NAKAMURA Takumi :
>> chapuni committed rL257984: [Cygwin] Use -femulated-tls by default since 
>> r257718 introduced the new pass..
>>
>> [Cygwin] Use -femulated-tls by default since r257718 introduced the new pass.
>>
>> FIXME: Add more targets to use emutls into 
>> clang/test/Driver/emulated-tls.cpp.
>> FIXME: Add cygwin tests into llvm/test/CodeGen/X86. Working in progress.
>>
>>
>> Files:
>>   /cfe/trunk/docs/ReleaseNotes.rst
>>   /cfe/trunk/lib/Driver/Tools.cpp
>>   /cfe/trunk/test/Driver/emulated-tls.cpp
>>   /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
>>
>> PATCH
>>
>> Index: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
>> ===
>> --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp   (revision 257983)
>> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp   (revision 257984)
>> @@ -12477,17 +12477,13 @@
>>
>>GlobalAddressSDNode *GA = cast(Op);
>>
>> -  // Cygwin uses emutls.
>> -  // FIXME: It may be EmulatedTLS-generic also for X86-Android.
>> -  if (Subtarget->isTargetWindowsCygwin())
>> +  if (DAG.getTarget().Options.EmulatedTLS)
>>  return LowerToTLSEmulatedModel(GA, DAG);
>>
>>const GlobalValue *GV = GA->getGlobal();
>>auto PtrVT = getPointerTy(DAG.getDataLayout());
>>
>>if (Subtarget->isTargetELF()) {
>> -if (DAG.getTarget().Options.EmulatedTLS)
>> -  return LowerToTLSEmulatedModel(GA, DAG);
>>  TLSModel::Model model = DAG.getTarget().getTLSModel(GV);
>>  switch (model) {
>>case TLSModel::GeneralDynamic:
>> Index: cfe/trunk/test/Driver/emulated-tls.cpp
>> ===
>> --- cfe/trunk/test/Driver/emulated-tls.cpp  (revision 0)
>> +++ cfe/trunk/test/Driver/emulated-tls.cpp  (revision 257984)
>> @@ -0,0 +1,5 @@
>> +// Cygwin uses emutls. Clang should pass -femulated-tls to cc1 and cc1 
>> should pass EmulatedTLS to LLVM CodeGen.
>> +// FIXME: Add more targets here to use emutls.
>> +// RUN: %clang -### -std=c++11 -target i686-pc-cygwin %s 2>&1 | FileCheck %s
>> +
>> +// CHECK: "-cc1" {{.*}}"-femulated-tls"
>> Index: cfe/trunk/docs/ReleaseNotes.rst
>> ===
>> --- cfe/trunk/docs/ReleaseNotes.rst (revision 257983)
>> +++ cfe/trunk/docs/ReleaseNotes.rst (revision 257984)
>> @@ -74,6 +74,8 @@
>>
>>  Clang's support for building native Windows programs ...
>>
>> +TLS is enabled for Cygwin defaults to -femulated-tls.
>> +
>>
>>  C Language Changes in Clang
>>  ---
>> Index: cfe/trunk/lib/Driver/Tools.cpp
>> ===
>> --- cfe/trunk/lib/Driver/Tools.cpp  (revision 257983)
>> +++ cfe/trunk/lib/Driver/Tools.cpp  (revision 257984)
>> @@ -4597,7 +4597,7 @@
>>Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names);
>>// Emulated TLS is enabled by default on Android, and can be enabled 
>> manually
>>// with -femulated-tls.
>> -  bool EmulatedTLSDefault = Triple.isAndroid();
>> +  bool EmulatedTLSDefault = Triple.isAndroid() || 
>> Triple.isWindowsCygwinEnvironment();
>>if (Args.hasFlag(options::OPT_femulated_tls, 
>> options::OPT_fno_emulated_tls,
>> EmulatedTLSDefault))
>>  CmdArgs.push_back("-femulated-tls");
>>
>> Users:
>>   chapuni (Author)
>>
>> http://reviews.llvm.org/rL257984
>>
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

tra marked 3 inline comments as done.


Comment at: lib/Sema/SemaCUDA.cpp:436
@@ +435,3 @@
+  if (CD->isTrivial())
+return true;
+

jlebar wrote:
> The test passes if I comment out this if statement.  I'm not sure if that's 
> expected; this may or may not be entirely covered below.
According to [[ 
http://en.cppreference.com/w/cpp/language/default_constructor#Trivial_default_constructor
 | CPP reference ]] trivial constructor will pass all other checks below. 


Comment at: lib/Sema/SemaCUDA.cpp:442
@@ +441,3 @@
+  // and the function body is an empty compound statement.
+  if (!(CD->isDefined() && CD->getNumParams() == 0 && CD->hasTrivialBody()))
+return false;

jlebar wrote:
> Tests pass if I comment out the isDefined check.
hasTrivialBody() would only return true if we have a body which only happens if 
function is defined. isDefined() is mostly for readability here.


Comment at: lib/Sema/SemaDecl.cpp:10186
@@ +10185,3 @@
+  const bool IsGlobal = VD->hasGlobalStorage() && !VD->isStaticLocal();
+  if (Init && IsGlobal && getLangOpts().CUDA && getLangOpts().CUDAIsDevice &&
+  (VD->hasAttr() || VD->hasAttr() ||

jlebar wrote:
> Test passes if I comment out IsGlobal or CUDAIsDevice.  (I'm not sure if you 
> care to test the latter, but the former seems important.)
IsGlobal -- all test cases were using either global or local variables. I've 
added a static __shared__ variable in the device function. Now IsGlobal check 
(or, rather !isStaticLocal() part of it) is required in order for the tests to 
succeed.

CUDAIsDevice is not triggered because all test cases are run with 
-fcuda-is-device.
It's hard to run host-side test with -verify here because I'd have to put 
#ifdef around every  'expected-error'



http://reviews.llvm.org/D15305



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


Re: r258128 - Add -Wexpansion-to-undefined: warn when using `defined` in a macro definition.

Thanks!
On Jan 19, 2016 3:34 PM, "Nico Weber"  wrote:

> I think I've fixed all warnings by now, and I've reenabled the warning for
> LLVM builds (in r258210; that commit's commit message links to the
> individual fixes.)
>
> On Tue, Jan 19, 2016 at 3:56 PM, Nico Weber  wrote:
>
>> r258181 should stop the bleeding. I'll look at fixing the warnings now.
>>
>> On Tue, Jan 19, 2016 at 3:46 PM, Nico Weber  wrote:
>>
>>> Back at my desk now, looking.
>>>
>>> On Tue, Jan 19, 2016 at 3:44 PM, Diego Novillo 
>>> wrote:
>>>


 On Tue, Jan 19, 2016 at 3:43 PM, Nico Weber  wrote:

> I mean you could pass a -Wno flag. It's undefined behavior that's
> actually causing bugs in practice; it should probably be on by default.
>

 But then you need to fix all the warnings it's producing in an llvm
 build.  That is currently blocking several folks (us included).

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


[libcxxabi] r258222 - Recommit r256322: Fix PR25898 - Check for incomplete pointers types in can_catch(...)

Author: ericwf
Date: Tue Jan 19 17:37:51 2016
New Revision: 258222

URL: http://llvm.org/viewvc/llvm-project?rev=258222=rev
Log:
Recommit r256322: Fix PR25898 - Check for incomplete pointers types in 
can_catch(...)

This patch re-commits r256322 and r256323. They were reverted due to a OS X
test failure. The test failure has been fixed by libc++ commit r258217.

This patch also adds some additional tests.

Modified:
libcxxabi/trunk/src/private_typeinfo.cpp

Modified: libcxxabi/trunk/src/private_typeinfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/private_typeinfo.cpp?rev=258222=258221=258222=diff
==
--- libcxxabi/trunk/src/private_typeinfo.cpp (original)
+++ libcxxabi/trunk/src/private_typeinfo.cpp Tue Jan 19 17:37:51 2016
@@ -34,9 +34,12 @@
 // 
 // _LIBCXX_DYNAMIC_FALLBACK is currently off by default.
 
+
+#include 
+
+
 #ifdef _LIBCXX_DYNAMIC_FALLBACK
 #include "abort_message.h"
-#include 
 #include 
 #endif
 
@@ -57,31 +60,19 @@ namespace __cxxabiv1
 
 #pragma GCC visibility push(hidden)
 
-#ifdef _LIBCXX_DYNAMIC_FALLBACK
-
 inline
 bool
 is_equal(const std::type_info* x, const std::type_info* y, bool use_strcmp)
 {
+#ifndef _WIN32
 if (!use_strcmp)
 return x == y;
 return strcmp(x->name(), y->name()) == 0;
-}
-
-#else  // !_LIBCXX_DYNAMIC_FALLBACK
-
-inline
-bool
-is_equal(const std::type_info* x, const std::type_info* y, bool)
-{
-#ifndef _WIN32
-return x == y;
 #else
 return (x == y) || (strcmp(x->name(), y->name()) == 0);
-#endif
+#endif
 }
 
-#endif  // _LIBCXX_DYNAMIC_FALLBACK
 
 // __shim_type_info
 
@@ -351,8 +342,17 @@ bool
 __pbase_type_info::can_catch(const __shim_type_info* thrown_type,
  void*&) const
 {
-return is_equal(this, thrown_type, false) ||
-   is_equal(thrown_type, (std::nullptr_t), false);
+if (is_equal(thrown_type, (std::nullptr_t), false)) return true;
+bool use_strcmp = this->__flags & (__incomplete_class_mask |
+   __incomplete_mask);
+if (!use_strcmp) {
+const __pbase_type_info* thrown_pbase = dynamic_cast(
+thrown_type);
+if (!thrown_pbase) return false;
+use_strcmp = thrown_pbase->__flags & (__incomplete_class_mask |
+  __incomplete_mask);
+}
+return is_equal(this, thrown_type, use_strcmp);
 }
 
 #ifdef __clang__


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


Re: [Diffusion] rL257984: [Cygwin] Use -femulated-tls by default since r257718 introduced the new pass.

May I push it (llvm and clang) into release_38?
It depends on r257718.

2016-01-16 12:48 GMT+09:00 NAKAMURA Takumi :
> chapuni committed rL257984: [Cygwin] Use -femulated-tls by default since 
> r257718 introduced the new pass..
>
> [Cygwin] Use -femulated-tls by default since r257718 introduced the new pass.
>
> FIXME: Add more targets to use emutls into clang/test/Driver/emulated-tls.cpp.
> FIXME: Add cygwin tests into llvm/test/CodeGen/X86. Working in progress.
>
>
> Files:
>   /cfe/trunk/docs/ReleaseNotes.rst
>   /cfe/trunk/lib/Driver/Tools.cpp
>   /cfe/trunk/test/Driver/emulated-tls.cpp
>   /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
>
> PATCH
>
> Index: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
> ===
> --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp   (revision 257983)
> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp   (revision 257984)
> @@ -12477,17 +12477,13 @@
>
>GlobalAddressSDNode *GA = cast(Op);
>
> -  // Cygwin uses emutls.
> -  // FIXME: It may be EmulatedTLS-generic also for X86-Android.
> -  if (Subtarget->isTargetWindowsCygwin())
> +  if (DAG.getTarget().Options.EmulatedTLS)
>  return LowerToTLSEmulatedModel(GA, DAG);
>
>const GlobalValue *GV = GA->getGlobal();
>auto PtrVT = getPointerTy(DAG.getDataLayout());
>
>if (Subtarget->isTargetELF()) {
> -if (DAG.getTarget().Options.EmulatedTLS)
> -  return LowerToTLSEmulatedModel(GA, DAG);
>  TLSModel::Model model = DAG.getTarget().getTLSModel(GV);
>  switch (model) {
>case TLSModel::GeneralDynamic:
> Index: cfe/trunk/test/Driver/emulated-tls.cpp
> ===
> --- cfe/trunk/test/Driver/emulated-tls.cpp  (revision 0)
> +++ cfe/trunk/test/Driver/emulated-tls.cpp  (revision 257984)
> @@ -0,0 +1,5 @@
> +// Cygwin uses emutls. Clang should pass -femulated-tls to cc1 and cc1 
> should pass EmulatedTLS to LLVM CodeGen.
> +// FIXME: Add more targets here to use emutls.
> +// RUN: %clang -### -std=c++11 -target i686-pc-cygwin %s 2>&1 | FileCheck %s
> +
> +// CHECK: "-cc1" {{.*}}"-femulated-tls"
> Index: cfe/trunk/docs/ReleaseNotes.rst
> ===
> --- cfe/trunk/docs/ReleaseNotes.rst (revision 257983)
> +++ cfe/trunk/docs/ReleaseNotes.rst (revision 257984)
> @@ -74,6 +74,8 @@
>
>  Clang's support for building native Windows programs ...
>
> +TLS is enabled for Cygwin defaults to -femulated-tls.
> +
>
>  C Language Changes in Clang
>  ---
> Index: cfe/trunk/lib/Driver/Tools.cpp
> ===
> --- cfe/trunk/lib/Driver/Tools.cpp  (revision 257983)
> +++ cfe/trunk/lib/Driver/Tools.cpp  (revision 257984)
> @@ -4597,7 +4597,7 @@
>Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names);
>// Emulated TLS is enabled by default on Android, and can be enabled 
> manually
>// with -femulated-tls.
> -  bool EmulatedTLSDefault = Triple.isAndroid();
> +  bool EmulatedTLSDefault = Triple.isAndroid() || 
> Triple.isWindowsCygwinEnvironment();
>if (Args.hasFlag(options::OPT_femulated_tls, options::OPT_fno_emulated_tls,
> EmulatedTLSDefault))
>  CmdArgs.push_back("-femulated-tls");
>
> Users:
>   chapuni (Author)
>
> http://reviews.llvm.org/rL257984
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [Diffusion] rL257984: [Cygwin] Use -femulated-tls by default since r257718 introduced the new pass.

Ah yes, I was confused. No need to pick up r257984. Sorry for the noise.

On Wed, Jan 20, 2016 at 8:54 AM Hans Wennborg  wrote:

> On Tue, Jan 19, 2016 at 3:43 PM, NAKAMURA Takumi 
> wrote:
> > May I push it (llvm and clang) into release_38?
> > It depends on r257718.
>
> r257718 was committed after the branch. Are you suggesting we merge that
> too?
>
> This looks like a pretty significant change. Can't it wait until 3.9?
>
>
> > 2016-01-16 12:48 GMT+09:00 NAKAMURA Takumi :
> >> chapuni committed rL257984: [Cygwin] Use -femulated-tls by default
> since r257718 introduced the new pass..
> >>
> >> [Cygwin] Use -femulated-tls by default since r257718 introduced the new
> pass.
> >>
> >> FIXME: Add more targets to use emutls into
> clang/test/Driver/emulated-tls.cpp.
> >> FIXME: Add cygwin tests into llvm/test/CodeGen/X86. Working in progress.
> >>
> >>
> >> Files:
> >>   /cfe/trunk/docs/ReleaseNotes.rst
> >>   /cfe/trunk/lib/Driver/Tools.cpp
> >>   /cfe/trunk/test/Driver/emulated-tls.cpp
> >>   /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
> >>
> >> PATCH
> >>
> >> Index: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
> >> ===
> >> --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp   (revision
> 257983)
> >> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp   (revision
> 257984)
> >> @@ -12477,17 +12477,13 @@
> >>
> >>GlobalAddressSDNode *GA = cast(Op);
> >>
> >> -  // Cygwin uses emutls.
> >> -  // FIXME: It may be EmulatedTLS-generic also for X86-Android.
> >> -  if (Subtarget->isTargetWindowsCygwin())
> >> +  if (DAG.getTarget().Options.EmulatedTLS)
> >>  return LowerToTLSEmulatedModel(GA, DAG);
> >>
> >>const GlobalValue *GV = GA->getGlobal();
> >>auto PtrVT = getPointerTy(DAG.getDataLayout());
> >>
> >>if (Subtarget->isTargetELF()) {
> >> -if (DAG.getTarget().Options.EmulatedTLS)
> >> -  return LowerToTLSEmulatedModel(GA, DAG);
> >>  TLSModel::Model model = DAG.getTarget().getTLSModel(GV);
> >>  switch (model) {
> >>case TLSModel::GeneralDynamic:
> >> Index: cfe/trunk/test/Driver/emulated-tls.cpp
> >> ===
> >> --- cfe/trunk/test/Driver/emulated-tls.cpp  (revision 0)
> >> +++ cfe/trunk/test/Driver/emulated-tls.cpp  (revision 257984)
> >> @@ -0,0 +1,5 @@
> >> +// Cygwin uses emutls. Clang should pass -femulated-tls to cc1 and cc1
> should pass EmulatedTLS to LLVM CodeGen.
> >> +// FIXME: Add more targets here to use emutls.
> >> +// RUN: %clang -### -std=c++11 -target i686-pc-cygwin %s 2>&1 |
> FileCheck %s
> >> +
> >> +// CHECK: "-cc1" {{.*}}"-femulated-tls"
> >> Index: cfe/trunk/docs/ReleaseNotes.rst
> >> ===
> >> --- cfe/trunk/docs/ReleaseNotes.rst (revision 257983)
> >> +++ cfe/trunk/docs/ReleaseNotes.rst (revision 257984)
> >> @@ -74,6 +74,8 @@
> >>
> >>  Clang's support for building native Windows programs ...
> >>
> >> +TLS is enabled for Cygwin defaults to -femulated-tls.
> >> +
> >>
> >>  C Language Changes in Clang
> >>  ---
> >> Index: cfe/trunk/lib/Driver/Tools.cpp
> >> ===
> >> --- cfe/trunk/lib/Driver/Tools.cpp  (revision 257983)
> >> +++ cfe/trunk/lib/Driver/Tools.cpp  (revision 257984)
> >> @@ -4597,7 +4597,7 @@
> >>Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names);
> >>// Emulated TLS is enabled by default on Android, and can be enabled
> manually
> >>// with -femulated-tls.
> >> -  bool EmulatedTLSDefault = Triple.isAndroid();
> >> +  bool EmulatedTLSDefault = Triple.isAndroid() ||
> Triple.isWindowsCygwinEnvironment();
> >>if (Args.hasFlag(options::OPT_femulated_tls,
> options::OPT_fno_emulated_tls,
> >> EmulatedTLSDefault))
> >>  CmdArgs.push_back("-femulated-tls");
> >>
> >> Users:
> >>   chapuni (Author)
> >>
> >> http://reviews.llvm.org/rL257984
> >>
> >>
> >>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r258251 - Module Debugging: Don't emit external type references to anonymous types.

On Tue, Jan 19, 2016 at 4:04 PM, Adrian Prantl  wrote:

>
> On Jan 19, 2016, at 3:52 PM, David Blaikie  wrote:
>
>
>
> On Tue, Jan 19, 2016 at 3:42 PM, Adrian Prantl via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: adrian
>> Date: Tue Jan 19 17:42:53 2016
>> New Revision: 258251
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=258251=rev
>> Log:
>> Module Debugging: Don't emit external type references to anonymous types.
>> Even if they exist in the module, they can't be matched with the forward
>> declaration in the object file.
>>
>
> They can't be matched because they're matched by (non-mangled) name?
>
>
> Yes, dsymutil and lldb use the (non-mangled) name + DeclContext (which
> includes the qualified module name).
>
> I thought at least they'd be matched by mangled name (& perhaps we need to
> emit DW_AT_linkage_name on them to make that possible)?
>
>
> Emitting the DW_AT_linkage_name and matching/indexing types based on it is
> definitely  interesting for the future (bag of dwarf ...), but currently
> LLVM doesn’t do that.
>

Even before bag-of-dwarf, it seems using mangled names might be helpful,
but I don't think I have enough context/brain-swap-space to think about it
too hard right now.


>
>
>
>> 
>>
>> Modified:
>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> cfe/trunk/test/Modules/ExtDebugInfo.cpp
>>
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=258251=258250=258251=diff
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Jan 19 17:42:53 2016
>> @@ -1536,8 +1536,9 @@ static bool shouldOmitDefinition(CodeGen
>>   const RecordDecl *RD,
>>   const LangOptions ) {
>>// Does the type exist in an imported clang module?
>> -  if (DebugTypeExtRefs && RD->isFromASTFile() && RD->getDefinition())
>> -  return true;
>> +  if (DebugTypeExtRefs && RD->isFromASTFile() && RD->getDefinition() &&
>> +  RD->isExternallyVisible())
>>
>
> Not sure if this is the right check. There might be named things that are
> static (so not externally visible) in headers?
>
>
> I used isExternallyVisible() because it implies that the type won’t have a
> mangled name, (mostly thinking about the future where this would become
> more relevant), but at the moment we can relax this to
> RD->getName().isEmpty() and worry about nonexisting mangled names later.
>

Might be more accurate.

Probably good to have a test case with a static named type in a module too,
then?


>
> -- adrian
>
>
>
>> +return true;
>>
>>if (DebugKind > CodeGenOptions::LimitedDebugInfo)
>>  return false;
>>
>> Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=258251=258250=258251=diff
>>
>> ==
>> --- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original)
>> +++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Tue Jan 19 17:42:53 2016
>> @@ -84,4 +84,13 @@ void foo() {
>>  // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, scope: ![[NS]],
>>  // CHECK-SAME: line: 16
>>
>> +// CHECK: !DIGlobalVariable(name: "GlobalUnion",
>> +// CHECK-SAME:  type: ![[GLOBAL_UNION:[0-9]+]]
>> +// CHECK: ![[GLOBAL_UNION]] = !DICompositeType(tag: DW_TAG_union_type,
>> +// CHECK-SAME:elements: !{{[0-9]+}})
>> +// CHECK: !DIGlobalVariable(name: "GlobalStruct",
>> +// CHECK-SAME:  type: ![[GLOBAL_STRUCT:[0-9]+]]
>> +// CHECK: ![[GLOBAL_STRUCT]] = !DICompositeType(tag:
>> DW_TAG_structure_type,
>> +// CHECK-SAME:elements: !{{[0-9]+}})
>> +
>>  // CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0,
>> entity: !"_ZTSN8DebugCXX6StructE", line: 24)
>>
>>
>> ___
>> 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] D15173: [Preprocessor] Fix assertion in AnnotatePreviousCachedTokens

Hi Richard,

>> +  // 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 &&
>
> Why do you only do this in one special case, rather than in the general case
> where we split a token?

Mostly because I don't know how other cases might come up here nor I
have such testcases.

Given the possible tokens in the context of this function, I tried
several variations of "..." but when dumping the tokens it's
always a combination of tok::greater and tok::greatergreater.

>> +  RemainingToken == tok::greater &&
>> +  PrevTok.getLocation().getRawEncoding() <=
>> +  PP.getLastCachedTokenLocation().getRawEncoding()) {
>
> A <= check on a source location raw encoding is pretty much meaningless if
> you don't know they have the same FileID (and even then, you should ask
> SourceManager to compare the locations).

Ok

> Can you push the "is this a cached token" check down into the preprocessor
> instead? (If we're doing token caching, how can it not be?)

Ok

>> +
>> +void Preprocessor::ReplaceCachedToken(const Token ,
>> +  SmallVectorImpl ) {
>
> It seems like this could always assume that it's replacing the most recent
> token (the one at CachedLexPos-1).

Ok, gonna rewrite to reflect that.

Thanks,

-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [Diffusion] rL257984: [Cygwin] Use -femulated-tls by default since r257718 introduced the new pass.

Glad to see that emutls is useful for Cygwin too.
The diff in rL257984 do not look like depending on rL257718.
It might work with my earlier implementation of emutls, before rL257718.
Anyway, I did not test on Cygwin, and don't care if rL257984 is in 3.8 or
not.
Thanks.


On Tue, Jan 19, 2016 at 4:01 PM, NAKAMURA Takumi 
wrote:

> Ah yes, I was confused. No need to pick up r257984. Sorry for the noise.
>
> On Wed, Jan 20, 2016 at 8:54 AM Hans Wennborg  wrote:
>
>> On Tue, Jan 19, 2016 at 3:43 PM, NAKAMURA Takumi 
>> wrote:
>> > May I push it (llvm and clang) into release_38?
>> > It depends on r257718.
>>
>> r257718 was committed after the branch. Are you suggesting we merge that
>> too?
>>
>> This looks like a pretty significant change. Can't it wait until 3.9?
>>
>>
>> > 2016-01-16 12:48 GMT+09:00 NAKAMURA Takumi :
>> >> chapuni committed rL257984: [Cygwin] Use -femulated-tls by default
>> since r257718 introduced the new pass..
>> >>
>> >> [Cygwin] Use -femulated-tls by default since r257718 introduced the
>> new pass.
>> >>
>> >> FIXME: Add more targets to use emutls into
>> clang/test/Driver/emulated-tls.cpp.
>> >> FIXME: Add cygwin tests into llvm/test/CodeGen/X86. Working in
>> progress.
>> >>
>> >>
>> >> Files:
>> >>   /cfe/trunk/docs/ReleaseNotes.rst
>> >>   /cfe/trunk/lib/Driver/Tools.cpp
>> >>   /cfe/trunk/test/Driver/emulated-tls.cpp
>> >>   /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
>> >>
>> >> PATCH
>> >>
>> >> Index: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
>> >> ===
>> >> --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp   (revision
>> 257983)
>> >> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp   (revision
>> 257984)
>> >> @@ -12477,17 +12477,13 @@
>> >>
>> >>GlobalAddressSDNode *GA = cast(Op);
>> >>
>> >> -  // Cygwin uses emutls.
>> >> -  // FIXME: It may be EmulatedTLS-generic also for X86-Android.
>> >> -  if (Subtarget->isTargetWindowsCygwin())
>> >> +  if (DAG.getTarget().Options.EmulatedTLS)
>> >>  return LowerToTLSEmulatedModel(GA, DAG);
>> >>
>> >>const GlobalValue *GV = GA->getGlobal();
>> >>auto PtrVT = getPointerTy(DAG.getDataLayout());
>> >>
>> >>if (Subtarget->isTargetELF()) {
>> >> -if (DAG.getTarget().Options.EmulatedTLS)
>> >> -  return LowerToTLSEmulatedModel(GA, DAG);
>> >>  TLSModel::Model model = DAG.getTarget().getTLSModel(GV);
>> >>  switch (model) {
>> >>case TLSModel::GeneralDynamic:
>> >> Index: cfe/trunk/test/Driver/emulated-tls.cpp
>> >> ===
>> >> --- cfe/trunk/test/Driver/emulated-tls.cpp  (revision 0)
>> >> +++ cfe/trunk/test/Driver/emulated-tls.cpp  (revision 257984)
>> >> @@ -0,0 +1,5 @@
>> >> +// Cygwin uses emutls. Clang should pass -femulated-tls to cc1 and
>> cc1 should pass EmulatedTLS to LLVM CodeGen.
>> >> +// FIXME: Add more targets here to use emutls.
>> >> +// RUN: %clang -### -std=c++11 -target i686-pc-cygwin %s 2>&1 |
>> FileCheck %s
>> >> +
>> >> +// CHECK: "-cc1" {{.*}}"-femulated-tls"
>> >> Index: cfe/trunk/docs/ReleaseNotes.rst
>> >> ===
>> >> --- cfe/trunk/docs/ReleaseNotes.rst (revision 257983)
>> >> +++ cfe/trunk/docs/ReleaseNotes.rst (revision 257984)
>> >> @@ -74,6 +74,8 @@
>> >>
>> >>  Clang's support for building native Windows programs ...
>> >>
>> >> +TLS is enabled for Cygwin defaults to -femulated-tls.
>> >> +
>> >>
>> >>  C Language Changes in Clang
>> >>  ---
>> >> Index: cfe/trunk/lib/Driver/Tools.cpp
>> >> ===
>> >> --- cfe/trunk/lib/Driver/Tools.cpp  (revision 257983)
>> >> +++ cfe/trunk/lib/Driver/Tools.cpp  (revision 257984)
>> >> @@ -4597,7 +4597,7 @@
>> >>Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names);
>> >>// Emulated TLS is enabled by default on Android, and can be
>> enabled manually
>> >>// with -femulated-tls.
>> >> -  bool EmulatedTLSDefault = Triple.isAndroid();
>> >> +  bool EmulatedTLSDefault = Triple.isAndroid() ||
>> Triple.isWindowsCygwinEnvironment();
>> >>if (Args.hasFlag(options::OPT_femulated_tls,
>> options::OPT_fno_emulated_tls,
>> >> EmulatedTLSDefault))
>> >>  CmdArgs.push_back("-femulated-tls");
>> >>
>> >> Users:
>> >>   chapuni (Author)
>> >>
>> >> http://reviews.llvm.org/rL257984
>> >>
>> >>
>> >>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

tra updated this revision to Diff 45312.
tra marked 2 inline comments as done.
tra added a comment.

Addressed Justin's comments.


http://reviews.llvm.org/D15305

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Sema/SemaCUDA.cpp
  lib/Sema/SemaDecl.cpp
  test/CodeGenCUDA/device-var-init.cu

Index: test/CodeGenCUDA/device-var-init.cu
===
--- /dev/null
+++ test/CodeGenCUDA/device-var-init.cu
@@ -0,0 +1,389 @@
+// REQUIRES: nvptx-registered-target
+
+// Make sure we don't allow dynamic initialization for device
+// variables, but accept empty constructors allowed by CUDA.
+
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -std=c++11 \
+// RUN: -fno-threadsafe-statics -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -std=c++11 \
+// RUN: -emit-llvm -DERROR_CASE -verify -o /dev/null %s
+
+#ifdef __clang__
+#include "Inputs/cuda.h"
+#endif
+
+// Base classes with different initializer variants.
+
+// trivial constructor -- allowed
+struct T {
+  int t;
+};
+
+// empty constructor
+struct EC {
+  int ec;
+  __device__ EC() {} // -- allowed
+  __device__ EC(int) {}  // -- not allowed
+};
+
+// empty templated constructor -- allowed with no arguments
+struct ETC {
+  template  __device__ ETC(T...) {}
+};
+
+// undefined constructor -- not allowed
+struct UC {
+  int uc;
+  __device__ UC();
+};
+
+// empty constructor w/ initializer list -- not allowed
+struct ECI {
+  int eci;
+  __device__ ECI() : eci(1) {}
+};
+
+// non-empty constructor -- not allowed
+struct NEC {
+  int nec;
+  __device__ NEC() { nec = 1; }
+};
+
+// no-constructor,  virtual method -- not allowed
+struct NCV {
+  int ncv;
+  __device__ virtual void vm() {}
+};
+
+// dynamic in-class field initializer -- not allowed
+__device__ int f();
+struct NCF {
+  int ncf = f();
+};
+
+// static in-class field initializer.
+struct NCFS {
+  int ncfs = 3;
+};
+
+// undefined templated constructor -- not allowed
+struct UTC {
+  template  __device__ UTC(T...);
+};
+
+// non-empty templated constructor -- not allowed
+struct NETC {
+  int netc;
+  template  __device__ NETC(T...) { netc = 1; }
+};
+
+__device__ int d_v;
+// CHECK: @d_v = addrspace(1) externally_initialized global i32 0,
+__shared__ int s_v;
+// CHECK: @s_v = addrspace(3) global i32 undef,
+__constant__ int c_v;
+// CHECK: addrspace(4) externally_initialized global i32 0,
+
+__device__ int d_v_i = 1;
+// CHECK: @d_v_i = addrspace(1) externally_initialized global i32 1,
+#ifdef ERROR_CASE
+__shared__ int s_v_i = 1;
+// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
+#endif
+__constant__ int c_v_i = 1;
+// CHECK: @c_v_i = addrspace(4) externally_initialized global i32 1,
+
+#ifdef ERROR_CASE
+__device__ int d_v_f = f();
+// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
+__shared__ int s_v_f = f();
+// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
+__constant__ int c_v_f = f();
+// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
+#endif
+
+__device__ T d_t;
+// CHECK: @d_t = addrspace(1) externally_initialized global %struct.T zeroinitializer
+__shared__ T s_t;
+// CHECK: @s_t = addrspace(3) global %struct.T undef,
+__constant__ T c_t;
+// CHECK: @c_t = addrspace(4) externally_initialized global %struct.T zeroinitializer,
+
+__device__ T d_t_i = {2};
+// CHECKL @d_t_i = addrspace(1) externally_initialized global %struct.T { i32 2 },
+#ifdef ERROR_CASE
+__shared__ T s_t_i = {2};
+// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
+#endif
+__constant__ T c_t_i = {2};
+// CHECK: @c_t_i = addrspace(4) externally_initialized global %struct.T { i32 2 },
+
+__device__ EC d_ec;
+// CHECK: @d_ec = addrspace(1) externally_initialized global %struct.EC zeroinitializer,
+__shared__ EC s_ec;
+// CHECK: @s_ec = addrspace(3) global %struct.EC undef,
+__constant__ EC c_ec;
+// CHECK: @c_ec = addrspace(4) externally_initialized global %struct.EC zeroinitializer,
+
+#if ERROR_CASE
+__device__ EC d_ec_i(3);
+// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
+__shared__ EC s_ec_i(3);
+// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
+__constant__ EC c_ec_i(3);
+// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
+
+__device__ EC d_ec_i2 = {3};
+// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
+__shared__ EC s_ec_i2 = {3};
+// expected-error@-1 {{initialization is not supported for __shared__ 

Re: [libcxxabi] r258249 - Recommit r256322: Fix PR25898 - Check for incomplete pointers types in can_catch(...)

Hi Hans,

I fixed the problem that caused Nico to revert this. I would like to
re-land this in 3.8.
This depends on libc++ commit r258217 also landing in 3.8.

@Marshall can you OK this?

/Eric

On Tue, Jan 19, 2016 at 4:42 PM, Eric Fiselier via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ericwf
> Date: Tue Jan 19 17:42:10 2016
> New Revision: 258249
>
> URL: http://llvm.org/viewvc/llvm-project?rev=258249=rev
> Log:
> Recommit r256322: Fix PR25898 - Check for incomplete pointers types in
> can_catch(...)
>
> This patch re-commits r256322 and r256323. They were reverted due to a OS X
> test failure. The test failure has been fixed by libc++ commit r258217.
>
> This patch also adds some additional tests.
>
> Added:
> libcxxabi/trunk/test/incomplete_type.sh.cpp
> Modified:
> libcxxabi/trunk/src/private_typeinfo.cpp
>
> Modified: libcxxabi/trunk/src/private_typeinfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/private_typeinfo.cpp?rev=258249=258248=258249=diff
>
> ==
> --- libcxxabi/trunk/src/private_typeinfo.cpp (original)
> +++ libcxxabi/trunk/src/private_typeinfo.cpp Tue Jan 19 17:42:10 2016
> @@ -34,9 +34,12 @@
>  //
>  // _LIBCXX_DYNAMIC_FALLBACK is currently off by default.
>
> +
> +#include 
> +
> +
>  #ifdef _LIBCXX_DYNAMIC_FALLBACK
>  #include "abort_message.h"
> -#include 
>  #include 
>  #endif
>
> @@ -57,31 +60,19 @@ namespace __cxxabiv1
>
>  #pragma GCC visibility push(hidden)
>
> -#ifdef _LIBCXX_DYNAMIC_FALLBACK
> -
>  inline
>  bool
>  is_equal(const std::type_info* x, const std::type_info* y, bool
> use_strcmp)
>  {
> +#ifndef _WIN32
>  if (!use_strcmp)
>  return x == y;
>  return strcmp(x->name(), y->name()) == 0;
> -}
> -
> -#else  // !_LIBCXX_DYNAMIC_FALLBACK
> -
> -inline
> -bool
> -is_equal(const std::type_info* x, const std::type_info* y, bool)
> -{
> -#ifndef _WIN32
> -return x == y;
>  #else
>  return (x == y) || (strcmp(x->name(), y->name()) == 0);
> -#endif
> +#endif
>  }
>
> -#endif  // _LIBCXX_DYNAMIC_FALLBACK
>
>  // __shim_type_info
>
> @@ -351,8 +342,17 @@ bool
>  __pbase_type_info::can_catch(const __shim_type_info* thrown_type,
>   void*&) const
>  {
> -return is_equal(this, thrown_type, false) ||
> -   is_equal(thrown_type, (std::nullptr_t), false);
> +if (is_equal(thrown_type, (std::nullptr_t), false)) return
> true;
> +bool use_strcmp = this->__flags & (__incomplete_class_mask |
> +   __incomplete_mask);
> +if (!use_strcmp) {
> +const __pbase_type_info* thrown_pbase = dynamic_cast __pbase_type_info*>(
> +thrown_type);
> +if (!thrown_pbase) return false;
> +use_strcmp = thrown_pbase->__flags & (__incomplete_class_mask |
> +  __incomplete_mask);
> +}
> +return is_equal(this, thrown_type, use_strcmp);
>  }
>
>  #ifdef __clang__
>
> Added: libcxxabi/trunk/test/incomplete_type.sh.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/incomplete_type.sh.cpp?rev=258249=auto
>
> ==
> --- libcxxabi/trunk/test/incomplete_type.sh.cpp (added)
> +++ libcxxabi/trunk/test/incomplete_type.sh.cpp Tue Jan 19 17:42:10 2016
> @@ -0,0 +1,172 @@
> +//===- incomplete_type.cpp
> --===//
> +//
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is dual licensed under the MIT and the University of
> Illinois Open
> +// Source Licenses. See LICENSE.TXT for details.
> +//
>
> +//===--===//
> +// http://mentorembedded.github.io/cxx-abi/abi.html#rtti-layout
> +
> +// Two abi::__pbase_type_info objects can always be compared for equality
> +// (i.e. of the types represented) or ordering by comparison of their name
> +// NTBS addresses. In addition, unless either or both have either of the
> +// incomplete flags set, equality can be tested by comparing the type_info
> +// addresses.
> +
> +// RUN: %cxx %flags %compile_flags -c %s -o %t.one.o
> +// RUN: %cxx %flags %compile_flags -c %s -o %t.two.o -DTU_ONE
> +// RUN: %cxx %flags %link_flags -o %t.exe %t.one.o %t.two.o
> +// RUN: %exec %t.exe
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +// Check that the addresses of the typeinfo differ but still compare equal
> +// via their NTBS.
> +inline void
> +AssertIncompleteTypeInfoEquals(std::type_info const& LHS, std::type_info
> const& RHS)
> +{
> +  assert( != );
> +  assert(strcmp(LHS.name(), RHS.name()) == 0);
> +}
> +
> +struct NeverDefined;
> +void ThrowNeverDefinedMP();
> +std::type_info const& ReturnTypeInfoNeverDefinedMP();
> +
> +struct IncompleteAtThrow;
> +void ThrowIncompleteMP();
> +void ThrowIncompletePP();
> +void 

Re: [PATCH] D16261: [CUDA] Only allow __global__ on free functions and static member functions.

This revision was automatically updated to reflect the committed changes.
jlebar marked 3 inline comments as done.
Closed by commit rL258263: [CUDA] Only allow __global__ on free functions and 
static member functions. (authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D16261?vs=45297=45324#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16261

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaCUDA.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/SemaCUDA/bad-attributes.cu

Index: cfe/trunk/lib/Sema/SemaCUDA.cpp
===
--- cfe/trunk/lib/Sema/SemaCUDA.cpp
+++ cfe/trunk/lib/Sema/SemaCUDA.cpp
@@ -273,12 +273,9 @@
 resolveCalleeCUDATargetConflict(Sema::CUDAFunctionTarget Target1,
 Sema::CUDAFunctionTarget Target2,
 Sema::CUDAFunctionTarget *ResolvedTarget) {
-  if (Target1 == Sema::CFT_Global && Target2 == Sema::CFT_Global) {
-// TODO: this shouldn't happen, really. Methods cannot be marked __global__.
-// Clang should detect this earlier and produce an error. Then this
-// condition can be changed to an assertion.
-return true;
-  }
+  // Only free functions and static member functions may be global.
+  assert(Target1 != Sema::CFT_Global);
+  assert(Target2 != Sema::CFT_Global);
 
   if (Target1 == Sema::CFT_HostDevice) {
 *ResolvedTarget = Target2;
Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -3617,11 +3617,21 @@
   : FixItHint());
 return;
   }
+  if (const auto *Method = dyn_cast(FD)) {
+if (Method->isInstance()) {
+  S.Diag(Method->getLocStart(), diag::err_kern_is_nonstatic_method)
+  << Method;
+  return;
+}
+S.Diag(Method->getLocStart(), diag::warn_kern_is_method) << Method;
+  }
+  // Only warn for "inline" when compiling for host, to cut down on noise.
+  if (FD->isInlineSpecified() && !S.getLangOpts().CUDAIsDevice)
+S.Diag(FD->getLocStart(), diag::warn_kern_is_inline) << FD;
 
   D->addAttr(::new (S.Context)
   CUDAGlobalAttr(Attr.getRange(), S.Context,
  Attr.getAttributeSpellingListIndex()));
-
 }
 
 static void handleGNUInlineAttr(Sema , Decl *D, const AttributeList ) {
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6403,6 +6403,8 @@
 
 def err_kern_type_not_void_return : Error<
   "kernel function type %0 must have void return type">;
+def err_kern_is_nonstatic_method : Error<
+  "kernel function %0 must be a free function or static member function">;
 def err_config_scalar_return : Error<
   "CUDA special function 'cudaConfigureCall' must have scalar return type">;
 def err_kern_call_not_global_function : Error<
@@ -6415,6 +6417,12 @@
 def warn_host_calls_from_host_device : Warning<
   "calling __host__ function %0 from __host__ __device__ function %1 can lead to runtime errors">,
   InGroup;
+def warn_kern_is_method : Extension<
+  "kernel function %0 is a member function; this may not be accepted by nvcc">,
+  InGroup;
+def warn_kern_is_inline : Warning<
+  "ignored 'inline' attribute on kernel function %0">,
+  InGroup;
 
 def warn_non_pod_vararg_with_format_string : Warning<
   "cannot pass %select{non-POD|non-trivial}0 object of type %1 to variadic "
Index: cfe/trunk/test/SemaCUDA/bad-attributes.cu
===
--- cfe/trunk/test/SemaCUDA/bad-attributes.cu
+++ cfe/trunk/test/SemaCUDA/bad-attributes.cu
@@ -4,8 +4,8 @@
 //
 // You should be able to run this file through nvcc for compatibility testing.
 //
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fcuda-is-device -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wcuda-compat -verify -DEXPECT_INLINE_WARNING %s
+// RUN: %clang_cc1 -fcuda-is-device -fsyntax-only -Wcuda-compat -verify %s
 
 #include "Inputs/cuda.h"
 
@@ -47,3 +47,15 @@
 // expected-note@-1 {{conflicting attribute is here}}
 __global__ __host__ void z12();  // expected-error {{attributes are not compatible}}
 // expected-note@-1 {{conflicting attribute is here}}
+
+struct S {
+  __global__ void foo() {};  // expected-error {{must be a free function or static member function}}
+  __global__ static void bar(); // expected-warning {{kernel function 'bar' is a member function}}
+  // Although this is implicitly inline, we shouldn't warn.
+  __global__ static void baz() {}; // expected-warning {{kernel function 'baz' is a member function}}
+};
+
+__global__ static inline void foobar() {};
+#ifdef EXPECT_INLINE_WARNING
+// 

Re: [PATCH] D16331: [CUDA] Bail, rather than crash, on va_arg in device code.

jlebar added a comment.

Fixed and submitted.


Repository:
  rL LLVM

http://reviews.llvm.org/D16331



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


Re: [PATCH] D16261: [CUDA] Only allow __global__ on free functions and static member functions.

tra added inline comments.


Comment at: lib/Sema/SemaDeclAttr.cpp:3620-3629
@@ -3619,2 +3619,12 @@
   }
+  if (const auto *Method = dyn_cast(FD)) {
+if (Method->isInstance()) {
+  S.Diag(Method->getLocStart(), diag::err_kern_is_nonstatic_method)
+  << Method;
+  return;
+}
+S.Diag(Method->getLocStart(), diag::warn_kern_is_method) << Method;
+  }
+  if (FD->isInlineSpecified())
+S.Diag(FD->getLocStart(), diag::warn_kern_is_inline) << FD;
 

jlebar wrote:
> tra wrote:
> > Perhaps we should emit diagnostics on device side only.
> Hm.  I don't feel strongly, but since we're talking about __global__ 
> functions, this seems sort of relevant for both host and device compilation?
Host-only works, too. Printing this on both host and device is a bit too much.


http://reviews.llvm.org/D16261



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


r258264 - [CUDA] Bail, rather than crash, on va_arg in device code.

Author: jlebar
Date: Tue Jan 19 18:27:00 2016
New Revision: 258264

URL: http://llvm.org/viewvc/llvm-project?rev=258264=rev
Log:
[CUDA] Bail, rather than crash, on va_arg in device code.

Reviewers: tra

Subscribers: echristo, jhen, cfe-commits

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

Added:
cfe/trunk/test/SemaCUDA/va-arg.cu
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=258264=258263=258264=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Jan 19 18:27:00 
2016
@@ -6423,6 +6423,8 @@ def warn_kern_is_method : Extension<
 def warn_kern_is_inline : Warning<
   "ignored 'inline' attribute on kernel function %0">,
   InGroup;
+def err_va_arg_in_device : Error<
+  "CUDA device code does not support va_arg">;
 
 def warn_non_pod_vararg_with_format_string : Warning<
   "cannot pass %select{non-POD|non-trivial}0 object of type %1 to variadic "

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=258264=258263=258264=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Jan 19 18:27:00 2016
@@ -11715,9 +11715,8 @@ ExprResult Sema::ActOnBlockStmtExpr(Sour
   return Result;
 }
 
-ExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc,
-Expr *E, ParsedType Ty,
-SourceLocation RPLoc) {
+ExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty,
+SourceLocation RPLoc) {
   TypeSourceInfo *TInfo;
   GetTypeFromParser(Ty, );
   return BuildVAArgExpr(BuiltinLoc, E, TInfo, RPLoc);
@@ -11729,6 +11728,15 @@ ExprResult Sema::BuildVAArgExpr(SourceLo
   Expr *OrigExpr = E;
   bool IsMS = false;
 
+  // CUDA device code does not support varargs.
+  if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
+if (const FunctionDecl *F = dyn_cast(CurContext)) {
+  CUDAFunctionTarget T = IdentifyCUDATarget(F);
+  if (T == CFT_Global || T == CFT_Device || T == CFT_HostDevice)
+return ExprError(Diag(E->getLocStart(), diag::err_va_arg_in_device));
+}
+  }
+
   // It might be a __builtin_ms_va_list. (But don't ever mark a va_arg()
   // as Microsoft ABI on an actual Microsoft platform, where
   // __builtin_ms_va_list and __builtin_va_list are the same.)

Added: cfe/trunk/test/SemaCUDA/va-arg.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/va-arg.cu?rev=258264=auto
==
--- cfe/trunk/test/SemaCUDA/va-arg.cu (added)
+++ cfe/trunk/test/SemaCUDA/va-arg.cu Tue Jan 19 18:27:00 2016
@@ -0,0 +1,28 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -fsyntax-only \
+// RUN:   -verify -DEXPECT_ERR %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only %s
+
+#include 
+#include "Inputs/cuda.h"
+
+__device__ void foo() {
+  va_list list;
+  va_arg(list, int);
+#ifdef EXPECT_ERR
+  // expected-error@-2 {{CUDA device code does not support va_arg}}
+#endif
+}
+
+void bar() {
+  va_list list;
+  va_arg(list, int);  // OK: host-only
+}
+
+__device__ void baz() {
+#if !defined(__CUDA_ARCH__)
+  va_list list;
+  va_arg(list, int);  // OK: only seen when compiling for host
+#endif
+}


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


  1   2   >