Re: [PATCH] D15999: Adding doxygen comments to the LLVM intrinsics (part 2, _wmmintrin_pclmul.h)

2016-01-24 Thread Katya Romanova via cfe-commits
kromanova added a comment.

I did some build time measurement on a big game code where the the intrisics 
are heavily used (PHC was enabled). The presence of comments didn't make any 
noticeable difference.
Sean did similar measurements without PCH and didn't see any difference in 
performance neither.


Repository:
  rL LLVM

http://reviews.llvm.org/D15999



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


[PATCH] D16524: [clang-format-vs] Fix sort include main include: Use current path for the '-assume-filename'

2016-01-24 Thread Jean-Philippe Dufraigne via cfe-commits
jeanphilippeD created this revision.
jeanphilippeD added a reviewer: djasper.
jeanphilippeD added a subscriber: cfe-commits.

clang-format sort include use the source file name to determine the "main 
include" that will be the 1st include (category 0).
Because the clang-format visual studio extension does not pass the file name 
and use the standard input, sort include cannot find a "main include":

Testing fix on llvm\tools\clang\lib\Format\Format.cpp:
Original file:
#include "clang/Format/Format.h"
...
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/Lexer.h"

Without fix, selecting the includes and running visual studio clang-format:
...
#include "clang/Basic/SourceManager.h"
#include "clang/Format/Format.h"
#include "clang/Lex/Lexer.h"

With fix, selecting the includes and running visual studio clang-format:
#include "clang/Format/Format.h"
...
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/Lexer.h"

Test 2 with main header not at the start:
Original file:
...
#include "clang/Format/Format.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/Lexer.h"

Without fix, selecting the includes and running visual studio clang-format:
...
#include "clang/Basic/SourceManager.h"
#include "clang/Format/Format.h"
#include "clang/Lex/Lexer.h"

With fix, selecting the includes and running visual studio clang-format:
#include "clang/Format/Format.h"
...
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/Lexer.h"


Caveat: My setup is not ideal for test (Visual studio 2015 only), and I am not 
familiar with visual studio extension development, but I think the changes are 
straight forward enough.
I've tested this fix building it and running it on Visual Studio 2015, but I do 
not think there would be any compatibility issue since I am using API that are 
already used in the GetDocumentParent function.

http://reviews.llvm.org/D16524

Files:
  tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs

Index: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
===
--- tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
+++ tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
@@ -202,9 +202,10 @@
 if (start >= text.Length && text.Length > 0)
 start = text.Length - 1;
 string path = GetDocumentParent(view);
+string filePath = GetDocumentPath(view);
 try
 {
-var root = XElement.Parse(RunClangFormat(text, start, length, 
path));
+var root = XElement.Parse(RunClangFormat(text, start, length, 
path, filePath));
 var edit = view.TextBuffer.CreateEdit();
 foreach (XElement replacement in 
root.Descendants("replacement"))
 {
@@ -237,7 +238,7 @@
 /// 
 /// Formats the text range starting at offset of the given length.
 /// 
-private string RunClangFormat(string text, int offset, int length, 
string path)
+private string RunClangFormat(string text, int offset, int length, 
string path, string filePath)
 {
 string vsixPath = Path.GetDirectoryName(
 typeof(ClangFormatPackage).Assembly.Location);
@@ -257,6 +258,8 @@
 if (GetSortIncludes())
   process.StartInfo.Arguments += " -sort-includes ";
 string assumeFilename = GetAssumeFilename();
+if (string.IsNullOrEmpty(assumeFilename))
+assumeFilename = filePath;
 if (!string.IsNullOrEmpty(assumeFilename))
   process.StartInfo.Arguments += " -assume-filename \"" + 
assumeFilename + "\"";
 process.StartInfo.CreateNoWindow = true;
@@ -355,5 +358,15 @@
 }
 return null;
 }
+
+private string GetDocumentPath(IWpfTextView view)
+{
+ITextDocument document;
+if 
(view.TextBuffer.Properties.TryGetProperty(typeof(ITextDocument), out document))
+{
+return document.FilePath;
+}
+return null;
+}
 }
 }


Index: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
===
--- tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
+++ tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
@@ -202,9 +202,10 @@
 if (start >= text.Length && text.Length > 0)
 start = text.Length - 1;
 string path = GetDocumentParent(view);
+string filePath = GetDocumentPath(view);
 try
 {
-var root = XElement.Parse(RunClangFormat(text, start, length, path));
+var root = XElement.Parse(RunClangFormat(text, start, length, path, filePath));
 var edit = view.TextBuffer.CreateEdit();
 foreach (XElement replacement in root.Descendants("replacement"))
 

Re: [PATCH] D8149: Extend hasType narrowing matcher for TypedefDecls, add functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes

2016-01-24 Thread Richard via cfe-commits
LegalizeAdulthood retitled this revision from "Add hasUnderlyingType narrowing 
matcher for TypedefDecls, functionProtoType matcher for FunctionProtoType 
nodes, extend parameterCountIs to FunctionProtoType nodes" to "Extend hasType 
narrowing matcher for TypedefDecls, add functionProtoType matcher for 
FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes".
LegalizeAdulthood updated this revision to Diff 45833.
LegalizeAdulthood added a comment.

Update from review comments.
Replace `hasUnderlyingType` with extension to `hasType`


http://reviews.llvm.org/D8149

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

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1091,6 +1091,16 @@
   notMatches("class X {}; void y() { X *x; }", varDecl(hasType(ClassX;
 }
 
+TEST(HasType, MatchesTypedefDecl) {
+  EXPECT_TRUE(matches("typedef int X;", typedefDecl(hasType(asString("int");
+  EXPECT_TRUE(matches("typedef const int T;",
+  typedefDecl(hasType(asString("const int");
+  EXPECT_TRUE(notMatches("typedef const int T;",
+ typedefDecl(hasType(asString("int");
+  EXPECT_TRUE(matches("typedef int foo; typedef foo bar;",
+  typedefDecl(hasType(asString("foo")), hasName("bar";
+}
+
 TEST(HasTypeLoc, MatchesDeclaratorDecls) {
   EXPECT_TRUE(matches("int x;",
   varDecl(hasName("x"), hasTypeLoc(loc(asString("int"));
@@ -1563,6 +1573,8 @@
  functionDecl(isVariadic(;
   EXPECT_TRUE(notMatches("void f();", functionDecl(isVariadic(;
   EXPECT_TRUE(notMatchesC("void f();", functionDecl(isVariadic(;
+  EXPECT_TRUE(matches("void f(...);", functionDecl(parameterCountIs(0;
+  EXPECT_TRUE(matches("void f(int, ...);", functionDecl(parameterCountIs(1;
 }
 
 TEST(FunctionTemplate, MatchesFunctionTemplateDeclarations) {
@@ -1719,6 +1731,7 @@
   EXPECT_TRUE(matches("class X { void f(int i) {} };", Function1Arg));
   EXPECT_TRUE(notMatches("void f() {}", Function1Arg));
   EXPECT_TRUE(notMatches("void f(int i, int j, int k) {}", Function1Arg));
+  EXPECT_TRUE(matches("void f(int i, ...) {};", Function1Arg));
 }
 
 TEST(Matcher, References) {
@@ -4425,6 +4438,15 @@
   EXPECT_TRUE(matches("void f(int i) {}", functionType()));
 }
 
+TEST(TypeMatching, MatchesFunctionProtoTypes) {
+  EXPECT_TRUE(matches("int (*f)(int);", functionProtoType()));
+  EXPECT_TRUE(matches("void f(int i);", functionProtoType()));
+  EXPECT_TRUE(matches("void f();", functionProtoType(parameterCountIs(0;
+  EXPECT_TRUE(notMatchesC("void f();", functionProtoType()));
+  EXPECT_TRUE(
+  matchesC("void f(void);", functionProtoType(parameterCountIs(0;
+}
+
 TEST(TypeMatching, MatchesParenType) {
   EXPECT_TRUE(
   matches("int (*array)[4];", varDecl(hasType(pointsTo(parenType());
@@ -5126,7 +5148,8 @@
   namespaceDecl(isInline(), hasName("m";
 }
 
-// FIXME: Figure out how to specify paths so the following tests pass on Windows.
+// FIXME: Figure out how to specify paths so the following tests pass on
+// Windows.
 #ifndef LLVM_ON_WIN32
 
 TEST(Matcher, IsExpansionInMainFileMatcher) {
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -182,6 +182,7 @@
   REGISTER_MATCHER(forStmt);
   REGISTER_MATCHER(friendDecl);
   REGISTER_MATCHER(functionDecl);
+  REGISTER_MATCHER(functionProtoType);
   REGISTER_MATCHER(functionTemplateDecl);
   REGISTER_MATCHER(functionType);
   REGISTER_MATCHER(gotoStmt);
Index: include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- include/clang/ASTMatchers/ASTMatchersInternal.h
+++ include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -60,6 +60,17 @@
 
 namespace internal {
 
+/// \brief Unifies obtaining the underlying type of a regular node through
+/// `getType` and a TypedefNameDecl node through `getUnderlyingType`.
+template 
+inline QualType getUnderlyingType(const NodeType &Node) {
+  return Node.getType();
+}
+
+template <> inline QualType getUnderlyingType(const TypedefDecl &Node) {
+  return Node.getUnderlyingType();
+}
+
 /// \brief Internal version of BoundNodes. Holds all the bound nodes.
 class BoundNodesMap {
 public:
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -2298,14 +2298,17 @@
 ///
 /// Example matches x (matcher = expr(hasT

[PATCH] D16526: Add hasRetValue narrowing matcher for returnStmt

2016-01-24 Thread Richard via cfe-commits
LegalizeAdulthood created this revision.
LegalizeAdulthood added a reviewer: klimek.
LegalizeAdulthood added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Add `hasRetValue` narrowing matcher for `returnStmt` so that you can match on 
the expression returned by a return stmt (or lack thereof).

Currently you can only match the type of a return value on a `functionDecl` 
with `returns`.

An example:

clanger> cat /tmp/a.cpp
void g() {
  return;
}

void f() {
  return (void) g();
}

int h() {
  return 1;
}

int j() {
  return h();
}

bool k() {
  return true;
}
~/dev/build
clanger> bin/clang-query /tmp/a.cpp -- -std=c++11
clang-query> match functionDecl(returns(voidType()))

Match #1:

/tmp/a.cpp:1:1: note: "root" binds here
void g() {
^~

Match #2:

/tmp/a.cpp:5:1: note: "root" binds here
void f() {
^~
2 matches.
clang-query> match returnStmt(unless(hasRetValue(expr(

Match #1:

/tmp/a.cpp:2:3: note: "root" binds here
  return;
  ^~
1 match.
clang-query> ^D


http://reviews.llvm.org/D16526

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

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1807,6 +1807,11 @@
   recordDecl(hasName("Y")));
 }
 
+TEST(HasRetValue, MatchesReturnExpressions) {
+  
+  EXPECT_TRUE(matches("bool f() { return true; }", 
returnStmt(hasRetValue(expr();
+}
+
 TEST(IsExternC, MatchesExternCFunctionDeclarations) {
   EXPECT_TRUE(matches("extern \"C\" void f() {}", functionDecl(isExternC(;
   EXPECT_TRUE(matches("extern \"C\" { void f() {} }",
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -235,6 +235,7 @@
   REGISTER_MATCHER(hasQualifier);
   REGISTER_MATCHER(hasRangeInit);
   REGISTER_MATCHER(hasReceiverType);
+  REGISTER_MATCHER(hasRetValue);
   REGISTER_MATCHER(hasRHS);
   REGISTER_MATCHER(hasSelector);
   REGISTER_MATCHER(hasSingleDecl);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -2977,6 +2977,14 @@
   return InnerMatcher.matches(Node.getReturnType(), Finder, Builder);
 }
 
+/// \brief Matches the return expression of a return statement.
+///
+AST_MATCHER_P(ReturnStmt, hasRetValue,
+  internal::Matcher, InnerMatcher) {
+  const Expr *const RetValue = Node.getRetValue();
+  return RetValue != nullptr && InnerMatcher.matches(*RetValue, Finder, 
Builder);
+}
+
 /// \brief Matches extern "C" function declarations.
 ///
 /// Given:
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -4607,6 +4607,12 @@
 
 
 
+MatcherReturnStmt>hasRetValueMatcherExpr> 
InnerMatcher
+Matches the return 
expression of a return statement.
+
+
+
+
 MatcherStmt>alignOfExprMatcherUnaryExprOrTypeTraitExpr>
  InnerMatcher
 Same as 
unaryExprOrTypeTraitExpr, but only matching
 alignof.


Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1807,6 +1807,11 @@
   recordDecl(hasName("Y")));
 }
 
+TEST(HasRetValue, MatchesReturnExpressions) {
+  
+  EXPECT_TRUE(matches("bool f() { return true; }", returnStmt(hasRetValue(expr();
+}
+
 TEST(IsExternC, MatchesExternCFunctionDeclarations) {
   EXPECT_TRUE(matches("extern \"C\" void f() {}", functionDecl(isExternC(;
   EXPECT_TRUE(matches("extern \"C\" { void f() {} }",
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -235,6 +235,7 @@
   REGISTER_MATCHER(hasQualifier);
   REGISTER_MATCHER(hasRangeInit);
   REGISTER_MATCHER(hasReceiverType);
+  REGISTER_MATCHER(hasRetValue);
   REGISTER_MATCHER(hasRHS);
   REGISTER_MATCHER(hasSelector);
   REGISTER_MATCHER(hasSingleDecl);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -2977,6 +297

Re: [PATCH] D16526: Add hasRetValue narrowing matcher for returnStmt

2016-01-24 Thread Richard via cfe-commits
LegalizeAdulthood updated this revision to Diff 45836.
LegalizeAdulthood added a comment.

Run clang-format


http://reviews.llvm.org/D16526

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

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1807,6 +1807,11 @@
   recordDecl(hasName("Y")));
 }
 
+TEST(HasRetValue, MatchesReturnExpressions) {
+  EXPECT_TRUE(
+  matches("bool f() { return true; }", returnStmt(hasRetValue(expr();
+}
+
 TEST(IsExternC, MatchesExternCFunctionDeclarations) {
   EXPECT_TRUE(matches("extern \"C\" void f() {}", functionDecl(isExternC(;
   EXPECT_TRUE(matches("extern \"C\" { void f() {} }",
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -235,6 +235,7 @@
   REGISTER_MATCHER(hasQualifier);
   REGISTER_MATCHER(hasRangeInit);
   REGISTER_MATCHER(hasReceiverType);
+  REGISTER_MATCHER(hasRetValue);
   REGISTER_MATCHER(hasRHS);
   REGISTER_MATCHER(hasSelector);
   REGISTER_MATCHER(hasSingleDecl);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -2977,6 +2977,14 @@
   return InnerMatcher.matches(Node.getReturnType(), Finder, Builder);
 }
 
+/// \brief Matches the return expression of a return statement.
+///
+AST_MATCHER_P(ReturnStmt, hasRetValue, internal::Matcher, InnerMatcher) {
+  const Expr *const RetValue = Node.getRetValue();
+  return RetValue != nullptr &&
+ InnerMatcher.matches(*RetValue, Finder, Builder);
+}
+
 /// \brief Matches extern "C" function declarations.
 ///
 /// Given:
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -4607,6 +4607,12 @@
 
 
 
+MatcherReturnStmt>hasRetValueMatcherExpr> 
InnerMatcher
+Matches the return 
expression of a return statement.
+
+
+
+
 MatcherStmt>alignOfExprMatcherUnaryExprOrTypeTraitExpr>
  InnerMatcher
 Same as 
unaryExprOrTypeTraitExpr, but only matching
 alignof.


Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1807,6 +1807,11 @@
   recordDecl(hasName("Y")));
 }
 
+TEST(HasRetValue, MatchesReturnExpressions) {
+  EXPECT_TRUE(
+  matches("bool f() { return true; }", returnStmt(hasRetValue(expr();
+}
+
 TEST(IsExternC, MatchesExternCFunctionDeclarations) {
   EXPECT_TRUE(matches("extern \"C\" void f() {}", functionDecl(isExternC(;
   EXPECT_TRUE(matches("extern \"C\" { void f() {} }",
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -235,6 +235,7 @@
   REGISTER_MATCHER(hasQualifier);
   REGISTER_MATCHER(hasRangeInit);
   REGISTER_MATCHER(hasReceiverType);
+  REGISTER_MATCHER(hasRetValue);
   REGISTER_MATCHER(hasRHS);
   REGISTER_MATCHER(hasSelector);
   REGISTER_MATCHER(hasSingleDecl);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -2977,6 +2977,14 @@
   return InnerMatcher.matches(Node.getReturnType(), Finder, Builder);
 }
 
+/// \brief Matches the return expression of a return statement.
+///
+AST_MATCHER_P(ReturnStmt, hasRetValue, internal::Matcher, InnerMatcher) {
+  const Expr *const RetValue = Node.getRetValue();
+  return RetValue != nullptr &&
+ InnerMatcher.matches(*RetValue, Finder, Builder);
+}
+
 /// \brief Matches extern "C" function declarations.
 ///
 /// Given:
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -4607,6 +4607,12 @@
 
 
 
+MatcherReturnStmt>hasRetValueMatcherExpr> InnerMatcher
+Matches the return expression of a return statement.
+
+
+
+

Re: [PATCH] D16526: Add hasRetValue narrowing matcher for returnStmt

2016-01-24 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.

I get the same behavior from the existing has() matcher -- how is this meant to 
differ?

clang-query> match returnStmt(unless(has(expr(

Match #1:

E:\Desktop\test4.cpp:2:3: note: "root" binds here

  return;
  ^~

clang-query> match returnStmt(has(expr(cxxBoolLiteral(

Match #1:

E:\Desktop\test4.cpp:18:3: note: "root" binds here

  return true;
  ^~~

1 match.


http://reviews.llvm.org/D16526



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


Re: [PATCH] D16517: ClangTidy check to flag uninitialized builtin and pointer fields.

2016-01-24 Thread Felix Berger via cfe-commits
flx removed rL LLVM as the repository for this revision.
flx updated this revision to Diff 45837.
flx added a comment.

Removed unused include and changed casing on Builder variable.


http://reviews.llvm.org/D16517

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/UninitializedFieldCheck.cpp
  clang-tidy/misc/UninitializedFieldCheck.h
  docs/clang-tidy/checks/misc-uninitialized-field.rst
  test/clang-tidy/misc-uninitialized-field-cxx98.cpp
  test/clang-tidy/misc-uninitialized-field.cpp

Index: test/clang-tidy/misc-uninitialized-field.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-uninitialized-field.cpp
@@ -0,0 +1,69 @@
+// RUN: %check_clang_tidy %s misc-uninitialized-field %t
+
+struct PositiveFieldBeforeConstructor {
+  int F;
+  // CHECK-FIXES: int F{};
+  PositiveFieldBeforeConstructor() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: F
+};
+
+struct PositiveFieldAfterConstructor {
+  PositiveFieldAfterConstructor() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: F, G
+  int F;
+  // CHECK-FIXES: int F{};
+  bool G /* with comment */;
+  // CHECK-FIXES: bool G{} /* with comment */;
+  PositiveFieldBeforeConstructor IgnoredField;
+};
+
+struct PositiveSeparateDefinition {
+  PositiveSeparateDefinition();
+  int F;
+  // CHECK-FIXES: int F{};
+};
+
+PositiveSeparateDefinition::PositiveSeparateDefinition() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize these built-in/pointer fields: F
+
+struct PositiveMixedFieldOrder {
+  PositiveMixedFieldOrder() : J(0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: I, K
+  int I;
+  // CHECK-FIXES: int I{};
+  int J;
+  int K;
+  // CHECK-FIXES: int K{};
+};
+
+struct NegativeFieldInitialized {
+  int F;
+
+  NegativeFieldInitialized() : F() {}
+};
+
+struct NegativeFieldInitializedInDefinition {
+  int F;
+
+  NegativeFieldInitializedInDefinition();
+};
+NegativeFieldInitializedInDefinition::NegativeFieldInitializedInDefinition() : F() {}
+
+
+struct NegativeInClassInitialized {
+  int F = 0;
+
+  NegativeInClassInitialized() {}
+};
+
+struct NegativeConstructorDelegated {
+  int F;
+
+  NegativeConstructorDelegated(int F) : F(F) {}
+  NegativeConstructorDelegated() : NegativeConstructorDelegated(0) {}
+};
+
+struct NegativeInitializedInBody {
+  NegativeInitializedInBody() { I = 0; }
+  int I;
+};
Index: test/clang-tidy/misc-uninitialized-field-cxx98.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-uninitialized-field-cxx98.cpp
@@ -0,0 +1,65 @@
+// RUN: %check_clang_tidy %s misc-uninitialized-field %t -- -- -std=c++98
+
+struct PositiveFieldBeforeConstructor {
+  int F;
+  PositiveFieldBeforeConstructor() /* some comment */ {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: F
+  // CHECK-FIXES: PositiveFieldBeforeConstructor() : F() /* some comment */ {}
+};
+
+struct PositiveFieldAfterConstructor {
+  PositiveFieldAfterConstructor() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: F, G, H
+  // CHECK-FIXES: PositiveFieldAfterConstructor() : F(), G(), H() {}
+  int F;
+  bool G /* with comment */;
+  int *H;
+  PositiveFieldBeforeConstructor IgnoredField;
+};
+
+struct PositiveSeparateDefinition {
+  PositiveSeparateDefinition();
+  int F;
+};
+
+PositiveSeparateDefinition::PositiveSeparateDefinition() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize these built-in/pointer fields: F
+// CHECK-FIXES: PositiveSeparateDefinition::PositiveSeparateDefinition() : F() {}
+
+struct PositiveMixedFieldOrder {
+  PositiveMixedFieldOrder() : /* some comment */ J(0), L(0), M(0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: I, K, N
+  // CHECK-FIXES: PositiveMixedFieldOrder() : I(), /* some comment */ J(0), K(), L(0), M(0), N() {}
+  int I;
+  int J;
+  int K;
+  int L;
+  int M;
+  int N;
+};
+
+struct PositiveAfterBaseInitializer : public PositiveMixedFieldOrder {
+  PositiveAfterBaseInitializer() : PositiveMixedFieldOrder() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: F
+  // CHECK-FIXES: PositiveAfterBaseInitializer() : PositiveMixedFieldOrder(), F() {}
+  int F;
+};
+
+struct NegativeFieldInitialized {
+  int F;
+
+  NegativeFieldInitialized() : F() {}
+};
+
+struct NegativeFieldInitializedInDefinition {
+  int F;
+
+  NegativeFieldInitializedInDefinition();
+};
+
+NegativeFieldInitializedInDefinition::NegativeFieldInitializedInDefinition() : F() {}
+
+struct NegativeInitializedInBody {
+  Negat

Re: [PATCH] D16517: ClangTidy check to flag uninitialized builtin and pointer fields.

2016-01-24 Thread Felix Berger via cfe-commits
flx updated this revision to Diff 45838.

http://reviews.llvm.org/D16517

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/UninitializedFieldCheck.cpp
  clang-tidy/misc/UninitializedFieldCheck.h
  docs/clang-tidy/checks/misc-uninitialized-field.rst
  test/clang-tidy/misc-uninitialized-field-cxx98.cpp
  test/clang-tidy/misc-uninitialized-field.cpp

Index: test/clang-tidy/misc-uninitialized-field.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-uninitialized-field.cpp
@@ -0,0 +1,69 @@
+// RUN: %check_clang_tidy %s misc-uninitialized-field %t
+
+struct PositiveFieldBeforeConstructor {
+  int F;
+  // CHECK-FIXES: int F{};
+  PositiveFieldBeforeConstructor() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: F
+};
+
+struct PositiveFieldAfterConstructor {
+  PositiveFieldAfterConstructor() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: F, G
+  int F;
+  // CHECK-FIXES: int F{};
+  bool G /* with comment */;
+  // CHECK-FIXES: bool G{} /* with comment */;
+  PositiveFieldBeforeConstructor IgnoredField;
+};
+
+struct PositiveSeparateDefinition {
+  PositiveSeparateDefinition();
+  int F;
+  // CHECK-FIXES: int F{};
+};
+
+PositiveSeparateDefinition::PositiveSeparateDefinition() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize these built-in/pointer fields: F
+
+struct PositiveMixedFieldOrder {
+  PositiveMixedFieldOrder() : J(0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: I, K
+  int I;
+  // CHECK-FIXES: int I{};
+  int J;
+  int K;
+  // CHECK-FIXES: int K{};
+};
+
+struct NegativeFieldInitialized {
+  int F;
+
+  NegativeFieldInitialized() : F() {}
+};
+
+struct NegativeFieldInitializedInDefinition {
+  int F;
+
+  NegativeFieldInitializedInDefinition();
+};
+NegativeFieldInitializedInDefinition::NegativeFieldInitializedInDefinition() : F() {}
+
+
+struct NegativeInClassInitialized {
+  int F = 0;
+
+  NegativeInClassInitialized() {}
+};
+
+struct NegativeConstructorDelegated {
+  int F;
+
+  NegativeConstructorDelegated(int F) : F(F) {}
+  NegativeConstructorDelegated() : NegativeConstructorDelegated(0) {}
+};
+
+struct NegativeInitializedInBody {
+  NegativeInitializedInBody() { I = 0; }
+  int I;
+};
Index: test/clang-tidy/misc-uninitialized-field-cxx98.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-uninitialized-field-cxx98.cpp
@@ -0,0 +1,65 @@
+// RUN: %check_clang_tidy %s misc-uninitialized-field %t -- -- -std=c++98
+
+struct PositiveFieldBeforeConstructor {
+  int F;
+  PositiveFieldBeforeConstructor() /* some comment */ {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: F
+  // CHECK-FIXES: PositiveFieldBeforeConstructor() : F() /* some comment */ {}
+};
+
+struct PositiveFieldAfterConstructor {
+  PositiveFieldAfterConstructor() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: F, G, H
+  // CHECK-FIXES: PositiveFieldAfterConstructor() : F(), G(), H() {}
+  int F;
+  bool G /* with comment */;
+  int *H;
+  PositiveFieldBeforeConstructor IgnoredField;
+};
+
+struct PositiveSeparateDefinition {
+  PositiveSeparateDefinition();
+  int F;
+};
+
+PositiveSeparateDefinition::PositiveSeparateDefinition() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize these built-in/pointer fields: F
+// CHECK-FIXES: PositiveSeparateDefinition::PositiveSeparateDefinition() : F() {}
+
+struct PositiveMixedFieldOrder {
+  PositiveMixedFieldOrder() : /* some comment */ J(0), L(0), M(0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: I, K, N
+  // CHECK-FIXES: PositiveMixedFieldOrder() : I(), /* some comment */ J(0), K(), L(0), M(0), N() {}
+  int I;
+  int J;
+  int K;
+  int L;
+  int M;
+  int N;
+};
+
+struct PositiveAfterBaseInitializer : public PositiveMixedFieldOrder {
+  PositiveAfterBaseInitializer() : PositiveMixedFieldOrder() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: F
+  // CHECK-FIXES: PositiveAfterBaseInitializer() : PositiveMixedFieldOrder(), F() {}
+  int F;
+};
+
+struct NegativeFieldInitialized {
+  int F;
+
+  NegativeFieldInitialized() : F() {}
+};
+
+struct NegativeFieldInitializedInDefinition {
+  int F;
+
+  NegativeFieldInitializedInDefinition();
+};
+
+NegativeFieldInitializedInDefinition::NegativeFieldInitializedInDefinition() : F() {}
+
+struct NegativeInitializedInBody {
+  NegativeInitializedInBody() { I = 0; }
+  int I;
+};
Index: docs/clang-tidy/checks/misc-uninitialized-field.rst

[PATCH] D16527: [OpenMP] Parsing + sema for defaultmap clause.

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

This patch adds parsing + sema for the defaultmap clause associated with the 
target directive (among others).

http://reviews.llvm.org/D16527

Files:
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/OpenMPKinds.def
  include/clang/Basic/OpenMPKinds.h
  include/clang/Sema/Sema.h
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/target_ast_print.cpp
  test/OpenMP/target_defaultmap_messages.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -2229,6 +2229,8 @@
   Visitor->AddStmt(C->getChunkSize());
   Visitor->AddStmt(C->getHelperChunkSize());
 }
+void OMPClauseEnqueue::VisitOMPDefaultmapClause(const OMPDefaultmapClause *C) {
+}
 }
 
 void EnqueueVisitor::EnqueueChildren(const OMPClause *S) {
Index: test/OpenMP/target_defaultmap_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_defaultmap_messages.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -verify -fopenmp %s
+
+void foo() {
+}
+
+template 
+T tmain(T argc, S **argv) {
+  #pragma omp target defaultmap // expected-error {{expected '(' after 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap ( // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target defaultmap () // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap (tofrom // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap (tofrom: // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap (tofrom) // expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap (tofrom scalar) // expected-warning {{missing ':' after defaultmap modifier - ignoring}}
+  foo();
+  #pragma omp target defaultmap (tofrom, // expected-error {{expected ')'}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target defaultmap (scalar: // expected-error {{expected ')'}} expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target defaultmap (tofrom, scalar // expected-error {{expected ')'}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} expected-note {{to match this '('}}
+  foo();
+
+  return argc;
+}
+
+int main(int argc, char **argv) {
+  #pragma omp target defaultmap // expected-error {{expected '(' after 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap ( // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target defaultmap () // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap (tofrom // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap (tofrom: // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap (tofrom) // expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap (tofrom scalar) // expected-warning {{missing ':' after defaultmap modifier - ignoring}}
+  foo();
+  #pragma omp target defaultmap (tofrom, // expected-error {{expected ')'}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp 

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

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

Hi pekka,
What is your opinion about this patch?
And how could we ask the release manager to squeeze this patch into LLVM 
release 3.8?
The pipe in OpneCL can only be handled by builtin functions, and this patch is 
needed for the pipe support.

Thanks
Xiuli


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] D16360: unordered_map: Avoid unnecessary mallocs when no insert occurs

2016-01-24 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Alright, so this is looking really good.  Once we land this would you be 
interested in applying the same optimization to `emplace` calls?



Comment at: include/__hash_table:863
@@ -862,2 +862,3 @@
 _LIBCPP_INLINE_VISIBILITY
-pair __insert_unique_value(_ValueTp&& __x);
+pair __insert_unique_value(_ValueTp&& __x)
+{return __insert_unique_key_value(__x, std::forward<_ValueTp>(__x));}

Woops, I know this was my suggestion, but I don't see any reason to have this 
function.

Please remove `__insert_unique_value`. Callers can call 
`__insert_unique_key_value` directly.


Comment at: include/__hash_table:875
@@ -867,1 +874,3 @@
+_LIBCPP_INLINE_VISIBILITY
+pair __insert_unique_key_value(const _ValueTp& __key, 
const _ValueTp& __x);
 #endif

Please use the following signature for this overload:

```
template 
pair __insert_unique_key_value(const _KeyTp& __key, const 
_ValueTp& __x);
```
Using `_ValueTp` twice in C++03, but `_KeyTp` in C++11 is confusing.
I understand that in C++03 `_KeyTp` should always be `_ValueTp` but it took me 
10 minutes to realize that.
 


Comment at: include/unordered_map:401
@@ -400,1 +400,3 @@
 {return static_cast(*this)(__x.__cc.first);}
+#if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+_LIBCPP_INLINE_VISIBILITY

Is there a reason your hiding these overloads in C++11 and beyond?

I would prefer as few conditional compilation blocks as possible.




Comment at: include/unordered_map:1004
@@ +1003,3 @@
+_LIBCPP_INLINE_VISIBILITY
+pair __insert_extract_key_if_pair(pair<_FirstTp, 
_SecondTp>&& __x)
+{return __insert_extract_key<_FirstTp>(_VSTD::move(__x));}

Overall the dispatch looks good, but it could be a lot simpler.  Instead of 
multi-level dispatch I would write a single trait to computer if "_Pp" is a 
keylike pair. Then `insert(_Pp&&)` just use that to call 
`__insert_extract_key_if_referenceable` directly using that trait. 

For example:
```
template ::type>
struct __is_keylike_pair : false_type {};

template 
struct __is_keylike_pair<_Key, _Pair, pair<_First, _Second> > : 
is_same::type, _Key> {};
```

We also should handle `pair<...>&` which you previously didn't have. 


http://reviews.llvm.org/D16360



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


Re: [PATCH] D16360: unordered_map: Avoid unnecessary mallocs when no insert occurs

2016-01-24 Thread Duncan P. N. Exon Smith via cfe-commits
dexonsmith added a subscriber: dexonsmith.
dexonsmith added a comment.

Great, I should have time to clean this up tomorrow afternoon.

Regarding emplace, this patch as is has tests for emplace, but
they depend on r258575 being in tree.  You asked me to revert
that... I'll wait for your response over in that thread:
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160118/147795.html

I have a few other questions inline below.


http://reviews.llvm.org/D16360



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


Re: [PATCH] D16360: unordered_map: Avoid unnecessary mallocs when no insert occurs

2016-01-24 Thread Duncan P. N. Exon Smith via cfe-commits
Great, I should have time to clean this up tomorrow afternoon.

Regarding emplace, this patch as is has tests for emplace, but
they depend on r258575 being in tree.  You asked me to revert
that... I'll wait for your response over in that thread:
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160118/147795.html

I have a few other questions inline below.

> On 2016-Jan-24, at 19:25, Eric Fiselier  wrote:
> 
> 
> 
> Comment at: include/unordered_map:401
> @@ -400,1 +400,3 @@
> {return static_cast(*this)(__x.__cc.first);}
> +#if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
> +_LIBCPP_INLINE_VISIBILITY
> 
> Is there a reason your hiding these overloads in C++11 and beyond?
> 
> I would prefer as few conditional compilation blocks as possible.

In C++11, this code is dead and untested.  Happy to drop the
conditionals though, it's tested in C++03 so it should be fine.

On second thought, I wonder if it would be possible to skip
this, and use the key directly like in C++11?  I'll take a
look.

> 
> Comment at: include/unordered_map:1004
> @@ +1003,3 @@
> +_LIBCPP_INLINE_VISIBILITY
> +pair __insert_extract_key_if_pair(pair<_FirstTp, 
> _SecondTp>&& __x)
> +{return __insert_extract_key<_FirstTp>(_VSTD::move(__x));}
> 
> Overall the dispatch looks good, but it could be a lot simpler.  Instead of 
> multi-level dispatch I would write a single trait to computer if "_Pp" is a 
> keylike pair. Then `insert(_Pp&&)` just use that to call 
> `__insert_extract_key_if_referenceable` directly using that trait. 
> 
> For example:
> ```
> template  __uncvref<_RawPair>::type>
> struct __is_keylike_pair : false_type {};
> 
> template 
> struct __is_keylike_pair<_Key, _Pair, pair<_First, _Second> > : 
> is_same::type, _Key> {};
> ```

Above the unordered_map<> definition a good place for this, or
would it be better to drop it in type_traits or some such?

> We also should handle `pair<...>&` which you previously didn't have. 

I guess that got lost when I switched away from the lazy logic
using decay.  I'll add it back.  Strange that none of the tests
failed... I guess I'll need to find a way to cover that case.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r258668 - Fixed processing of GNU extensions to C99 designated initializers

2016-01-24 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Sun Jan 24 23:14:03 2016
New Revision: 258668

URL: http://llvm.org/viewvc/llvm-project?rev=258668&view=rev
Log:
Fixed processing of GNU extensions to C99 designated initializers
Clang did not handles correctly inner parts of arrays/structures initializers 
in GNU extensions to C99 designated initializers. 

Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/CodeGen/init.c

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=258668&r1=258667&r2=258668&view=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Sun Jan 24 23:14:03 2016
@@ -2276,7 +2276,7 @@ InitListChecker::CheckDesignatedInitiali
   if (CheckDesignatedInitializer(MemberEntity, IList, DIE, DesigIdx + 1,
  FieldType, nullptr, nullptr, Index,
  StructuredList, newStructuredIndex,
- true, false))
+ FinishSubobjectInit, false))
 return true;
 }
 
@@ -2467,11 +2467,11 @@ InitListChecker::CheckDesignatedInitiali
 Index = OldIndex;
 
 ElementEntity.setElementIndex(ElementIndex);
-if (CheckDesignatedInitializer(ElementEntity, IList, DIE, DesigIdx + 1,
-   ElementType, nullptr, nullptr, Index,
-   StructuredList, ElementIndex,
-   (DesignatedStartIndex == 
DesignatedEndIndex),
-   false))
+if (CheckDesignatedInitializer(
+ElementEntity, IList, DIE, DesigIdx + 1, ElementType, nullptr,
+nullptr, Index, StructuredList, ElementIndex,
+FinishSubobjectInit && (DesignatedStartIndex == 
DesignatedEndIndex),
+false))
   return true;
 
 // Move to the next index in the array that we'll be initializing.

Modified: cfe/trunk/test/CodeGen/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/init.c?rev=258668&r1=258667&r2=258668&view=diff
==
--- cfe/trunk/test/CodeGen/init.c (original)
+++ cfe/trunk/test/CodeGen/init.c Sun Jan 24 23:14:03 2016
@@ -1,5 +1,16 @@
 // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck 
%s
 
+struct I { int k[3]; };
+struct M { struct I o[2]; };
+struct M v1[1] = { [0].o[0 ... 1].k[0 ... 1] = 4, 5 };
+unsigned v2[2][3] = {[0 ... 1][0 ... 1] = , };
+
+// CHECK-DAG: %struct.M = type { [2 x %struct.I] }
+// CHECK-DAG: %struct.I = type { [3 x i32] }
+
+// CHECK: [1 x %struct.M] [%struct.M { [2 x %struct.I] [%struct.I { [3 x i32] 
[i32 4, i32 4, i32 0] }, %struct.I { [3 x i32] [i32 4, i32 4, i32 5] }] }],
+// CHECK: [2 x [3 x i32]] {{[[][[]}}3 x i32] [i32 , i32 , i32 0], [3 x 
i32] [i32 , i32 , i32 ]],
+
 void f1() {
   // Scalars in braces.
   int a = { 1 };


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


Re: [PATCH] D16360: unordered_map: Avoid unnecessary mallocs when no insert occurs

2016-01-24 Thread Eric Fiselier via cfe-commits
On Sun, Jan 24, 2016 at 9:46 PM, Duncan P. N. Exon Smith <
dexonsm...@apple.com> wrote:

> Great, I should have time to clean this up tomorrow afternoon.
>
> Regarding emplace, this patch as is has tests for emplace, but
> they depend on r258575 being in tree.  You asked me to revert
> that... I'll wait for your response over in that thread:
>
> http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160118/147795.html
>
> I have a few other questions inline below.
>
> > On 2016-Jan-24, at 19:25, Eric Fiselier  wrote:
> >
> >
> > 
> > Comment at: include/unordered_map:401
> > @@ -400,1 +400,3 @@
> > {return static_cast(*this)(__x.__cc.first);}
> > +#if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
> > +_LIBCPP_INLINE_VISIBILITY
> > 
> > Is there a reason your hiding these overloads in C++11 and beyond?
> >
> > I would prefer as few conditional compilation blocks as possible.
>
> In C++11, this code is dead and untested.  Happy to drop the
> conditionals though, it's tested in C++03 so it should be fine.
>

It's actually not dead in C++11, its just not tested. Without this overload
the hasher will still *accept* "value_type" but it performs an implicit
conversion to __hash_value_type.
This is super bad. I think __hash_value_type's ctors should be made
explicit but I'm not sure.


> On second thought, I wonder if it would be possible to skip
> this, and use the key directly like in C++11?  I'll take a
> look.
>
> > 
> > Comment at: include/unordered_map:1004
> > @@ +1003,3 @@
> > +_LIBCPP_INLINE_VISIBILITY
> > +pair __insert_extract_key_if_pair(pair<_FirstTp,
> _SecondTp>&& __x)
> > +{return __insert_extract_key<_FirstTp>(_VSTD::move(__x));}
> > 
> > Overall the dispatch looks good, but it could be a lot simpler.  Instead
> of multi-level dispatch I would write a single trait to computer if "_Pp"
> is a keylike pair. Then `insert(_Pp&&)` just use that to call
> `__insert_extract_key_if_referenceable` directly using that trait.
> >
> > For example:
> > ```
> > template  __uncvref<_RawPair>::type>
> > struct __is_keylike_pair : false_type {};
> >
> > template 
> > struct __is_keylike_pair<_Key, _Pair, pair<_First, _Second> > :
> is_same::type, _Key> {};
> > ```
>
> Above the unordered_map<> definition a good place for this, or
> would it be better to drop it in type_traits or some such?
>

Somewhere in  is fine.


>
> > We also should handle `pair<...>&` which you previously didn't have.
>
> I guess that got lost when I switched away from the lazy logic
> using decay.  I'll add it back.  Strange that none of the tests
> failed... I guess I'll need to find a way to cover that case.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16360: unordered_map: Avoid unnecessary mallocs when no insert occurs

2016-01-24 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

In http://reviews.llvm.org/D16360#334781, @dexonsmith wrote:

> Great, I should have time to clean this up tomorrow afternoon.
>
> Regarding emplace, this patch as is has tests for emplace, but
>  they depend on r258575 being in tree.  You asked me to revert
>  that... I'll wait for your response over in that thread:
>  http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160118/147795.html


Lets talk about that here to keep it together.

I agree with your approach where `insert(_Pp&&)` dispatchs to `emplace()`.  The 
single argument emplace call should then call `__insert_extract_key_if_pair`.


http://reviews.llvm.org/D16360



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


Re: [PATCH] D16527: [OpenMP] Parsing + sema for defaultmap clause.

2016-01-24 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: include/clang/AST/OpenMPClause.h:3408-3409
@@ +3407,4 @@
+Kind(Kind), KindLoc(KLoc) {
+Modifier = M;
+ModifierLoc = MLoc;
+  }

Why these are not initialized in initializer list, along with Kind, KindLoc 
etc.?


Comment at: include/clang/AST/OpenMPClause.h:3417
@@ +3416,3 @@
+Kind(OMPC_DEFAULTMAP_unknown) {
+Modifier = OMPC_DEFAULTMAP_MODIFIER_unknown;
+  }

Also, initialize this one in initializer list


Comment at: lib/AST/StmtPrinter.cpp:925
@@ +924,3 @@
+  OS << "defaultmap(";
+  if (Node->getDefaultmapModifier() != OMPC_DEFAULTMAP_MODIFIER_unknown) {
+OS << getOpenMPSimpleClauseTypeName(OMPC_defaultmap,

I don't think that this check is required. According to defaultmap() syntax 
Modifier must be set, so I don't think it is allowed to have 'unknown' value 
here. I mean, output modifier and ':' unconditionally.


Comment at: lib/Sema/SemaOpenMP.cpp:8807
@@ +8806,3 @@
+Value += "'";
+Diag(KindLoc, diag::err_omp_unexpected_clause_value)
+<< Value << getOpenMPClauseName(OMPC_defaultmap);

I think for modifier Diag shall accept MLoc, not KindLoc


Comment at: lib/Sema/TreeTransform.h:7954-7957
@@ +7953,6 @@
+TreeTransform::TransformOMPDefaultmapClause(OMPDefaultmapClause *C) {
+  return getDerived().RebuildOMPDefaultmapClause(
+  C->getDefaultmapModifier(), C->getDefaultmapKind(), C->getLocStart(),
+  C->getLParenLoc(), C->getDefaultmapModifierLoc(),
+  C->getDefaultmapKindLoc(), C->getLocEnd());
+}

I don't think you need to rebuild anything here, you can just return C. This 
new clause does not contain any possibly dependent members.


http://reviews.llvm.org/D16527



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


Re: [PATCH] D16526: Add hasRetValue narrowing matcher for returnStmt

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

In http://reviews.llvm.org/D16526#334742, @aaron.ballman wrote:

> I get the same behavior from the existing has() matcher -- how is this meant 
> to differ?


Hmm!  Good question.  I suppose it doesn't do anything different.

I was thinking how to write such matching expressions and I looked through the 
matcher reference and the header file for things related to ReturnStmt and 
found only `returns`.  It never occurred to me to use `has`.  Not seeing 
returnStmt mentioned anywhere, it seemed that I couldn't write such matching 
expressions and needed a new matcher.

So the question remains: is it bad to have a matcher that explicitly models the 
narrowing for a return statement's return expression when you can achieve the 
same thing with `has`?


http://reviews.llvm.org/D16526



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


r258669 - Allow capture typedefs/type aliases for VLAs in lambdas/captured statements chain.

2016-01-24 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Jan 25 01:06:23 2016
New Revision: 258669

URL: http://llvm.org/viewvc/llvm-project?rev=258669&view=rev
Log:
Allow capture typedefs/type aliases for VLAs in lambdas/captured statements 
chain.
Previous it was allowed to capture VLAs/types with arrays of runtime bounds 
only inside the first lambda/capture statement in stack. Patch allows to 
capture these typedefs implicitly in chains of lambdas/captured statements.

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CodeGenCXX/lambda-expressions.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=258669&r1=258668&r2=258669&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Jan 25 01:06:23 2016
@@ -3887,14 +3887,24 @@ Sema::CreateUnaryExprOrTypeTraitExpr(Typ
 
   if (T->isVariablyModifiedType() && FunctionScopes.size() > 1) {
 if (auto *TT = T->getAs()) {
-  if (auto *CSI = dyn_cast(FunctionScopes.back())) {
+  for (auto I = FunctionScopes.rbegin(),
+E = std::prev(FunctionScopes.rend());
+   I != E; ++I) {
+auto *CSI = dyn_cast(*I);
+if (CSI == nullptr)
+  break;
 DeclContext *DC = nullptr;
-if (auto LSI = dyn_cast(CSI))
+if (auto *LSI = dyn_cast(CSI))
   DC = LSI->CallOperator;
-else if (auto CRSI = dyn_cast(CSI))
+else if (auto *CRSI = dyn_cast(CSI))
   DC = CRSI->TheCapturedDecl;
-if (DC && TT->getDecl()->getDeclContext() != DC)
+else if (auto *BSI = dyn_cast(CSI))
+  DC = BSI->TheDecl;
+if (DC) {
+  if (DC->containsDecl(TT->getDecl()))
+break;
   captureVariablyModifiedType(Context, T, CSI);
+}
   }
 }
   }

Modified: cfe/trunk/test/CodeGenCXX/lambda-expressions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/lambda-expressions.cpp?rev=258669&r1=258668&r2=258669&view=diff
==
--- cfe/trunk/test/CodeGenCXX/lambda-expressions.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/lambda-expressions.cpp Mon Jan 25 01:06:23 2016
@@ -12,12 +12,16 @@ extern "C" auto cvar = []{};
 
 // CHECK-LABEL: define i32 @_Z9ARBSizeOfi(i32
 int ARBSizeOf(int n) {
-  typedef double (T)[8][n];
-  using TT = double [8][n];
+  typedef double(T)[8][n];
+  using TT = double[8][n];
   return [&]() -> int {
 typedef double(T1)[8][n];
 using TT1 = double[8][n];
-return sizeof(T) + sizeof(T1) + sizeof(TT) + sizeof(TT1);
+return [&n]() -> int {
+  typedef double(T2)[8][n];
+  using TT2 = double[8][n];
+  return sizeof(T) + sizeof(T1) + sizeof(T2) + sizeof(TT) + sizeof(TT1) + 
sizeof(TT2);
+}();
   }();
 }
 


___
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-control-flow check

2016-01-24 Thread Richard via cfe-commits
LegalizeAdulthood updated this revision to Diff 45842.
LegalizeAdulthood added a comment.

Improve matcher to simplify callback


http://reviews.llvm.org/D16259

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/RedundantControlFlowCheck.cpp
  clang-tidy/readability/RedundantControlFlowCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-redundant-control-flow.rst
  test/clang-tidy/readability-redundant-control-flow.cpp

Index: test/clang-tidy/readability-redundant-control-flow.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-redundant-control-flow.cpp
@@ -0,0 +1,222 @@
+// RUN: %check_clang_tidy %s readability-redundant-control-flow %t
+
+void g(int i);
+void j();
+
+void f() {
+  return;
+}
+// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: redundant return statement at the end of void function [readability-redundant-control-flow]
+// CHECK-FIXES: {{^}}void f() {{{$}}
+// CHECK-FIXES-NEXT: {{^ *}$}}
+
+void g() {
+  f();
+  return;
+}
+// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: redundant return statement
+// CHECK-FIXES: {{^  }}f();{{$}}
+// CHECK-FIXES-NEXT: {{^ *}$}}
+
+void g(int i) {
+  if (i < 0) {
+return;
+  }
+  if (i < 10) {
+f();
+  }
+}
+
+int h() {
+  return 1;
+}
+
+void j() {
+}
+
+void k() {
+  for (int i = 0; i < 10; ++i) {
+continue;
+  }
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: redundant continue statement at the end of loop statement
+// CHECK-FIXES: {{^}}  for (int i = 0; i < 10; ++i) {{{$}}
+// CHECK-FIXES-NEXT: {{^ *}$}}
+
+void k2() {
+  int v[10] = { 0 };
+  for (auto i : v) {
+continue;
+  }
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: redundant continue statement
+// CHECK-FIXES: {{^}}  for (auto i : v) {{{$}}
+// CHECK-FIXES-NEXT: {{^ *}$}}
+
+void m() {
+  int i = 0;
+  do {
+++i;
+continue;
+  } while (i < 10);
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: redundant continue statement
+// CHECK-FIXES: {{^  do {$}}
+// CHECK-FIXES-NEXT: {{^}}++i;{{$}}
+// CHECK-FIXES-NEXT: {{^ *}}} while (i < 10);{{$}}
+
+void p() {
+  int i = 0;
+  while (i < 10) {
+++i;
+continue;
+  }
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: redundant continue statement
+// CHECK-FIXES: {{^}}  while (i < 10) {{{$}}
+// CHECK-FIXES-NEXT: {{^}}++i;{{$}}
+// CHECK-FIXES-NEXT: {{^ *}$}}
+
+void im_not_dead(int i) {
+  if (i > 0) {
+return;
+  }
+  g();
+}
+
+void im_still_not_dead(int i) {
+  for (int j = 0; j < 10; ++j) {
+if (i < 10) {
+  continue;
+}
+g();
+  }
+}
+
+void im_dead(int i) {
+  if (i > 0) {
+return;
+g();
+  }
+  g();
+}
+
+void im_still_dead(int i) {
+  for (int j = 0; j < 10; ++j) {
+if (i < 10) {
+  continue;
+  g();
+}
+g();
+  }
+}
+
+void void_return() {
+  return g();
+}
+
+void nested_return_unmolested() {
+  g();
+  {
+g();
+return;
+  }
+}
+
+void nested_continue_unmolested() {
+  for (int i = 0; i < 10; ++i) {
+if (i < 5) {
+  continue;
+}
+  }
+}
+
+#define MACRO_RETURN_UNMOLESTED(fn_)  \
+  (fn_)();\
+  return
+
+#define MACRO_CONTINUE_UNMOLESTED(x_) \
+  do {\
+for (int i = 0; i < (x_); ++i) {  \
+  continue;   \
+} \
+  } while (false)
+
+void macro_return() {
+  MACRO_RETURN_UNMOLESTED(g);
+}
+
+void macro_continue() {
+  MACRO_CONTINUE_UNMOLESTED(10);
+}
+
+#define MACRO_RETURN_ARG(stmt_) \
+  stmt_
+
+#define MACRO_CONTINUE_ARG(stmt_)   \
+  do {  \
+for (int i = 0; i < 10; ++i) {  \
+  stmt_;\
+}   \
+  } while (false)
+
+void macro_arg_return() {
+  MACRO_RETURN_ARG(return);
+}
+
+void macro_arg_continue() {
+  MACRO_CONTINUE_ARG(continue);
+}
+
+template 
+void template_return(T check) {
+  if (check < T(0)) {
+return;
+  }
+  return;
+}
+// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: redundant return statement
+// CHECK-FIXES: {{^}}  if (check < T(0)) {{{$}}
+// CHECK-FIXES-NEXT: {{^return;$}}
+// CHECK-FIXES-NEXT: {{^ *}$}}
+
+template <>
+void template_return(int check) {
+  if (check < 0) {
+return;
+  }
+  return;
+}
+// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: redundant return statement
+// CHECK-FIXES: {{^}}  if (check < 0) {{{$}}
+// CHECK-FIXES-NEXT: {{^return;$}}
+// CHECK-FIXES-NEXT: {{^ *}$}}
+
+template 
+void template_loop(T end) {
+  for (T i = 0; i < end; ++i) {
+continue;
+  }
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: redundant continue statement
+// CHECK-FIXES: {{^}}  for (T i = 0; i < end; ++i) {{{$}}
+// CHECK-FIXES-NEXT: {{^ *}$}}
+
+template <>
+void template_loop(int end) {
+  for (int i = 0; i < end; ++i) {
+continue;
+  }
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: redundant continue statement
+// CHECK-FIXES: {{^}}  for 

Re: r257947 - Avoid self-assignment of SmallString, trigger UB behavior down the road.

2016-01-24 Thread Richard Smith via cfe-commits
Approved for branch.
On 23 Jan 2016 11:56 p.m., "Joerg Sonnenberger" 
wrote:

> On Sat, Jan 16, 2016 at 03:51:11PM +0100, Joerg Sonnenberger via
> cfe-commits wrote:
> > Hello Richard,
> > can this be merged into 3.8? It creates some trivial noise under
> > valgrind.
>
> Ping?
>
> Joerg
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits