r274830 - Recommit r274348 and r274349. The Windows failures should be fixed.

2016-07-08 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Fri Jul  8 03:33:56 2016
New Revision: 274830

URL: http://llvm.org/viewvc/llvm-project?rev=274830&view=rev
Log:
Recommit r274348 and r274349. The Windows failures should be fixed.

Original commit message:
"Add postorder traversal support to the RecursiveASTVisitor.

This feature needs to be explicitly enabled by overriding 
shouldTraversePostOrder()
as it has performance drawbacks for the iterative Stmt-traversal.

Patch by Raphael Isemann!

Reviewed by Richard Smith and Benjamin Kramer."

Added:
cfe/trunk/unittests/AST/PostOrderASTVisitor.cpp
Modified:
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/unittests/AST/CMakeLists.txt

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=274830&r1=274829&r2=274830&view=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Fri Jul  8 03:33:56 2016
@@ -72,8 +72,8 @@ namespace clang {
   return false;
\
   } while (0)
 
-/// \brief A class that does preorder depth-first traversal on the
-/// entire Clang AST and visits each node.
+/// \brief A class that does preordor or postorder
+/// depth-first traversal on the entire Clang AST and visits each node.
 ///
 /// This class performs three distinct tasks:
 ///   1. traverse the AST (i.e. go to each node);
@@ -133,6 +133,10 @@ namespace clang {
 /// to return true, in which case all known implicit and explicit
 /// instantiations will be visited at the same time as the pattern
 /// from which they were produced.
+///
+/// By default, this visitor preorder traverses the AST. If postorder traversal
+/// is needed, the \c shouldTraversePostOrder method needs to be overriden
+/// to return \c true.
 template  class RecursiveASTVisitor {
 public:
   /// A queue used for performing data recursion over statements.
@@ -158,6 +162,9 @@ public:
   /// code, e.g., implicit constructors and destructors.
   bool shouldVisitImplicitCode() const { return false; }
 
+  /// \brief Return whether this visitor should traverse post-order.
+  bool shouldTraversePostOrder() const { return false; }
+
   /// \brief Recursively visit a statement or expression, by
   /// dispatching to Traverse*() based on the argument's dynamic type.
   ///
@@ -349,7 +356,7 @@ public:
   bool TraverseUnary##NAME(UnaryOperator *S,   
\
DataRecursionQueue *Queue = nullptr) {  
\
 TRY_TO(WalkUpFromUnary##NAME(S));  
\
-TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSubExpr());  
  \
+TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSubExpr());  
\
 return true;   
\
   }
\
   bool WalkUpFromUnary##NAME(UnaryOperator *S) {   
\
@@ -367,9 +374,10 @@ public:
 // (they're all opcodes in BinaryOperator) but do have visitors.
 #define GENERAL_BINOP_FALLBACK(NAME, BINOP_TYPE)   
\
   bool TraverseBin##NAME(BINOP_TYPE *S, DataRecursionQueue *Queue = nullptr) { 
\
-TRY_TO(WalkUpFromBin##NAME(S));
\
-TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLHS());  
  \
-TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getRHS());  
  \
+if (!getDerived().shouldTraversePostOrder())   
\
+  TRY_TO(WalkUpFromBin##NAME(S));  
\
+TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLHS());  
\
+TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getRHS());  
\
 return true;   
\
   }
\
   bool WalkUpFromBin##NAME(BINOP_TYPE *S) {
\
@@ -499,6 +507,7 @@ private:
   bool VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *Node);
 
   bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue);
+  bool PostVisitStmt(Stmt *S);
 };
 
 template 
@@ -556,6 +565,24 @@ bool RecursiveASTVisitor::dataT
 
 #undef DISPATCH_STMT
 
+
+template 
+bool RecursiveASTVisitor::PostVisitStmt(Stmt *S) {
+  switch (S->getStmtClass()) {
+  case Stmt::NoStmtClass:
+break;
+#define ABSTRACT_STMT(STMT)
+#define STMT(CLASS, PARENT)
\
+  case Stmt::CLASS##Class: 
\
+TRY_TO(WalkUpFrom##CLASS(static_cast(S))); break;
+#

Re: [PATCH] Flag to limit depth of evaluated source locations during macro expansion

2016-07-08 Thread Андрей Серебро via cfe-commits
Ping 28.06.2016, 02:41, "Андрей Серебро via cfe-commits" :Hello everyone.This patch introduces flag --max-macro-exploc-depth=, which allows to set maximum depth of expansion, on which expansion locations will be evaluated. So, if expansion goes deeper than that, no expansion locations are evaluated, which has following features:time isn't wasted on location creationssource locations are saved (running out of source locations will be less frequent)Not passing this flag just gives standard clang.I have tested the patch on boost 1.61. Compiling first 15000 files gave same compilation success with and without using the flag, so I have tested it a lot. Here is example of successful compilation with this flag and unsuccessful otherwise:clang -c -ftemplate-depth-32 -O3 -finline-functions -Wno-inline -Wall -pedantic -Wno-variadic-macros -pedantic-errors -std=c++11 -I $BOOST_1_61_HOME -max-macro-exploc-depth=0$BOOST_1_61_HOME/libs/vmd/test/test_doc_modifiers_return_type.cppHere is thread about this and some other proposals.http://clang-developers.42468.n3.nabble.com/Re-llvm-dev-Clang-Preprocessor-Speed-Up-tt4050728.htmlI attach preprocessing time for boost statistics so it's possible to see profit gained using new flag. All times there are measured in microseconds.  -- Regards, Andrei Serebrotel. +79111758381  ,___cfe-commits mailing listcfe-commits@lists.llvm.orghttp://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits  -- Regards, Andrei Serebrotel. +79111758381 ___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20867: [PCH] Fix timestamp check on windows hosts.

2016-07-08 Thread pierre gousseau via cfe-commits
pgousseau added a comment.

Ping!


http://reviews.llvm.org/D20867



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


[clang-tools-extra] r274832 - [include-fixer] Add missing namespace qualifiers after inserting a missing header.

2016-07-08 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Jul  8 04:10:29 2016
New Revision: 274832

URL: http://llvm.org/viewvc/llvm-project?rev=274832&view=rev
Log:
[include-fixer] Add missing namespace qualifiers after inserting a missing 
header.

Summary:
This is an initial version of fixing namespace issues by adding missing
namespace qualifiers to an unidentified symbol.

This version only fixes the first discovered unidentified symbol.
In the long run, include-fixer should fix all unidentified symbols
with a same name at one run.

Currently, it works on command-line tool. The vim integration is not
implemented yet.

Reviewers: klimek, bkramer, djasper

Subscribers: bkramer, ioeric, cfe-commits

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

Modified:
clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h
clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h
clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp
clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp?rev=274832&r1=274831&r2=274832&view=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Fri Jul  8 04:10:29 
2016
@@ -70,7 +70,11 @@ public:
   return false;
 
 clang::ASTContext &context = getCompilerInstance().getASTContext();
-query(T.getUnqualifiedType().getAsString(context.getPrintingPolicy()), 
Loc);
+std::string QueryString =
+T.getUnqualifiedType().getAsString(context.getPrintingPolicy());
+DEBUG(llvm::dbgs() << "Query missing complete type '" << QueryString
+   << "'");
+query(QueryString, "", tooling::Range());
 return false;
   }
 
@@ -152,32 +156,31 @@ public:
 
 /// If we have a scope specification, use that to get more precise results.
 std::string QueryString;
+tooling::Range SymbolRange;
+const auto &SM = getCompilerInstance().getSourceManager();
+auto CreateToolingRange = [&QueryString, &SM](SourceLocation BeginLoc) {
+  return tooling::Range(SM.getDecomposedLoc(BeginLoc).second,
+QueryString.size());
+};
 if (SS && SS->getRange().isValid()) {
   auto Range = CharSourceRange::getTokenRange(SS->getRange().getBegin(),
   Typo.getLoc());
 
   QueryString = ExtendNestedNameSpecifier(Range);
+  SymbolRange = CreateToolingRange(Range.getBegin());
 } else if (Typo.getName().isIdentifier() && !Typo.getLoc().isMacroID()) {
   auto Range =
   CharSourceRange::getTokenRange(Typo.getBeginLoc(), Typo.getEndLoc());
 
   QueryString = ExtendNestedNameSpecifier(Range);
+  SymbolRange = CreateToolingRange(Range.getBegin());
 } else {
   QueryString = Typo.getAsString();
+  SymbolRange = CreateToolingRange(Typo.getLoc());
 }
 
-// Follow C++ Lookup rules. Firstly, lookup the identifier with scoped
-// namespace contexts. If fails, falls back to identifier.
-// For example:
-//
-// namespace a {
-// b::foo f;
-// }
-//
-// 1. lookup a::b::foo.
-// 2. lookup b::foo.
-if (!query(TypoScopeString + QueryString, Typo.getLoc()))
-  query(QueryString, Typo.getLoc());
+DEBUG(llvm::dbgs() << "TypoScopeQualifiers: " << TypoScopeString << "\n");
+query(QueryString, TypoScopeString, SymbolRange);
 
 // FIXME: We should just return the name we got as input here and prevent
 // clang from trying to correct the typo by itself. That may change the
@@ -215,32 +218,63 @@ public:
   IncludeFixerContext
   getIncludeFixerContext(const clang::SourceManager &SourceManager,
  clang::HeaderSearch &HeaderSearch) {
-IncludeFixerContext FixerContext;
-FixerContext.SymbolIdentifier = QuerySymbol;
-for (const auto &Header : SymbolQueryResults)
-  FixerContext.Headers.push_back(
-  minimizeInclude(Header, SourceManager, HeaderSearch));
-
-return FixerContext;
+std::vector SymbolCandidates;
+for (const auto &Symbol : MatchedSymbols) {
+  std::string FilePath = Symbol.getFilePath().str();
+  std::string MinimizedFilePath = minimizeInclude(
+  ((FilePath[0] == '"' || FilePath[0] == '<') ? FilePath
+  : "\"" + FilePath + 
"\""),
+  SourceManager, HeaderSearch);
+  SymbolCandidates.emplace_back(Symbol.getName(), Symbol.getSymbolKind(),
+  

Re: [PATCH] D21603: [include-fixer] Add missing namespace qualifiers after inserting a missing header.

2016-07-08 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL274832: [include-fixer] Add missing namespace qualifiers 
after inserting a missing… (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D21603?vs=63043&id=63189#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21603

Files:
  clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
  clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h
  clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
  clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h
  clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp
  clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
  clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
  clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Index: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
===
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
@@ -82,14 +82,17 @@
   IncludeFixerContext FixerContext;
   IncludeFixerActionFactory Factory(*SymbolIndexMgr, FixerContext, "llvm");
 
-  runOnCode(&Factory, Code, "input.cc", ExtraArgs);
-  if (FixerContext.Headers.empty())
+  std::string FakeFileName = "input.cc";
+  runOnCode(&Factory, Code, FakeFileName, ExtraArgs);
+  if (FixerContext.getMatchedSymbols().empty())
 return Code;
   tooling::Replacements Replacements =
   clang::include_fixer::createInsertHeaderReplacements(
-  Code, "input.cc", FixerContext.Headers.front());
+  Code, FakeFileName, FixerContext.getHeaders().front());
   clang::RewriterTestContext Context;
-  clang::FileID ID = Context.createInMemoryFile("input.cc", Code);
+  clang::FileID ID = Context.createInMemoryFile(FakeFileName, Code);
+  if (FixerContext.getSymbolRange().getLength() > 0)
+Replacements.insert(FixerContext.createSymbolReplacement(FakeFileName, 0));
   clang::tooling::applyAllReplacements(Replacements, Context.Rewrite);
   return Context.getRewrittenText(ID);
 }
@@ -113,23 +116,17 @@
   "#include \"foo.h\"\n#include \nstd::string::size_type foo;\n",
   runIncludeFixer("#include \"foo.h\"\nstd::string::size_type foo;\n"));
 
-  // string without "std::" can also be fixed since fixed db results go through
-  // SymbolIndexManager, and SymbolIndexManager matches unqualified identifiers
-  // too.
-  EXPECT_EQ("#include \nstring foo;\n",
+  EXPECT_EQ("#include \nstd::string foo;\n",
 runIncludeFixer("string foo;\n"));
 
-  // Fully qualified name.
-  EXPECT_EQ("#include \n::std::string foo;\n",
-runIncludeFixer("::std::string foo;\n"));
   // Should not match std::string.
   EXPECT_EQ("::string foo;\n", runIncludeFixer("::string foo;\n"));
 }
 
 TEST(IncludeFixer, IncompleteType) {
   EXPECT_EQ(
   "#include \"foo.h\"\n#include \n"
-  "namespace std {\nclass string;\n}\nstring foo;\n",
+  "namespace std {\nclass string;\n}\nstd::string foo;\n",
   runIncludeFixer("#include \"foo.h\"\n"
   "namespace std {\nclass string;\n}\nstring foo;\n"));
 }
@@ -186,7 +183,7 @@
 runIncludeFixer("namespace A { c::b::bar b; }\n"));
   // FIXME: The header should not be added here. Remove this after we support
   // full match.
-  EXPECT_EQ("#include \"bar.h\"\nnamespace A {\nb::bar b;\n}",
+  EXPECT_EQ("#include \"bar.h\"\nnamespace A {\na::b::bar b;\n}",
 runIncludeFixer("namespace A {\nb::bar b;\n}"));
 }
 
@@ -221,6 +218,44 @@
 runIncludeFixer("a::Vector v;"));
 }
 
+TEST(IncludeFixer, FixNamespaceQualifiers) {
+  EXPECT_EQ("#include \"bar.h\"\na::b::bar b;\n",
+runIncludeFixer("b::bar b;\n"));
+  EXPECT_EQ("#include \"bar.h\"\na::b::bar b;\n",
+runIncludeFixer("a::b::bar b;\n"));
+  EXPECT_EQ("#include \"bar.h\"\na::b::bar b;\n",
+runIncludeFixer("bar b;\n"));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nb::bar b;\n}\n",
+runIncludeFixer("namespace a {\nb::bar b;\n}\n"));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nb::bar b;\n}\n",
+runIncludeFixer("namespace a {\nbar b;\n}\n"));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nnamespace b{\nbar b;\n}\n}\n",
+runIncludeFixer("namespace a {\nnamespace b{\nbar b;\n}\n}\n"));
+  EXPECT_EQ("c::b::bar b;\n",
+runIncludeFixer("c::b::bar b;\n"));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace c {\na::b::bar b;\n}\n",
+runIncludeFixer("namespace c {\nbar b;\n}\n"));
+
+  // Test nested classes.
+  EXPECT_EQ("#include \"bar.h\"\nnamespace c {\na::b::bar::t b;\n}\n",
+runIncludeFixer("namespace c {\nbar::t b;\n}\n"));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nb::bar::t b;\n}\n",
+runIncludeFixer("namespace a {\nbar::t b;\n}\n"));
+
+  EXPECT_EQ(
+

[PATCH] D22127: [include-fixer] Don't add qualifiers to symbols which have global scope operator.

2016-07-08 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: bkramer.
hokein added a subscriber: cfe-commits.

http://reviews.llvm.org/D22127

Files:
  include-fixer/IncludeFixerContext.h
  unittests/include-fixer/IncludeFixerTest.cpp

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -242,18 +242,18 @@
   EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nb::bar::t b;\n}\n",
 runIncludeFixer("namespace a {\nbar::t b;\n}\n"));
 
-  EXPECT_EQ(
-  "#include \"color.h\"\nint test = a::b::Green;\n",
-  runIncludeFixer("int test = Green;\n"));
+  EXPECT_EQ("#include \"color.h\"\nint test = a::b::Green;\n",
+runIncludeFixer("int test = Green;\n"));
   EXPECT_EQ("#include \"color.h\"\nnamespace d {\nint test = 
a::b::Green;\n}\n",
 runIncludeFixer("namespace d {\nint test = Green;\n}\n"));
   EXPECT_EQ("#include \"color.h\"\nnamespace a {\nint test = b::Green;\n}\n",
 runIncludeFixer("namespace a {\nint test = Green;\n}\n"));
 
-  // FIXME: Fix-namespace should not fix the global qualified identifier.
-  EXPECT_EQ(
-  "#include \"bar.h\"\na::b::bar b;\n",
-  runIncludeFixer("::a::b::bar b;\n"));
+  // Test global scope operator.
+  EXPECT_EQ("#include \"bar.h\"\n::a::b::bar b;\n",
+runIncludeFixer("::a::b::bar b;\n"));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a {\n::a::b::bar b;\n}\n",
+runIncludeFixer("namespace a {\n::a::b::bar b;\n}\n"));
 }
 
 } // namespace
Index: include-fixer/IncludeFixerContext.h
===
--- include-fixer/IncludeFixerContext.h
+++ include-fixer/IncludeFixerContext.h
@@ -44,6 +44,10 @@
   tooling::Replacement createSymbolReplacement(llvm::StringRef FilePath,
size_t Idx = 0) {
 assert(Idx < MatchedSymbols.size());
+// No need to add missing qualifiers if SymbolIndentifer has a global scope
+// operator "::".
+if (getSymbolIdentifier().startswith("::"))
+  return tooling::Replacement();
 std::string QualifiedName = MatchedSymbols[Idx].getQualifiedName();
 // For nested classes, the qualified name constructed from database misses
 // some stripped qualifiers, because when we search a symbol in database,


Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -242,18 +242,18 @@
   EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nb::bar::t b;\n}\n",
 runIncludeFixer("namespace a {\nbar::t b;\n}\n"));
 
-  EXPECT_EQ(
-  "#include \"color.h\"\nint test = a::b::Green;\n",
-  runIncludeFixer("int test = Green;\n"));
+  EXPECT_EQ("#include \"color.h\"\nint test = a::b::Green;\n",
+runIncludeFixer("int test = Green;\n"));
   EXPECT_EQ("#include \"color.h\"\nnamespace d {\nint test = a::b::Green;\n}\n",
 runIncludeFixer("namespace d {\nint test = Green;\n}\n"));
   EXPECT_EQ("#include \"color.h\"\nnamespace a {\nint test = b::Green;\n}\n",
 runIncludeFixer("namespace a {\nint test = Green;\n}\n"));
 
-  // FIXME: Fix-namespace should not fix the global qualified identifier.
-  EXPECT_EQ(
-  "#include \"bar.h\"\na::b::bar b;\n",
-  runIncludeFixer("::a::b::bar b;\n"));
+  // Test global scope operator.
+  EXPECT_EQ("#include \"bar.h\"\n::a::b::bar b;\n",
+runIncludeFixer("::a::b::bar b;\n"));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a {\n::a::b::bar b;\n}\n",
+runIncludeFixer("namespace a {\n::a::b::bar b;\n}\n"));
 }
 
 } // namespace
Index: include-fixer/IncludeFixerContext.h
===
--- include-fixer/IncludeFixerContext.h
+++ include-fixer/IncludeFixerContext.h
@@ -44,6 +44,10 @@
   tooling::Replacement createSymbolReplacement(llvm::StringRef FilePath,
size_t Idx = 0) {
 assert(Idx < MatchedSymbols.size());
+// No need to add missing qualifiers if SymbolIndentifer has a global scope
+// operator "::".
+if (getSymbolIdentifier().startswith("::"))
+  return tooling::Replacement();
 std::string QualifiedName = MatchedSymbols[Idx].getQualifiedName();
 // For nested classes, the qualified name constructed from database misses
 // some stripped qualifiers, because when we search a symbol in database,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21799: [ASTMatchers] Add missing forEachArgumentWithParam() to code sample

2016-07-08 Thread Alexander Kornienko via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL274835: [ASTMatchers] Add missing forEachArgumentWithParam() 
to code sample (authored by alexfh).

Changed prior to commit:
  http://reviews.llvm.org/D21799?vs=62103&id=63196#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21799

Files:
  cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h

Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
===
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
@@ -3186,8 +3186,11 @@
 ///   int y;
 ///   f(y);
 /// \endcode
-/// callExpr(declRefExpr(to(varDecl(hasName("y",
-/// parmVarDecl(hasType(isInteger(
+/// callExpr(
+///   forEachArgumentWithParam(
+/// declRefExpr(to(varDecl(hasName("y",
+/// parmVarDecl(hasType(isInteger()))
+/// ))
 ///   matches f(y);
 /// with declRefExpr(...)
 ///   matching int y


Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
===
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
@@ -3186,8 +3186,11 @@
 ///   int y;
 ///   f(y);
 /// \endcode
-/// callExpr(declRefExpr(to(varDecl(hasName("y",
-/// parmVarDecl(hasType(isInteger(
+/// callExpr(
+///   forEachArgumentWithParam(
+/// declRefExpr(to(varDecl(hasName("y",
+/// parmVarDecl(hasType(isInteger()))
+/// ))
 ///   matches f(y);
 /// with declRefExpr(...)
 ///   matching int y
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21895: CFGBuilder: Fix crash when visiting a range-based for over a dependent type

2016-07-08 Thread Alexander Kornienko via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL274834: CFGBuilder: Fix crash when visiting a range-based 
for over a dependent type (authored by alexfh).

Changed prior to commit:
  http://reviews.llvm.org/D21895?vs=62374&id=63194#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21895

Files:
  cfe/trunk/lib/Analysis/CFG.cpp
  cfe/trunk/unittests/Analysis/CFGTest.cpp
  cfe/trunk/unittests/Analysis/CMakeLists.txt
  cfe/trunk/unittests/CMakeLists.txt

Index: cfe/trunk/lib/Analysis/CFG.cpp
===
--- cfe/trunk/lib/Analysis/CFG.cpp
+++ cfe/trunk/lib/Analysis/CFG.cpp
@@ -3457,6 +3457,8 @@
 // continue statements.
 Block = nullptr;
 Succ = addStmt(S->getInc());
+if (badCFG)
+  return nullptr;
 ContinueJumpTarget = JumpTarget(Succ, ContinueScopePos);
 
 // The starting block for the loop increment is the block that should
Index: cfe/trunk/unittests/Analysis/CFGTest.cpp
===
--- cfe/trunk/unittests/Analysis/CFGTest.cpp
+++ cfe/trunk/unittests/Analysis/CFGTest.cpp
@@ -0,0 +1,58 @@
+//===- unittests/Analysis/CFGTest.cpp - CFG tests -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Analysis/CFG.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+
+namespace clang {
+namespace analysis {
+namespace {
+
+// Constructing a CFG for a range-based for over a dependent type fails (but
+// should not crash).
+TEST(CFG, RangeBasedForOverDependentType) {
+  const char *Code = "class Foo;\n"
+ "template \n"
+ "void f(const T &Range) {\n"
+ "  for (const Foo *TheFoo : Range) {\n"
+ "  }\n"
+ "}\n";
+
+  class CFGCallback : public ast_matchers::MatchFinder::MatchCallback {
+  public:
+bool SawFunctionBody = false;
+
+void run(const ast_matchers::MatchFinder::MatchResult &Result) override {
+  const auto *Func = Result.Nodes.getNodeAs("func");
+  Stmt *Body = Func->getBody();
+  if (!Body)
+return;
+  SawFunctionBody = true;
+  std::unique_ptr cfg =
+  CFG::buildCFG(nullptr, Body, Result.Context, CFG::BuildOptions());
+  EXPECT_EQ(nullptr, cfg);
+}
+  } Callback;
+
+  ast_matchers::MatchFinder Finder;
+  Finder.addMatcher(ast_matchers::functionDecl().bind("func"), &Callback);
+  std::unique_ptr Factory(
+  tooling::newFrontendActionFactory(&Finder));
+  std::vector Args = {"-std=c++11"};
+  ASSERT_TRUE(tooling::runToolOnCodeWithArgs(Factory->create(), Code, Args));
+  EXPECT_TRUE(Callback.SawFunctionBody);
+}
+
+} // namespace
+} // namespace analysis
+} // namespace clang
Index: cfe/trunk/unittests/Analysis/CMakeLists.txt
===
--- cfe/trunk/unittests/Analysis/CMakeLists.txt
+++ cfe/trunk/unittests/Analysis/CMakeLists.txt
@@ -0,0 +1,13 @@
+set(LLVM_LINK_COMPONENTS
+  Support
+  )
+
+add_clang_unittest(CFGTests
+  CFGTest.cpp
+  )
+
+target_link_libraries(CFGTests
+  clangAnalysis
+  clangASTMatchers
+  clangTooling
+  )
Index: cfe/trunk/unittests/CMakeLists.txt
===
--- cfe/trunk/unittests/CMakeLists.txt
+++ cfe/trunk/unittests/CMakeLists.txt
@@ -13,6 +13,7 @@
 add_subdirectory(Lex)
 add_subdirectory(Driver)
 if(CLANG_ENABLE_STATIC_ANALYZER)
+  add_subdirectory(Analysis)
   add_subdirectory(StaticAnalyzer)
   add_subdirectory(Frontend)
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r274835 - [ASTMatchers] Add missing forEachArgumentWithParam() to code sample

2016-07-08 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Jul  8 05:51:00 2016
New Revision: 274835

URL: http://llvm.org/viewvc/llvm-project?rev=274835&view=rev
Log:
[ASTMatchers] Add missing forEachArgumentWithParam() to code sample

Reviewers: klimek

Subscribers: cfe-commits, klimek

Patch by Martin Boehme!

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

Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=274835&r1=274834&r2=274835&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Fri Jul  8 05:51:00 2016
@@ -3186,8 +3186,11 @@ AST_MATCHER_P2(FunctionDecl, hasParamete
 ///   int y;
 ///   f(y);
 /// \endcode
-/// callExpr(declRefExpr(to(varDecl(hasName("y",
-/// parmVarDecl(hasType(isInteger(
+/// callExpr(
+///   forEachArgumentWithParam(
+/// declRefExpr(to(varDecl(hasName("y",
+/// parmVarDecl(hasType(isInteger()))
+/// ))
 ///   matches f(y);
 /// with declRefExpr(...)
 ///   matching int y


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


r274834 - CFGBuilder: Fix crash when visiting a range-based for over a dependent type

2016-07-08 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Jul  8 05:50:51 2016
New Revision: 274834

URL: http://llvm.org/viewvc/llvm-project?rev=274834&view=rev
Log:
CFGBuilder: Fix crash when visiting a range-based for over a dependent type

Summary:
CFG generation is expected to fail in this case, but it should not crash.

Also added a test that reproduces the crash.

Reviewers: klimek

Subscribers: cfe-commits

Patch by Martin Boehme!

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

Added:
cfe/trunk/unittests/Analysis/
cfe/trunk/unittests/Analysis/CFGTest.cpp
cfe/trunk/unittests/Analysis/CMakeLists.txt
Modified:
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/unittests/CMakeLists.txt

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=274834&r1=274833&r2=274834&view=diff
==
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Fri Jul  8 05:50:51 2016
@@ -3457,6 +3457,8 @@ CFGBlock *CFGBuilder::VisitCXXForRangeSt
 // continue statements.
 Block = nullptr;
 Succ = addStmt(S->getInc());
+if (badCFG)
+  return nullptr;
 ContinueJumpTarget = JumpTarget(Succ, ContinueScopePos);
 
 // The starting block for the loop increment is the block that should

Added: cfe/trunk/unittests/Analysis/CFGTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Analysis/CFGTest.cpp?rev=274834&view=auto
==
--- cfe/trunk/unittests/Analysis/CFGTest.cpp (added)
+++ cfe/trunk/unittests/Analysis/CFGTest.cpp Fri Jul  8 05:50:51 2016
@@ -0,0 +1,58 @@
+//===- unittests/Analysis/CFGTest.cpp - CFG tests 
-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Analysis/CFG.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+
+namespace clang {
+namespace analysis {
+namespace {
+
+// Constructing a CFG for a range-based for over a dependent type fails (but
+// should not crash).
+TEST(CFG, RangeBasedForOverDependentType) {
+  const char *Code = "class Foo;\n"
+ "template \n"
+ "void f(const T &Range) {\n"
+ "  for (const Foo *TheFoo : Range) {\n"
+ "  }\n"
+ "}\n";
+
+  class CFGCallback : public ast_matchers::MatchFinder::MatchCallback {
+  public:
+bool SawFunctionBody = false;
+
+void run(const ast_matchers::MatchFinder::MatchResult &Result) override {
+  const auto *Func = Result.Nodes.getNodeAs("func");
+  Stmt *Body = Func->getBody();
+  if (!Body)
+return;
+  SawFunctionBody = true;
+  std::unique_ptr cfg =
+  CFG::buildCFG(nullptr, Body, Result.Context, CFG::BuildOptions());
+  EXPECT_EQ(nullptr, cfg);
+}
+  } Callback;
+
+  ast_matchers::MatchFinder Finder;
+  Finder.addMatcher(ast_matchers::functionDecl().bind("func"), &Callback);
+  std::unique_ptr Factory(
+  tooling::newFrontendActionFactory(&Finder));
+  std::vector Args = {"-std=c++11"};
+  ASSERT_TRUE(tooling::runToolOnCodeWithArgs(Factory->create(), Code, Args));
+  EXPECT_TRUE(Callback.SawFunctionBody);
+}
+
+} // namespace
+} // namespace analysis
+} // namespace clang

Added: cfe/trunk/unittests/Analysis/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Analysis/CMakeLists.txt?rev=274834&view=auto
==
--- cfe/trunk/unittests/Analysis/CMakeLists.txt (added)
+++ cfe/trunk/unittests/Analysis/CMakeLists.txt Fri Jul  8 05:50:51 2016
@@ -0,0 +1,13 @@
+set(LLVM_LINK_COMPONENTS
+  Support
+  )
+
+add_clang_unittest(CFGTests
+  CFGTest.cpp
+  )
+
+target_link_libraries(CFGTests
+  clangAnalysis
+  clangASTMatchers
+  clangTooling
+  )

Modified: cfe/trunk/unittests/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/CMakeLists.txt?rev=274834&r1=274833&r2=274834&view=diff
==
--- cfe/trunk/unittests/CMakeLists.txt (original)
+++ cfe/trunk/unittests/CMakeLists.txt Fri Jul  8 05:50:51 2016
@@ -13,6 +13,7 @@ add_subdirectory(Basic)
 add_subdirectory(Lex)
 add_subdirectory(Driver)
 if(CLANG_ENABLE_STATIC_ANALYZER)
+  add_subdirectory(Analysis)
   add_subdirectory(StaticAnalyzer)
   add_subdirectory(Frontend)
 endif()


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


[PATCH] D22128: Make CastExpr::getSubExprAsWritten look through implicit temporary under CK_ConstructorConversion

2016-07-08 Thread Stephan Bergmann via cfe-commits
sberg created this revision.
sberg added a reviewer: rsmith.
sberg added a subscriber: cfe-commits.
Herald added a subscriber: aemerson.

With

> struct S1 {};
> struct S2 { operator S1(); };
> S1 f(S2 s) { return static_cast(s); }

the static_cast expr is

> CXXStaticCastExpr 0x... 'struct S1' static_cast 
> 
> `-CXXConstructExpr 0x... 'struct S1' 'void (struct S1 &&) noexcept' elidable
>   `-MaterializeTemporaryExpr 0x... 'struct S1' xvalue
> `-ImplicitCastExpr 0x... 'struct S1' 
>   `-CXXMemberCallExpr 0x... 'struct S1'
> `-MemberExpr 0x... '' .operator S1 0x...
>   `-DeclRefExpr 0x... 'struct S2' lvalue ParmVar 0x... 's' 'struct S2'

getSubExprAsWritten used to return the MaterializeTemporaryExpr (of type S1) 
under the CXXConstructExpr, instead of unwinding further to the DeclRefExpr (of 
type S2) at the bottom.

http://reviews.llvm.org/D22128

Files:
  lib/AST/Expr.cpp

Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -1602,25 +1602,32 @@
   llvm_unreachable("Unhandled cast kind!");
 }
 
+namespace {
+  Expr *skipImplicitTemporary(Expr *expr) {
+// Skip through reference binding to temporary.
+if (MaterializeTemporaryExpr *Materialize
+  = dyn_cast(expr))
+  expr = Materialize->GetTemporaryExpr();
+
+// Skip any temporary bindings; they're implicit.
+if (CXXBindTemporaryExpr *Binder = dyn_cast(expr))
+  expr = Binder->getSubExpr();
+
+return expr;
+  }
+}
+
 Expr *CastExpr::getSubExprAsWritten() {
   Expr *SubExpr = nullptr;
   CastExpr *E = this;
   do {
-SubExpr = E->getSubExpr();
+SubExpr = skipImplicitTemporary(E->getSubExpr());
 
-// Skip through reference binding to temporary.
-if (MaterializeTemporaryExpr *Materialize 
-  = 
dyn_cast(SubExpr))
-  SubExpr = Materialize->GetTemporaryExpr();
-
-// Skip any temporary bindings; they're implicit.
-if (CXXBindTemporaryExpr *Binder = dyn_cast(SubExpr))
-  SubExpr = Binder->getSubExpr();
-
 // Conversions by constructor and conversion functions have a
 // subexpression describing the call; strip it off.
 if (E->getCastKind() == CK_ConstructorConversion)
-  SubExpr = cast(SubExpr)->getArg(0);
+  SubExpr =
+skipImplicitTemporary(cast(SubExpr)->getArg(0));
 else if (E->getCastKind() == CK_UserDefinedConversion) {
   assert((isa(SubExpr) ||
   isa(SubExpr)) &&


Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -1602,25 +1602,32 @@
   llvm_unreachable("Unhandled cast kind!");
 }
 
+namespace {
+  Expr *skipImplicitTemporary(Expr *expr) {
+// Skip through reference binding to temporary.
+if (MaterializeTemporaryExpr *Materialize
+  = dyn_cast(expr))
+  expr = Materialize->GetTemporaryExpr();
+
+// Skip any temporary bindings; they're implicit.
+if (CXXBindTemporaryExpr *Binder = dyn_cast(expr))
+  expr = Binder->getSubExpr();
+
+return expr;
+  }
+}
+
 Expr *CastExpr::getSubExprAsWritten() {
   Expr *SubExpr = nullptr;
   CastExpr *E = this;
   do {
-SubExpr = E->getSubExpr();
+SubExpr = skipImplicitTemporary(E->getSubExpr());
 
-// Skip through reference binding to temporary.
-if (MaterializeTemporaryExpr *Materialize 
-  = dyn_cast(SubExpr))
-  SubExpr = Materialize->GetTemporaryExpr();
-
-// Skip any temporary bindings; they're implicit.
-if (CXXBindTemporaryExpr *Binder = dyn_cast(SubExpr))
-  SubExpr = Binder->getSubExpr();
-
 // Conversions by constructor and conversion functions have a
 // subexpression describing the call; strip it off.
 if (E->getCastKind() == CK_ConstructorConversion)
-  SubExpr = cast(SubExpr)->getArg(0);
+  SubExpr =
+skipImplicitTemporary(cast(SubExpr)->getArg(0));
 else if (E->getCastKind() == CK_UserDefinedConversion) {
   assert((isa(SubExpr) ||
   isa(SubExpr)) &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22128: Make CastExpr::getSubExprAsWritten look through implicit temporary under CK_ConstructorConversion

2016-07-08 Thread Stephan Bergmann via cfe-commits
sberg added a comment.

(I'm not sure where and how to add a test for this?)


http://reviews.llvm.org/D22128



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


[PATCH] D22129: [clang-rename] add documentation

2016-07-08 Thread Kirill Bobyrev via cfe-commits
omtcyf0 created this revision.
omtcyf0 added reviewers: alexfh, ioeric, bkramer, klimek, hokein.
omtcyf0 added a subscriber: cfe-commits.

clang-rename needs at least to have a minimum documentation to provide a small 
introduction for new users

http://reviews.llvm.org/D22129

Files:
  docs/clang-rename.rst
  docs/index.rst

Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -24,6 +24,7 @@
include-fixer
modularize
pp-trace
+   clang-rename
 
 
 Doxygen Documentation
Index: docs/clang-rename.rst
===
--- /dev/null
+++ docs/clang-rename.rst
@@ -0,0 +1,99 @@
+
+Clang-Rename
+
+
+.. contents::
+
+See also:
+
+.. toctree::
+   :maxdepth: 1
+
+
+:program:`clang-rename` is a clang-based C++ "linter" tool. Its purpose is to
+perform efficient renaming actions in large-scale projects such as renaming
+classes, functions, variables, arguments, namespaces etc.
+
+The tool development is in very early stage, so you might encounter bugs and
+crashes. Submitting reports with information about how to reproduce the issue
+to `llvm bugtracker `_ will definitely help the project.
+If you have any ideas or suggestions, you might want to put a feature request
+there.
+
+Using clang-rename
+==
+
+:program:`clang-rename` is a `LibTooling
+`_-based tool, and it's easier to
+work with if you set up a compile command database for your project (for an
+example of how to do this see `How To Setup Tooling For LLVM
+`_). You can also
+specify compilation options on the command line after ``--``:
+
+.. code-block:: console
+
+  $ clang-rename -offset=42 -new-name=foo test.cpp -- -Imy_project/include -DMY_DEFINES ...
+
+
+To get an offset of a symbol in a file run
+
+.. code-block:: console
+
+  $ grep -FUbo 'foo' file.cpp
+
+
+The tool is currently supporting renaming actions inside single Translation Unit
+only. It is planned to extend tool functionality to support multi-TU renaming
+actions in the future.
+
+:program:`clang-rename` also aims to be easily integrated into popular text
+editors, such as Vim, and improve workflow of users.
+
+Although command line interface exists, it is highly recommended to use text
+editors interface instead for better experience.
+
+.. code-block:: console
+
+  $ clang-rename -help
+  OVERVIEW: A tool to rename symbols in C/C++ code.
+  clang-rename renames every occurrence of a symbol found at  in
+  . If -i is specified, the edited files are overwritten to disk.
+  Otherwise, the results are written to stdout.
+
+  USAGE: clang-rename [subcommand] [options]  [... ]
+
+  OPTIONS:
+
+  Clang-rename options:
+
+-export-fixes=   - YAML file to store suggested fixes in.
+-extra-arg=- Additional argument to append to the compiler command line
+-extra-arg-before= - Additional argument to prepend to the compiler command line
+-i - Overwrite edited s.
+-new-name= - The new name to change the symbol to.
+-offset= - Locates the symbol by offset as opposed to :.
+-old-name= - The fully qualified name of the symbol, if -offset is not used.
+-p=- Build path
+-pl- Print the locations affected by renaming to stderr.
+-pn- Print the found symbol's name prior to renaming to stderr.
+
+  Generic Options:
+
+-help  - Display available options (-help-hidden for more)
+-help-list - Display list of available options (-help-list-hidden for more)
+-version   - Display the version of this program
+
+
+clang-rename Vim integration
+
+
+You can call :program:`clang-rename` directly from Vim! To set up
+:program:`clang-rename` integration for Vim see
+`clang-rename/tool/clang-rename.py
+`_.
+
+Once installed, you can point your cursor to the symbols you want to rename,
+press `,cr` and print new desired name.
+
+Please note that **you have to save all buffers, in which the replacement will
+happen before running the tool**.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22100: [clang-rename] fix typo in Python script for Vim integration

2016-07-08 Thread Haojian Wu via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM.


http://reviews.llvm.org/D22100



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


Re: [PATCH] D22100: [clang-rename] fix typo in Python script for Vim integration

2016-07-08 Thread Kirill Bobyrev via cfe-commits
omtcyf0 added a comment.

@hokein thanks! Can you please land it? I don't have commit access.


http://reviews.llvm.org/D22100



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


Re: [PATCH] D22129: [clang-rename] add documentation

2016-07-08 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: docs/clang-rename.rst:13
@@ +12,3 @@
+
+:program:`clang-rename` is a clang-based C++ "linter" tool. Its purpose is to
+perform efficient renaming actions in large-scale projects such as renaming

s/"linter"//


http://reviews.llvm.org/D22129



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


Re: [PATCH] D22129: [clang-rename] add documentation

2016-07-08 Thread Kirill Bobyrev via cfe-commits
omtcyf0 updated this revision to Diff 63202.
omtcyf0 marked an inline comment as done.

http://reviews.llvm.org/D22129

Files:
  docs/clang-rename.rst
  docs/index.rst

Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -24,6 +24,7 @@
include-fixer
modularize
pp-trace
+   clang-rename
 
 
 Doxygen Documentation
Index: docs/clang-rename.rst
===
--- /dev/null
+++ docs/clang-rename.rst
@@ -0,0 +1,99 @@
+
+Clang-Rename
+
+
+.. contents::
+
+See also:
+
+.. toctree::
+   :maxdepth: 1
+
+
+:program:`clang-rename` is a clang-based C++ tool. Its purpose is to
+perform efficient renaming actions in large-scale projects such as renaming
+classes, functions, variables, arguments, namespaces etc.
+
+The tool development is in very early stage, so you might encounter bugs and
+crashes. Submitting reports with information about how to reproduce the issue
+to `llvm bugtracker `_ will definitely help the project.
+If you have any ideas or suggestions, you might want to put a feature request
+there.
+
+Using clang-rename
+==
+
+:program:`clang-rename` is a `LibTooling
+`_-based tool, and it's easier to
+work with if you set up a compile command database for your project (for an
+example of how to do this see `How To Setup Tooling For LLVM
+`_). You can also
+specify compilation options on the command line after ``--``:
+
+.. code-block:: console
+
+  $ clang-rename -offset=42 -new-name=foo test.cpp -- -Imy_project/include -DMY_DEFINES ...
+
+
+To get an offset of a symbol in a file run
+
+.. code-block:: console
+
+  $ grep -FUbo 'foo' file.cpp
+
+
+The tool is currently supporting renaming actions inside single Translation Unit
+only. It is planned to extend tool functionality to support multi-TU renaming
+actions in the future.
+
+:program:`clang-rename` also aims to be easily integrated into popular text
+editors, such as Vim, and improve workflow of users.
+
+Although command line interface exists, it is highly recommended to use text
+editors interface instead for better experience.
+
+.. code-block:: console
+
+  $ clang-rename -help
+  OVERVIEW: A tool to rename symbols in C/C++ code.
+  clang-rename renames every occurrence of a symbol found at  in
+  . If -i is specified, the edited files are overwritten to disk.
+  Otherwise, the results are written to stdout.
+
+  USAGE: clang-rename [subcommand] [options]  [... ]
+
+  OPTIONS:
+
+  Clang-rename options:
+
+-export-fixes=   - YAML file to store suggested fixes in.
+-extra-arg=- Additional argument to append to the compiler command line
+-extra-arg-before= - Additional argument to prepend to the compiler command line
+-i - Overwrite edited s.
+-new-name= - The new name to change the symbol to.
+-offset= - Locates the symbol by offset as opposed to :.
+-old-name= - The fully qualified name of the symbol, if -offset is not used.
+-p=- Build path
+-pl- Print the locations affected by renaming to stderr.
+-pn- Print the found symbol's name prior to renaming to stderr.
+
+  Generic Options:
+
+-help  - Display available options (-help-hidden for more)
+-help-list - Display list of available options (-help-list-hidden for more)
+-version   - Display the version of this program
+
+
+clang-rename Vim integration
+
+
+You can call :program:`clang-rename` directly from Vim! To set up
+:program:`clang-rename` integration for Vim see
+`clang-rename/tool/clang-rename.py
+`_.
+
+Once installed, you can point your cursor to the symbols you want to rename,
+press `,cr` and print new desired name.
+
+Please note that **you have to save all buffers, in which the replacement will
+happen before running the tool**.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r274839 - [clang-rename] fix typo in Python script for Vim integration

2016-07-08 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Jul  8 07:05:06 2016
New Revision: 274839

URL: http://llvm.org/viewvc/llvm-project?rev=274839&view=rev
Log:
[clang-rename] fix typo in Python script for Vim integration

Patch by Kirill Bobyrev!

Reviewers: kimgr, alexfh, bkramer, ioeric, hokein

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-rename/tool/clang-rename.py

Modified: clang-tools-extra/trunk/clang-rename/tool/clang-rename.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/tool/clang-rename.py?rev=274839&r1=274838&r2=274839&view=diff
==
--- clang-tools-extra/trunk/clang-rename/tool/clang-rename.py (original)
+++ clang-tools-extra/trunk/clang-rename/tool/clang-rename.py Fri Jul  8 
07:05:06 2016
@@ -14,8 +14,8 @@ To install, simply put this into your ~/
 IMPORTANT NOTE: Before running the tool, make sure you saved the file.
 
 All you have to do now is to place a cursor on a variable/function/class which
-you would like to rename and press ',cr'. You will be promted a new name if the
-cursor points to a valid symbol.
+you would like to rename and press ',cr'. You will be prompted for a new name 
if
+the cursor points to a valid symbol.
 '''
 
 import vim


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


Re: [PATCH] D22100: [clang-rename] fix typo in Python script for Vim integration

2016-07-08 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL274839: [clang-rename] fix typo in Python script for Vim 
integration (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D22100?vs=63101&id=63203#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D22100

Files:
  clang-tools-extra/trunk/clang-rename/tool/clang-rename.py

Index: clang-tools-extra/trunk/clang-rename/tool/clang-rename.py
===
--- clang-tools-extra/trunk/clang-rename/tool/clang-rename.py
+++ clang-tools-extra/trunk/clang-rename/tool/clang-rename.py
@@ -14,8 +14,8 @@
 IMPORTANT NOTE: Before running the tool, make sure you saved the file.
 
 All you have to do now is to place a cursor on a variable/function/class which
-you would like to rename and press ',cr'. You will be promted a new name if the
-cursor points to a valid symbol.
+you would like to rename and press ',cr'. You will be prompted for a new name 
if
+the cursor points to a valid symbol.
 '''
 
 import vim


Index: clang-tools-extra/trunk/clang-rename/tool/clang-rename.py
===
--- clang-tools-extra/trunk/clang-rename/tool/clang-rename.py
+++ clang-tools-extra/trunk/clang-rename/tool/clang-rename.py
@@ -14,8 +14,8 @@
 IMPORTANT NOTE: Before running the tool, make sure you saved the file.
 
 All you have to do now is to place a cursor on a variable/function/class which
-you would like to rename and press ',cr'. You will be promted a new name if the
-cursor points to a valid symbol.
+you would like to rename and press ',cr'. You will be prompted for a new name if
+the cursor points to a valid symbol.
 '''
 
 import vim
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] r274840 - [PATCH] [libunwind][ehabi] Use early returns where possible.

2016-07-08 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Fri Jul  8 07:13:31 2016
New Revision: 274840

URL: http://llvm.org/viewvc/llvm-project?rev=274840&view=rev
Log:
[PATCH] [libunwind][ehabi] Use early returns where possible.

Just a minor code cleanup. NFC.

Modified:
libunwind/trunk/src/Registers.hpp

Modified: libunwind/trunk/src/Registers.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Registers.hpp?rev=274840&r1=274839&r2=274840&view=diff
==
--- libunwind/trunk/src/Registers.hpp (original)
+++ libunwind/trunk/src/Registers.hpp Fri Jul  8 07:13:31 2016
@@ -1442,26 +1442,34 @@ inline bool Registers_arm::validRegister
   // virtual register set (VRS).
   if (regNum == UNW_REG_IP)
 return true;
+
   if (regNum == UNW_REG_SP)
 return true;
+
   if (regNum >= UNW_ARM_R0 && regNum <= UNW_ARM_R15)
 return true;
+
 #if defined(__ARM_WMMX)
   if (regNum >= UNW_ARM_WC0 && regNum <= UNW_ARM_WC3)
 return true;
 #endif
+
   return false;
 }
 
 inline uint32_t Registers_arm::getRegister(int regNum) {
   if (regNum == UNW_REG_SP || regNum == UNW_ARM_SP)
 return _registers.__sp;
+
   if (regNum == UNW_ARM_LR)
 return _registers.__lr;
+
   if (regNum == UNW_REG_IP || regNum == UNW_ARM_IP)
 return _registers.__pc;
+
   if (regNum >= UNW_ARM_R0 && regNum <= UNW_ARM_R12)
 return _registers.__r[regNum];
+
 #if defined(__ARM_WMMX)
   if (regNum >= UNW_ARM_WC0 && regNum <= UNW_ARM_WC3) {
 if (!_saved_iwmmx_control) {
@@ -1471,29 +1479,43 @@ inline uint32_t Registers_arm::getRegist
 return _iwmmx_control[regNum - UNW_ARM_WC0];
   }
 #endif
+
   _LIBUNWIND_ABORT("unsupported arm register");
 }
 
 inline void Registers_arm::setRegister(int regNum, uint32_t value) {
-  if (regNum == UNW_REG_SP || regNum == UNW_ARM_SP)
+  if (regNum == UNW_REG_SP || regNum == UNW_ARM_SP) {
 _registers.__sp = value;
-  else if (regNum == UNW_ARM_LR)
+return;
+  }
+
+  if (regNum == UNW_ARM_LR) {
 _registers.__lr = value;
-  else if (regNum == UNW_REG_IP || regNum == UNW_ARM_IP)
+return;
+  }
+
+  if (regNum == UNW_REG_IP || regNum == UNW_ARM_IP) {
 _registers.__pc = value;
-  else if (regNum >= UNW_ARM_R0 && regNum <= UNW_ARM_R12)
+return;
+  }
+
+  if (regNum >= UNW_ARM_R0 && regNum <= UNW_ARM_R12) {
 _registers.__r[regNum] = value;
+return;
+  }
+
 #if defined(__ARM_WMMX)
-  else if (regNum >= UNW_ARM_WC0 && regNum <= UNW_ARM_WC3) {
+  if (regNum >= UNW_ARM_WC0 && regNum <= UNW_ARM_WC3) {
 if (!_saved_iwmmx_control) {
   _saved_iwmmx_control = true;
   saveiWMMXControl(_iwmmx_control);
 }
 _iwmmx_control[regNum - UNW_ARM_WC0] = value;
+return;
   }
 #endif
-  else
-_LIBUNWIND_ABORT("unsupported arm register");
+
+  _LIBUNWIND_ABORT("unsupported arm register");
 }
 
 inline const char *Registers_arm::getRegisterName(int regNum) {
@@ -1685,15 +1707,18 @@ inline unw_fpreg_t Registers_arm::getFlo
 saveVFPWithFSTMD(_vfp_d0_d15_pad);
 }
 return _vfp_d0_d15_pad[regNum - UNW_ARM_D0];
-  } else if (regNum >= UNW_ARM_D16 && regNum <= UNW_ARM_D31) {
+  }
+
+  if (regNum >= UNW_ARM_D16 && regNum <= UNW_ARM_D31) {
 if (!_saved_vfp_d16_d31) {
   _saved_vfp_d16_d31 = true;
   saveVFPv3(_vfp_d16_d31);
 }
 return _vfp_d16_d31[regNum - UNW_ARM_D16];
   }
+
 #if defined(__ARM_WMMX)
-  else if (regNum >= UNW_ARM_WR0 && regNum <= UNW_ARM_WR15) {
+  if (regNum >= UNW_ARM_WR0 && regNum <= UNW_ARM_WR15) {
 if (!_saved_iwmmx) {
   _saved_iwmmx = true;
   saveiWMMX(_iwmmx);
@@ -1701,8 +1726,8 @@ inline unw_fpreg_t Registers_arm::getFlo
 return _iwmmx[regNum - UNW_ARM_WR0];
   }
 #endif
-  else
-_LIBUNWIND_ABORT("Unknown ARM float register");
+
+  _LIBUNWIND_ABORT("Unknown ARM float register");
 }
 
 inline void Registers_arm::setFloatRegister(int regNum, unw_fpreg_t value) {
@@ -1715,24 +1740,30 @@ inline void Registers_arm::setFloatRegis
 saveVFPWithFSTMD(_vfp_d0_d15_pad);
 }
 _vfp_d0_d15_pad[regNum - UNW_ARM_D0] = value;
-  } else if (regNum >= UNW_ARM_D16 && regNum <= UNW_ARM_D31) {
+return;
+  }
+
+  if (regNum >= UNW_ARM_D16 && regNum <= UNW_ARM_D31) {
 if (!_saved_vfp_d16_d31) {
   _saved_vfp_d16_d31 = true;
   saveVFPv3(_vfp_d16_d31);
 }
 _vfp_d16_d31[regNum - UNW_ARM_D16] = value;
+return;
   }
+
 #if defined(__ARM_WMMX)
-  else if (regNum >= UNW_ARM_WR0 && regNum <= UNW_ARM_WR15) {
+  if (regNum >= UNW_ARM_WR0 && regNum <= UNW_ARM_WR15) {
 if (!_saved_iwmmx) {
   _saved_iwmmx = true;
   saveiWMMX(_iwmmx);
 }
 _iwmmx[regNum - UNW_ARM_WR0] = value;
+return;
   }
 #endif
-  else
-_LIBUNWIND_ABORT("Unknown ARM float register");
+
+  _LIBUNWIND_ABORT("Unknown ARM float register");
 }
 
 inline bool Registers_arm::validVectorRegister(int) const {


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

Re: [PATCH] D19311: [analyzer] Self Assignment Checker

2016-07-08 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware updated this revision to Diff 63204.
baloghadamsoftware added a comment.

Issues fixed.


http://reviews.llvm.org/D19311

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
  lib/StaticAnalyzer/Core/BugReporter.cpp
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  test/Analysis/self-assign.cpp

Index: test/Analysis/self-assign.cpp
===
--- /dev/null
+++ test/Analysis/self-assign.cpp
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -std=c++11 -analyze -analyzer-checker=core,cplusplus,unix.Malloc,debug.ExprInspection %s -verify
+
+extern "C" char *strdup(const char* s);
+extern "C" void free(void* ptr);
+
+namespace std {
+template struct remove_reference  { typedef T type; };
+template struct remove_reference  { typedef T type; };
+template struct remove_reference { typedef T type; };
+template typename remove_reference::type&& move(T&& t);
+}
+
+void clang_analyzer_eval(int);
+
+class StringUsed {
+public:
+  StringUsed(const char *s = "") : str(strdup(s)) {}
+  StringUsed(const StringUsed &rhs) : str(strdup(rhs.str)) {}
+  ~StringUsed();
+  StringUsed& operator=(const StringUsed &rhs);
+  StringUsed& operator=(StringUsed &&rhs);
+  operator const char*() const;
+private:
+  char *str;
+};
+
+StringUsed::~StringUsed() {
+  free(str);
+}
+
+StringUsed& StringUsed::operator=(const StringUsed &rhs) {
+  clang_analyzer_eval(*this == rhs); // expected-warning{{TRUE}} expected-warning{{UNKNOWN}}
+  free(str);
+  str = strdup(rhs.str); // expected-warning{{Use of memory after it is freed}}
+  return *this;
+}
+
+StringUsed& StringUsed::operator=(StringUsed &&rhs) {
+  clang_analyzer_eval(*this == rhs); // expected-warning{{TRUE}} expected-warning{{UNKNOWN}}
+  str = rhs.str;
+  rhs.str = nullptr;
+  return *this;
+}
+
+StringUsed::operator const char*() const {
+  return str;
+}
+
+class StringUnused {
+public:
+  StringUnused(const char *s = "") : str(strdup(s)) {}
+  StringUnused(const StringUnused &rhs) : str(strdup(rhs.str)) {}
+  ~StringUnused();
+  StringUnused& operator=(const StringUnused &rhs);
+  StringUnused& operator=(StringUnused &&rhs);
+  operator const char*() const;
+private:
+  char *str;
+};
+
+StringUnused::~StringUnused() {
+  free(str);
+}
+
+StringUnused& StringUnused::operator=(const StringUnused &rhs) {
+  clang_analyzer_eval(*this == rhs); // expected-warning{{TRUE}} expected-warning{{UNKNOWN}}
+  free(str);
+  str = strdup(rhs.str); // expected-warning{{Use of memory after it is freed}}
+  return *this;
+}
+
+StringUnused& StringUnused::operator=(StringUnused &&rhs) {
+  clang_analyzer_eval(*this == rhs); // expected-warning{{TRUE}} expected-warning{{UNKNOWN}}
+  str = rhs.str;
+  rhs.str = nullptr;
+  return *this;
+}
+
+StringUnused::operator const char*() const {
+  return str;
+}
+
+
+int main() {
+  StringUsed s1 ("test"), s2;
+  s2 = s1;
+  s2 = std::move(s1);
+  return 0;
+}
Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -431,6 +431,13 @@
   //   Count naming convention errors more aggressively.
   if (isa(D))
 return false;
+  // We also want to reanalyze all C++ copy and move assignment operators to
+  // separately check the two cases where 'this' aliases with the parameter and
+  // where it may not. (cplusplus.SelfAssignmentChecker)
+  if (const auto *MD = dyn_cast(D)) {
+if (MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator())
+  return false;
+  }
 
   // Otherwise, if we visited the function before, do not reanalyze it.
   return Visited.count(D);
@@ -442,9 +449,7 @@
   // We want to reanalyze all ObjC methods as top level to report Retain
   // Count naming convention errors more aggressively. But we should tune down
   // inlining when reanalyzing an already inlined function.
-  if (Visited.count(D)) {
-assert(isa(D) &&
-   "We are only reanalyzing ObjCMethods.");
+  if (Visited.count(D) && isa(D)) {
 const ObjCMethodDecl *ObjCM = cast(D);
 if (ObjCM->getMethodFamily() != OMF_init)
   return ExprEngine::Inline_Minimal;
Index: lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -662,6 +662,7 @@
   if (Optional BE = P.getAs()) {
 const CFGBlock *BSrc = BE->getSrc();
 S = BSrc->getTerminatorCondition();
+assert(S && "Terminator Condition is null!");
   } else if (Optional SP = P.getAs()) {
 S = SP->getStmt();
 if (P.getAs()

Re: [PATCH] D21385: Adjust Registry interface to not require plugins to export a registry

2016-07-08 Thread Rudy Pons via cfe-commits
Ilod added a comment.

LGTM

Plugins tests are still disabled by lit.cfg I think, as it only checks for 
enable_shared, which is disabled. I suppose we could wait for both this and the 
SampleAnalyzerPlugin to be patched before enabling plugins tests if we have 
LLVM_EXPORT_SYMBOLS_FOR_PLUGINS, as every plugin test should work after this.


Repository:
  rL LLVM

http://reviews.llvm.org/D21385



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


Re: [PATCH] D21971: Explicitly export symbols from the sample analyzer plugin

2016-07-08 Thread Rudy Pons via cfe-commits
Ilod added a comment.

LGTM.

Do you known if there is any good reason Analyzer plugins aren't using the 
Registry system (thus forcing plugin writers to manually export the functions)?


Repository:
  rL LLVM

http://reviews.llvm.org/D21971



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


Re: [PATCH] D19311: [analyzer] Self Assignment Checker

2016-07-08 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware marked 3 inline comments as done.
baloghadamsoftware added a comment.

http://reviews.llvm.org/D19311



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


[PATCH] D22130: Link static PIE programs against rcrt0.o on OpenBSD

2016-07-08 Thread Stefan Kempf via cfe-commits
sisnkemp created this revision.
sisnkemp added a reviewer: rafael.
sisnkemp added a subscriber: cfe-commits.

When building a static PIE binary, linking against /usr/lib/crt0.o results in 
segfaults when trying to run the binary.
Static PIE programs must link against /usr/lib/rcrt0.o instead to run 
correctly. Bitrig has this patch in their local clang tree also.


http://reviews.llvm.org/D22130

Files:
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -8083,6 +8083,10 @@
   if (Args.hasArg(options::OPT_pg))
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("gcrt0.o")));
+  else if (Args.hasArg(options::OPT_static) &&
+   !Args.hasArg(options::OPT_nopie))
+CmdArgs.push_back(
+Args.MakeArgString(getToolChain().GetFilePath("rcrt0.o")));
   else
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("crt0.o")));


Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -8083,6 +8083,10 @@
   if (Args.hasArg(options::OPT_pg))
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("gcrt0.o")));
+  else if (Args.hasArg(options::OPT_static) &&
+   !Args.hasArg(options::OPT_nopie))
+CmdArgs.push_back(
+Args.MakeArgString(getToolChain().GetFilePath("rcrt0.o")));
   else
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("crt0.o")));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19311: [analyzer] Self Assignment Checker

2016-07-08 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware updated this revision to Diff 63207.
baloghadamsoftware added a comment.

Debug line removed.


http://reviews.llvm.org/D19311

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
  lib/StaticAnalyzer/Core/BugReporter.cpp
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  test/Analysis/self-assign.cpp

Index: test/Analysis/self-assign.cpp
===
--- /dev/null
+++ test/Analysis/self-assign.cpp
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -std=c++11 -analyze -analyzer-checker=core,cplusplus,unix.Malloc,debug.ExprInspection %s -verify
+
+extern "C" char *strdup(const char* s);
+extern "C" void free(void* ptr);
+
+namespace std {
+template struct remove_reference  { typedef T type; };
+template struct remove_reference  { typedef T type; };
+template struct remove_reference { typedef T type; };
+template typename remove_reference::type&& move(T&& t);
+}
+
+void clang_analyzer_eval(int);
+
+class StringUsed {
+public:
+  StringUsed(const char *s = "") : str(strdup(s)) {}
+  StringUsed(const StringUsed &rhs) : str(strdup(rhs.str)) {}
+  ~StringUsed();
+  StringUsed& operator=(const StringUsed &rhs);
+  StringUsed& operator=(StringUsed &&rhs);
+  operator const char*() const;
+private:
+  char *str;
+};
+
+StringUsed::~StringUsed() {
+  free(str);
+}
+
+StringUsed& StringUsed::operator=(const StringUsed &rhs) {
+  clang_analyzer_eval(*this == rhs); // expected-warning{{TRUE}} expected-warning{{UNKNOWN}}
+  free(str);
+  str = strdup(rhs.str); // expected-warning{{Use of memory after it is freed}}
+  return *this;
+}
+
+StringUsed& StringUsed::operator=(StringUsed &&rhs) {
+  clang_analyzer_eval(*this == rhs); // expected-warning{{TRUE}} expected-warning{{UNKNOWN}}
+  str = rhs.str;
+  rhs.str = nullptr;
+  return *this;
+}
+
+StringUsed::operator const char*() const {
+  return str;
+}
+
+class StringUnused {
+public:
+  StringUnused(const char *s = "") : str(strdup(s)) {}
+  StringUnused(const StringUnused &rhs) : str(strdup(rhs.str)) {}
+  ~StringUnused();
+  StringUnused& operator=(const StringUnused &rhs);
+  StringUnused& operator=(StringUnused &&rhs);
+  operator const char*() const;
+private:
+  char *str;
+};
+
+StringUnused::~StringUnused() {
+  free(str);
+}
+
+StringUnused& StringUnused::operator=(const StringUnused &rhs) {
+  clang_analyzer_eval(*this == rhs); // expected-warning{{TRUE}} expected-warning{{UNKNOWN}}
+  free(str);
+  str = strdup(rhs.str); // expected-warning{{Use of memory after it is freed}}
+  return *this;
+}
+
+StringUnused& StringUnused::operator=(StringUnused &&rhs) {
+  clang_analyzer_eval(*this == rhs); // expected-warning{{TRUE}} expected-warning{{UNKNOWN}}
+  str = rhs.str;
+  rhs.str = nullptr;
+  return *this;
+}
+
+StringUnused::operator const char*() const {
+  return str;
+}
+
+
+int main() {
+  StringUsed s1 ("test"), s2;
+  s2 = s1;
+  s2 = std::move(s1);
+  return 0;
+}
Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -431,6 +431,13 @@
   //   Count naming convention errors more aggressively.
   if (isa(D))
 return false;
+  // We also want to reanalyze all C++ copy and move assignment operators to
+  // separately check the two cases where 'this' aliases with the parameter and
+  // where it may not. (cplusplus.SelfAssignmentChecker)
+  if (const auto *MD = dyn_cast(D)) {
+if (MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator())
+  return false;
+  }
 
   // Otherwise, if we visited the function before, do not reanalyze it.
   return Visited.count(D);
@@ -442,9 +449,7 @@
   // We want to reanalyze all ObjC methods as top level to report Retain
   // Count naming convention errors more aggressively. But we should tune down
   // inlining when reanalyzing an already inlined function.
-  if (Visited.count(D)) {
-assert(isa(D) &&
-   "We are only reanalyzing ObjCMethods.");
+  if (Visited.count(D) && isa(D)) {
 const ObjCMethodDecl *ObjCM = cast(D);
 if (ObjCM->getMethodFamily() != OMF_init)
   return ExprEngine::Inline_Minimal;
Index: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -1693,3 +1693,53 @@
   }
   return nullptr;
 }
+
+PathDiagnosticPiece *
+CXXSelfAssignmentBRVisitor::VisitNode(const ExplodedNode *Succ,
+  const ExplodedNode *Pred,
+  BugReporterContext &BRC, BugReport &BR) {
+  if (Sa

Re: [PATCH] D19311: [analyzer] Self Assignment Checker

2016-07-08 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware added inline comments.


Comment at: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:452
@@ -444,5 +451,3 @@
   // inlining when reanalyzing an already inlined function.
-  if (Visited.count(D)) {
-assert(isa(D) &&
-   "We are only reanalyzing ObjCMethods.");
+  if (Visited.count(D) && isa(D)) {
 const ObjCMethodDecl *ObjCM = cast(D);

I made a quick measurement on our build server using clang as target code. 
Real/user/system times were 75/575/18 for minimal and 76/587/18 for regular. 
This does not seem too much. However, since the semantics of a copy assignment 
operator is often composed of the semantics of a destructor and the semantics 
of a copy constructor implementations often put these two functionalities into 
separate functions and call them from the destructor, copy constructor and copy 
assignment operator. Such implementations requires regular inlining to be 
checked.


http://reviews.llvm.org/D19311



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


[clang-tools-extra] r274845 - [include-fixer] Pull out Context implementation code to a cpp file.

2016-07-08 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Jul  8 08:11:38 2016
New Revision: 274845

URL: http://llvm.org/viewvc/llvm-project?rev=274845&view=rev
Log:
[include-fixer] Pull out Context implementation code to a cpp file.

Added:
clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
Modified:
clang-tools-extra/trunk/include-fixer/CMakeLists.txt
clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h

Modified: clang-tools-extra/trunk/include-fixer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/CMakeLists.txt?rev=274845&r1=274844&r2=274845&view=diff
==
--- clang-tools-extra/trunk/include-fixer/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/include-fixer/CMakeLists.txt Fri Jul  8 08:11:38 
2016
@@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS
 
 add_clang_library(clangIncludeFixer
   IncludeFixer.cpp
+  IncludeFixerContext.cpp
   InMemorySymbolIndex.cpp
   SymbolIndexManager.cpp
   YamlSymbolIndex.cpp

Added: clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp?rev=274845&view=auto
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp (added)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp Fri Jul  8 
08:11:38 2016
@@ -0,0 +1,61 @@
+//===-- IncludeFixerContext.cpp - Include fixer context -*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "IncludeFixerContext.h"
+#include 
+
+namespace clang {
+namespace include_fixer {
+
+IncludeFixerContext::IncludeFixerContext(
+llvm::StringRef Name, llvm::StringRef ScopeQualifiers,
+const std::vector Symbols,
+tooling::Range Range)
+: SymbolIdentifier(Name), SymbolScopedQualifiers(ScopeQualifiers),
+  MatchedSymbols(Symbols), SymbolRange(Range) {
+  // Deduplicate headers, so that we don't want to suggest the same header
+  // twice.
+  for (const auto &Symbol : MatchedSymbols)
+Headers.push_back(Symbol.getFilePath());
+  Headers.erase(std::unique(Headers.begin(), Headers.end(),
+[](const std::string &A, const std::string &B) {
+  return A == B;
+}),
+Headers.end());
+}
+
+tooling::Replacement
+IncludeFixerContext::createSymbolReplacement(llvm::StringRef FilePath,
+ size_t Idx) {
+  assert(Idx < MatchedSymbols.size());
+  std::string QualifiedName = MatchedSymbols[Idx].getQualifiedName();
+  // For nested classes, the qualified name constructed from database misses
+  // some stripped qualifiers, because when we search a symbol in database,
+  // we strip qualifiers from the end until we find a result. So append the
+  // missing stripped qualifiers here.
+  //
+  // Get stripped qualifiers.
+  llvm::SmallVector SymbolQualifiers;
+  getSymbolIdentifier().split(SymbolQualifiers, "::");
+  std::string StrippedQualifiers;
+  while (!SymbolQualifiers.empty() &&
+ !llvm::StringRef(QualifiedName).endswith(SymbolQualifiers.back())) {
+StrippedQualifiers = "::" + SymbolQualifiers.back().str();
+SymbolQualifiers.pop_back();
+  }
+  // Append the missing stripped qualifiers.
+  std::string FullyQualifiedName = QualifiedName + StrippedQualifiers;
+  auto pos = FullyQualifiedName.find(SymbolScopedQualifiers);
+  return {FilePath, SymbolRange.getOffset(), SymbolRange.getLength(),
+  FullyQualifiedName.substr(
+  pos == std::string::npos ? 0 : SymbolScopedQualifiers.size())};
+}
+
+} // include_fixer
+} // clang

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h?rev=274845&r1=274844&r2=274845&view=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h Fri Jul  8 
08:11:38 2016
@@ -12,7 +12,6 @@
 
 #include "find-all-symbols/SymbolInfo.h"
 #include "clang/Tooling/Core/Replacement.h"
-#include 
 #include 
 #include 
 
@@ -22,51 +21,15 @@ namespace include_fixer {
 /// \brief A context for the symbol being queried.
 class IncludeFixerContext {
 public:
-  IncludeFixerContext() {}
+  IncludeFixerContext() = default;
   IncludeFixerContext(llvm::StringRef Name, llvm::StringRef ScopeQualifiers,
   const std::vector Symbols,
-  tooling::Range Range)
-  : SymbolIdentifier(Na

Re: [PATCH] D21851: [Driver][OpenMP][CUDA] Add capability to bundle object files in sections of the host binary format.

2016-07-08 Thread Jonas Hahnfeld via cfe-commits
Hahnfeld added a comment.

Another overall question: Back in February you said that it would be possible 
to have a "default" object that can be taken without knowledge of the bundler 
(see http://lists.llvm.org/pipermail/cfe-dev/2016-February/047555.html).

In my tests with the patch, this has not worked yet - am I missing something or 
is this not yet implemented?



Comment at: tools/clang-offload-bundler/ClangOffloadBundler.cpp:477-490
@@ +476,16 @@
+
+// Do the incremental linking. We write to the output file directly. So, we
+// close it and use the name to pass down to clang.
+OS.close();
+SmallString<128> TargetName = getTriple(TargetNames.front());
+const char *ClangArgs[] = {"clang",
+   "-r",
+   "-target",
+   TargetName.c_str(),
+   "-o",
+   OutputFileNames.front().c_str(),
+   InputFileNames.front().c_str(),
+   BitcodeFileName.c_str(),
+   "-nostdlib",
+   nullptr};
+

sfantao wrote:
> Hahnfeld wrote:
> > `test/Driver/clang-offload-bundler.c` gives me
> > ```
> > /..//bin/ld: unrecognised emulation mode: elf64lppc
> > Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 i386linux elf_l1om 
> > elf_k1om
> > ```
> > and therefore fails.
> > 
> > I'm on an x86_64 Linux and obviously my `GNU ld version 2.23.52.0.1-55.el7 
> > 20130226` doesn't support Power :-(
> Oh, right... I cannot run the bundler in the regression tests to tests the 
> bundler. I guess I need some sort of dry run option to check the commands are 
> correct without actually running them.
> 
> I'll fix that.
Yes, comparable to `-###` in `clang`?

Another option (that I don't really prefer, just for completeness) would be to 
have separate tests that have appropriate `REQUIRES`...


http://reviews.llvm.org/D21851



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


Re: [PATCH] D22127: [include-fixer] Don't add qualifiers to symbols which have global scope operator.

2016-07-08 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

This looks like the right thing to do to me.


http://reviews.llvm.org/D22127



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


Re: [PATCH] D22067: [OpenCL] Add missing -cl-no-signed-zeros option into driver

2016-07-08 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

LGTM. Thanks.


http://reviews.llvm.org/D22067



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


Re: [PATCH] D19311: [analyzer] Self Assignment Checker

2016-07-08 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware added a comment.

I added tests for move assignment operators, but I could not find out any other 
simple test case than memory leak. However memory leaks are currently only 
detected by Unix.malloc for malloc. So I tried to replace strdup with malloc, 
strlen and strcpy, but even in this case leak bug is only reported for string 
used but not for string unused. That would require a more complex leak checker 
which we currently do not have.


http://reviews.llvm.org/D19311



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


Re: [PATCH] D20561: Warn when taking address of packed member

2016-07-08 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

Ping?

Looking forward any further comments before committing.

Thank you very much.


http://reviews.llvm.org/D20561



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


Re: [PATCH] D20948: [OpenCL] Fix access qualifiers handling for typedefs

2016-07-08 Thread Andrew Savonichev via cfe-commits
asavonic marked 2 inline comments as done.
asavonic added a comment.

http://reviews.llvm.org/D20948



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


Re: [PATCH] D21968: [libcxx] Externally threaded libc++ variant - Take 2

2016-07-08 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

@mclow.lists, @ericwf: Gentle ping.


http://reviews.llvm.org/D21968



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


[clang-tools-extra] r274848 - [include-fixer] Don't add qualifiers to symbols which have global scope operator.

2016-07-08 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Jul  8 09:28:43 2016
New Revision: 274848

URL: http://llvm.org/viewvc/llvm-project?rev=274848&view=rev
Log:
[include-fixer] Don't add qualifiers to symbols which have global scope 
operator.

Reviewers: bkramer

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h
clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp?rev=274848&r1=274847&r2=274848&view=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp Fri Jul  8 
09:28:43 2016
@@ -34,6 +34,10 @@ tooling::Replacement
 IncludeFixerContext::createSymbolReplacement(llvm::StringRef FilePath,
  size_t Idx) {
   assert(Idx < MatchedSymbols.size());
+  // No need to add missing qualifiers if SymbolIndentifer has a global scope
+  // operator "::".
+  if (getSymbolIdentifier().startswith("::"))
+return tooling::Replacement();
   std::string QualifiedName = MatchedSymbols[Idx].getQualifiedName();
   // For nested classes, the qualified name constructed from database misses
   // some stripped qualifiers, because when we search a symbol in database,

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h?rev=274848&r1=274847&r2=274848&view=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h Fri Jul  8 
09:28:43 2016
@@ -30,6 +30,7 @@ public:
   /// symbol.
   tooling::Replacement createSymbolReplacement(llvm::StringRef FilePath,
size_t Idx = 0);
+
   /// \brief Get symbol name.
   llvm::StringRef getSymbolIdentifier() const { return SymbolIdentifier; }
 

Modified: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp?rev=274848&r1=274847&r2=274848&view=diff
==
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Fri 
Jul  8 09:28:43 2016
@@ -242,18 +242,18 @@ TEST(IncludeFixer, FixNamespaceQualifier
   EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nb::bar::t b;\n}\n",
 runIncludeFixer("namespace a {\nbar::t b;\n}\n"));
 
-  EXPECT_EQ(
-  "#include \"color.h\"\nint test = a::b::Green;\n",
-  runIncludeFixer("int test = Green;\n"));
+  EXPECT_EQ("#include \"color.h\"\nint test = a::b::Green;\n",
+runIncludeFixer("int test = Green;\n"));
   EXPECT_EQ("#include \"color.h\"\nnamespace d {\nint test = 
a::b::Green;\n}\n",
 runIncludeFixer("namespace d {\nint test = Green;\n}\n"));
   EXPECT_EQ("#include \"color.h\"\nnamespace a {\nint test = b::Green;\n}\n",
 runIncludeFixer("namespace a {\nint test = Green;\n}\n"));
 
-  // FIXME: Fix-namespace should not fix the global qualified identifier.
-  EXPECT_EQ(
-  "#include \"bar.h\"\na::b::bar b;\n",
-  runIncludeFixer("::a::b::bar b;\n"));
+  // Test global scope operator.
+  EXPECT_EQ("#include \"bar.h\"\n::a::b::bar b;\n",
+runIncludeFixer("::a::b::bar b;\n"));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a {\n::a::b::bar b;\n}\n",
+runIncludeFixer("namespace a {\n::a::b::bar b;\n}\n"));
 }
 
 } // namespace


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


Re: [PATCH] D22127: [include-fixer] Don't add qualifiers to symbols which have global scope operator.

2016-07-08 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL274848: [include-fixer] Don't add qualifiers to symbols 
which have global scope… (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D22127?vs=63221&id=63223#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D22127

Files:
  clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
  clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h
  clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Index: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
===
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
@@ -242,18 +242,18 @@
   EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nb::bar::t b;\n}\n",
 runIncludeFixer("namespace a {\nbar::t b;\n}\n"));
 
-  EXPECT_EQ(
-  "#include \"color.h\"\nint test = a::b::Green;\n",
-  runIncludeFixer("int test = Green;\n"));
+  EXPECT_EQ("#include \"color.h\"\nint test = a::b::Green;\n",
+runIncludeFixer("int test = Green;\n"));
   EXPECT_EQ("#include \"color.h\"\nnamespace d {\nint test = 
a::b::Green;\n}\n",
 runIncludeFixer("namespace d {\nint test = Green;\n}\n"));
   EXPECT_EQ("#include \"color.h\"\nnamespace a {\nint test = b::Green;\n}\n",
 runIncludeFixer("namespace a {\nint test = Green;\n}\n"));
 
-  // FIXME: Fix-namespace should not fix the global qualified identifier.
-  EXPECT_EQ(
-  "#include \"bar.h\"\na::b::bar b;\n",
-  runIncludeFixer("::a::b::bar b;\n"));
+  // Test global scope operator.
+  EXPECT_EQ("#include \"bar.h\"\n::a::b::bar b;\n",
+runIncludeFixer("::a::b::bar b;\n"));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a {\n::a::b::bar b;\n}\n",
+runIncludeFixer("namespace a {\n::a::b::bar b;\n}\n"));
 }
 
 } // namespace
Index: clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h
===
--- clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h
+++ clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h
@@ -30,6 +30,7 @@
   /// symbol.
   tooling::Replacement createSymbolReplacement(llvm::StringRef FilePath,
size_t Idx = 0);
+
   /// \brief Get symbol name.
   llvm::StringRef getSymbolIdentifier() const { return SymbolIdentifier; }
 
Index: clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
===
--- clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
+++ clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
@@ -34,6 +34,10 @@
 IncludeFixerContext::createSymbolReplacement(llvm::StringRef FilePath,
  size_t Idx) {
   assert(Idx < MatchedSymbols.size());
+  // No need to add missing qualifiers if SymbolIndentifer has a global scope
+  // operator "::".
+  if (getSymbolIdentifier().startswith("::"))
+return tooling::Replacement();
   std::string QualifiedName = MatchedSymbols[Idx].getQualifiedName();
   // For nested classes, the qualified name constructed from database misses
   // some stripped qualifiers, because when we search a symbol in database,


Index: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
===
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
@@ -242,18 +242,18 @@
   EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nb::bar::t b;\n}\n",
 runIncludeFixer("namespace a {\nbar::t b;\n}\n"));
 
-  EXPECT_EQ(
-  "#include \"color.h\"\nint test = a::b::Green;\n",
-  runIncludeFixer("int test = Green;\n"));
+  EXPECT_EQ("#include \"color.h\"\nint test = a::b::Green;\n",
+runIncludeFixer("int test = Green;\n"));
   EXPECT_EQ("#include \"color.h\"\nnamespace d {\nint test = a::b::Green;\n}\n",
 runIncludeFixer("namespace d {\nint test = Green;\n}\n"));
   EXPECT_EQ("#include \"color.h\"\nnamespace a {\nint test = b::Green;\n}\n",
 runIncludeFixer("namespace a {\nint test = Green;\n}\n"));
 
-  // FIXME: Fix-namespace should not fix the global qualified identifier.
-  EXPECT_EQ(
-  "#include \"bar.h\"\na::b::bar b;\n",
-  runIncludeFixer("::a::b::bar b;\n"));
+  // Test global scope operator.
+  EXPECT_EQ("#include \"bar.h\"\n::a::b::bar b;\n",
+runIncludeFixer("::a::b::bar b;\n"));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a {\n::a::b::bar b;\n}\n",
+runIncludeFixer("namespace a {\n::a::b::bar b;\n}\n"));
 }
 
 } // namespace
Index: clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h
===

Re: [PATCH] D20948: [OpenCL] Fix access qualifiers handling for typedefs

2016-07-08 Thread Andrew Savonichev via cfe-commits
asavonic marked an inline comment as done.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2509-2510
@@ -2508,4 +2508,4 @@
   "functions, methods, and parameters|classes|enums|variables|methods|"
-  "fields and global variables|structs|variables and typedefs|thread-local 
variables|"
-  "variables and fields|variables, data members and tag types|"
+  "fields and global variables|structs|parameters and typedefs|variables and 
typedefs|"
+  "thread-local variables|variables and fields|variables, data members and tag 
types|"
   "types and namespaces|Objective-C interfaces|methods and properties|"

Yes, because I added "ExpectedParameterOrTypedef" diagnostic to support access 
qualifiers in typedef decl.


http://reviews.llvm.org/D20948



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


Re: [PATCH] D22127: [include-fixer] Don't add qualifiers to symbols which have global scope operator.

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

Rebase to master.


http://reviews.llvm.org/D22127

Files:
  include-fixer/IncludeFixerContext.cpp
  include-fixer/IncludeFixerContext.h
  unittests/include-fixer/IncludeFixerTest.cpp

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -242,18 +242,18 @@
   EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nb::bar::t b;\n}\n",
 runIncludeFixer("namespace a {\nbar::t b;\n}\n"));
 
-  EXPECT_EQ(
-  "#include \"color.h\"\nint test = a::b::Green;\n",
-  runIncludeFixer("int test = Green;\n"));
+  EXPECT_EQ("#include \"color.h\"\nint test = a::b::Green;\n",
+runIncludeFixer("int test = Green;\n"));
   EXPECT_EQ("#include \"color.h\"\nnamespace d {\nint test = 
a::b::Green;\n}\n",
 runIncludeFixer("namespace d {\nint test = Green;\n}\n"));
   EXPECT_EQ("#include \"color.h\"\nnamespace a {\nint test = b::Green;\n}\n",
 runIncludeFixer("namespace a {\nint test = Green;\n}\n"));
 
-  // FIXME: Fix-namespace should not fix the global qualified identifier.
-  EXPECT_EQ(
-  "#include \"bar.h\"\na::b::bar b;\n",
-  runIncludeFixer("::a::b::bar b;\n"));
+  // Test global scope operator.
+  EXPECT_EQ("#include \"bar.h\"\n::a::b::bar b;\n",
+runIncludeFixer("::a::b::bar b;\n"));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a {\n::a::b::bar b;\n}\n",
+runIncludeFixer("namespace a {\n::a::b::bar b;\n}\n"));
 }
 
 } // namespace
Index: include-fixer/IncludeFixerContext.h
===
--- include-fixer/IncludeFixerContext.h
+++ include-fixer/IncludeFixerContext.h
@@ -30,6 +30,7 @@
   /// symbol.
   tooling::Replacement createSymbolReplacement(llvm::StringRef FilePath,
size_t Idx = 0);
+
   /// \brief Get symbol name.
   llvm::StringRef getSymbolIdentifier() const { return SymbolIdentifier; }
 
Index: include-fixer/IncludeFixerContext.cpp
===
--- include-fixer/IncludeFixerContext.cpp
+++ include-fixer/IncludeFixerContext.cpp
@@ -34,6 +34,10 @@
 IncludeFixerContext::createSymbolReplacement(llvm::StringRef FilePath,
  size_t Idx) {
   assert(Idx < MatchedSymbols.size());
+  // No need to add missing qualifiers if SymbolIndentifer has a global scope
+  // operator "::".
+  if (getSymbolIdentifier().startswith("::"))
+return tooling::Replacement();
   std::string QualifiedName = MatchedSymbols[Idx].getQualifiedName();
   // For nested classes, the qualified name constructed from database misses
   // some stripped qualifiers, because when we search a symbol in database,


Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -242,18 +242,18 @@
   EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nb::bar::t b;\n}\n",
 runIncludeFixer("namespace a {\nbar::t b;\n}\n"));
 
-  EXPECT_EQ(
-  "#include \"color.h\"\nint test = a::b::Green;\n",
-  runIncludeFixer("int test = Green;\n"));
+  EXPECT_EQ("#include \"color.h\"\nint test = a::b::Green;\n",
+runIncludeFixer("int test = Green;\n"));
   EXPECT_EQ("#include \"color.h\"\nnamespace d {\nint test = a::b::Green;\n}\n",
 runIncludeFixer("namespace d {\nint test = Green;\n}\n"));
   EXPECT_EQ("#include \"color.h\"\nnamespace a {\nint test = b::Green;\n}\n",
 runIncludeFixer("namespace a {\nint test = Green;\n}\n"));
 
-  // FIXME: Fix-namespace should not fix the global qualified identifier.
-  EXPECT_EQ(
-  "#include \"bar.h\"\na::b::bar b;\n",
-  runIncludeFixer("::a::b::bar b;\n"));
+  // Test global scope operator.
+  EXPECT_EQ("#include \"bar.h\"\n::a::b::bar b;\n",
+runIncludeFixer("::a::b::bar b;\n"));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a {\n::a::b::bar b;\n}\n",
+runIncludeFixer("namespace a {\n::a::b::bar b;\n}\n"));
 }
 
 } // namespace
Index: include-fixer/IncludeFixerContext.h
===
--- include-fixer/IncludeFixerContext.h
+++ include-fixer/IncludeFixerContext.h
@@ -30,6 +30,7 @@
   /// symbol.
   tooling::Replacement createSymbolReplacement(llvm::StringRef FilePath,
size_t Idx = 0);
+
   /// \brief Get symbol name.
   llvm::StringRef getSymbolIdentifier() const { return SymbolIdentifier; }
 
Index: include-fixer/IncludeFixerContext.cpp
===
--- include-fixer/IncludeFixerContext.cpp
+++ include-fixer/IncludeFixerContext.cpp
@@ -

Re: [PATCH] D20948: [OpenCL] Fix access qualifiers handling for typedefs

2016-07-08 Thread Andrew Savonichev via cfe-commits
asavonic updated this revision to Diff 63222.
asavonic added a comment.

Change diagnostic wording


http://reviews.llvm.org/D20948

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/AttributeList.h
  lib/Sema/SemaType.cpp
  test/CodeGenOpenCL/kernel-arg-info.cl
  test/SemaOpenCL/access-qualifier.cl
  test/SemaOpenCL/invalid-access-qualifier.cl

Index: test/SemaOpenCL/invalid-access-qualifier.cl
===
--- test/SemaOpenCL/invalid-access-qualifier.cl
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: %clang_cc1 -verify %s
-// RUN: %clang_cc1 -verify -cl-std=CL2.0 -DCL20 %s
-
-void test1(read_only int i){} // expected-error{{access qualifier can only be used for pipe and image type}}
-
-void test2(read_only write_only image1d_t i){} // expected-error{{multiple access qualifiers}}
-
-void test3(read_only read_only image1d_t i){} // expected-error{{multiple access qualifiers}}
-
-#ifdef CL20
-void test4(read_write pipe int i){} // expected-error{{access qualifier 'read_write' can not be used for 'pipe int'}}
-#else
-void test4(__read_write image1d_t i) {} // expected-error{{access qualifier '__read_write' can not be used for '__read_write image1d_t' earlier than OpenCL version 2.0}}
-#endif
Index: test/SemaOpenCL/access-qualifier.cl
===
--- /dev/null
+++ test/SemaOpenCL/access-qualifier.cl
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -verify -pedantic -fsyntax-only -cl-std=CL1.2 %s
+// RUN: %clang_cc1 -verify -pedantic -fsyntax-only -cl-std=CL2.0 %s
+
+typedef image1d_t img1d_ro_default; // expected-note {{previously declared 'read_only' here}}
+
+typedef write_only image1d_t img1d_wo; // expected-note {{previously declared 'write_only' here}}
+typedef read_only image1d_t img1d_ro;
+
+#if __OPENCL_C_VERSION__ >= 200
+typedef read_write image1d_t img1d_rw;
+#endif
+
+typedef int Int;
+typedef read_only int IntRO; // expected-error {{access qualifier can only be used for pipe and image type}}
+
+
+void myWrite(write_only image1d_t); // expected-note {{passing argument to parameter here}} expected-note {{passing argument to parameter here}}
+void myRead(read_only image1d_t); // expected-note {{passing argument to parameter here}}
+
+#if __OPENCL_C_VERSION__ >= 200
+void myReadWrite(read_write image1d_t);
+#else
+void myReadWrite(read_write image1d_t); // expected-error {{access qualifier 'read_write' can not be used for '__read_write image1d_t' prior to OpenCL version 2.0}}
+#endif
+
+
+kernel void k1(img1d_wo img) {
+  myRead(img); // expected-error {{passing 'img1d_wo' (aka '__write_only image1d_t') to parameter of incompatible type '__read_only image1d_t'}}
+}
+
+kernel void k2(img1d_ro img) {
+  myWrite(img); // expected-error {{passing 'img1d_ro' (aka '__read_only image1d_t') to parameter of incompatible type '__write_only image1d_t'}}
+}
+
+kernel void k3(img1d_wo img) {
+  myWrite(img);
+}
+
+#if __OPENCL_C_VERSION__ >= 200
+kernel void k4(img1d_rw img) {
+  myReadWrite(img);
+}
+#endif
+
+kernel void k5(img1d_ro_default img) {
+  myWrite(img); // expected-error {{passing 'img1d_ro_default' (aka '__read_only image1d_t') to parameter of incompatible type '__write_only image1d_t'}}
+}
+
+kernel void k6(img1d_ro img) {
+  myRead(img);
+}
+
+kernel void k7(read_only img1d_wo img){} // expected-error {{multiple access qualifiers}}
+
+kernel void k8(write_only img1d_ro_default img){} // expected-error {{multiple access qualifiers}}
+
+kernel void k9(read_only int i){} // expected-error{{access qualifier can only be used for pipe and image type}}
+
+kernel void k10(read_only Int img){} // expected-error {{access qualifier can only be used for pipe and image type}}
+
+kernel void k11(read_only write_only image1d_t i){} // expected-error{{multiple access qualifiers}}
+
+kernel void k12(read_only read_only image1d_t i){} // expected-error{{multiple access qualifiers}}
+
+#if __OPENCL_C_VERSION__ >= 200
+kernel void k13(read_write pipe int i){} // expected-error{{access qualifier 'read_write' can not be used for 'pipe int'}}
+#else
+kernel void k13(__read_write image1d_t i){} // expected-error{{access qualifier '__read_write' can not be used for '__read_write image1d_t' prior to OpenCL version 2.0}}
+#endif
Index: test/CodeGenOpenCL/kernel-arg-info.cl
===
--- test/CodeGenOpenCL/kernel-arg-info.cl
+++ test/CodeGenOpenCL/kernel-arg-info.cl
@@ -49,7 +49,7 @@
 // ARGINFO: !kernel_arg_name ![[MD46:[0-9]+]]
 
 typedef image1d_t myImage;
-kernel void foo5(read_only myImage img1, write_only image1d_t img2) {
+kernel void foo5(myImage img1, write_only image1d_t img2) {
 }
 // CHECK: define spir_kernel void @foo5{{[^!]+}}
 // CHECK: !kernel_arg_addr_space ![[MD41:[0-9]+]]
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/Se

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-07-08 Thread Tavian Barnes via cfe-commits
tavianator updated this revision to Diff 63232.
tavianator marked 6 inline comments as done.
tavianator added a comment.

- Bring back HAVE___CXA_THREAD_ATEXIT_IMPL, and avoid the weak symbol/fallback 
implementation in that case
- Fix a leak in an error path
- Add a CreatesThreadLocalInDestructor to a non-main thread in the destructor 
ordering test


http://reviews.llvm.org/D21803

Files:
  src/cxa_thread_atexit.cpp
  test/CMakeLists.txt
  test/cxa_thread_atexit_test.pass.cpp
  test/libcxxabi/test/config.py
  test/lit.site.cfg.in
  test/thread_local_destruction_order.pass.cpp

Index: test/thread_local_destruction_order.pass.cpp
===
--- test/thread_local_destruction_order.pass.cpp
+++ test/thread_local_destruction_order.pass.cpp
@@ -0,0 +1,59 @@
+//===-- thread_local_destruction_order.pass.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.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+#include 
+#include 
+
+int seq = 0;
+
+class OrderChecker {
+public:
+  explicit OrderChecker(int n) : n_{n} { }
+
+  ~OrderChecker() {
+assert(seq++ == n_);
+  }
+
+private:
+  int n_;
+};
+
+class CreatesThreadLocalInDestructor {
+public:
+  CreatesThreadLocalInDestructor(int n) : n_{n} { }
+
+  ~CreatesThreadLocalInDestructor() {
+thread_local OrderChecker checker{n_};
+  }
+
+private:
+  int n_;
+};
+
+OrderChecker global{6};
+
+void thread_fn() {
+  static OrderChecker fn_static{4};
+  thread_local OrderChecker fn_thread_local{1};
+  thread_local CreatesThreadLocalInDestructor creates_tl{0};
+}
+
+int main() {
+  static OrderChecker fn_static{5};
+
+  std::thread{thread_fn}.join();
+  assert(seq == 2);
+
+  thread_local OrderChecker fn_thread_local{3};
+  thread_local CreatesThreadLocalInDestructor creates_tl{2};
+
+  return 0;
+}
Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -13,7 +13,6 @@
 config.enable_32bit = "@LIBCXXABI_BUILD_32_BITS@"
 config.target_info  = "@LIBCXXABI_TARGET_INFO@"
 config.executor = "@LIBCXXABI_EXECUTOR@"
-config.thread_atexit= "@LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL@"
 config.libcxxabi_shared = "@LIBCXXABI_ENABLE_SHARED@"
 config.enable_shared= "@LIBCXX_ENABLE_SHARED@"
 config.enable_exceptions= "@LIBCXXABI_ENABLE_EXCEPTIONS@"
Index: test/libcxxabi/test/config.py
===
--- test/libcxxabi/test/config.py
+++ test/libcxxabi/test/config.py
@@ -37,8 +37,6 @@
 super(Configuration, self).configure_features()
 if not self.get_lit_bool('enable_exceptions', True):
 self.config.available_features.add('libcxxabi-no-exceptions')
-if self.get_lit_bool('thread_atexit', True):
-self.config.available_features.add('thread_atexit')
 
 def configure_compile_flags(self):
 self.cxx.compile_flags += ['-DLIBCXXABI_NO_TIMER']
Index: test/cxa_thread_atexit_test.pass.cpp
===
--- test/cxa_thread_atexit_test.pass.cpp
+++ test/cxa_thread_atexit_test.pass.cpp
@@ -8,7 +8,6 @@
 //===--===//
 
 // REQUIRES: linux
-// REQUIRES: thread_atexit
 
 #include 
 #include 
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -16,7 +16,6 @@
 pythonize_bool(LIBCXXABI_ENABLE_THREADS)
 pythonize_bool(LIBCXXABI_ENABLE_EXCEPTIONS)
 pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
-pythonize_bool(LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL)
 set(LIBCXXABI_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
 "TargetInfo to use when setting up test environment.")
 set(LIBCXXABI_EXECUTOR "None" CACHE STRING
Index: src/cxa_thread_atexit.cpp
===
--- src/cxa_thread_atexit.cpp
+++ src/cxa_thread_atexit.cpp
@@ -7,20 +7,138 @@
 //
 //===--===//
 
+#include "abort_message.h"
 #include "cxxabi.h"
+#include 
+#include 
 
 namespace __cxxabiv1 {
-extern "C" {
 
-#ifdef HAVE___CXA_THREAD_ATEXIT_IMPL
+  using Dtor = void(*)(void*);
 
-_LIBCXXABI_FUNC_VIS int __cxa_thread_atexit(void (*dtor)(void *), void *obj,
-void *dso_symbol) throw() {
-  extern int __cxa_thread_atexit_impl(void (*)(void *), void *, void *);
-  return __cxa_thread_atexit_impl(dtor, obj, dso_symbol);
-}
+  extern "C"
+#ifndef HAVE___CXA_THREAD_ATEXIT_IMPL
+  // A weak symbol 

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-07-08 Thread Tavian Barnes via cfe-commits
tavianator marked 9 inline comments as done.
tavianator added a comment.

http://reviews.llvm.org/D21803



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


[libcxx] r274857 - [libc++] Check hash before calling __hash_table key_eq function

2016-07-08 Thread Kwasi Mensah via cfe-commits
Author: kmensah
Date: Fri Jul  8 10:34:28 2016
New Revision: 274857

URL: http://llvm.org/viewvc/llvm-project?rev=274857&view=rev
Log:
[libc++] Check hash before calling __hash_table key_eq function

Summary: The current implementations of __hash_table::find used by 
std::unordered_set/unordered_map call key_eq on each key that lands in the same 
bucket as the key you're looking for. However, since equal objects mush hash to 
the same value, you can short-circuit the possibly expensive call to key_eq by 
checking the hashes first.

Reviewers: EricWF

Subscribers: kmensah, cfe-commits

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

Modified:
libcxx/trunk/include/__hash_table

Modified: libcxx/trunk/include/__hash_table
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__hash_table?rev=274857&r1=274856&r2=274857&view=diff
==
--- libcxx/trunk/include/__hash_table (original)
+++ libcxx/trunk/include/__hash_table Fri Jul  8 10:34:28 2016
@@ -2205,7 +2205,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 || __constrain_hash(__nd->__hash_, __bc) == __chash);
__nd = 
__nd->__next_)
 {
-if (key_eq()(__nd->__value_, __k))
+if ((__nd->__hash_ == __hash) && key_eq()(__nd->__value_, __k))
 #if _LIBCPP_DEBUG_LEVEL >= 2
 return iterator(__nd, this);
 #else
@@ -2235,7 +2235,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 || __constrain_hash(__nd->__hash_, __bc) == __chash);
__nd = 
__nd->__next_)
 {
-if (key_eq()(__nd->__value_, __k))
+if ((__nd->__hash_ == __hash) && key_eq()(__nd->__value_, __k))
 #if _LIBCPP_DEBUG_LEVEL >= 2
 return const_iterator(__nd, this);
 #else


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


r274858 - [OpenCL] Fix access qualifiers handling for typedefs

2016-07-08 Thread Alexey Bader via cfe-commits
Author: bader
Date: Fri Jul  8 10:34:59 2016
New Revision: 274858

URL: http://llvm.org/viewvc/llvm-project?rev=274858&view=rev
Log:
[OpenCL] Fix access qualifiers handling for typedefs

OpenCL s6.6: "Access qualifier must be used with image object arguments
of kernels and of user-defined functions [...] If no qualifier is
provided, read_only is assumed".

This does not define the behavior for image types used in typedef
declaration, but following the spec logic, we should allow access
qualifiers specification in typedefs, e.g.:

  typedef write_only image1d_t img1d_wo;

Unlike cv-qualifiers, user cannot add access qualifier to a typedef
type, i.e. this is not allowed:

  typedef image1d_t img1d; // note: previously declared 'read_only' here
  void foo(write_only img1d im) {} // error: multiple access qualifier

Patch by Andrew Savonichev.
Reviewers: Anastasia Stulova.

Differential revision: http://reviews.llvm.org/D20948

Added:
cfe/trunk/test/SemaOpenCL/access-qualifier.cl
Removed:
cfe/trunk/test/SemaOpenCL/invalid-access-qualifier.cl
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/SemaType.cpp
cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=274858&r1=274857&r2=274858&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Fri Jul  8 10:34:59 2016
@@ -688,7 +688,8 @@ def OpenCLAccess : Attr {
   let Spellings = [Keyword<"__read_only">, Keyword<"read_only">,
Keyword<"__write_only">, Keyword<"write_only">,
Keyword<"__read_write">, Keyword<"read_write">];
-  let Subjects = SubjectList<[ParmVar], ErrorDiag>;
+  let Subjects = SubjectList<[ParmVar, TypedefName], ErrorDiag,
+ "ExpectedParameterOrTypedef">;
   let Accessors = [Accessor<"isReadOnly", [Keyword<"__read_only">,
Keyword<"read_only">]>,
Accessor<"isReadWrite", [Keyword<"__read_write">,

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=274858&r1=274857&r2=274858&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jul  8 10:34:59 
2016
@@ -2506,8 +2506,8 @@ def warn_attribute_wrong_decl_type : War
   "variables and functions|functions and methods|parameters|"
   "functions, methods and blocks|functions, methods, and classes|"
   "functions, methods, and parameters|classes|enums|variables|methods|"
-  "fields and global variables|structs|variables and typedefs|thread-local 
variables|"
-  "variables and fields|variables, data members and tag types|"
+  "fields and global variables|structs|parameters and typedefs|variables and 
typedefs|"
+  "thread-local variables|variables and fields|variables, data members and tag 
types|"
   "types and namespaces|Objective-C interfaces|methods and properties|"
   "struct or union|struct, union or class|types|"
   "Objective-C instance methods|init methods of interface or class extension 
declarations|"
@@ -7923,9 +7923,11 @@ def err_opencl_builtin_pipe_invalid_acce
 def err_opencl_invalid_access_qualifier : Error<
   "access qualifier can only be used for pipe and image type">;
 def err_opencl_invalid_read_write : Error<
-  "access qualifier %0 can not be used for %1 %select{|earlier than OpenCL 
version 2.0}2">;
+  "access qualifier %0 can not be used for %1 %select{|prior to OpenCL version 
2.0}2">;
 def err_opencl_multiple_access_qualifiers : Error<
   "multiple access qualifiers">;
+def note_opencl_typedef_access_qualifier : Note<
+  "previously declared '%0' here">;
 
 // OpenCL Section 6.8.g
 def err_opencl_unknown_type_specifier : Error<

Modified: cfe/trunk/include/clang/Sema/AttributeList.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=274858&r1=274857&r2=274858&view=diff
==
--- cfe/trunk/include/clang/Sema/AttributeList.h (original)
+++ cfe/trunk/include/clang/Sema/AttributeList.h Fri Jul  8 10:34:59 2016
@@ -880,6 +880,7 @@ enum AttributeDeclKind {
   ExpectedMethod,
   ExpectedFieldOrGlobalVar,
   ExpectedStruct,
+  ExpectedParameterOrTypedef,
   ExpectedVariableOrTypedef,
   ExpectedTLSVar,
   ExpectedVariableOrField,

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=274858&r1=274857&r2=274858&view=diff
==

Re: [PATCH] D20948: [OpenCL] Fix access qualifiers handling for typedefs

2016-07-08 Thread Alexey Bader via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL274858: [OpenCL] Fix access qualifiers handling for typedefs 
(authored by bader).

Changed prior to commit:
  http://reviews.llvm.org/D20948?vs=63222&id=63235#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20948

Files:
  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/SemaType.cpp
  cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl
  cfe/trunk/test/SemaOpenCL/access-qualifier.cl
  cfe/trunk/test/SemaOpenCL/invalid-access-qualifier.cl

Index: cfe/trunk/include/clang/Sema/AttributeList.h
===
--- cfe/trunk/include/clang/Sema/AttributeList.h
+++ cfe/trunk/include/clang/Sema/AttributeList.h
@@ -880,6 +880,7 @@
   ExpectedMethod,
   ExpectedFieldOrGlobalVar,
   ExpectedStruct,
+  ExpectedParameterOrTypedef,
   ExpectedVariableOrTypedef,
   ExpectedTLSVar,
   ExpectedVariableOrField,
Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -688,7 +688,8 @@
   let Spellings = [Keyword<"__read_only">, Keyword<"read_only">,
Keyword<"__write_only">, Keyword<"write_only">,
Keyword<"__read_write">, Keyword<"read_write">];
-  let Subjects = SubjectList<[ParmVar], ErrorDiag>;
+  let Subjects = SubjectList<[ParmVar, TypedefName], ErrorDiag,
+ "ExpectedParameterOrTypedef">;
   let Accessors = [Accessor<"isReadOnly", [Keyword<"__read_only">,
Keyword<"read_only">]>,
Accessor<"isReadWrite", [Keyword<"__read_write">,
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2506,8 +2506,8 @@
   "variables and functions|functions and methods|parameters|"
   "functions, methods and blocks|functions, methods, and classes|"
   "functions, methods, and parameters|classes|enums|variables|methods|"
-  "fields and global variables|structs|variables and typedefs|thread-local variables|"
-  "variables and fields|variables, data members and tag types|"
+  "fields and global variables|structs|parameters and typedefs|variables and typedefs|"
+  "thread-local variables|variables and fields|variables, data members and tag types|"
   "types and namespaces|Objective-C interfaces|methods and properties|"
   "struct or union|struct, union or class|types|"
   "Objective-C instance methods|init methods of interface or class extension declarations|"
@@ -7923,9 +7923,11 @@
 def err_opencl_invalid_access_qualifier : Error<
   "access qualifier can only be used for pipe and image type">;
 def err_opencl_invalid_read_write : Error<
-  "access qualifier %0 can not be used for %1 %select{|earlier than OpenCL version 2.0}2">;
+  "access qualifier %0 can not be used for %1 %select{|prior to OpenCL version 2.0}2">;
 def err_opencl_multiple_access_qualifiers : Error<
   "multiple access qualifiers">;
+def note_opencl_typedef_access_qualifier : Note<
+  "previously declared '%0' here">;
 
 // OpenCL Section 6.8.g
 def err_opencl_unknown_type_specifier : Error<
Index: cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl
===
--- cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl
+++ cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl
@@ -49,7 +49,7 @@
 // ARGINFO: !kernel_arg_name ![[MD46:[0-9]+]]
 
 typedef image1d_t myImage;
-kernel void foo5(read_only myImage img1, write_only image1d_t img2) {
+kernel void foo5(myImage img1, write_only image1d_t img2) {
 }
 // CHECK: define spir_kernel void @foo5{{[^!]+}}
 // CHECK: !kernel_arg_addr_space ![[MD41:[0-9]+]]
Index: cfe/trunk/test/SemaOpenCL/access-qualifier.cl
===
--- cfe/trunk/test/SemaOpenCL/access-qualifier.cl
+++ cfe/trunk/test/SemaOpenCL/access-qualifier.cl
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -verify -pedantic -fsyntax-only -cl-std=CL1.2 %s
+// RUN: %clang_cc1 -verify -pedantic -fsyntax-only -cl-std=CL2.0 %s
+
+typedef image1d_t img1d_ro_default; // expected-note {{previously declared 'read_only' here}}
+
+typedef write_only image1d_t img1d_wo; // expected-note {{previously declared 'write_only' here}}
+typedef read_only image1d_t img1d_ro;
+
+#if __OPENCL_C_VERSION__ >= 200
+typedef read_write image1d_t img1d_rw;
+#endif
+
+typedef int Int;
+typedef read_only int IntRO; // expected-error {{access qualifier can only be used for pipe and image type}}
+
+
+void myWrite(write_only image1d_t); // expected-note {{passing argument to parameter here}} expected-note {{passin

Re: [PATCH] D21851: [Driver][OpenMP][CUDA] Add capability to bundle object files in sections of the host binary format.

2016-07-08 Thread Samuel Antao via cfe-commits
sfantao added a comment.

In http://reviews.llvm.org/D21851#477905, @Hahnfeld wrote:

> Another overall question: Back in February you said that it would be possible 
> to have a "default" object that can be taken without knowledge of the bundler 
> (see http://lists.llvm.org/pipermail/cfe-dev/2016-February/047555.html).
>
> In my tests with the patch, this has not worked yet - am I missing something 
> or is this not yet implemented?


What I have proposed in the patch should be able to produce a bundled object 
file that can be read by other tools (the device image is embedded in 
designated sections, so these other tools may just ignore these sections). 
Also, if you feed the bundled an object file that does not have device 
sections, it should produce empty device files instead of just failing. That's 
what I was proposing there. Did you have something different in mind?

That's actually tested in the regression tests that goes with the patch. It 
won't work for you as is because of the ppc64le specific problem that I have to 
fix, but if you change that to x86_64 you may be able to test it.



Comment at: tools/clang-offload-bundler/ClangOffloadBundler.cpp:477-490
@@ +476,16 @@
+
+// Do the incremental linking. We write to the output file directly. So, we
+// close it and use the name to pass down to clang.
+OS.close();
+SmallString<128> TargetName = getTriple(TargetNames.front());
+const char *ClangArgs[] = {"clang",
+   "-r",
+   "-target",
+   TargetName.c_str(),
+   "-o",
+   OutputFileNames.front().c_str(),
+   InputFileNames.front().c_str(),
+   BitcodeFileName.c_str(),
+   "-nostdlib",
+   nullptr};
+

Hahnfeld wrote:
> sfantao wrote:
> > Hahnfeld wrote:
> > > `test/Driver/clang-offload-bundler.c` gives me
> > > ```
> > > /..//bin/ld: unrecognised emulation mode: elf64lppc
> > > Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 i386linux elf_l1om 
> > > elf_k1om
> > > ```
> > > and therefore fails.
> > > 
> > > I'm on an x86_64 Linux and obviously my `GNU ld version 
> > > 2.23.52.0.1-55.el7 20130226` doesn't support Power :-(
> > Oh, right... I cannot run the bundler in the regression tests to tests the 
> > bundler. I guess I need some sort of dry run option to check the commands 
> > are correct without actually running them.
> > 
> > I'll fix that.
> Yes, comparable to `-###` in `clang`?
> 
> Another option (that I don't really prefer, just for completeness) would be 
> to have separate tests that have appropriate `REQUIRES`...
Yes, `-###` is exactly what I was aiming at.


http://reviews.llvm.org/D21851



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


Re: [PATCH] D21971: Explicitly export symbols from the sample analyzer plugin

2016-07-08 Thread John Brawn via cfe-commits
john.brawn added a comment.

> Do you known if there is any good reason Analyzer plugins aren't using the 
> Registry system (thus forcing plugin writers to manually export the 
> functions)?


Your guess is as good as mine.


Repository:
  rL LLVM

http://reviews.llvm.org/D21971



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


r274859 - Don't crash when printing auto variables.

2016-07-08 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Fri Jul  8 11:04:22 2016
New Revision: 274859

URL: http://llvm.org/viewvc/llvm-project?rev=274859&view=rev
Log:
Don't crash when printing auto variables.

Patch by Axel Naumann!

Modified:
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/test/SemaCXX/ast-print.cpp

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=274859&r1=274858&r2=274859&view=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Fri Jul  8 11:04:22 2016
@@ -132,6 +132,8 @@ static QualType GetBaseType(QualType T)
   BaseType = VTy->getElementType();
 else if (const ReferenceType *RTy = BaseType->getAs())
   BaseType = RTy->getPointeeType();
+else if (const AutoType *ATy = BaseType->getAs())
+  BaseType = ATy->getDeducedType();
 else
   llvm_unreachable("Unknown declarator!");
   }

Modified: cfe/trunk/test/SemaCXX/ast-print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ast-print.cpp?rev=274859&r1=274858&r2=274859&view=diff
==
--- cfe/trunk/test/SemaCXX/ast-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/ast-print.cpp Fri Jul  8 11:04:22 2016
@@ -227,3 +227,12 @@ template  struct Foo : T {
   using T::operator-;
 };
 }
+
+namespace dont_crash {
+struct T { enum E {X = 12ll }; };
+struct S {
+  struct  { int I; } ADecl;
+  static const auto Y = T::X;
+};
+//CHECK: static const auto Y = T::X;
+}


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


r274871 - Explicitly export symbols from the sample analyzer plugin

2016-07-08 Thread John Brawn via cfe-commits
Author: john.brawn
Date: Fri Jul  8 11:20:57 2016
New Revision: 274871

URL: http://llvm.org/viewvc/llvm-project?rev=274871&view=rev
Log:
Explicitly export symbols from the sample analyzer plugin

This is done so that it will work when built using MSVC if
LLVM_EXPORT_SYMBOLS_FOR_PLUGINS=ON.

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

Added:
cfe/trunk/examples/analyzer-plugin/SampleAnalyzerPlugin.exports
Modified:
cfe/trunk/examples/analyzer-plugin/CMakeLists.txt

Modified: cfe/trunk/examples/analyzer-plugin/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/analyzer-plugin/CMakeLists.txt?rev=274871&r1=274870&r2=274871&view=diff
==
--- cfe/trunk/examples/analyzer-plugin/CMakeLists.txt (original)
+++ cfe/trunk/examples/analyzer-plugin/CMakeLists.txt Fri Jul  8 11:20:57 2016
@@ -1,4 +1,5 @@
-add_llvm_loadable_module(SampleAnalyzerPlugin MainCallChecker.cpp)
+set(LLVM_EXPORTED_SYMBOL_FILE 
${CMAKE_CURRENT_SOURCE_DIR}/SampleAnalyzerPlugin.exports)
+add_llvm_loadable_module(SampleAnalyzerPlugin MainCallChecker.cpp PLUGIN_TOOL 
clang)
 
 if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
   target_link_libraries(SampleAnalyzerPlugin PRIVATE

Added: cfe/trunk/examples/analyzer-plugin/SampleAnalyzerPlugin.exports
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/analyzer-plugin/SampleAnalyzerPlugin.exports?rev=274871&view=auto
==
--- cfe/trunk/examples/analyzer-plugin/SampleAnalyzerPlugin.exports (added)
+++ cfe/trunk/examples/analyzer-plugin/SampleAnalyzerPlugin.exports Fri Jul  8 
11:20:57 2016
@@ -0,0 +1,2 @@
+clang_registerCheckers
+clang_analyzerAPIVersionString


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


Re: [PATCH] D21971: Explicitly export symbols from the sample analyzer plugin

2016-07-08 Thread John Brawn via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL274871: Explicitly export symbols from the sample analyzer 
plugin (authored by john.brawn).

Changed prior to commit:
  http://reviews.llvm.org/D21971?vs=62674&id=63248#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21971

Files:
  cfe/trunk/examples/analyzer-plugin/CMakeLists.txt
  cfe/trunk/examples/analyzer-plugin/SampleAnalyzerPlugin.exports

Index: cfe/trunk/examples/analyzer-plugin/CMakeLists.txt
===
--- cfe/trunk/examples/analyzer-plugin/CMakeLists.txt
+++ cfe/trunk/examples/analyzer-plugin/CMakeLists.txt
@@ -1,4 +1,5 @@
-add_llvm_loadable_module(SampleAnalyzerPlugin MainCallChecker.cpp)
+set(LLVM_EXPORTED_SYMBOL_FILE 
${CMAKE_CURRENT_SOURCE_DIR}/SampleAnalyzerPlugin.exports)
+add_llvm_loadable_module(SampleAnalyzerPlugin MainCallChecker.cpp PLUGIN_TOOL 
clang)
 
 if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
   target_link_libraries(SampleAnalyzerPlugin PRIVATE
Index: cfe/trunk/examples/analyzer-plugin/SampleAnalyzerPlugin.exports
===
--- cfe/trunk/examples/analyzer-plugin/SampleAnalyzerPlugin.exports
+++ cfe/trunk/examples/analyzer-plugin/SampleAnalyzerPlugin.exports
@@ -0,0 +1,2 @@
+clang_registerCheckers
+clang_analyzerAPIVersionString


Index: cfe/trunk/examples/analyzer-plugin/CMakeLists.txt
===
--- cfe/trunk/examples/analyzer-plugin/CMakeLists.txt
+++ cfe/trunk/examples/analyzer-plugin/CMakeLists.txt
@@ -1,4 +1,5 @@
-add_llvm_loadable_module(SampleAnalyzerPlugin MainCallChecker.cpp)
+set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/SampleAnalyzerPlugin.exports)
+add_llvm_loadable_module(SampleAnalyzerPlugin MainCallChecker.cpp PLUGIN_TOOL clang)
 
 if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
   target_link_libraries(SampleAnalyzerPlugin PRIVATE
Index: cfe/trunk/examples/analyzer-plugin/SampleAnalyzerPlugin.exports
===
--- cfe/trunk/examples/analyzer-plugin/SampleAnalyzerPlugin.exports
+++ cfe/trunk/examples/analyzer-plugin/SampleAnalyzerPlugin.exports
@@ -0,0 +1,2 @@
+clang_registerCheckers
+clang_analyzerAPIVersionString
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r274879 - clang/unittests/Analysis/CFGTest.cpp: Appease msc targets with -fno-delayed-template-parsing.

2016-07-08 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Fri Jul  8 11:52:36 2016
New Revision: 274879

URL: http://llvm.org/viewvc/llvm-project?rev=274879&view=rev
Log:
clang/unittests/Analysis/CFGTest.cpp: Appease msc targets with 
-fno-delayed-template-parsing.

Modified:
cfe/trunk/unittests/Analysis/CFGTest.cpp

Modified: cfe/trunk/unittests/Analysis/CFGTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Analysis/CFGTest.cpp?rev=274879&r1=274878&r2=274879&view=diff
==
--- cfe/trunk/unittests/Analysis/CFGTest.cpp (original)
+++ cfe/trunk/unittests/Analysis/CFGTest.cpp Fri Jul  8 11:52:36 2016
@@ -48,7 +48,7 @@ TEST(CFG, RangeBasedForOverDependentType
   Finder.addMatcher(ast_matchers::functionDecl().bind("func"), &Callback);
   std::unique_ptr Factory(
   tooling::newFrontendActionFactory(&Finder));
-  std::vector Args = {"-std=c++11"};
+  std::vector Args = {"-std=c++11", 
"-fno-delayed-template-parsing"};
   ASSERT_TRUE(tooling::runToolOnCodeWithArgs(Factory->create(), Code, Args));
   EXPECT_TRUE(Callback.SawFunctionBody);
 }


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


[libcxx] r274880 - Implement LWG685 (which is from C++11!). Fixes PR#28421. Note: this (subtly) changes the return type of operator-(Iter1, Iter2) where Iter1 is a reverse iterator or a move_iterator,

2016-07-08 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Fri Jul  8 11:54:47 2016
New Revision: 274880

URL: http://llvm.org/viewvc/llvm-project?rev=274880&view=rev
Log:
Implement LWG685 (which is from C++11!). Fixes PR#28421.  Note: this (subtly) 
changes the return type of operator-(Iter1, Iter2) where Iter1 is a reverse 
iterator or a move_iterator, and Iter2 is some other move/reverse iterator 
type. In practice, I believe that almost every time the second param will be 
const_XXX and this will mean that the return type will be the same as it was 
before.


Modified:
libcxx/trunk/include/iterator

Modified: libcxx/trunk/include/iterator
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iterator?rev=274880&r1=274879&r2=274880&view=diff
==
--- libcxx/trunk/include/iterator (original)
+++ libcxx/trunk/include/iterator Fri Jul  8 11:54:47 2016
@@ -131,8 +131,9 @@ bool
 operator<=(const reverse_iterator& x, const 
reverse_iterator& y);
 
 template 
-typename reverse_iterator::difference_type
-operator-(const reverse_iterator& x, const 
reverse_iterator& y);
+auto
+operator-(const reverse_iterator& x, const 
reverse_iterator& y)
+-> decltype(__y.base() - __x.base());
 
 template 
 reverse_iterator
@@ -205,6 +206,73 @@ public:
 template 
 insert_iterator inserter(Container& x, Iterator i);
 
+template 
+class move_iterator {
+public:
+typedef Iterator  
iterator_type;
+typedef typename iterator_traits::difference_type   
difference_type;
+typedef Iterator  pointer;
+typedef typename iterator_traits::value_typevalue_type;
+typedef typename iterator_traits::iterator_category 
iterator_category;
+typedef value_type&&  reference;
+ 
+move_iterator();
+explicit move_iterator(Iterator i);
+template  move_iterator(const move_iterator& u);
+template  move_iterator& operator=(const move_iterator& u);
+iterator_type base() const;
+reference operator*() const;
+pointer operator->() const;
+move_iterator& operator++();
+move_iterator operator++(int);
+move_iterator& operator--();
+move_iterator operator--(int);
+move_iterator operator+(difference_type n) const; 
+move_iterator& operator+=(difference_type n); 
+move_iterator operator-(difference_type n) const; 
+move_iterator& operator-=(difference_type n); 
+unspecified operator[](difference_type n) const;
+private:
+Iterator current; // exposition only
+};
+
+template 
+bool
+operator==(const move_iterator& x, const move_iterator& 
y);
+
+template 
+bool
+operator!=(const move_iterator& x, const move_iterator& 
y);
+
+template 
+bool
+operator<(const move_iterator& x, const move_iterator& 
y);
+
+template 
+bool
+operator<=(const move_iterator& x, const move_iterator& 
y);
+
+template 
+bool
+operator>(const move_iterator& x, const move_iterator& 
y);
+
+template 
+bool
+operator>=(const move_iterator& x, const move_iterator& 
y);
+
+template 
+auto
+operator-(const move_iterator& x,
+  const move_iterator& y) -> decltype(x.base() - y.base());
+
+template 
+move_iterator operator+(typename 
move_iterator::difference_type n, 
+ const move_iterator& x);
+
+template 
+move_iterator make_move_iterator(const Iterator& i);
+
+
 template , 
class Distance = ptrdiff_t>
 class istream_iterator
 : public iterator
@@ -632,6 +700,16 @@ operator<=(const reverse_iterator<_Iter1
 return __x.base() >= __y.base();
 }
 
+#if __cplusplus >= 201103L
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+auto
+operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& 
__y)
+-> decltype(__y.base() - __x.base())
+{
+return __y.base() - __x.base();
+}
+#else
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 typename reverse_iterator<_Iter1>::difference_type
@@ -639,6 +717,7 @@ operator-(const reverse_iterator<_Iter1>
 {
 return __y.base() - __x.base();
 }
+#endif
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
@@ -1038,6 +1117,16 @@ operator<=(const move_iterator<_Iter1>&
 return __x.base() <= __y.base();
 }
 
+#if __cplusplus >= 201103L
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+auto
+operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
+-> decltype(__x.base() - __y.base())
+{
+return __x.base() - __y.base();
+}
+#else
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 typename move_iterator<_Iter1>::difference_type
@@ -1045,6 +1134,7 @@ operator-(const move_iterator<_Iter1>& _
 {
 return __x.base() - __y.base();
 }
+#endif
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
@@ -1096,10 +1186,18 @@ _LIBCPP_INLINE_VISIBILITY
 bool
 operator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
 
+#if __cplusplus >= 201103L
+template 
+_LIBCPP_INLINE_VISIBILITY
+auto
+operator-(const __wrap_iter<_Iter1>

[libcxx] r274882 - Fix typo in #ifdef; leave tests commented out b/c gcc 4.8 harks on them.

2016-07-08 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Fri Jul  8 11:59:54 2016
New Revision: 274882

URL: http://llvm.org/viewvc/llvm-project?rev=274882&view=rev
Log:
Fix typo in #ifdef; leave tests commented out b/c gcc 4.8 harks on them.


Modified:

libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp?rev=274882&r1=274881&r2=274882&view=diff
==
--- 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
 Fri Jul  8 11:59:54 2016
@@ -104,10 +104,10 @@ int main()
 
 //  LWG 2560  -- postpone this test until bots updated
 // test_is_not_constructible ();
-// #if TEST_STD_VERS > 11
+#if TEST_STD_VER > 11
 // test_is_not_constructible ();
 // test_is_not_constructible ();
 // test_is_not_constructible ();
 // test_is_not_constructible ();
-// #endif
+#endif
 }


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


r274885 - CFGTests: Update libdeps.

2016-07-08 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Fri Jul  8 12:06:27 2016
New Revision: 274885

URL: http://llvm.org/viewvc/llvm-project?rev=274885&view=rev
Log:
CFGTests: Update libdeps.

Modified:
cfe/trunk/unittests/Analysis/CMakeLists.txt

Modified: cfe/trunk/unittests/Analysis/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Analysis/CMakeLists.txt?rev=274885&r1=274884&r2=274885&view=diff
==
--- cfe/trunk/unittests/Analysis/CMakeLists.txt (original)
+++ cfe/trunk/unittests/Analysis/CMakeLists.txt Fri Jul  8 12:06:27 2016
@@ -8,6 +8,9 @@ add_clang_unittest(CFGTests
 
 target_link_libraries(CFGTests
   clangAnalysis
+  clangAST
   clangASTMatchers
+  clangBasic
+  clangFrontend
   clangTooling
   )


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


Re: [PATCH] D21823: [Driver] Add flags for enabling both types of PGO Instrumentation

2016-07-08 Thread Xinliang David Li via cfe-commits
On Sun, Jul 3, 2016 at 1:50 PM, Sean Silva  wrote:

>
>
> On Sat, Jul 2, 2016 at 7:38 PM, Xinliang David Li 
> wrote:
>
>> Sanitizers are different IMO. Different santizers are rather independent,
>> and there is no such thing as -fsantize to mean -fsantize=all
>>
>> For PGO, in most of the cases, users do not need to care about the
>> sub-options implied -- by default they should just get the best profiling
>> (whatever that is). Fine-grained control is more useful for savvy users.
>> Besides, any flavor of value profiling usually does not make sense to be
>> used standalone and need to be used with edge profiling for max benefit
>> (also not supported in our implementation) - so I don't see why pgo control
>> needs to be done in a way similar to sanitizers.
>>
>
> Thanks for the explanation. So I think we can start by reducing this patch
> to just `-fpgo-train` (enables IRPGO), `-fpgo-train-file=`, and
> `-fpgo-apply=`.
>
> While -fpgo-apply= is technically redundant with -fprofile-instr-use, I
> think it is useful for consistency.
>
> I'm also indifferent to adding
> `-fpgo-train=source`/`-fpgo-train=optimizer` in this patch.
>


I like this suggestion (the reduced version).



>
> btw, I don't understand the intuition for calling IRPGO "cfg"; maybe you
> could explain?
>


> I like "optimizer" because it is easy to document to users, as users
> generally understand the difference between the "optimizer" and
> source-level analysis of their program. For example, we could document:
> "-fpgo-train=source instruments at source-level similar to code coverage
> instrumentation. -fpgo-train=optimizer applies the instrumentation inside
> the optimizer and has freedom to do sophisticated analyses and
> transformations as part of the instrumentation process; these analyses and
> transformations allow it to reduce instrumentation overhead and increase
> profile accuracy."
>
>
I am fine with using source/optimizer. I was mainly against overloading
-fpgo-train to do fine grain control.

David


>
> -- Sean Silva
>
>
>>
>>  In other words, I don't think the primary option -fpgo-train should be
>> used for fine-grain suboption control.   If we have a different option to
>> do fine-grain control for PGO, using sanitize like syntax is fine with me:
>>
>> -fpgo-xxx=y:z  turn on y and z for pgo
>> -fno-pgo-xxx=y:z  turn off y and z for pgo
>> or
>> -fpgo-xxx=no-w:no-y:z   turn on z but turn off w, and y
>>
>>
>> David
>>
>>
>> On Sat, Jul 2, 2016 at 6:45 PM, Sean Silva  wrote:
>>
>>>
>>>
>>> On Sat, Jul 2, 2016 at 1:57 PM, Xinliang David Li 
>>> wrote:
>>>


 On Fri, Jul 1, 2016 at 4:32 PM, Sean Silva 
 wrote:

> silvas added inline comments.
>
> 
> Comment at: lib/Driver/Tools.cpp:3560
> @@ +3559,3 @@
> +if (PGOTrainArg->getOption().matches(options::OPT_fpgo_train_EQ))
> {
> +  if (StringRef(PGOTrainArg->getValue()) == "source-cfg")
> +CmdArgs.push_back("-fprofile-instrument=clang");
> 
> davidxl wrote:
> > I think it is better to make the selector  'source' vs 'cfg'.
> >
> > -fpgo-train=source
> > -fpgo-train=cfg
> So would `-fpgo-train=cfg` enable icall instrumentation or not?
>
> My thinking is that down the road we will have one flag for each
> independent instrumentation capability (and of course some are mutually
> incompatible). This mirrors what the sanitizers do. For example, we would
> have:
> `-fpgo-train=optimizer-cfg` --> IR edge profiling
> `-fpgo-train=optimizer-icall` --> IR icall value profiling
> `-fpgo-train=optimizer-...` --> other independent instrumentation we
> can do in IR instrumentation.
> `-fpgo-train=source-cfg` --> FE edge profiling
> `-fpgo-train=source-icall` --> FE icall profiling (if that even
> exists; I see some code but there is no user-visible flag)
> `-fpgo-train=source-...` --> other FE instrumentation.
>
> We can then have `-fpgo-train=optimizer` enable e.g.
> `-fpgo-train=optimizer-cfg,optimizer-icall`.
> We can also have `-fpgo-train=source` enable e.g.
> `-fpgo-train=source-cfg`.
>
> Since instrumentation can have different overheads or different
> runtime requirements, users may want to disable some instrumentation.
>
>

 -fpgo-train is the new umbrella option that turn on at least edge
 profiling and some other flavor of value profiling (icall, or stringop, etc
 in the the future). There is a default setting for source or cfg based PGO.
 The fine grain control of each sub-option should be done via a different
 flag -- otherwise we will have to introduce 2 x N sub-options if used with
 -fpgo-train.  In other words, -fpgo-train=cfg turns on edge and icall
 profiling as of today.

 To summarize, I think the following behavior will be nice to users:

 1) -fpgo-train when used without any option, it defaults to IR

Re: [PATCH] D22067: [OpenCL] Add missing -cl-no-signed-zeros option into driver

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

LGTM! Thanks!


http://reviews.llvm.org/D22067



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


Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-07-08 Thread Ben Craig via cfe-commits
bcraig added a comment.

LGTM (with a comment nit), but you'll need to get approval from @ericwf or 
@mclow.lists.

I would like some of the information from your stack overflow post to make it's 
way to the comments.  In particular, I think I would like to see it documented 
that we have made a choice for some undefined behavior.


http://reviews.llvm.org/D21803



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


r274897 - Fix flag name in comment in cuda-version-check.cu.

2016-07-08 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Fri Jul  8 12:59:24 2016
New Revision: 274897

URL: http://llvm.org/viewvc/llvm-project?rev=274897&view=rev
Log:
Fix flag name in comment in cuda-version-check.cu.

Modified:
cfe/trunk/test/Driver/cuda-version-check.cu

Modified: cfe/trunk/test/Driver/cuda-version-check.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-version-check.cu?rev=274897&r1=274896&r2=274897&view=diff
==
--- cfe/trunk/test/Driver/cuda-version-check.cu (original)
+++ cfe/trunk/test/Driver/cuda-version-check.cu Fri Jul  8 12:59:24 2016
@@ -34,7 +34,7 @@
 // RUN:--sysroot=%S/Inputs/CUDA 2>&1 %s | \
 // RUN:FileCheck %s --check-prefix=OK
 
-// -nocuda-version-check should suppress all of these errors.
+// --no-cuda-version-check should suppress all of these errors.
 // RUN: %clang -v -### --cuda-gpu-arch=sm_60 --sysroot=%S/Inputs/CUDA 2>&1 \
 // RUN:--no-cuda-version-check %s | \
 // RUN:FileCheck %s --check-prefix=OK


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


Re: [PATCH] D20795: Added basic capabilities to detect source code clones.

2016-07-08 Thread Raphael Isemann via cfe-commits
teemperor updated this revision to Diff 63262.
teemperor marked 7 inline comments as done.

http://reviews.llvm.org/D20795

Files:
  include/clang/AST/CloneDetection.h
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/AST/CMakeLists.txt
  lib/AST/CloneDetection.cpp
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  test/Analysis/copypaste/test-min-max.cpp
  test/Analysis/copypaste/test-sub-sequences.cpp

Index: test/Analysis/copypaste/test-sub-sequences.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-sub-sequences.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=clone.CloneChecker -verify %s
+
+// We test if sub-sequences can match with normal sequences containing only
+// a single statement.
+
+void log2(int a);
+void log();
+
+int max(int a, int b) {
+  log2(a);
+  log(); // expected-warning{{Detected code clone.}}
+  if (a > b)
+return a;
+  return b;
+}
+
+int maxClone(int a, int b) {
+  log(); // expected-note{{Related code clone is here.}}
+  if (a > b)
+return a;
+  return b;
+}
+
+// Functions below are not clones and should not be reported.
+
+int foo(int a, int b) {
+  return a + b;
+}
Index: test/Analysis/copypaste/test-min-max.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-min-max.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=clone.CloneChecker -verify %s
+
+void log();
+
+int max(int a, int b) { // expected-warning{{Detected code clone.}}
+  log();
+  if (a > b)
+return a;
+  return b;
+}
+
+int maxClone(int a, int b) { // expected-note{{Related code clone is here.}}
+  log();
+  if (a > b)
+return a;
+  return b;
+}
+
+// False positives below. These clones should not be reported.
+
+// FIXME: Detect different binary operator kinds.
+int min1(int a, int b) { // expected-note{{Related code clone is here.}}
+  log();
+  if (a < b)
+return a;
+  return b;
+}
+
+// FIXME: Detect different variable patterns.
+int min2(int a, int b) { // expected-note{{Related code clone is here.}}
+  log();
+  if (b > a)
+return a;
+  return b;
+}
+
+// Functions below are not clones and should not be reported.
+
+int foo(int a, int b) {
+  return a + b;
+}
Index: lib/StaticAnalyzer/Checkers/CloneChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/CloneChecker.cpp
@@ -0,0 +1,67 @@
+//===--- CloneDetection.cpp - Clone detection checkers --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// CloneChecker is a checker that reports clones in the current translation
+/// unit.
+///
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/AST/CloneDetection.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+class CloneChecker : public Checker {
+
+public:
+  void checkEndOfTranslationUnit(const TranslationUnitDecl *TU,
+ AnalysisManager &Mgr, BugReporter &BR) const;
+};
+} // end anonymous namespace
+
+void CloneChecker::checkEndOfTranslationUnit(const TranslationUnitDecl *TU,
+ AnalysisManager &Mgr,
+ BugReporter &BR) const {
+  CloneDetector CloneDetector;
+  CloneDetector.AnalyzeTranslationUnitDecl(
+  TU->getASTContext().getTranslationUnitDecl());
+
+  std::vector CloneGroups;
+  CloneDetector.findClones(CloneGroups);
+
+  DiagnosticsEngine &DiagEngine = Mgr.getDiagnostic();
+
+  unsigned WarnID = DiagEngine.getCustomDiagID(DiagnosticsEngine::Warning,
+   "Detected code clone.");
+
+  unsigned NoteID = DiagEngine.getCustomDiagID(DiagnosticsEngine::Note,
+   "Related code clone is here.");
+
+  for (CloneDetector::CloneGroup &Group : CloneGroups) {
+DiagEngine.Report(Group.front().getStartLoc(), WarnID);
+for (unsigned J = 1; J < Group.size(); ++J) {
+  DiagEngine.Report(Group[J].getStartLoc(), NoteID);
+}
+  }
+}
+
+//===--===//
+// Register CloneChecker
+//===--===//
+
+void ento::registerCloneChecker(CheckerManager &Mgr) {
+  Mgr.registerChecker();
+}
Index: li

LLVM buildmaster will be restarted tonight

2016-07-08 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] D20786: Fix undefined behavior in __tree

2016-07-08 Thread Eric Fiselier via cfe-commits
EricWF updated this revision to Diff 63267.
EricWF added a comment.

Fix merge conflicts in __config.


http://reviews.llvm.org/D20786

Files:
  include/__config
  include/__tree
  test/libcxx/containers/associative/tree_balance_after_insert.pass.cpp
  test/libcxx/containers/associative/tree_left_rotate.pass.cpp
  test/libcxx/containers/associative/tree_remove.pass.cpp
  test/libcxx/containers/associative/tree_right_rotate.pass.cpp

Index: test/libcxx/containers/associative/tree_right_rotate.pass.cpp
===
--- test/libcxx/containers/associative/tree_right_rotate.pass.cpp
+++ test/libcxx/containers/associative/tree_right_rotate.pass.cpp
@@ -23,6 +23,9 @@
 Node* __right_;
 Node* __parent_;
 
+Node* __parent_unsafe() const { return __parent_; }
+void __set_parent(Node* x) { __parent_ = x;}
+
 Node() : __left_(), __right_(), __parent_() {}
 };
 
Index: test/libcxx/containers/associative/tree_remove.pass.cpp
===
--- test/libcxx/containers/associative/tree_remove.pass.cpp
+++ test/libcxx/containers/associative/tree_remove.pass.cpp
@@ -24,6 +24,9 @@
 Node* __parent_;
 bool __is_black_;
 
+Node* __parent_unsafe() const { return __parent_; }
+void __set_parent(Node* x) { __parent_ = x;}
+
 Node() : __left_(), __right_(), __parent_(), __is_black_() {}
 };
 
Index: test/libcxx/containers/associative/tree_left_rotate.pass.cpp
===
--- test/libcxx/containers/associative/tree_left_rotate.pass.cpp
+++ test/libcxx/containers/associative/tree_left_rotate.pass.cpp
@@ -23,6 +23,9 @@
 Node* __right_;
 Node* __parent_;
 
+Node* __parent_unsafe() const { return __parent_; }
+void __set_parent(Node* x) { __parent_ = x;}
+
 Node() : __left_(), __right_(), __parent_() {}
 };
 
Index: test/libcxx/containers/associative/tree_balance_after_insert.pass.cpp
===
--- test/libcxx/containers/associative/tree_balance_after_insert.pass.cpp
+++ test/libcxx/containers/associative/tree_balance_after_insert.pass.cpp
@@ -24,6 +24,9 @@
 Node* __parent_;
 bool __is_black_;
 
+Node* __parent_unsafe() const { return __parent_; }
+void __set_parent(Node* x) { __parent_ = x;}
+
 Node() : __left_(), __right_(), __parent_(), __is_black_() {}
 };
 
Index: include/__tree
===
--- include/__tree
+++ include/__tree
@@ -165,21 +165,36 @@
 if (__x->__right_ != nullptr)
 return __tree_min(__x->__right_);
 while (!__tree_is_left_child(__x))
-__x = __x->__parent_;
-return __x->__parent_;
+__x = __x->__parent_unsafe();
+return __x->__parent_unsafe();
+}
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+_EndNodePtr
+__tree_next_iter(_NodePtr __x) _NOEXCEPT
+{
+if (__x->__right_ != nullptr)
+return static_cast<_EndNodePtr>(__tree_min(__x->__right_));
+while (!__tree_is_left_child(__x))
+__x = __x->__parent_unsafe();
+return static_cast<_EndNodePtr>(__x->__parent_);
 }
 
 // Returns:  pointer to the previous in-order node before __x.
 // Precondition:  __x != nullptr.
-template 
+// Note: __x may be the end node.
+template 
+inline _LIBCPP_INLINE_VISIBILITY
 _NodePtr
-__tree_prev(_NodePtr __x) _NOEXCEPT
+__tree_prev_iter(_EndNodePtr __x) _NOEXCEPT
 {
 if (__x->__left_ != nullptr)
 return __tree_max(__x->__left_);
-while (__tree_is_left_child(__x))
-__x = __x->__parent_;
-return __x->__parent_;
+_NodePtr __xx = static_cast<_NodePtr>(__x);
+while (__tree_is_left_child(__xx))
+__xx = __xx->__parent_unsafe();
+return __xx->__parent_unsafe();
 }
 
 // Returns:  pointer to a node which has no children
@@ -215,14 +230,14 @@
 _NodePtr __y = __x->__right_;
 __x->__right_ = __y->__left_;
 if (__x->__right_ != nullptr)
-__x->__right_->__parent_ = __x;
+__x->__right_->__set_parent(__x);
 __y->__parent_ = __x->__parent_;
 if (__tree_is_left_child(__x))
 __x->__parent_->__left_ = __y;
 else
-__x->__parent_->__right_ = __y;
+__x->__parent_unsafe()->__right_ = __y;
 __y->__left_ = __x;
-__x->__parent_ = __y;
+__x->__set_parent(__y);
 }
 
 // Effects:  Makes __x->__left_ the subtree root with __x as its right child
@@ -235,14 +250,14 @@
 _NodePtr __y = __x->__left_;
 __x->__left_ = __y->__right_;
 if (__x->__left_ != nullptr)
-__x->__left_->__parent_ = __x;
+__x->__left_->__set_parent(__x);
 __y->__parent_ = __x->__parent_;
 if (__tree_is_left_child(__x))
 __x->__parent_->__left_ = __y;
 else
-__x->__parent_->__right_ = __y;
+__x->__parent_unsafe()->__right_ = __y;
 __y->__right_ = __x;
-__x->__parent_ = __y;
+__x->__set_parent(__y);

Re: [PATCH] D20795: Added basic capabilities to detect source code clones.

2016-07-08 Thread Raphael Isemann via cfe-commits
teemperor updated this revision to Diff 63266.
teemperor added a comment.

- StmtSequence is now treating all Stmt objects as const.


http://reviews.llvm.org/D20795

Files:
  include/clang/AST/CloneDetection.h
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/AST/CMakeLists.txt
  lib/AST/CloneDetection.cpp
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  test/Analysis/copypaste/test-min-max.cpp
  test/Analysis/copypaste/test-sub-sequences.cpp

Index: test/Analysis/copypaste/test-sub-sequences.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-sub-sequences.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=clone.CloneChecker -verify %s
+
+// We test if sub-sequences can match with normal sequences containing only
+// a single statement.
+
+void log2(int a);
+void log();
+
+int max(int a, int b) {
+  log2(a);
+  log(); // expected-warning{{Detected code clone.}}
+  if (a > b)
+return a;
+  return b;
+}
+
+int maxClone(int a, int b) {
+  log(); // expected-note{{Related code clone is here.}}
+  if (a > b)
+return a;
+  return b;
+}
+
+// Functions below are not clones and should not be reported.
+
+int foo(int a, int b) {
+  return a + b;
+}
Index: test/Analysis/copypaste/test-min-max.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-min-max.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=clone.CloneChecker -verify %s
+
+void log();
+
+int max(int a, int b) { // expected-warning{{Detected code clone.}}
+  log();
+  if (a > b)
+return a;
+  return b;
+}
+
+int maxClone(int a, int b) { // expected-note{{Related code clone is here.}}
+  log();
+  if (a > b)
+return a;
+  return b;
+}
+
+// False positives below. These clones should not be reported.
+
+// FIXME: Detect different binary operator kinds.
+int min1(int a, int b) { // expected-note{{Related code clone is here.}}
+  log();
+  if (a < b)
+return a;
+  return b;
+}
+
+// FIXME: Detect different variable patterns.
+int min2(int a, int b) { // expected-note{{Related code clone is here.}}
+  log();
+  if (b > a)
+return a;
+  return b;
+}
+
+// Functions below are not clones and should not be reported.
+
+int foo(int a, int b) {
+  return a + b;
+}
Index: lib/StaticAnalyzer/Checkers/CloneChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/CloneChecker.cpp
@@ -0,0 +1,67 @@
+//===--- CloneDetection.cpp - Clone detection checkers --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// CloneChecker is a checker that reports clones in the current translation
+/// unit.
+///
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/AST/CloneDetection.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+class CloneChecker : public Checker {
+
+public:
+  void checkEndOfTranslationUnit(const TranslationUnitDecl *TU,
+ AnalysisManager &Mgr, BugReporter &BR) const;
+};
+} // end anonymous namespace
+
+void CloneChecker::checkEndOfTranslationUnit(const TranslationUnitDecl *TU,
+ AnalysisManager &Mgr,
+ BugReporter &BR) const {
+  CloneDetector CloneDetector;
+  CloneDetector.AnalyzeTranslationUnitDecl(
+  TU->getASTContext().getTranslationUnitDecl());
+
+  std::vector CloneGroups;
+  CloneDetector.findClones(CloneGroups);
+
+  DiagnosticsEngine &DiagEngine = Mgr.getDiagnostic();
+
+  unsigned WarnID = DiagEngine.getCustomDiagID(DiagnosticsEngine::Warning,
+   "Detected code clone.");
+
+  unsigned NoteID = DiagEngine.getCustomDiagID(DiagnosticsEngine::Note,
+   "Related code clone is here.");
+
+  for (CloneDetector::CloneGroup &Group : CloneGroups) {
+DiagEngine.Report(Group.front().getStartLoc(), WarnID);
+for (unsigned J = 1; J < Group.size(); ++J) {
+  DiagEngine.Report(Group[J].getStartLoc(), NoteID);
+}
+  }
+}
+
+//===--===//
+// Register CloneChecker
+//===--===//
+
+void ento::registerCloneChecker(CheckerManager &Mg

[PATCH] D22146: clang-format: [JS] Sort imports case insensitive.

2016-07-08 Thread Martin Probst via cfe-commits
mprobst created this revision.
mprobst added a reviewer: djasper.
mprobst added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

ASCII case sorting does not help finding imported symbols quickly, and it is 
common to have e.g. class Foo and function fooFactory exported/imported from 
the same file.

http://reviews.llvm.org/D22146

Files:
  lib/Format/SortJavaScriptImports.cpp
  unittests/Format/SortImportsTestJS.cpp

Index: unittests/Format/SortImportsTestJS.cpp
===
--- unittests/Format/SortImportsTestJS.cpp
+++ unittests/Format/SortImportsTestJS.cpp
@@ -236,6 +236,27 @@
  "1;");
 }
 
+TEST_F(SortImportsTestJS, SortCaseInsensitive) {
+  verifySort("import {A} from 'aa';\n"
+ "import {A} from 'Ab';\n"
+ "import {A} from 'b';\n"
+ "import {A} from 'Bc';\n"
+ "\n"
+ "1;",
+ "import {A} from 'b';\n"
+ "import {A} from 'Bc';\n"
+ "import {A} from 'Ab';\n"
+ "import {A} from 'aa';\n"
+ "\n"
+ "1;");
+  verifySort("import {aa, Ab, b, Bc} from 'x';\n"
+ "\n"
+ "1;",
+ "import {b, Bc, Ab, aa} from 'x';\n"
+ "\n"
+ "1;");
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/SortJavaScriptImports.cpp
===
--- lib/Format/SortJavaScriptImports.cpp
+++ lib/Format/SortJavaScriptImports.cpp
@@ -105,8 +105,8 @@
   // Empty URLs sort *last* (for export {...};).
   if (LHS.URL.empty() != RHS.URL.empty())
 return LHS.URL.empty() < RHS.URL.empty();
-  if (LHS.URL != RHS.URL)
-return LHS.URL < RHS.URL;
+  if (int Res = LHS.URL.compare_lower(RHS.URL))
+return Res < 0;
   // '*' imports (with prefix) sort before {a, b, ...} imports.
   if (LHS.Prefix.empty() != RHS.Prefix.empty())
 return LHS.Prefix.empty() < RHS.Prefix.empty();
@@ -245,7 +245,8 @@
 std::stable_sort(
 Symbols.begin(), Symbols.end(),
 [&](const JsImportedSymbol &LHS, const JsImportedSymbol &RHS) {
-  return LHS.Symbol < RHS.Symbol;
+  int Res = LHS.Symbol.compare_lower(RHS.Symbol);
+  return Res < 0;
 });
 if (Symbols == Reference.Symbols) {
   // No change in symbol order.


Index: unittests/Format/SortImportsTestJS.cpp
===
--- unittests/Format/SortImportsTestJS.cpp
+++ unittests/Format/SortImportsTestJS.cpp
@@ -236,6 +236,27 @@
  "1;");
 }
 
+TEST_F(SortImportsTestJS, SortCaseInsensitive) {
+  verifySort("import {A} from 'aa';\n"
+ "import {A} from 'Ab';\n"
+ "import {A} from 'b';\n"
+ "import {A} from 'Bc';\n"
+ "\n"
+ "1;",
+ "import {A} from 'b';\n"
+ "import {A} from 'Bc';\n"
+ "import {A} from 'Ab';\n"
+ "import {A} from 'aa';\n"
+ "\n"
+ "1;");
+  verifySort("import {aa, Ab, b, Bc} from 'x';\n"
+ "\n"
+ "1;",
+ "import {b, Bc, Ab, aa} from 'x';\n"
+ "\n"
+ "1;");
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/SortJavaScriptImports.cpp
===
--- lib/Format/SortJavaScriptImports.cpp
+++ lib/Format/SortJavaScriptImports.cpp
@@ -105,8 +105,8 @@
   // Empty URLs sort *last* (for export {...};).
   if (LHS.URL.empty() != RHS.URL.empty())
 return LHS.URL.empty() < RHS.URL.empty();
-  if (LHS.URL != RHS.URL)
-return LHS.URL < RHS.URL;
+  if (int Res = LHS.URL.compare_lower(RHS.URL))
+return Res < 0;
   // '*' imports (with prefix) sort before {a, b, ...} imports.
   if (LHS.Prefix.empty() != RHS.Prefix.empty())
 return LHS.Prefix.empty() < RHS.Prefix.empty();
@@ -245,7 +245,8 @@
 std::stable_sort(
 Symbols.begin(), Symbols.end(),
 [&](const JsImportedSymbol &LHS, const JsImportedSymbol &RHS) {
-  return LHS.Symbol < RHS.Symbol;
+  int Res = LHS.Symbol.compare_lower(RHS.Symbol);
+  return Res < 0;
 });
 if (Symbols == Reference.Symbols) {
   // No change in symbol order.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D22147: clang-format: [JS] support trailing commas in imports.

2016-07-08 Thread Martin Probst via cfe-commits
mprobst created this revision.
mprobst added a reviewer: djasper.
mprobst added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

http://reviews.llvm.org/D22147

Files:
  lib/Format/SortJavaScriptImports.cpp
  unittests/Format/SortImportsTestJS.cpp

Index: unittests/Format/SortImportsTestJS.cpp
===
--- unittests/Format/SortImportsTestJS.cpp
+++ unittests/Format/SortImportsTestJS.cpp
@@ -236,6 +236,10 @@
  "1;");
 }
 
+TEST_F(SortImportsTestJS, TrailingComma) {
+  verifySort("import {A, B,} from 'aa';\n", "import {B, A,} from 'aa';\n");
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/SortJavaScriptImports.cpp
===
--- lib/Format/SortJavaScriptImports.cpp
+++ lib/Format/SortJavaScriptImports.cpp
@@ -396,6 +396,8 @@
 // {sym as alias, sym2 as ...} from '...';
 nextToken();
 while (true) {
+  if (Current->is(tok::r_brace))
+return true;
   if (Current->isNot(tok::identifier))
 return false;
 


Index: unittests/Format/SortImportsTestJS.cpp
===
--- unittests/Format/SortImportsTestJS.cpp
+++ unittests/Format/SortImportsTestJS.cpp
@@ -236,6 +236,10 @@
  "1;");
 }
 
+TEST_F(SortImportsTestJS, TrailingComma) {
+  verifySort("import {A, B,} from 'aa';\n", "import {B, A,} from 'aa';\n");
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/SortJavaScriptImports.cpp
===
--- lib/Format/SortJavaScriptImports.cpp
+++ lib/Format/SortJavaScriptImports.cpp
@@ -396,6 +396,8 @@
 // {sym as alias, sym2 as ...} from '...';
 nextToken();
 while (true) {
+  if (Current->is(tok::r_brace))
+return true;
   if (Current->isNot(tok::identifier))
 return false;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22146: clang-format: [JS] Sort imports case insensitive.

2016-07-08 Thread Martin Probst via cfe-commits
mprobst updated this revision to Diff 63271.
mprobst added a comment.

- clang-format: [JS] support trailing commas in imports.


http://reviews.llvm.org/D22146

Files:
  lib/Format/SortJavaScriptImports.cpp
  unittests/Format/SortImportsTestJS.cpp

Index: unittests/Format/SortImportsTestJS.cpp
===
--- unittests/Format/SortImportsTestJS.cpp
+++ unittests/Format/SortImportsTestJS.cpp
@@ -236,6 +236,27 @@
  "1;");
 }
 
+TEST_F(SortImportsTestJS, SortCaseInsensitive) {
+  verifySort("import {A} from 'aa';\n"
+ "import {A} from 'Ab';\n"
+ "import {A} from 'b';\n"
+ "import {A} from 'Bc';\n"
+ "\n"
+ "1;",
+ "import {A} from 'b';\n"
+ "import {A} from 'Bc';\n"
+ "import {A} from 'Ab';\n"
+ "import {A} from 'aa';\n"
+ "\n"
+ "1;");
+  verifySort("import {aa, Ab, b, Bc} from 'x';\n"
+ "\n"
+ "1;",
+ "import {b, Bc, Ab, aa} from 'x';\n"
+ "\n"
+ "1;");
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/SortJavaScriptImports.cpp
===
--- lib/Format/SortJavaScriptImports.cpp
+++ lib/Format/SortJavaScriptImports.cpp
@@ -105,8 +105,8 @@
   // Empty URLs sort *last* (for export {...};).
   if (LHS.URL.empty() != RHS.URL.empty())
 return LHS.URL.empty() < RHS.URL.empty();
-  if (LHS.URL != RHS.URL)
-return LHS.URL < RHS.URL;
+  if (int Res = LHS.URL.compare_lower(RHS.URL))
+return Res < 0;
   // '*' imports (with prefix) sort before {a, b, ...} imports.
   if (LHS.Prefix.empty() != RHS.Prefix.empty())
 return LHS.Prefix.empty() < RHS.Prefix.empty();
@@ -245,7 +245,7 @@
 std::stable_sort(
 Symbols.begin(), Symbols.end(),
 [&](const JsImportedSymbol &LHS, const JsImportedSymbol &RHS) {
-  return LHS.Symbol < RHS.Symbol;
+  return LHS.Symbol.compare_lower(RHS.Symbol) < 0;
 });
 if (Symbols == Reference.Symbols) {
   // No change in symbol order.


Index: unittests/Format/SortImportsTestJS.cpp
===
--- unittests/Format/SortImportsTestJS.cpp
+++ unittests/Format/SortImportsTestJS.cpp
@@ -236,6 +236,27 @@
  "1;");
 }
 
+TEST_F(SortImportsTestJS, SortCaseInsensitive) {
+  verifySort("import {A} from 'aa';\n"
+ "import {A} from 'Ab';\n"
+ "import {A} from 'b';\n"
+ "import {A} from 'Bc';\n"
+ "\n"
+ "1;",
+ "import {A} from 'b';\n"
+ "import {A} from 'Bc';\n"
+ "import {A} from 'Ab';\n"
+ "import {A} from 'aa';\n"
+ "\n"
+ "1;");
+  verifySort("import {aa, Ab, b, Bc} from 'x';\n"
+ "\n"
+ "1;",
+ "import {b, Bc, Ab, aa} from 'x';\n"
+ "\n"
+ "1;");
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/SortJavaScriptImports.cpp
===
--- lib/Format/SortJavaScriptImports.cpp
+++ lib/Format/SortJavaScriptImports.cpp
@@ -105,8 +105,8 @@
   // Empty URLs sort *last* (for export {...};).
   if (LHS.URL.empty() != RHS.URL.empty())
 return LHS.URL.empty() < RHS.URL.empty();
-  if (LHS.URL != RHS.URL)
-return LHS.URL < RHS.URL;
+  if (int Res = LHS.URL.compare_lower(RHS.URL))
+return Res < 0;
   // '*' imports (with prefix) sort before {a, b, ...} imports.
   if (LHS.Prefix.empty() != RHS.Prefix.empty())
 return LHS.Prefix.empty() < RHS.Prefix.empty();
@@ -245,7 +245,7 @@
 std::stable_sort(
 Symbols.begin(), Symbols.end(),
 [&](const JsImportedSymbol &LHS, const JsImportedSymbol &RHS) {
-  return LHS.Symbol < RHS.Symbol;
+  return LHS.Symbol.compare_lower(RHS.Symbol) < 0;
 });
 if (Symbols == Reference.Symbols) {
   // No change in symbol order.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22091: [clang-rename] exit code-related bugfix and code cleanup

2016-07-08 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

In http://reviews.llvm.org/D22091#476756, @vmiklos wrote:

> Can you please postpone the cleanup till http://reviews.llvm.org/D21814 is 
> reviewed? The two patches conflict with each other, I fear. Thanks. :-)


Ignore this, that one won't land as-is after all.


http://reviews.llvm.org/D22091



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


Re: r274628 - Include debug info for nested structs and classes

2016-07-08 Thread David Blaikie via cfe-commits
On Thu, Jul 7, 2016 at 4:22 PM, Adrian McCarthy  wrote:

> This patch was reverted because it breaks a test on the buildbots (that
> I've been unable to reproduce locally), so that's why you didn't seen
> anything.  I'll try again to land the patch once I can fix and verify that
> test.
>
> This patch is one part of the change.  The other part is
> http://reviews.llvm.org/D21939, which ensures this extra info is carried
> through for CodeView debug info.
>
> I'm not familiar with DWARF type units (but am currently reading about
> them).  I don't immediately see how this change would affect the
> calculation of the type signature.
>

Actually we build the signature based on the mangled name of the type - not
the DIEs that make up the type unit. So we want to ensure that the type
unit for the same type comes out the same in any TU.

Since we weren't including unreferenced nested types, what we would do is
not include nested types in the member list - that way when we build the
type we don't include those nested types (we use the same technique for
implicit special members and member function templates). Those elements end
up in the other part of the DWARF that references the type unit - the same
way declarations for defined members appear there (since DWARF type units
don't provide a way to reference anything other than the type - so...
anyway, long story).


> The intent is to ensure that there is a type record for Bar in code like
> this:
>
> struct Foo {
>   struct Bar {};
> };
>
> Without this change, Bar is omitted from the debug info metadata.
>

Do you know how this will work with this case:

struct Foo {
  struct Bar;
};

Where Bar is defined and used in one TU but not defined in the other? I
don't think we have the ability to emit both a declaration and a definition
of a type in the same translation unit, which would make it difficult to
describe Foo the same in both translation units (since in the TU without
Bar's definition Foo would contain a declaration, and in the TU with Bar's
definition we'd need to emit the definition and perhaps have no way
(currently) to also emit the declaration)

Also, from a debug info size perspective, it'd be unfortunate if we
required all nested types to be fully defined/emitted (if we can support
the decl/def situation above, perhaps we could make even inline nested type
definitions appear as separate decl/def to keep the option to omit the
nested type definition and keep debug info size small-ish (it'd still grow
a bit by adding the declarations even when the type's unreferenced - so I'd
sort of like to keep that for DWARF if reasonable))

Also: if consistency of type definition is important for CV: What happens
with implicit special members and member function templates?


>
>
> On Thu, Jul 7, 2016 at 4:03 PM, David Blaikie  wrote:
>
>> This may cause problems for DWARF type unit consistency...
>>
>> Under what conditions do nested types appear in the member list? (my
>> simple test case on a fresh clang didn't seem to produce anything about the
>> nested type: struct outer { struct inner { int i; }; int j; }; outer o; )
>>
>> On Wed, Jul 6, 2016 at 7:46 AM, Adrian McCarthy via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: amccarth
>>> Date: Wed Jul  6 09:46:42 2016
>>> New Revision: 274628
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=274628&view=rev
>>> Log:
>>> Include debug info for nested structs and classes
>>>
>>> This includes nested types in the member list, even if there are no
>>> members of that type. Note that structs and classes have themselves as an
>>> "implicit struct" as the first member, so we skip implicit ones.
>>>
>>> Differential Revision: http://reviews.llvm.org/D21705
>>>
>>> Modified:
>>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>>> cfe/trunk/lib/CodeGen/CGDebugInfo.h
>>> cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
>>> cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp
>>> cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp
>>>
>>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=274628&r1=274627&r2=274628&view=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Jul  6 09:46:42 2016
>>> @@ -1095,6 +1095,13 @@ void CGDebugInfo::CollectRecordNormalFie
>>>elements.push_back(FieldType);
>>>  }
>>>
>>> +void CGDebugInfo::CollectRecordNestedRecord(
>>> +const RecordDecl *RD, SmallVectorImpl &elements) {
>>> +  QualType Ty = CGM.getContext().getTypeDeclType(RD);
>>> +  llvm::DIType *nestedType = getOrCreateType(Ty, getOrCreateMainFile());
>>> +  elements.push_back(nestedType);
>>> +}
>>> +
>>>  void CGDebugInfo::CollectRecordFields(
>>>  const RecordDecl *record, llvm::DIFile *tunit,
>>>  SmallVectorImpl &elements,
>>> @@ -1131,6 +1138,9

[PATCH] D22154: [clang-tidy] Pass absolute path to OptionsProvider::getOptions/getRawOptions.

2016-07-08 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: alexfh.
hokein added a subscriber: cfe-commits.

Although there is no guarantee of getOptions/getRawOptions receiving an
absolute path, we try to make it if possible. So FileOptionProvider subclasses
don't have to convert the path to an absolute path.

http://reviews.llvm.org/D22154

Files:
  clang-tidy/ClangTidyOptions.cpp
  clang-tidy/tool/ClangTidyMain.cpp
  test/clang-tidy/list-checks.cpp

Index: test/clang-tidy/list-checks.cpp
===
--- /dev/null
+++ test/clang-tidy/list-checks.cpp
@@ -0,0 +1,5 @@
+// REQUIRES: shell
+// RUN: mkdir -p %T/clang-tidy/list-checks/
+// RUN: echo '{Checks: "-*,google-*"}' > %T/clang-tidy/.clang-tidy
+// RUN: cd %T/clang-tidy/list-checks
+// RUN: clang-tidy -list-checks | grep "^ *google-"
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -313,13 +313,19 @@
   if (!PathList.empty()) {
 FileName = PathList.front();
   }
-  ClangTidyOptions EffectiveOptions = OptionsProvider->getOptions(FileName);
+
+  SmallString<256> FilePath(FileName);
+  if (std::error_code EC = llvm::sys::fs::make_absolute(FilePath)) {
+llvm::errs() << "Can't make absolute path from " << FileName << ": "
+ << EC.message() << "\n";
+  }
+  ClangTidyOptions EffectiveOptions = OptionsProvider->getOptions(FilePath);
   std::vector EnabledChecks = getCheckNames(EffectiveOptions);
 
   if (ExplainConfig) {
 //FIXME: Show other ClangTidyOptions' fields, like ExtraArg.
 std::vector
-RawOptions = OptionsProvider->getRawOptions(FileName);
+RawOptions = OptionsProvider->getRawOptions(FilePath);
 for (const std::string &Check : EnabledChecks) {
   for (auto It = RawOptions.rbegin(); It != RawOptions.rend(); ++It) {
 if (It->first.Checks && GlobList(*It->first.Checks).contains(Check)) {
Index: clang-tidy/ClangTidyOptions.cpp
===
--- clang-tidy/ClangTidyOptions.cpp
+++ clang-tidy/ClangTidyOptions.cpp
@@ -218,15 +218,6 @@
 std::vector
 FileOptionsProvider::getRawOptions(StringRef FileName) {
   DEBUG(llvm::dbgs() << "Getting options for file " << FileName << "...\n");
-  SmallString<256> FilePath(FileName);
-
-  if (std::error_code EC = llvm::sys::fs::make_absolute(FilePath)) {
-llvm::errs() << "Can't make absolute path from " << FileName << ": "
- << EC.message() << "\n";
-// FIXME: Figure out what to do.
-  } else {
-FileName = FilePath;
-  }
 
   std::vector RawOptions =
   DefaultOptionsProvider::getRawOptions(FileName);


Index: test/clang-tidy/list-checks.cpp
===
--- /dev/null
+++ test/clang-tidy/list-checks.cpp
@@ -0,0 +1,5 @@
+// REQUIRES: shell
+// RUN: mkdir -p %T/clang-tidy/list-checks/
+// RUN: echo '{Checks: "-*,google-*"}' > %T/clang-tidy/.clang-tidy
+// RUN: cd %T/clang-tidy/list-checks
+// RUN: clang-tidy -list-checks | grep "^ *google-"
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -313,13 +313,19 @@
   if (!PathList.empty()) {
 FileName = PathList.front();
   }
-  ClangTidyOptions EffectiveOptions = OptionsProvider->getOptions(FileName);
+
+  SmallString<256> FilePath(FileName);
+  if (std::error_code EC = llvm::sys::fs::make_absolute(FilePath)) {
+llvm::errs() << "Can't make absolute path from " << FileName << ": "
+ << EC.message() << "\n";
+  }
+  ClangTidyOptions EffectiveOptions = OptionsProvider->getOptions(FilePath);
   std::vector EnabledChecks = getCheckNames(EffectiveOptions);
 
   if (ExplainConfig) {
 //FIXME: Show other ClangTidyOptions' fields, like ExtraArg.
 std::vector
-RawOptions = OptionsProvider->getRawOptions(FileName);
+RawOptions = OptionsProvider->getRawOptions(FilePath);
 for (const std::string &Check : EnabledChecks) {
   for (auto It = RawOptions.rbegin(); It != RawOptions.rend(); ++It) {
 if (It->first.Checks && GlobList(*It->first.Checks).contains(Check)) {
Index: clang-tidy/ClangTidyOptions.cpp
===
--- clang-tidy/ClangTidyOptions.cpp
+++ clang-tidy/ClangTidyOptions.cpp
@@ -218,15 +218,6 @@
 std::vector
 FileOptionsProvider::getRawOptions(StringRef FileName) {
   DEBUG(llvm::dbgs() << "Getting options for file " << FileName << "...\n");
-  SmallString<256> FilePath(FileName);
-
-  if (std::error_code EC = llvm::sys::fs::make_absolute(FilePath)) {
-llvm::errs() << "Can't make absolute path from " << FileName << ": "
- << EC.message() << "\n";
-// FIXME: Figure out what to do.
-  } else {
-FileName = FilePath;
- 

[PATCH] D22155: [libcxx] [test] Fix portability issues in tests.

2016-07-08 Thread Stephan T. Lavavej via cfe-commits
STL_MSFT created this revision.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.

Fix portability issues in  tests.

Three tests were asserting equal() after shuffling a sequence, which assumes 
the exact behavior of libc++'s implementation. To be portable, yet retain some 
level of validation, I'm marking the equal() checks as libc++ specific, but 
adding unconditional is_permutation() checks.

Additionally, one test was assuming libc++'s choice of default_random_engine, 
which isn't guaranteed by the Standard. Mark that assert as libc++ specific.

http://reviews.llvm.org/D22155

Files:
  
test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
  
test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
  
test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp
  test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp

Index: test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp
===
--- test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp
+++ test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp
@@ -14,9 +14,11 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 std::default_random_engine e;
 e.discard();
-assert(e() == 399268537u);
+LIBCPP_ASSERT(e() == 399268537u);
 }
Index: 
test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp
===
--- 
test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp
+++ 
test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp
@@ -17,15 +17,19 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 int ia[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
 int ia1[] = {2, 7, 1, 4, 3, 6, 5, 10, 9, 8};
 int ia2[] = {1, 8, 3, 4, 6, 9, 5, 7, 2, 10};
 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
 std::minstd_rand g;
 std::shuffle(ia, ia+sa, g);
-assert(std::equal(ia, ia+sa, ia1));
+LIBCPP_ASSERT(std::equal(ia, ia+sa, ia1));
+assert(std::is_permutation(ia, ia+sa, ia1));
 std::shuffle(ia, ia+sa, g);
-assert(std::equal(ia, ia+sa, ia2));
+LIBCPP_ASSERT(std::equal(ia, ia+sa, ia2));
+assert(std::is_permutation(ia, ia+sa, ia2));
 }
Index: 
test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
===
--- 
test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
+++ 
test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
@@ -18,6 +18,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct gen
 {
 int operator()(int n)
@@ -33,5 +35,6 @@
 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
 gen r;
 std::random_shuffle(ia, ia+sa, r);
-assert(std::equal(ia, ia+sa, ia1));
+LIBCPP_ASSERT(std::equal(ia, ia+sa, ia1));
+assert(std::is_permutation(ia, ia+sa, ia1));
 }
Index: 
test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
===
--- 
test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
+++ 
test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
@@ -17,14 +17,18 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 int ia[] = {1, 2, 3, 4};
 int ia1[] = {1, 4, 3, 2};
 int ia2[] = {4, 1, 2, 3};
 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
 std::random_shuffle(ia, ia+sa);
-assert(std::equal(ia, ia+sa, ia1));
+LIBCPP_ASSERT(std::equal(ia, ia+sa, ia1));
+assert(std::is_permutation(ia, ia+sa, ia1));
 std::random_shuffle(ia, ia+sa);
-assert(std::equal(ia, ia+sa, ia2));
+LIBCPP_ASSERT(std::equal(ia, ia+sa, ia2));
+assert(std::is_permutation(ia, ia+sa, ia2));
 }


Index: test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp
===
--- test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp
+++ test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp
@@ -14,9 +14,11 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 std::default_random_engine e;
 e.discard();
-assert(e() == 399268537u);
+LIBCPP_ASSERT(e() == 399268537u);
 }
Index: test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp
===
--- test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp
+++ test/std/algorithms/alg.modifying.operations/a

[PATCH] D22157: [libcxx] [test] Mark bucket() assertions as nonportable.

2016-07-08 Thread Stephan T. Lavavej via cfe-commits
STL_MSFT created this revision.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.

Mark bucket() assertions as nonportable.

The Standard doesn't guarantee what bucket an element will land in, even if you 
control the hash. All such assertions are inherently nonportable and should be 
marked accordingly.

http://reviews.llvm.org/D22157

Files:
  test/std/containers/unord/unord.map/bucket.pass.cpp
  test/std/containers/unord/unord.multimap/bucket.pass.cpp
  test/std/containers/unord/unord.multiset/bucket.pass.cpp
  test/std/containers/unord/unord.set/bucket.pass.cpp

Index: test/std/containers/unord/unord.set/bucket.pass.cpp
===
--- test/std/containers/unord/unord.set/bucket.pass.cpp
+++ test/std/containers/unord/unord.set/bucket.pass.cpp
@@ -22,6 +22,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "min_allocator.h"
 
 int main()
@@ -42,7 +43,7 @@
 size_t bc = c.bucket_count();
 assert(bc >= 5);
 for (size_t i = 0; i < 13; ++i)
-assert(c.bucket(i) == i % bc);
+LIBCPP_ASSERT(c.bucket(i) == i % bc);
 }
 #if TEST_STD_VER >= 11
 {
@@ -61,7 +62,7 @@
 size_t bc = c.bucket_count();
 assert(bc >= 5);
 for (size_t i = 0; i < 13; ++i)
-assert(c.bucket(i) == i % bc);
+LIBCPP_ASSERT(c.bucket(i) == i % bc);
 }
 #endif
 #if _LIBCPP_DEBUG_LEVEL >= 1
Index: test/std/containers/unord/unord.multiset/bucket.pass.cpp
===
--- test/std/containers/unord/unord.multiset/bucket.pass.cpp
+++ test/std/containers/unord/unord.multiset/bucket.pass.cpp
@@ -22,6 +22,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "min_allocator.h"
 
 int main()
@@ -42,7 +43,7 @@
 size_t bc = c.bucket_count();
 assert(bc >= 7);
 for (size_t i = 0; i < 13; ++i)
-assert(c.bucket(i) == i % bc);
+LIBCPP_ASSERT(c.bucket(i) == i % bc);
 }
 #if TEST_STD_VER >= 11
 {
@@ -62,7 +63,7 @@
 size_t bc = c.bucket_count();
 assert(bc >= 7);
 for (size_t i = 0; i < 13; ++i)
-assert(c.bucket(i) == i % bc);
+LIBCPP_ASSERT(c.bucket(i) == i % bc);
 }
 #endif
 #if _LIBCPP_DEBUG_LEVEL >= 1
Index: test/std/containers/unord/unord.multimap/bucket.pass.cpp
===
--- test/std/containers/unord/unord.multimap/bucket.pass.cpp
+++ test/std/containers/unord/unord.multimap/bucket.pass.cpp
@@ -23,6 +23,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "min_allocator.h"
 
 int main()
@@ -43,7 +44,7 @@
 size_t bc = c.bucket_count();
 assert(bc >= 7);
 for (size_t i = 0; i < 13; ++i)
-assert(c.bucket(i) == i % bc);
+LIBCPP_ASSERT(c.bucket(i) == i % bc);
 }
 #if TEST_STD_VER >= 11
 {
@@ -63,7 +64,7 @@
 size_t bc = c.bucket_count();
 assert(bc >= 7);
 for (size_t i = 0; i < 13; ++i)
-assert(c.bucket(i) == i % bc);
+LIBCPP_ASSERT(c.bucket(i) == i % bc);
 }
 #endif
 #if _LIBCPP_DEBUG_LEVEL >= 1
Index: test/std/containers/unord/unord.map/bucket.pass.cpp
===
--- test/std/containers/unord/unord.map/bucket.pass.cpp
+++ test/std/containers/unord/unord.map/bucket.pass.cpp
@@ -23,6 +23,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "min_allocator.h"
 
 int main()
@@ -43,7 +44,7 @@
 size_t bc = c.bucket_count();
 assert(bc >= 5);
 for (size_t i = 0; i < 13; ++i)
-assert(c.bucket(i) == i % bc);
+LIBCPP_ASSERT(c.bucket(i) == i % bc);
 }
 #if TEST_STD_VER >= 11
 {
@@ -63,7 +64,7 @@
 size_t bc = c.bucket_count();
 assert(bc >= 5);
 for (size_t i = 0; i < 13; ++i)
-assert(c.bucket(i) == i % bc);
+LIBCPP_ASSERT(c.bucket(i) == i % bc);
 }
 #endif
 #if _LIBCPP_DEBUG_LEVEL >= 1
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D22159: [libcxx] [test] Mark bucket_size() assertions as nonportable.

2016-07-08 Thread Stephan T. Lavavej via cfe-commits
STL_MSFT created this revision.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.

Mark bucket_size() assertions as nonportable.

Even if you control the hash, the Standard doesn't guarantee what the bucket 
population sizes will be. All of these assertions are nonportable and should be 
marked accordingly.

http://reviews.llvm.org/D22159

Files:
  test/std/containers/unord/unord.map/bucket_size.pass.cpp
  test/std/containers/unord/unord.multimap/bucket_size.pass.cpp
  test/std/containers/unord/unord.multiset/bucket_size.pass.cpp
  test/std/containers/unord/unord.set/bucket_size.pass.cpp

Index: test/std/containers/unord/unord.set/bucket_size.pass.cpp
===
--- test/std/containers/unord/unord.set/bucket_size.pass.cpp
+++ test/std/containers/unord/unord.set/bucket_size.pass.cpp
@@ -22,6 +22,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "min_allocator.h"
 
 int main()
@@ -40,11 +41,11 @@
 };
 const C c(std::begin(a), std::end(a));
 assert(c.bucket_count() >= 5);
-assert(c.bucket_size(0) == 0);
-assert(c.bucket_size(1) == 1);
-assert(c.bucket_size(2) == 1);
-assert(c.bucket_size(3) == 1);
-assert(c.bucket_size(4) == 1);
+LIBCPP_ASSERT(c.bucket_size(0) == 0);
+LIBCPP_ASSERT(c.bucket_size(1) == 1);
+LIBCPP_ASSERT(c.bucket_size(2) == 1);
+LIBCPP_ASSERT(c.bucket_size(3) == 1);
+LIBCPP_ASSERT(c.bucket_size(4) == 1);
 }
 #if TEST_STD_VER >= 11
 {
@@ -61,11 +62,11 @@
 };
 const C c(std::begin(a), std::end(a));
 assert(c.bucket_count() >= 5);
-assert(c.bucket_size(0) == 0);
-assert(c.bucket_size(1) == 1);
-assert(c.bucket_size(2) == 1);
-assert(c.bucket_size(3) == 1);
-assert(c.bucket_size(4) == 1);
+LIBCPP_ASSERT(c.bucket_size(0) == 0);
+LIBCPP_ASSERT(c.bucket_size(1) == 1);
+LIBCPP_ASSERT(c.bucket_size(2) == 1);
+LIBCPP_ASSERT(c.bucket_size(3) == 1);
+LIBCPP_ASSERT(c.bucket_size(4) == 1);
 }
 #endif
 #if _LIBCPP_DEBUG_LEVEL >= 1
Index: test/std/containers/unord/unord.multiset/bucket_size.pass.cpp
===
--- test/std/containers/unord/unord.multiset/bucket_size.pass.cpp
+++ test/std/containers/unord/unord.multiset/bucket_size.pass.cpp
@@ -22,6 +22,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "min_allocator.h"
 
 int main()
@@ -40,13 +41,13 @@
 };
 const C c(std::begin(a), std::end(a));
 assert(c.bucket_count() >= 7);
-assert(c.bucket_size(0) == 0);
-assert(c.bucket_size(1) == 2);
-assert(c.bucket_size(2) == 2);
-assert(c.bucket_size(3) == 1);
-assert(c.bucket_size(4) == 1);
-assert(c.bucket_size(5) == 0);
-assert(c.bucket_size(6) == 0);
+LIBCPP_ASSERT(c.bucket_size(0) == 0);
+LIBCPP_ASSERT(c.bucket_size(1) == 2);
+LIBCPP_ASSERT(c.bucket_size(2) == 2);
+LIBCPP_ASSERT(c.bucket_size(3) == 1);
+LIBCPP_ASSERT(c.bucket_size(4) == 1);
+LIBCPP_ASSERT(c.bucket_size(5) == 0);
+LIBCPP_ASSERT(c.bucket_size(6) == 0);
 }
 #if TEST_STD_VER >= 11
 {
@@ -64,13 +65,13 @@
 };
 const C c(std::begin(a), std::end(a));
 assert(c.bucket_count() >= 7);
-assert(c.bucket_size(0) == 0);
-assert(c.bucket_size(1) == 2);
-assert(c.bucket_size(2) == 2);
-assert(c.bucket_size(3) == 1);
-assert(c.bucket_size(4) == 1);
-assert(c.bucket_size(5) == 0);
-assert(c.bucket_size(6) == 0);
+LIBCPP_ASSERT(c.bucket_size(0) == 0);
+LIBCPP_ASSERT(c.bucket_size(1) == 2);
+LIBCPP_ASSERT(c.bucket_size(2) == 2);
+LIBCPP_ASSERT(c.bucket_size(3) == 1);
+LIBCPP_ASSERT(c.bucket_size(4) == 1);
+LIBCPP_ASSERT(c.bucket_size(5) == 0);
+LIBCPP_ASSERT(c.bucket_size(6) == 0);
 }
 #endif
 #if _LIBCPP_DEBUG_LEVEL >= 1
Index: test/std/containers/unord/unord.multimap/bucket_size.pass.cpp
===
--- test/std/containers/unord/unord.multimap/bucket_size.pass.cpp
+++ test/std/containers/unord/unord.multimap/bucket_size.pass.cpp
@@ -23,6 +23,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "min_allocator.h"
 
 int main()
@@ -41,13 +42,13 @@
 };
 const C c(std::begin(a), std::end(a));
 assert(c.bucket_count() >= 7);
-assert(c.bucket_size(0) == 0);
-assert(c.bucket_size(1) == 2);
-assert(c.bucket_size(2) == 2);
-assert(c.bucket_size(3) == 1);
-assert(c.bucket_size(4) == 1);
-assert(c.bucket_size(5) == 0);
-assert(c.bucket_size(6) == 0);
+LIBCPP_ASSERT(c.bucket_size(0) == 0);
+LIBCPP_ASSERT(c.bucket_size(1) == 2);
+LIBCP

[PATCH] D22165: [libcxx] [test] Make bucket_count() greater-equal assertions portable.

2016-07-08 Thread Stephan T. Lavavej via cfe-commits
STL_MSFT created this revision.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.

Make bucket_count() greater-equal assertions portable.

The Standard provides a guarantee here, but these assertions were going beyond 
that guarantee. These containers have 8 elements, so the bucket count is 
guaranteed to be at least 8, but may not be as large as 11 (and isn't in MSVC's 
implementation).

http://reviews.llvm.org/D22165

Files:
  test/std/containers/unord/unord.map/bucket_count.pass.cpp
  test/std/containers/unord/unord.multimap/bucket_count.pass.cpp
  test/std/containers/unord/unord.multiset/bucket_count.pass.cpp
  test/std/containers/unord/unord.set/bucket_count.pass.cpp

Index: test/std/containers/unord/unord.set/bucket_count.pass.cpp
===
--- test/std/containers/unord/unord.set/bucket_count.pass.cpp
+++ test/std/containers/unord/unord.set/bucket_count.pass.cpp
@@ -46,7 +46,7 @@
 P(80)
 };
 const C c(std::begin(a), std::end(a));
-assert(c.bucket_count() >= 11);
+assert(c.bucket_count() >= 8);
 }
 #if TEST_STD_VER >= 11
 {
@@ -72,7 +72,7 @@
 P(80)
 };
 const C c(std::begin(a), std::end(a));
-assert(c.bucket_count() >= 11);
+assert(c.bucket_count() >= 8);
 }
 #endif
 }
Index: test/std/containers/unord/unord.multiset/bucket_count.pass.cpp
===
--- test/std/containers/unord/unord.multiset/bucket_count.pass.cpp
+++ test/std/containers/unord/unord.multiset/bucket_count.pass.cpp
@@ -46,7 +46,7 @@
 P(80)
 };
 const C c(std::begin(a), std::end(a));
-assert(c.bucket_count() >= 11);
+assert(c.bucket_count() >= 8);
 }
 #if TEST_STD_VER >= 11
 {
@@ -74,7 +74,7 @@
 P(80)
 };
 const C c(std::begin(a), std::end(a));
-assert(c.bucket_count() >= 11);
+assert(c.bucket_count() >= 8);
 }
 #endif
 }
Index: test/std/containers/unord/unord.multimap/bucket_count.pass.cpp
===
--- test/std/containers/unord/unord.multimap/bucket_count.pass.cpp
+++ test/std/containers/unord/unord.multimap/bucket_count.pass.cpp
@@ -46,6 +46,6 @@
 P(80, "eighty"),
 };
 const C c(std::begin(a), std::end(a));
-assert(c.bucket_count() >= 11);
+assert(c.bucket_count() >= 8);
 }
 }
Index: test/std/containers/unord/unord.map/bucket_count.pass.cpp
===
--- test/std/containers/unord/unord.map/bucket_count.pass.cpp
+++ test/std/containers/unord/unord.map/bucket_count.pass.cpp
@@ -44,7 +44,7 @@
 P(80, "eighty"),
 };
 const C c(std::begin(a), std::end(a));
-assert(c.bucket_count() >= 11);
+assert(c.bucket_count() >= 8);
 }
 #if TEST_STD_VER >= 11
 {
@@ -69,7 +69,7 @@
 P(80, "eighty"),
 };
 const C c(std::begin(a), std::end(a));
-assert(c.bucket_count() >= 11);
+assert(c.bucket_count() >= 8);
 }
 #endif
 }


Index: test/std/containers/unord/unord.set/bucket_count.pass.cpp
===
--- test/std/containers/unord/unord.set/bucket_count.pass.cpp
+++ test/std/containers/unord/unord.set/bucket_count.pass.cpp
@@ -46,7 +46,7 @@
 P(80)
 };
 const C c(std::begin(a), std::end(a));
-assert(c.bucket_count() >= 11);
+assert(c.bucket_count() >= 8);
 }
 #if TEST_STD_VER >= 11
 {
@@ -72,7 +72,7 @@
 P(80)
 };
 const C c(std::begin(a), std::end(a));
-assert(c.bucket_count() >= 11);
+assert(c.bucket_count() >= 8);
 }
 #endif
 }
Index: test/std/containers/unord/unord.multiset/bucket_count.pass.cpp
===
--- test/std/containers/unord/unord.multiset/bucket_count.pass.cpp
+++ test/std/containers/unord/unord.multiset/bucket_count.pass.cpp
@@ -46,7 +46,7 @@
 P(80)
 };
 const C c(std::begin(a), std::end(a));
-assert(c.bucket_count() >= 11);
+assert(c.bucket_count() >= 8);
 }
 #if TEST_STD_VER >= 11
 {
@@ -74,7 +74,7 @@
 P(80)
 };
 const C c(std::begin(a), std::end(a));
-assert(c.bucket_count() >= 11);
+assert(c.bucket_count() >= 8);
 }
 #endif
 }
Index: test/std/containers/unord/unord.multimap/bucket_count.pass.cpp
===
--- test/std/containers/unord/unord.multimap/bucket_count.pass.cpp
+++ test/std/containers/unord/unord.multimap/bucket_count.pass.cpp
@@ -46,6 +46,6 @@
 P(80, "eighty"),
 };
 const C c(std::begin(a), std::end(a));
-assert(c.bucket_cou

Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-08 Thread Yaxun Liu via cfe-commits
yaxunl updated the summary for this revision.
yaxunl updated this revision to Diff 63286.
yaxunl added a comment.

Drop the sampler initializer structure as Anastasia suggested. Now 
`__translate_sampler_initializer` accepts an integer parameter.


http://reviews.llvm.org/D21567

Files:
  include/clang/AST/OperationKinds.def
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CGOpenCLRuntime.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaInit.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/CodeGenOpenCL/opencl_types.cl
  test/CodeGenOpenCL/sampler.cl
  test/SemaOpenCL/sampler_t.cl

Index: test/SemaOpenCL/sampler_t.cl
===
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -13,6 +13,7 @@
   const sampler_t const_smp = 7;
   foo(glb_smp);
   foo(const_smp);
+  foo(argsmp);
   foo(5); // expected-error {{sampler_t variable required - got 'int'}}
   sampler_t sa[] = {argsmp, const_smp}; // expected-error {{array of 'sampler_t' type is invalid in OpenCL}}
 }
Index: test/CodeGenOpenCL/sampler.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/sampler.cl
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple spir-unknown-unknown -o - -O0 | FileCheck %s
+
+#define CLK_ADDRESS_CLAMP_TO_EDGE   2
+#define CLK_NORMALIZED_COORDS_TRUE  1
+#define CLK_FILTER_NEAREST  0x10
+#define CLK_FILTER_LINEAR   0x20
+
+constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+
+// CHECK: %__sampler = type opaque
+
+void fnc4smp(sampler_t s) {}
+// CHECK: define spir_func void @fnc4smp(%__sampler addrspace(2)* %
+
+kernel void foo() {
+  sampler_t smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST;
+  // CHECK-LABEL: define spir_kernel void @foo()
+  // CHECK: [[smp_ptr:%[A-Za-z0-9_\.]+]] = alloca %__sampler addrspace(2)*
+  // CHECK: [[SAMP:%[0-9]+]] = call %__sampler addrspace(2)* @__translate_sampler_initializer(i32 19)
+  // CHECK: store %__sampler addrspace(2)* [[SAMP]], %__sampler addrspace(2)** [[smp_ptr]]
+
+  fnc4smp(smp);
+  // CHECK: [[SAMP:%[0-9]+]] = call %__sampler addrspace(2)* @__translate_sampler_initializer(i32 19)
+  // CHECK: call spir_func void @fnc4smp(%__sampler addrspace(2)* [[SAMP]])
+
+  fnc4smp(glb_smp);
+  // CHECK: [[SAMP:%[0-9]+]] = call %__sampler addrspace(2)* @__translate_sampler_initializer(i32 35)
+  // CHECK: call spir_func void @fnc4smp(%__sampler addrspace(2)* [[SAMP]])
+}
Index: test/CodeGenOpenCL/opencl_types.cl
===
--- test/CodeGenOpenCL/opencl_types.cl
+++ test/CodeGenOpenCL/opencl_types.cl
@@ -1,39 +1,43 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 | FileCheck %s
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -emit-llvm -o - -O0 | FileCheck %s
 
-constant sampler_t glb_smp = 7;
-// CHECK: constant i32 7
+#define CLK_ADDRESS_CLAMP_TO_EDGE   2
+#define CLK_NORMALIZED_COORDS_TRUE  1
+#define CLK_FILTER_NEAREST  0x10
+#define CLK_FILTER_LINEAR   0x20
+
+constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE|CLK_NORMALIZED_COORDS_TRUE|CLK_FILTER_NEAREST;
 
 void fnc1(image1d_t img) {}
-// CHECK: @fnc1(%opencl.image1d_ro_t*
+// CHECK: @fnc1(%opencl.image1d_ro_t addrspace(1)*
 
 void fnc1arr(image1d_array_t img) {}
-// CHECK: @fnc1arr(%opencl.image1d_array_ro_t*
+// CHECK: @fnc1arr(%opencl.image1d_array_ro_t addrspace(1)*
 
 void fnc1buff(image1d_buffer_t img) {}
-// CHECK: @fnc1buff(%opencl.image1d_buffer_ro_t*
+// CHECK: @fnc1buff(%opencl.image1d_buffer_ro_t addrspace(1)*
 
 void fnc2(image2d_t img) {}
-// CHECK: @fnc2(%opencl.image2d_ro_t*
+// CHECK: @fnc2(%opencl.image2d_ro_t addrspace(1)*
 
 void fnc2arr(image2d_array_t img) {}
-// CHECK: @fnc2arr(%opencl.image2d_array_ro_t*
+// CHECK: @fnc2arr(%opencl.image2d_array_ro_t addrspace(1)*
 
 void fnc3(image3d_t img) {}
-// CHECK: @fnc3(%opencl.image3d_ro_t*
+// CHECK: @fnc3(%opencl.image3d_ro_t addrspace(1)*
 
 void fnc4smp(sampler_t s) {}
-// CHECK-LABEL: define {{.*}}void @fnc4smp(i32
+// CHECK-LABEL: define {{.*}}void @fnc4smp(%__sampler addrspace(2)*
 
 kernel void foo(image1d_t img) {
-  sampler_t smp = 5;
-  // CHECK: alloca i32
+  sampler_t smp = CLK_ADDRESS_CLAMP_TO_EDGE|CLK_NORMALIZED_COORDS_TRUE|CLK_FILTER_LINEAR;
+  // CHECK: alloca %__sampler addrspace(2)*
   event_t evt;
   // CHECK: alloca %opencl.event_t*
-  // CHECK: store i32 5,

Re: [PATCH] D20352: Add XRay flags to Clang

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

I applied your patch locally and got a few compile errors with MSVC 2015:

'bool 
llvm::opt::ArgList::hasArg(llvm::opt::OptSpecifier,llvm::opt::OptSpecifier,llvm::opt::OptSpecifier)
 const': cannot convert argument 3 from 'bool' to 'llvm::opt::OptSpecifier'
E:\llvm\llvm\tools\clang\lib\Driver\Tools.cpp   3187
'bool 
llvm::opt::ArgList::hasArg(llvm::opt::OptSpecifier,llvm::opt::OptSpecifier,llvm::opt::OptSpecifier)
 const': cannot convert argument 3 from 'bool' to 'llvm::opt::OptSpecifier'
E:\llvm\llvm\tools\clang\lib\Driver\Tools.cpp   4608

There is no hasArg() overload that accepts a bool argument; perhaps that's a 
feature of one of the dependencies this patch depends on?


http://reviews.llvm.org/D20352



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


Re: [PATCH] D21453: Add support for attribute "overallocated"

2016-07-08 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 63299.
ahatanak added a comment.

Address review comments.


http://reviews.llvm.org/D21453

Files:
  include/clang/AST/Decl.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/AttributeList.h
  lib/AST/Decl.cpp
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenTBAA.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExpr.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGen/object-size.c
  test/CodeGenCXX/catch-undef-behavior.cpp
  test/SemaCXX/flexible-array-attr.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -2641,6 +2641,7 @@
 case GenericRecord:
   return "(S.getLangOpts().CPlusPlus ? ExpectedStructOrUnionOrClass : "
"ExpectedStructOrUnion)";
+case Field: return "ExpectedField";
 case Func | ObjCMethod | Block: return "ExpectedFunctionMethodOrBlock";
 case Func | ObjCMethod | Class: return "ExpectedFunctionMethodOrClass";
 case Func | Param:
Index: test/SemaCXX/flexible-array-attr.cpp
===
--- /dev/null
+++ test/SemaCXX/flexible-array-attr.cpp
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+int g0[16] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to non-static data members}}
+
+struct S0 {
+  int a[4];
+  int foo1() __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to non-static data members}}
+};
+
+struct S1 {
+  int a[4];
+  int *b __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to fixed sized array members}}
+};
+
+struct S2 {
+  int a[4];
+  int b[4] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to the last member of a struct}}
+  int c[4];
+};
+
+struct S3 {
+  int a[4];
+  int b[] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to fixed sized array members}}
+};
+
+struct S4 {
+  int a[4];
+  int b[0] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to array members that have at least one element}}
+};
+
+template
+struct S5 {
+  int a[4];
+  int b[N] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to fixed sized array members}}
+};
+
+struct S6 {
+  int a[4];
+  int b[1] __attribute__((flexible_array));
+};
+
+struct S7 : S6 { // expected-error {{base class 'S6' has a flexible array member}}
+};
+
+struct S8 {
+  int a;
+  S6 s6; // expected-error {{struct with a member marked 'flexible_array' cannot be nested}}
+};
+
+union U0 {
+  int a[4];
+  int b[4] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to members of structs or classes}}
+};
+
+int lambda_capture(S6 a) { // expected-note {{'a' declared here}}
+  return [a](){ return 0; }(); // expected-error {{variable 'a' with flexible array member cannot be captured in a lambda expression}}
+}
Index: test/CodeGenCXX/catch-undef-behavior.cpp
===
--- test/CodeGenCXX/catch-undef-behavior.cpp
+++ test/CodeGenCXX/catch-undef-behavior.cpp
@@ -327,6 +327,17 @@
   return incomplete[n];
 }
 
+struct FlexibleArray {
+  int a1[4];
+  int a2[4] __attribute__((flexible_array));
+};
+
+// CHECK-LABEL: @_Z14flexible_array
+int flexible_array(FlexibleArray *p, int n) {
+  // CHECK-NOT: call void @__ubsan_handle_out_of_bounds(
+  return p->a2[n];
+}
+
 typedef __attribute__((ext_vector_type(4))) int V4I;
 // CHECK-LABEL: @_Z12vector_index
 int vector_index(V4I v, int n) {
Index: test/CodeGen/object-size.c
===
--- test/CodeGen/object-size.c
+++ test/CodeGen/object-size.c
@@ -517,3 +517,19 @@
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
   gi = __builtin_object_size(&dsv[9].snd[0], 1);
 }
+
+struct S0 {
+  int a[16];
+  int b[16] __attribute__((flexible_array));
+};
+
+// CHECK-LABEL: @test32
+void test32() {
+  struct S0 *s0;
+
+  // CHECK: store i32 64, i32* @gi
+  gi = __builtin_object_size(s0->a, 1);
+
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(s0->b, 1);
+}
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -457,6 +457,7 @@
 void ASTDeclWriter::VisitRecordDecl(RecordDecl *D) {
   VisitTag

Re: [PATCH] D21453: Add support for attribute "overallocated"

2016-07-08 Thread Akira Hatanaka via cfe-commits
ahatanak marked 7 inline comments as done.


Comment at: include/clang/AST/Decl.h:3249
@@ -3248,1 +3248,3 @@
 
+  /// This is true if this struct ends with an array marked 'flexible_array'.
+  bool HasFlexibleArrayAttr : 1;

Probably it can be looked up although it would require incrementing the 
field_iterator until it reaches the last non-static data member of the record.


Comment at: lib/AST/ExprConstant.cpp:170
@@ +169,3 @@
+/// Indicator of whether the last array added is marked flexible_array.
+bool IsFlexibleArray : 1;
+

I don't think there is a way to do that reliably. The FieldDecl for the array 
isn't always available in struct LValue, as far as I can tell, so it looks like 
we'll need a bit here.


http://reviews.llvm.org/D21453



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


Re: [PATCH] D22154: [clang-tidy] Pass absolute path to OptionsProvider::getOptions/getRawOptions.

2016-07-08 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG


http://reviews.llvm.org/D22154



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


Re: r274246 - [codeview] Emit qualified display names if -gline-tables-only is on

2016-07-08 Thread David Blaikie via cfe-commits
On Thu, Jul 7, 2016 at 4:10 PM, Reid Kleckner  wrote:

> On Thu, Jul 7, 2016 at 3:45 PM, David Blaikie  wrote:
>
>> Yeah - is this necessary for CodeView? (does something break, or do you
>> just get simple names where you'd prefer full mangled or qualified names)
>>
>> It was chosen pretty deliberately to do it this way (use unqualified
>> names) for gmlt to keep size down. Have you got numbers for the size delta
>> for CodeView with this change? I'd really prefer to make the same choice
>> for both - it'd seem a bit arbitrary to choose our size optimization based
>> on differences in the kind of workloads we happen to have on these two
>> platforms.
>>
>
> It's problematic for CodeView because there is no equivalent field like
> DW_AT_linkage_name in any of the symbol records. There is only the display
> name, which includes scope qualifiers.
>
> I'm suggesting we reverse our decision for DWARF because our space saving
> optimization breaks standard stack dumpers on Linux (gdb and addr2line),
>

What breakage are you referring to here?

If we're talking about printing out the simple name - that comes up even in
llvm-symbolizer if a function is inlined. So I think that's an intentional
tradeoff that would apply to CV as well.


> and that seems like a Bad Thing. Instead we've told users to user
> llvm-symbolizer, which is OK, but kind of crappy.
>

I imagine that depends on how much it costs us - we've been pretty careful
about binary size growth/minimization/etc for a while now, so it may be
worth the tradeoff to say that llvm-symbolizer produces a better experience
on this extra minimized data.


> For CodeView, because the linkage name isn't present anywhere, we can't
> actually do any better with llvm-symbolizer, and we need the fully scoped
> name.
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r274246 - [codeview] Emit qualified display names if -gline-tables-only is on

2016-07-08 Thread Nico Weber via cfe-commits
On Fri, Jul 8, 2016 at 3:57 PM, David Blaikie via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
>
> On Thu, Jul 7, 2016 at 4:10 PM, Reid Kleckner  wrote:
>
>> On Thu, Jul 7, 2016 at 3:45 PM, David Blaikie  wrote:
>>
>>> Yeah - is this necessary for CodeView? (does something break, or do you
>>> just get simple names where you'd prefer full mangled or qualified names)
>>>
>>> It was chosen pretty deliberately to do it this way (use unqualified
>>> names) for gmlt to keep size down. Have you got numbers for the size delta
>>> for CodeView with this change? I'd really prefer to make the same choice
>>> for both - it'd seem a bit arbitrary to choose our size optimization based
>>> on differences in the kind of workloads we happen to have on these two
>>> platforms.
>>>
>>
>> It's problematic for CodeView because there is no equivalent field like
>> DW_AT_linkage_name in any of the symbol records. There is only the display
>> name, which includes scope qualifiers.
>>
>> I'm suggesting we reverse our decision for DWARF because our space saving
>> optimization breaks standard stack dumpers on Linux (gdb and addr2line),
>>
>
> What breakage are you referring to here?
>
> If we're talking about printing out the simple name - that comes up even
> in llvm-symbolizer if a function is inlined. So I think that's an
> intentional tradeoff that would apply to CV as well.
>
>
>> and that seems like a Bad Thing. Instead we've told users to user
>> llvm-symbolizer, which is OK, but kind of crappy.
>>
>
> I imagine that depends on how much it costs us - we've been pretty careful
> about binary size growth/minimization/etc for a while now
>

Does this add much size? This only makes strings longer and doesn't force
emission of types, right? (From what I understand, types are what makes
-fline-tables-only output much smaller.) Sorry about the uninformed
question :-) If that's roughly correct though, maybe it'd be good to get an
idea how much bigger debug info would get with qualified names -- we can't
use -fline-tables-only 'cause they make stacks look very bad, and if
qualified names in debug info would give us decent stacks while still being
smaller, that'd be cool. (See also thread "rfc: Adding a mode to
-gline-tables-only to include parameter names, namespaces" from a while
ago.)


> , so it may be worth the tradeoff to say that llvm-symbolizer produces a
> better experience on this extra minimized data.
>
>
>> For CodeView, because the linkage name isn't present anywhere, we can't
>> actually do any better with llvm-symbolizer, and we need the fully scoped
>> name.
>>
>
>
> ___
> 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] D21515: Update clang for D21514. NFC

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

Assuming http://reviews.llvm.org/D21514 will get accepted, this looks find to 
me.


http://reviews.llvm.org/D21515



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


r274923 - [OpenCL] Add missing -cl-no-signed-zeros option into driver

2016-07-08 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Fri Jul  8 15:28:29 2016
New Revision: 274923

URL: http://llvm.org/viewvc/llvm-project?rev=274923&view=rev
Log:
[OpenCL] Add missing -cl-no-signed-zeros option into driver

Add OCL option -cl-no-signed-zeros to driver options.

Also added to opencl.cl testcases.

Patch by Aaron En Ye Shi.

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

Added:
cfe/trunk/test/CodeGenOpenCL/no-signed-zeros.cl
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Driver/opencl.cl

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=274923&r1=274922&r2=274923&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Jul  8 15:28:29 2016
@@ -383,6 +383,8 @@ def cl_fast_relaxed_math : Flag<["-"], "
   HelpText<"OpenCL only. Sets -cl-finite-math-only and 
-cl-unsafe-math-optimizations, and defines __FAST_RELAXED_MATH__.">;
 def cl_mad_enable : Flag<["-"], "cl-mad-enable">, Group, 
Flags<[CC1Option]>,
   HelpText<"OpenCL only. Allow use of less precise MAD computations in the 
generated binary.">;
+def cl_no_signed_zeros : Flag<["-"], "cl-no-signed-zeros">, 
Group, Flags<[CC1Option]>,
+  HelpText<"OpenCL only. Allow use of less precise no signed zeros 
computations in the generated binary.">;
 def cl_std_EQ : Joined<["-"], "cl-std=">, Group, 
Flags<[CC1Option]>,
   HelpText<"OpenCL language standard to compile for.">;
 def cl_denorms_are_zero : Flag<["-"], "cl-denorms-are-zero">, 
Group, Flags<[CC1Option]>,

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=274923&r1=274922&r2=274923&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Fri Jul  8 15:28:29 2016
@@ -1732,6 +1732,8 @@ void CodeGenModule::ConstructAttributeLi
llvm::toStringRef(CodeGenOpts.SoftFloat));
 FuncAttrs.addAttribute("stack-protector-buffer-size",
llvm::utostr(CodeGenOpts.SSPBufferSize));
+FuncAttrs.addAttribute("no-signed-zeros-fp-math",
+   llvm::toStringRef(CodeGenOpts.NoSignedZeros));
 
 if (CodeGenOpts.StackRealignment)
   FuncAttrs.addAttribute("stackrealign");

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=274923&r1=274922&r2=274923&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Jul  8 15:28:29 2016
@@ -5139,6 +5139,9 @@ void Clang::ConstructJob(Compilation &C,
   if (Args.getLastArg(options::OPT_cl_mad_enable)) {
 CmdArgs.push_back("-cl-mad-enable");
   }
+  if (Args.getLastArg(options::OPT_cl_no_signed_zeros)) {
+CmdArgs.push_back("-cl-no-signed-zeros");
+  }
   if (Arg *A = Args.getLastArg(options::OPT_cl_std_EQ)) {
 std::string CLStdStr = "-cl-std=";
 CLStdStr += A->getValue();

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=274923&r1=274922&r2=274923&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Jul  8 15:28:29 2016
@@ -564,7 +564,8 @@ static bool ParseCodeGenArgs(CodeGenOpti
Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
Args.hasArg(OPT_cl_finite_math_only) ||
Args.hasArg(OPT_cl_fast_relaxed_math));
-  Opts.NoSignedZeros = Args.hasArg(OPT_fno_signed_zeros);
+  Opts.NoSignedZeros = (Args.hasArg(OPT_fno_signed_zeros) ||
+Args.hasArg(OPT_cl_no_signed_zeros));
   Opts.ReciprocalMath = Args.hasArg(OPT_freciprocal_math);
   Opts.NoZeroInitializedInBSS = Args.hasArg(OPT_mno_zero_initialized_in_bss);
   Opts.BackendOptions = Args.getAllArgValues(OPT_backend_option);

Added: cfe/trunk/test/CodeGenOpenCL/no-signed-zeros.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/no-signed-zeros.cl?rev=274923&view=auto
==
--- cfe/trunk/test/CodeGenOpenCL/no-signed-zeros.cl (added)
+++ cfe/trunk/test/CodeGenOpenCL/no-signed-zeros.cl Fri Jul  8 15:28:29 2016
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s -check-prefix=NORMAL
+// RUN: %clang_cc1 %s -emit-llvm -cl-no-signed-zeros -o - | FileCheck %s 
-check-pref

Re: [PATCH] D22067: [OpenCL] Add missing -cl-no-signed-zeros option into driver

2016-07-08 Thread Yaxun Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL274923: [OpenCL] Add missing -cl-no-signed-zeros option into 
driver (authored by yaxunl).

Changed prior to commit:
  http://reviews.llvm.org/D22067?vs=63143&id=63308#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D22067

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGenOpenCL/no-signed-zeros.cl
  cfe/trunk/test/Driver/opencl.cl

Index: cfe/trunk/test/Driver/opencl.cl
===
--- cfe/trunk/test/Driver/opencl.cl
+++ cfe/trunk/test/Driver/opencl.cl
@@ -11,12 +11,13 @@
 // RUN: %clang -S -### -cl-single-precision-constant %s | FileCheck --check-prefix=CHECK-SINGLE-PRECISION-CONST %s
 // RUN: %clang -S -### -cl-finite-math-only %s | FileCheck --check-prefix=CHECK-FINITE-MATH-ONLY %s
 // RUN: %clang -S -### -cl-kernel-arg-info %s | FileCheck --check-prefix=CHECK-KERNEL-ARG-INFO %s
-// RUN: %clang -S -### -cl-unsafe-math-optimizations %s | FileCheck --check-prefix=CHECK-UNSAFE-MATH-OPT %s
-// RUN: %clang -S -### -cl-fast-relaxed-math %s | FileCheck --check-prefix=CHECK-FAST-RELAXED-MATH %s
-// RUN: %clang -S -### -cl-mad-enable %s | FileCheck --check-prefix=CHECK-MAD-ENABLE %s
-// RUN: %clang -S -### -cl-denorms-are-zero %s | FileCheck --check-prefix=CHECK-DENORMS-ARE-ZERO %s
-// RUN: not %clang_cc1 -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
-// RUN: not %clang_cc1 -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
+// RUN: %clang -S -### -cl-unsafe-math-optimizations %s | FileCheck --check-prefix=CHECK-UNSAFE-MATH-OPT %s
+// RUN: %clang -S -### -cl-fast-relaxed-math %s | FileCheck --check-prefix=CHECK-FAST-RELAXED-MATH %s
+// RUN: %clang -S -### -cl-mad-enable %s | FileCheck --check-prefix=CHECK-MAD-ENABLE %s
+// RUN: %clang -S -### -cl-no-signed-zeros %s | FileCheck --check-prefix=CHECK-NO-SIGNED-ZEROS %s
+// RUN: %clang -S -### -cl-denorms-are-zero %s | FileCheck --check-prefix=CHECK-DENORMS-ARE-ZERO %s
+// RUN: not %clang_cc1 -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
+// RUN: not %clang_cc1 -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
 
 // CHECK-CL: .*clang.* "-cc1" .* "-cl-std=CL"
 // CHECK-CL11: .*clang.* "-cc1" .* "-cl-std=CL1.1"
@@ -30,11 +31,12 @@
 // CHECK-SINGLE-PRECISION-CONST: .*clang.* "-cc1" .* "-cl-single-precision-constant"
 // CHECK-FINITE-MATH-ONLY: .*clang.* "-cc1" .* "-cl-finite-math-only"
 // CHECK-KERNEL-ARG-INFO: .*clang.* "-cc1" .* "-cl-kernel-arg-info"
-// CHECK-UNSAFE-MATH-OPT: .*clang.* "-cc1" .* "-cl-unsafe-math-optimizations"
-// CHECK-FAST-RELAXED-MATH: .*clang.* "-cc1" .* "-cl-fast-relaxed-math"
-// CHECK-MAD-ENABLE: .*clang.* "-cc1" .* "-cl-mad-enable"
-// CHECK-DENORMS-ARE-ZERO: .*clang.* "-cc1" .* "-cl-denorms-are-zero"
-// CHECK-C99: error: invalid argument '-cl-std=c99' not allowed with 'OpenCL'
-// CHECK-INVALID: error: invalid value 'invalid' in '-cl-std=invalid'
+// CHECK-UNSAFE-MATH-OPT: .*clang.* "-cc1" .* "-cl-unsafe-math-optimizations"
+// CHECK-FAST-RELAXED-MATH: .*clang.* "-cc1" .* "-cl-fast-relaxed-math"
+// CHECK-MAD-ENABLE: .*clang.* "-cc1" .* "-cl-mad-enable"
+// CHECK-NO-SIGNED-ZEROS: .*clang.* "-cc1" .* "-cl-no-signed-zeros"
+// CHECK-DENORMS-ARE-ZERO: .*clang.* "-cc1" .* "-cl-denorms-are-zero"
+// CHECK-C99: error: invalid argument '-cl-std=c99' not allowed with 'OpenCL'
+// CHECK-INVALID: error: invalid value 'invalid' in '-cl-std=invalid'
 
 kernel void func(void);
Index: cfe/trunk/test/CodeGenOpenCL/no-signed-zeros.cl
===
--- cfe/trunk/test/CodeGenOpenCL/no-signed-zeros.cl
+++ cfe/trunk/test/CodeGenOpenCL/no-signed-zeros.cl
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s -check-prefix=NORMAL
+// RUN: %clang_cc1 %s -emit-llvm -cl-no-signed-zeros -o - | FileCheck %s -check-prefix=NO-SIGNED-ZEROS
+
+float signedzeros(float a) {
+  return a;
+}
+
+// CHECK: attributes
+// NORMAL: "no-signed-zeros-fp-math"="false"
+// NO-SIGNED-ZEROS: "no-signed-zeros-fp-math"="true"
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -564,7 +564,8 @@
Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
Args.hasArg(OPT_cl_finite_math_only) ||
Args.hasArg(OPT_cl_fast_relaxed_math));
-  Opts.NoSignedZeros = Args.hasArg(OPT_fno_signed_zeros);
+  Opts.NoSignedZeros = (Args.hasArg(OPT_fno_signed_zeros) ||
+Args.hasArg(OPT_cl_no_signed_zeros));
   Opts.ReciprocalMath = Args.hasArg(OPT_freciprocal_math);
   Opts.NoZeroInitializedInBSS =

[PATCH] D22169: [OpenMP] add more tests for 'distribute parallel for simd' pragma

2016-07-08 Thread Kelvin Li via cfe-commits
kkwli0 created this revision.
kkwli0 added reviewers: ABataev, sfantao, carlo.bertolli, arpith-jacob, hfinkel.
kkwli0 added a subscriber: cfe-commits.

This patch is to add two additional tests for testing 'distribute parallel for 
simd' pragma with disallowed clauses and loops.

http://reviews.llvm.org/D22169

Files:
  test/OpenMP/distribute_parallel_for_simd_loop_messages.cpp
  test/OpenMP/distribute_parallel_for_simd_misc_messages.c

Index: test/OpenMP/distribute_parallel_for_simd_misc_messages.c
===
--- /dev/null
+++ test/OpenMP/distribute_parallel_for_simd_misc_messages.c
@@ -0,0 +1,954 @@
+// RUN: %clang_cc1 -fsyntax-only -fopenmp -verify %s
+
+// expected-error@+1 {{unexpected OpenMP directive '#pragma omp distribute parallel for simd'}}
+#pragma omp distribute parallel for simd
+
+// expected-error@+1 {{unexpected OpenMP directive '#pragma omp distribute parallel for simd'}}
+#pragma omp distribute parallel for simd foo
+
+void test_no_clause() {
+  int i;
+#pragma omp distribute parallel for simd
+  for (i = 0; i < 16; ++i)
+;
+
+// expected-error@+2 {{statement after '#pragma omp distribute parallel for simd' must be a for loop}}
+#pragma omp distribute parallel for simd
+  ++i;
+}
+
+void test_branch_protected_scope() {
+  int i = 0;
+L1:
+  ++i;
+
+  int x[24];
+
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute parallel for simd
+  for (i = 0; i < 16; ++i) {
+if (i == 5)
+  goto L1; // expected-error {{use of undeclared label 'L1'}}
+else if (i == 6)
+  return; // expected-error {{cannot return from OpenMP region}}
+else if (i == 7)
+  goto L2;
+else if (i == 8) {
+L2:
+  x[i]++;
+}
+  }
+
+  if (x[0] == 0)
+goto L2; // expected-error {{use of undeclared label 'L2'}}
+  else if (x[1] == 1)
+goto L1;
+}
+
+void test_invalid_clause() {
+  int i;
+#pragma omp target
+#pragma omp teams
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp distribute parallel for simd' are ignored}}
+#pragma omp distribute parallel for simd foo bar
+  for (i = 0; i < 16; ++i)
+;
+}
+
+void test_non_identifiers() {
+  int i, x;
+
+#pragma omp target
+#pragma omp teams
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp distribute parallel for simd' are ignored}}
+#pragma omp distribute parallel for simd;
+  for (i = 0; i < 16; ++i)
+;
+#pragma omp target
+#pragma omp teams
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp distribute parallel for simd' are ignored}}
+#pragma omp distribute parallel for simd linear(x);
+  for (i = 0; i < 16; ++i)
+;
+
+#pragma omp target
+#pragma omp teams
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp distribute parallel for simd' are ignored}}
+#pragma omp distribute parallel for simd private(x);
+  for (i = 0; i < 16; ++i)
+;
+
+#pragma omp target
+#pragma omp teams
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp distribute parallel for simd' are ignored}}
+#pragma omp distribute parallel for simd, private(x);
+  for (i = 0; i < 16; ++i)
+;
+}
+
+extern int foo();
+void test_safelen() {
+  int i;
+#pragma omp target
+#pragma omp teams
+// expected-error@+1 {{expected '('}}
+#pragma omp distribute parallel for simd safelen
+  for (i = 0; i < 16; ++i)
+;
+#pragma omp target
+#pragma omp teams
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp distribute parallel for simd safelen(
+  for (i = 0; i < 16; ++i)
+;
+#pragma omp target
+#pragma omp teams
+// expected-error@+1 {{expected expression}}
+#pragma omp distribute parallel for simd safelen()
+  for (i = 0; i < 16; ++i)
+;
+#pragma omp target
+#pragma omp teams
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp distribute parallel for simd safelen(,
+  for (i = 0; i < 16; ++i)
+;
+#pragma omp target
+#pragma omp teams
+// expected-error@+1 {{expected expression}}  expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp distribute parallel for simd safelen(, )
+  for (i = 0; i < 16; ++i)
+;
+#pragma omp target
+#pragma omp teams
+// expected-warning@+2 {{extra tokens at the end of '#pragma omp distribute parallel for simd' are ignored}}
+// expected-error@+1 {{expected '('}}
+#pragma omp distribute parallel for simd safelen 4)
+  for (i = 0; i < 16; ++i)
+;
+#pragma omp target
+#pragma omp teams
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp distribute parallel for simd safelen(4
+  for (i = 0; i < 16; ++i)
+;
+#pragma omp target
+#pragma omp teams
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp distribute parallel for simd safelen(4,
+  for (i = 0; i < 16; ++i)
+;
+#pragma omp target
+#pragma

[PATCH] D22170: [OpenCL] Fixes opencl.cl testcase issues and cl-strict-aliasing only allowed with cl-std=CL

2016-07-08 Thread Aaron En Ye Shi via cfe-commits
ashi1 created this revision.
ashi1 added reviewers: Anastasia, bkramer.
ashi1 added subscribers: nhaustov, rsmith, bader, pxli168, cfe-commits, yaxunl.
ashi1 set the repository for this revision to rL LLVM.

Fixes failures in test/Driver/opencl.cl.

Also fixes strict-aliasing option to only be allowed when OpenCL Version 1.0. 
Added testcase in test/Frontend/opencl-blocks.cl . 

Repository:
  rL LLVM

http://reviews.llvm.org/D22170

Files:
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/opencl.cl
  test/Frontend/opencl-blocks.cl

Index: test/Frontend/opencl-blocks.cl
===
--- test/Frontend/opencl-blocks.cl
+++ test/Frontend/opencl-blocks.cl
@@ -6,6 +6,9 @@
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -fblocks -DBLOCKS
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -fblocks -DBLOCKS
 // RUN: %clang_cc1 %s -triple amdgcn--amdhsa -x c -std=c99 -verify -fsyntax-only
+// RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
+// RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s
+// RUN: %clang_cc1 -cl-std=CL2.0 -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION20 %s
 
 void f(void (^g)(void)) {
 #ifdef __OPENCL_C_VERSION__
@@ -18,3 +21,7 @@
   // expected-error@-8{{blocks support disabled - compile with -fblocks or pick a deployment target that supports them}}
 #endif
 }
+
+// CHECK-INVALID-OPENCL-VERSION11: warning: OpenCL version 1.1 does not support the option '-cl-strict-aliasing'
+// CHECK-INVALID-OPENCL-VERSION12: warning: OpenCL version 1.2 does not support the option '-cl-strict-aliasing'
+// CHECK-INVALID-OPENCL-VERSION20: warning: OpenCL version 2.0 does not support the option '-cl-strict-aliasing'
\ No newline at end of file
Index: test/Driver/opencl.cl
===
--- test/Driver/opencl.cl
+++ test/Driver/opencl.cl
@@ -1,42 +1,35 @@
-// XFAIL: *
-// RUN: %clang -S -### -cl-std=CL %s | FileCheck --check-prefix=CHECK-CL %s
-// RUN: %clang -S -### -cl-std=CL1.1 %s | FileCheck --check-prefix=CHECK-CL11 %s
-// RUN: %clang -S -### -cl-std=CL1.2 %s | FileCheck --check-prefix=CHECK-CL12 %s
-// RUN: %clang -S -### -cl-std=CL2.0 %s | FileCheck --check-prefix=CHECK-CL20 %s
-// RUN: %clang -S -### -cl-opt-disable %s | FileCheck --check-prefix=CHECK-OPT-DISABLE %s
-// RUN: %clang -S -### -cl-strict-aliasing %s | FileCheck --check-prefix=CHECK-STRICT-ALIASING %s
-// RUN: %clang -S -### -cl-std=CL1.1 -cl-strict-aliasing %s | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
-// RUN: %clang -S -### -cl-std=CL1.2 -cl-strict-aliasing %s | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s
-// RUN: %clang -S -### -cl-std=CL2.0 -cl-strict-aliasing %s | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION20 %s
-// RUN: %clang -S -### -cl-single-precision-constant %s | FileCheck --check-prefix=CHECK-SINGLE-PRECISION-CONST %s
-// RUN: %clang -S -### -cl-finite-math-only %s | FileCheck --check-prefix=CHECK-FINITE-MATH-ONLY %s
-// RUN: %clang -S -### -cl-kernel-arg-info %s | FileCheck --check-prefix=CHECK-KERNEL-ARG-INFO %s
-// RUN: %clang -S -### -cl-unsafe-math-optimizations %s | FileCheck --check-prefix=CHECK-UNSAFE-MATH-OPT %s
-// RUN: %clang -S -### -cl-fast-relaxed-math %s | FileCheck --check-prefix=CHECK-FAST-RELAXED-MATH %s
-// RUN: %clang -S -### -cl-mad-enable %s | FileCheck --check-prefix=CHECK-MAD-ENABLE %s
-// RUN: %clang -S -### -cl-no-signed-zeros %s | FileCheck --check-prefix=CHECK-NO-SIGNED-ZEROS %s
-// RUN: %clang -S -### -cl-denorms-are-zero %s | FileCheck --check-prefix=CHECK-DENORMS-ARE-ZERO %s
-// RUN: not %clang_cc1 -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
-// RUN: not %clang_cc1 -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
+// RUN: %clang -S -### -cl-std=CL %s 2>&1 | FileCheck --check-prefix=CHECK-CL %s
+// RUN: %clang -S -### -cl-std=CL1.1 %s 2>&1 | FileCheck --check-prefix=CHECK-CL11 %s
+// RUN: %clang -S -### -cl-std=CL1.2 %s 2>&1 | FileCheck --check-prefix=CHECK-CL12 %s
+// RUN: %clang -S -### -cl-std=CL2.0 %s 2>&1 | FileCheck --check-prefix=CHECK-CL20 %s
+// RUN: %clang -S -### -cl-opt-disable %s 2>&1 | FileCheck --check-prefix=CHECK-OPT-DISABLE %s
+// RUN: %clang -S -### -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-STRICT-ALIASING %s
+// RUN: %clang -S -### -cl-single-precision-constant %s 2>&1 | FileCheck --check-prefix=CHECK-SINGLE-PRECISION-CONST %s
+// RUN: %clang -S -### -cl-finite-math-only %s 2>&1 | FileCheck --check-prefix=CHECK-FINITE-MATH-ONLY %s
+// RUN: %clang -S -### -cl-kernel-arg-info %s 2>&1 | FileCheck --check-prefix=CHECK-KERNEL-ARG-INFO %s
+// RUN: %clang -S -### -cl-unsafe-math-optimizations %s 2>&1 | FileCheck --check-prefix=CHECK-UNSAFE-MATH-OPT %s
+// RUN: %clang -S -###

[PATCH] D22171: [ObjC Availability] Implement parser support for Objective-C's @available

2016-07-08 Thread Erik Pilkington via cfe-commits
erik.pilkington created this revision.
erik.pilkington added reviewers: manmanren, dexonsmith.
erik.pilkington added a subscriber: cfe-commits.

This patch is the first of the feature I proposed on Monday here: 
http://lists.llvm.org/pipermail/cfe-dev/2016-July/049851.html

This patch adds a new AST node, `ObjCAvailabilityCheckExpr`, and teaches the 
parser and Sema to build it. Currently, if compiled without `-fsyntax-only`, 
Clang errors out in CodeGen. Up next is a patch that implements the 
availability violation warning itself, then CodeGen support.

`ObjCAvailabilityCheckExpr` is an predicate expression that will end up 
compiling into a runtime check of the host's OS version. It can be spelled in 
two ways:
```
  @available(macos 10.10, *); // Objective-C only
  __builtin_available(macos 10.10, *); // C, C++, and Objective-C
```

It's main purpose in life is to guard calls to API calls that are marked with 
an `__attribute__((availability()))` greater than the current deployment 
target, so users can safely use new APIs while still supporting old OS versions.

Thanks!

http://reviews.llvm.org/D22171

Files:
  include/clang-c/Index.h
  include/clang/AST/Availability.h
  include/clang/AST/ExprObjC.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/StmtNodes.td
  include/clang/Basic/TokenKinds.def
  include/clang/Basic/VersionTuple.h
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/Expr.cpp
  lib/AST/ExprClassification.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseObjc.cpp
  lib/Sema/SemaExceptionSpec.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/Parser/objc-available.m
  tools/libclang/CIndex.cpp
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -447,7 +447,11 @@
   case Stmt::ObjCBoolLiteralExprClass:
 K = CXCursor_ObjCBoolLiteralExpr;
 break;
-  
+
+  case Stmt::ObjCAvailabilityCheckExprClass:
+K = CXCursor_ObjCAvailabilityCheckExpr;
+break;
+
   case Stmt::ObjCBridgedCastExprClass:
 K = CXCursor_ObjCBridgedCastExpr;
 break;
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -4598,6 +4598,8 @@
   return cxstring::createRef("ObjCStringLiteral");
   case CXCursor_ObjCBoolLiteralExpr:
   return cxstring::createRef("ObjCBoolLiteralExpr");
+  case CXCursor_ObjCAvailabilityCheckExpr:
+  return cxstring::createRef("ObjCAvailabilityCheckExpr");
   case CXCursor_ObjCSelfExpr:
   return cxstring::createRef("ObjCSelfExpr");
   case CXCursor_ObjCEncodeExpr:
Index: test/Parser/objc-available.m
===
--- test/Parser/objc-available.m
+++ test/Parser/objc-available.m
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunguarded-availability -triple x86_64-apple-macosx10.10.0 -verify %s
+
+void f() {
+
+  if (@available(macos 10.12, *)) {}
+  else if (@available(macos 10.11, *)) {}
+  else {}
+
+  (void)__builtin_available(ios 8, macos 10.10, *);
+
+  (void)@available(macos 10.11); // expected-error{{must handle potential future platforms with '*'}}
+  (void)@available(macos 10.11, macos 10.11, *); // expected-error{{version for 'macos' already specified}}
+
+  (void)@available(erik_os 10.11, *); // expected-error{{unrecognized platform name erik_os}}
+
+  (void)@available(ios 8, *); // expected-warning{{using '*' case here, platform macos is not accounted for}}
+
+  (void)@available(); // expected-error{{expected a platform name here}}
+  (void)@available(macos 10.10,); // expected-error{{expected a platform name here}}
+  (void)@available(macos); // expected-error{{expected a version}}
+  (void)@available; // expected-error{{expected '('}}
+}
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -915,6 +915,7 @@
 case Stmt::CXXScalarValueInitExprClass:
 case Stmt::CXXBoolLiteralExprClass:
 case Stmt::ObjCBoolLiteralExprClass:
+case Stmt::ObjCAvailabilityCheckExprClass:
 case Stmt::FloatingLiteralClass:
 case Stmt::NoInitExprClass:
 case Stmt::SizeOfPackExprClass:
Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt

r274930 - Teach -ast-print to print constexpr variables.

2016-07-08 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Fri Jul  8 16:09:08 2016
New Revision: 274930

URL: http://llvm.org/viewvc/llvm-project?rev=274930&view=rev
Log:
Teach -ast-print to print constexpr variables.

Patch reviewed by Richard Smith (D22168).

Modified:
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/test/SemaCXX/ast-print.cpp

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=274930&r1=274929&r2=274930&view=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Fri Jul  8 16:09:08 2016
@@ -715,6 +715,11 @@ void DeclPrinter::VisitLabelDecl(LabelDe
 
 void DeclPrinter::VisitVarDecl(VarDecl *D) {
   prettyPrintPragmas(D);
+
+  QualType T = D->getTypeSourceInfo()
+? D->getTypeSourceInfo()->getType()
+: D->getASTContext().getUnqualifiedObjCPointerType(D->getType());
+
   if (!Policy.SuppressSpecifiers) {
 StorageClass SC = D->getStorageClass();
 if (SC != SC_None)
@@ -736,11 +741,13 @@ void DeclPrinter::VisitVarDecl(VarDecl *
 
 if (D->isModulePrivate())
   Out << "__module_private__ ";
+
+if (D->isConstexpr()) {
+  Out << "constexpr ";
+  T.removeLocalConst();
+}
   }
 
-  QualType T = D->getTypeSourceInfo()
-? D->getTypeSourceInfo()->getType()
-: D->getASTContext().getUnqualifiedObjCPointerType(D->getType());
   printDeclType(T, D->getName());
   Expr *Init = D->getInit();
   if (!Policy.SuppressInitializers && Init) {

Modified: cfe/trunk/test/SemaCXX/ast-print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ast-print.cpp?rev=274930&r1=274929&r2=274930&view=diff
==
--- cfe/trunk/test/SemaCXX/ast-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/ast-print.cpp Fri Jul  8 16:09:08 2016
@@ -228,11 +228,13 @@ template  struct Foo : T {
 };
 }
 
-namespace dont_crash {
+namespace dont_crash_on_auto_vars {
 struct T { enum E {X = 12ll }; };
 struct S {
   struct  { int I; } ADecl;
   static const auto Y = T::X;
 };
 //CHECK: static const auto Y = T::X;
+constexpr auto var = T::X;
+//CHECK: constexpr auto var = T::X;
 }


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


[PATCH] D22176: [OpenMP] add more tests for 'distribute simd' pragma

2016-07-08 Thread Kelvin Li via cfe-commits
kkwli0 created this revision.
kkwli0 added reviewers: ABataev, sfantao, carlo.bertolli, hfinkel, arpith-jacob.
kkwli0 added a subscriber: cfe-commits.

This patch is to add two additional tests for testing 'distribute simd' pragma 
with disallowed clauses and loops.

http://reviews.llvm.org/D22176

Files:
  test/OpenMP/distribute_simd_loop_messages.cpp
  test/OpenMP/distribute_simd_misc_messages.c

Index: test/OpenMP/distribute_simd_misc_messages.c
===
--- /dev/null
+++ test/OpenMP/distribute_simd_misc_messages.c
@@ -0,0 +1,1091 @@
+// RUN: %clang_cc1 -fsyntax-only -fopenmp -verify %s
+
+// expected-error@+1 {{unexpected OpenMP directive '#pragma omp distribute simd'}}
+#pragma omp distribute simd
+
+// expected-error@+1 {{unexpected OpenMP directive '#pragma omp distribute simd'}}
+#pragma omp distribute simd foo
+
+// expected-error@+1 {{unexpected OpenMP directive '#pragma omp distribute simd'}}
+#pragma omp distribute simd safelen(4)
+
+void test_no_clause() {
+  int i;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd
+  for (i = 0; i < 16; ++i)
+;
+
+#pragma omp target
+#pragma omp teams
+// expected-error@+2 {{statement after '#pragma omp distribute simd' must be a for loop}}
+#pragma omp distribute simd
+  ++i;
+}
+
+void test_branch_protected_scope() {
+  int i = 0;
+L1:
+  ++i;
+
+  int x[24];
+
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd
+  for (i = 0; i < 16; ++i) {
+if (i == 5)
+  goto L1; // expected-error {{use of undeclared label 'L1'}}
+else if (i == 6)
+  return; // expected-error {{cannot return from OpenMP region}}
+else if (i == 7)
+  goto L2;
+else if (i == 8) {
+L2:
+  x[i]++;
+}
+  }
+
+  if (x[0] == 0)
+goto L2; // expected-error {{use of undeclared label 'L2'}}
+  else if (x[1] == 1)
+goto L1;
+}
+
+void test_invalid_clause() {
+  int i;
+#pragma omp target
+#pragma omp teams
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp distribute simd' are ignored}}
+#pragma omp distribute simd foo bar
+  for (i = 0; i < 16; ++i)
+;
+}
+
+void test_non_identifiers() {
+  int i, x;
+
+#pragma omp target
+#pragma omp teams
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp distribute simd' are ignored}}
+#pragma omp distribute simd;
+  for (i = 0; i < 16; ++i)
+;
+
+#pragma omp target
+#pragma omp teams
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp distribute simd' are ignored}}
+#pragma omp distribute simd private(x);
+  for (i = 0; i < 16; ++i)
+;
+
+#pragma omp target
+#pragma omp teams
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp distribute simd' are ignored}}
+#pragma omp distribute simd, private(x);
+  for (i = 0; i < 16; ++i)
+;
+}
+
+extern int foo();
+void test_safelen() {
+  int i;
+#pragma omp target
+#pragma omp teams
+// expected-error@+1 {{expected '('}}
+#pragma omp distribute simd safelen
+  for (i = 0; i < 16; ++i)
+;
+#pragma omp target
+#pragma omp teams
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp distribute simd safelen(
+  for (i = 0; i < 16; ++i)
+;
+#pragma omp target
+#pragma omp teams
+// expected-error@+1 {{expected expression}}
+#pragma omp distribute simd safelen()
+  for (i = 0; i < 16; ++i)
+;
+#pragma omp target
+#pragma omp teams
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp distribute simd safelen(,
+  for (i = 0; i < 16; ++i)
+;
+#pragma omp target
+#pragma omp teams
+// expected-error@+1 {{expected expression}}  expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp distribute simd safelen(, )
+  for (i = 0; i < 16; ++i)
+;
+#pragma omp target
+#pragma omp teams
+// expected-warning@+2 {{extra tokens at the end of '#pragma omp distribute simd' are ignored}}
+// expected-error@+1 {{expected '('}}
+#pragma omp distribute simd safelen 4)
+  for (i = 0; i < 16; ++i)
+;
+#pragma omp target
+#pragma omp teams
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp distribute simd safelen(4
+  for (i = 0; i < 16; ++i)
+;
+#pragma omp target
+#pragma omp teams
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp distribute simd safelen(4,
+  for (i = 0; i < 16; ++i)
+;
+#pragma omp target
+#pragma omp teams
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp distribute simd safelen(4, )
+  for (i = 0; i < 16; ++i)
+;
+#pragma omp target
+#pragma omp teams
+// xxpected-error@+1 {{expected expression}}
+#pragma omp distribute simd safelen(4)
+  for (i = 0; i < 16; ++i)
+;
+#pragma omp target
+#pragma omp teams
+// expected-error@+2 {{expected ')'}}
+// expected-n

Re: [PATCH] D21823: [Driver] Add flags for enabling both types of PGO Instrumentation

2016-07-08 Thread Sean Silva via cfe-commits
On Fri, Jul 8, 2016 at 10:22 AM, Xinliang David Li 
wrote:

>
>
> On Sun, Jul 3, 2016 at 1:50 PM, Sean Silva  wrote:
>
>>
>>
>> On Sat, Jul 2, 2016 at 7:38 PM, Xinliang David Li 
>> wrote:
>>
>>> Sanitizers are different IMO. Different santizers are rather
>>> independent, and there is no such thing as -fsantize to mean -fsantize=all
>>>
>>> For PGO, in most of the cases, users do not need to care about the
>>> sub-options implied -- by default they should just get the best profiling
>>> (whatever that is). Fine-grained control is more useful for savvy users.
>>> Besides, any flavor of value profiling usually does not make sense to be
>>> used standalone and need to be used with edge profiling for max benefit
>>> (also not supported in our implementation) - so I don't see why pgo control
>>> needs to be done in a way similar to sanitizers.
>>>
>>
>> Thanks for the explanation. So I think we can start by reducing this
>> patch to just `-fpgo-train` (enables IRPGO), `-fpgo-train-file=`, and
>> `-fpgo-apply=`.
>>
>> While -fpgo-apply= is technically redundant with -fprofile-instr-use, I
>> think it is useful for consistency.
>>
>> I'm also indifferent to adding
>> `-fpgo-train=source`/`-fpgo-train=optimizer` in this patch.
>>
>
>
> I like this suggestion (the reduced version).
>
>
>
>>
>> btw, I don't understand the intuition for calling IRPGO "cfg"; maybe you
>> could explain?
>>
>
>
>> I like "optimizer" because it is easy to document to users, as users
>> generally understand the difference between the "optimizer" and
>> source-level analysis of their program. For example, we could document:
>> "-fpgo-train=source instruments at source-level similar to code coverage
>> instrumentation. -fpgo-train=optimizer applies the instrumentation inside
>> the optimizer and has freedom to do sophisticated analyses and
>> transformations as part of the instrumentation process; these analyses and
>> transformations allow it to reduce instrumentation overhead and increase
>> profile accuracy."
>>
>>
> I am fine with using source/optimizer. I was mainly against overloading
> -fpgo-train to do fine grain control.
>

Ok, thanks for the clarification.

-- Sean Silva


>
> David
>
>
>>
>> -- Sean Silva
>>
>>
>>>
>>>  In other words, I don't think the primary option -fpgo-train should be
>>> used for fine-grain suboption control.   If we have a different option to
>>> do fine-grain control for PGO, using sanitize like syntax is fine with me:
>>>
>>> -fpgo-xxx=y:z  turn on y and z for pgo
>>> -fno-pgo-xxx=y:z  turn off y and z for pgo
>>> or
>>> -fpgo-xxx=no-w:no-y:z   turn on z but turn off w, and y
>>>
>>>
>>> David
>>>
>>>
>>> On Sat, Jul 2, 2016 at 6:45 PM, Sean Silva 
>>> wrote:
>>>


 On Sat, Jul 2, 2016 at 1:57 PM, Xinliang David Li 
 wrote:

>
>
> On Fri, Jul 1, 2016 at 4:32 PM, Sean Silva 
> wrote:
>
>> silvas added inline comments.
>>
>> 
>> Comment at: lib/Driver/Tools.cpp:3560
>> @@ +3559,3 @@
>> +if
>> (PGOTrainArg->getOption().matches(options::OPT_fpgo_train_EQ)) {
>> +  if (StringRef(PGOTrainArg->getValue()) == "source-cfg")
>> +CmdArgs.push_back("-fprofile-instrument=clang");
>> 
>> davidxl wrote:
>> > I think it is better to make the selector  'source' vs 'cfg'.
>> >
>> > -fpgo-train=source
>> > -fpgo-train=cfg
>> So would `-fpgo-train=cfg` enable icall instrumentation or not?
>>
>> My thinking is that down the road we will have one flag for each
>> independent instrumentation capability (and of course some are mutually
>> incompatible). This mirrors what the sanitizers do. For example, we would
>> have:
>> `-fpgo-train=optimizer-cfg` --> IR edge profiling
>> `-fpgo-train=optimizer-icall` --> IR icall value profiling
>> `-fpgo-train=optimizer-...` --> other independent instrumentation we
>> can do in IR instrumentation.
>> `-fpgo-train=source-cfg` --> FE edge profiling
>> `-fpgo-train=source-icall` --> FE icall profiling (if that even
>> exists; I see some code but there is no user-visible flag)
>> `-fpgo-train=source-...` --> other FE instrumentation.
>>
>> We can then have `-fpgo-train=optimizer` enable e.g.
>> `-fpgo-train=optimizer-cfg,optimizer-icall`.
>> We can also have `-fpgo-train=source` enable e.g.
>> `-fpgo-train=source-cfg`.
>>
>> Since instrumentation can have different overheads or different
>> runtime requirements, users may want to disable some instrumentation.
>>
>>
>
> -fpgo-train is the new umbrella option that turn on at least edge
> profiling and some other flavor of value profiling (icall, or stringop, 
> etc
> in the the future). There is a default setting for source or cfg based 
> PGO.
> The fine grain control of each sub-option should be done via a different
> flag -- otherwise we will have to introduce 2 x N sub-

Re: [PATCH] D21814: clang-rename: support multiple renames with one invocation

2016-07-08 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

As far as I see `tooling::CommonOptionsParser` (in its current form) does not 
handle cl::SubCommand instances. Should I fix that or would it be OK to switch 
to using `cl::ParseCommandLineOptions` directly in clang-rename?


http://reviews.llvm.org/D21814



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


Re: [PATCH] D21851: [Driver][OpenMP][CUDA] Add capability to bundle object files in sections of the host binary format.

2016-07-08 Thread Samuel Antao via cfe-commits
sfantao marked 4 inline comments as done.
sfantao added a comment.

That was probably not the reason why you were getting the failure, but the 
bundler was not prepared to bundle files if the host was not the first input. I 
fixed that.

I also replaced the test that was running the linker by something that checks 
the command and temporary files using -###. However, I'm still producing 
temporary files with -###. This problem is similar to the linker script test in 
http://reviews.llvm.org/D21847. Once we figure out how to tests the linker 
script I'll replicate the solution here too.


http://reviews.llvm.org/D21851



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


Re: [PATCH] D21851: [Driver][OpenMP][CUDA] Add capability to bundle object files in sections of the host binary format.

2016-07-08 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 63361.
sfantao added a comment.

- Allow host object to come in any order when generating the binary. Add 
testing for that.
- Add save temps and command print option.
- Add bundled object for testing.


http://reviews.llvm.org/D21851

Files:
  test/Driver/clang-offload-bundler.c
  test/Driver/clang-offload-bundler.c.o
  tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -72,20 +72,39 @@
  cl::desc("Unbundle bundled file into several output files.\n"),
  cl::init(false), cl::cat(ClangOffloadBundlerCategory));
 
+static cl::opt PrintExternalCommands(
+"###", cl::desc("Print the external commands that are to be executed "
+"instead of actually execute them.\n"),
+cl::init(false), cl::cat(ClangOffloadBundlerCategory));
+
+static cl::opt SaveTemps("save-temps",
+   cl::desc("Keep any created temporary files.\n"),
+   cl::init(false),
+   cl::cat(ClangOffloadBundlerCategory));
+
 /// Magic string that marks the existence of offloading data.
 #define OFFLOAD_BUNDLER_MAGIC_STR "__CLANG_OFFLOAD_BUNDLE__"
 
 /// The index of the host input in the list of inputs.
 static unsigned HostInputIndex = ~0u;
 
+/// Path to the current binary.
+static std::string BundlerExecutable;
+
 /// Obtain the offload kind and real machine triple out of the target
 /// information specified by the user.
 static void getOffloadKindAndTriple(StringRef Target, StringRef &OffloadKind,
 StringRef &Triple) {
   auto KindTriplePair = Target.split('-');
   OffloadKind = KindTriplePair.first;
   Triple = KindTriplePair.second;
 }
+static StringRef getTriple(StringRef Target) {
+  StringRef OffloadKind;
+  StringRef Triple;
+  getOffloadKindAndTriple(Target, OffloadKind, Triple);
+  return Triple;
+}
 static bool hasHostKind(StringRef Target) {
   StringRef OffloadKind;
   StringRef Triple;
@@ -116,8 +135,8 @@
   /// \a OS.
   virtual void WriteBundleStart(raw_fd_ostream &OS, StringRef TargetTriple) = 0;
   /// Write the marker that closes a bundle for the triple \a TargetTriple to \a
-  /// OS.
-  virtual void WriteBundleEnd(raw_fd_ostream &OS, StringRef TargetTriple) = 0;
+  /// OS. Return true if any error was found.
+  virtual bool WriteBundleEnd(raw_fd_ostream &OS, StringRef TargetTriple) = 0;
   /// Write the bundle from \a Input into \a OS.
   virtual void WriteBundle(raw_fd_ostream &OS, MemoryBuffer &Input) = 0;
 
@@ -303,15 +322,253 @@
 }
   }
   void WriteBundleStart(raw_fd_ostream &OS, StringRef TargetTriple) {}
-  void WriteBundleEnd(raw_fd_ostream &OS, StringRef TargetTriple) {}
+  bool WriteBundleEnd(raw_fd_ostream &OS, StringRef TargetTriple) {
+return false;
+  }
   void WriteBundle(raw_fd_ostream &OS, MemoryBuffer &Input) {
 OS.write(Input.getBufferStart(), Input.getBufferSize());
   }
 
   BinaryFileHandler() : FileHandler() {}
   ~BinaryFileHandler() {}
 };
 
+/// Handler for object files. The bundles are organized by sections with a
+/// designated name.
+///
+/// In order to bundle we create an IR file with the content of each section and
+/// use incremental linking to produce the resulting object. We also add section
+/// with a single byte to state the name of the component the main object file
+/// (the one we are bundling into) refers to.
+///
+/// To unbundle, we use just copy the contents of the designated section. If the
+/// requested bundle refer to the main object file, we just copy it with no
+/// changes.
+class ObjectFileHandler final : public FileHandler {
+
+  /// The object file we are currently dealing with.
+  ObjectFile &Obj;
+
+  /// Return the input file contents.
+  StringRef getInputFileContents() const { return Obj.getData(); }
+
+  /// Return true if the provided section is an offload section and return the
+  /// triple by reference.
+  static bool IsOffloadSection(SectionRef CurSection,
+   StringRef &OffloadTriple) {
+StringRef SectionName;
+CurSection.getName(SectionName);
+
+if (SectionName.empty())
+  return false;
+
+// If it does not start with the reserved suffix, just skip this section.
+if (!SectionName.startswith(OFFLOAD_BUNDLER_MAGIC_STR))
+  return false;
+
+// Return the triple that is right after the reserved prefix.
+OffloadTriple = SectionName.substr(sizeof(OFFLOAD_BUNDLER_MAGIC_STR) - 1);
+return true;
+  }
+
+  /// Total number of inputs.
+  unsigned NumberOfInputs = 0;
+
+  /// Total number of processed inputs, i.e, inputs that were already
+  /// read from the buffers.
+  unsigned NumberOfProcessedInputs = 0;
+
+  /// LLVM context used to to create the 

Re: [PATCH] D13909: clang-offload-bundler - offload files bundling/unbundling tool

2016-07-08 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 63362.
sfantao added a comment.

- Add tests for when the host does not come first.
- Fix format of comments and add variable to trace the position of the host 
input.


http://reviews.llvm.org/D13909

Files:
  test/CMakeLists.txt
  test/Driver/clang-offload-bundler.c
  tools/CMakeLists.txt
  tools/clang-offload-bundler/CMakeLists.txt
  tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- /dev/null
+++ tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -0,0 +1,680 @@
+//===-- clang-offload-bundler/ClangOffloadBundler.cpp - Clang format tool -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// \brief This file implements a clang-offload-bundler that bundles different
+/// files that relate with the same source code but different targets into a
+/// single one. Also the implements the opposite functionality, i.e. unbundle
+/// files previous created by this tool.
+///
+//===--===//
+
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/Version.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Bitcode/ReaderWriter.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#include "llvm/Object/Binary.h"
+#include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Object/ObjectFile.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/Signals.h"
+
+using namespace llvm;
+using namespace llvm::object;
+
+static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
+
+// Mark all our options with this category, everything else (except for -version
+// and -help) will be hidden.
+static cl::OptionCategory
+ClangOffloadBundlerCategory("clang-offload-bundler options");
+
+static cl::list
+InputFileNames("inputs", cl::CommaSeparated, cl::OneOrMore,
+   cl::desc("[,...]"),
+   cl::cat(ClangOffloadBundlerCategory));
+static cl::list
+OutputFileNames("outputs", cl::CommaSeparated, cl::OneOrMore,
+cl::desc("[,...]"),
+cl::cat(ClangOffloadBundlerCategory));
+static cl::list
+TargetNames("targets", cl::CommaSeparated, cl::OneOrMore,
+cl::desc("[-,...]"),
+cl::cat(ClangOffloadBundlerCategory));
+static cl::opt
+FilesType("type", cl::Required,
+  cl::desc("Type of the files to be bundled/unbundled.\n"
+   "Current supported types are:\n"
+   "  i   - cpp-output\n"
+   "  ii  - c++-cpp-output\n"
+   "  ll  - llvm\n"
+   "  bc  - llvm-bc\n"
+   "  s   - assembler\n"
+   "  o   - object\n"
+   "  gch - precompiled-header\n"
+   "  ast - clang AST file"),
+  cl::cat(ClangOffloadBundlerCategory));
+static cl::opt
+Unbundle("unbundle",
+ cl::desc("Unbundle bundled file into several output files.\n"),
+ cl::init(false), cl::cat(ClangOffloadBundlerCategory));
+
+/// Magic string that marks the existence of offloading data.
+#define OFFLOAD_BUNDLER_MAGIC_STR "__CLANG_OFFLOAD_BUNDLE__"
+
+/// The index of the host input in the list of inputs.
+static unsigned HostInputIndex = ~0u;
+
+/// Obtain the offload kind and real machine triple out of the target
+/// information specified by the user.
+static void getOffloadKindAndTriple(StringRef Target, StringRef &OffloadKind,
+StringRef &Triple) {
+  auto KindTriplePair = Target.split('-');
+  OffloadKind = KindTriplePair.first;
+  Triple = KindTriplePair.second;
+}
+static bool hasHostKind(StringRef Target) {
+  StringRef OffloadKind;
+  StringRef Triple;
+  getOffloadKindAndTriple(Target, OffloadKind, Triple);
+  return OffloadKind == "host";
+}
+
+/// Generic file handler interface.
+class FileHandler {
+public:
+  /// Update the file handler with information from the header of the bundled
+  /// file
+  virtual void ReadHeader(MemoryBuffer &Input) = 0;
+  /// Read the marker of the next bundled to be read in the file. The triple of
+  /// the target associated with that bundled is returned. An empty string is
+  /// returned if there are no more bundles to be read.
+  virtual StringRef ReadBundleStart(MemoryBuffer &Input) = 0;
+  /// Read the marker that closes the current bundle.
+  virtual void ReadBundleEnd(MemoryBuffer &Inpu

Re: [PATCH] D21847: [Driver][OpenMP] Build jobs for OpenMP offloading actions for targets using gcc tool chains.

2016-07-08 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 63365.
sfantao marked an inline comment as done.
sfantao added a comment.

- Bind an action to an offloading prefix even if no bound architecture is used.


http://reviews.llvm.org/D21847

Files:
  lib/Driver/Driver.cpp
  lib/Driver/Tools.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -138,3 +138,95 @@
 // CHK-PHASES-FILES: 38: assembler, {37}, object, (device-openmp)
 // CHK-PHASES-FILES: 39: linker, {26, 32, 38}, image, (device-openmp)
 // CHK-PHASES-FILES: 40: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {11}, "device-openmp (x86_64-pc-linux-gnu)" {25}, "device-openmp (powerpc64-ibm-linux-gnu)" {39}, image
+
+
+/// ###
+
+/// Check of the commands passed to each tool when using valid OpenMP targets.
+/// Here we also check that offloading does not break the use of integrated
+/// assembler. It does however preclude the merge of the host compile and
+/// backend phases. There are also two offloading specific options:
+/// -fopenmp-is-device: will tell the frontend that it will generate code for a
+/// target.
+/// -fopenmp-host-ir-file-path: specifies the host IR file that can be loaded by
+/// the target code generation to gather information about which declaration
+/// really need to be emitted.
+///
+// RUN:   %clang -### -fopenmp -o %t.out -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-COMMANDS %s
+// Run the save temp test in a temporary folder as the linker script will be
+// created there.
+// RUN:   cd %T &&  \
+// RUN:   %clang -### -fopenmp -o %t.out -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s -save-temps 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-COMMANDS-ST %s
+// RUN:   FileCheck -check-prefix=CHK-LKS %s --input-file %t.lk
+//
+// Generate host BC file.
+//
+// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "c" "[[INPUT:.+\.c]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu"
+// CHK-COMMANDS-ST: clang-3.9" "-cc1" "-triple" "powerpc64le--linux" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTPP:.+\.i]]" "-x" "c" "[[INPUT:.+\.c]]"
+// CHK-COMMANDS-ST: clang-3.9" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "cpp-output" "[[HOSTPP]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu"
+
+//
+// Compile for the powerpc device.
+/
+// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-COMMANDS: ld" {{.*}}"-o" "[[T1BIN:.+\.out]]" {{.*}}"[[T1OBJ]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1PP:.+\.i]]" "-x" "c" "[[INPUT]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1BC:.+\.bc]]" "-x" "cpp-output" "[[T1PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1ASM:.+\.s]]" "-x" "ir" "[[T1BC]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le-ibm-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "[[T1ASM]]"
+// CHK-COMMANDS-ST: ld" {{.*}}"-o" "[[T1BIN:.+\.out-device-openmp-powerpc64le-ibm-linux-gnu]]" {{.*}}[[T1OBJ]]
+
+//
+// Compile for the x86 device.
+//
+// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj"  {{.*}}"-fopenmp"  {{.*}}"-o" "[[T2OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-COMMANDS: ld" {{.*}}"-o" "[[T2BIN:.+\.out]]" {{.*}}"[[T2OBJ]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2PP:.+\.i]]" "-x" "c" "[[INPUT]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2BC:.+\.bc]]" "-x" "cpp-output" "[[T2PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2ASM:.+\.s]]" "-x" "ir" "[[T2BC]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "x86_64-pc-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "[[T2ASM]]"
+// CHK-COMMANDS-ST: ld" {{.*}}"-o" "[[T2BIN:.+\.out-device-openmp-x86_64-pc-linux-gnu]]" {{.*}}[[T2OBJ]]
+
+//
+// Generate host object from the BC file and link using the linker script.
+//

[PATCH] D22183: [SemObjC] Fix TypoExpr handling in TransformObjCDictionaryLiteral

2016-07-08 Thread Bruno Cardoso Lopes via cfe-commits
bruno created this revision.
bruno added reviewers: manmanren, doug.gregor.
bruno added a subscriber: cfe-commits.

Calls to TransformExpr for NSDictionary elements (keys and values) in
TransformObjCDictionaryLiteral might fail to obtain TypoCorrections. This is OK,
but the early exits with ExprError() don't allow TransformExpr to run for other
elements.

This avoids typo correction suggestions to kick in and has a major
drawback to compile time; it forces Transform to call TryTransform more
times than it should. Before this patch, the testcase added used to take
5s to compile!!! A bit more elaborate NSDictionary literal with some
undeclared enums would make the compiler take 22min to run, followed by
a crash.

http://reviews.llvm.org/D22183

Files:
  lib/Sema/TreeTransform.h
  test/SemaObjC/objc-dictionary-literal.m

Index: test/SemaObjC/objc-dictionary-literal.m
===
--- test/SemaObjC/objc-dictionary-literal.m
+++ test/SemaObjC/objc-dictionary-literal.m
@@ -63,3 +63,11 @@
return 0;
 }
 
+enum XXXYYYZZZType { XXXYYYZZZTypeAny }; // expected-note {{'XXXYYYZZZTypeAny' 
declared here}}
+
+void foo() {
+  NSDictionary *d = @{
+@"A" : @(XXXYYYZZZTypeA), // expected-error {{use of undeclared identifier 
'XXXYYYZZZTypeA'; did you mean 'XXXYYYZZZTypeAny'}}
+@"F" : @(XXXYYYZZZTypeSomethingSomething), // expected-error {{use of 
undeclared identifier 'XXXYYYZZZTypeSomethingSomething'}}
+  };
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -10956,23 +10956,19 @@
 
 // Transform and check key.
 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
-if (Key.isInvalid())
-  return ExprError();
-
-if (Key.get() != OrigElement.Key)
+if (!Key.isInvalid() && Key.get() != OrigElement.Key)
   ArgChanged = true;
 
 // Transform and check value.
 ExprResult Value
   = getDerived().TransformExpr(OrigElement.Value);
-if (Value.isInvalid())
-  return ExprError();
-
-if (Value.get() != OrigElement.Value)
+if (!Value.isInvalid() && Value.get() != OrigElement.Value)
   ArgChanged = true;
 
 ObjCDictionaryElement Element = {
-  Key.get(), Value.get(), SourceLocation(), None
+Key.isInvalid() ? OrigElement.Key : Key.get(),
+Value.isInvalid() ? OrigElement.Value : Value.get(), SourceLocation(),
+None
 };
 Elements.push_back(Element);
   }


Index: test/SemaObjC/objc-dictionary-literal.m
===
--- test/SemaObjC/objc-dictionary-literal.m
+++ test/SemaObjC/objc-dictionary-literal.m
@@ -63,3 +63,11 @@
 	return 0;
 }
 
+enum XXXYYYZZZType { XXXYYYZZZTypeAny }; // expected-note {{'XXXYYYZZZTypeAny' declared here}}
+
+void foo() {
+  NSDictionary *d = @{
+@"A" : @(XXXYYYZZZTypeA), // expected-error {{use of undeclared identifier 'XXXYYYZZZTypeA'; did you mean 'XXXYYYZZZTypeAny'}}
+@"F" : @(XXXYYYZZZTypeSomethingSomething), // expected-error {{use of undeclared identifier 'XXXYYYZZZTypeSomethingSomething'}}
+  };
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -10956,23 +10956,19 @@
 
 // Transform and check key.
 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
-if (Key.isInvalid())
-  return ExprError();
-
-if (Key.get() != OrigElement.Key)
+if (!Key.isInvalid() && Key.get() != OrigElement.Key)
   ArgChanged = true;
 
 // Transform and check value.
 ExprResult Value
   = getDerived().TransformExpr(OrigElement.Value);
-if (Value.isInvalid())
-  return ExprError();
-
-if (Value.get() != OrigElement.Value)
+if (!Value.isInvalid() && Value.get() != OrigElement.Value)
   ArgChanged = true;
 
 ObjCDictionaryElement Element = {
-  Key.get(), Value.get(), SourceLocation(), None
+Key.isInvalid() ? OrigElement.Key : Key.get(),
+Value.isInvalid() ? OrigElement.Value : Value.get(), SourceLocation(),
+None
 };
 Elements.push_back(Element);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21823: [Driver] Add flags for enabling both types of PGO Instrumentation

2016-07-08 Thread Jake VanAdrighem via cfe-commits
jakev updated the summary for this revision.
jakev updated this revision to Diff 63367.
jakev marked 3 inline comments as done.
jakev added a comment.

Reduce instrumentation flags to `fpgo-train` and change profile output file 
flag to `fpgo-train-output`.


Repository:
  rL LLVM

http://reviews.llvm.org/D21823

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChain.cpp
  lib/Driver/Tools.cpp
  test/Driver/clang_f_opts.c

Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -97,23 +97,36 @@
 // RUN: %clang -### -S -fcoverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-COVERAGE-AND-GEN %s
 // RUN: %clang -### -S -fcoverage-mapping -fno-coverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-COVERAGE %s
 // RUN: %clang -### -S -fprofile-instr-generate -fcoverage-mapping -fno-coverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-COVERAGE %s
+// RUN: %clang -### -S -fpgo-train %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-LLVM %s
+// RUN: %clang -### -S -fpgo-train-output=file %s 2>&1 | FileCheck -check-prefix=CHECK-DEFAULT-AND-TRAIN %s
+// RUN: %clang -### -S -fpgo-train -fpgo-train-output=/tmp/somefile.profraw %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-FILE %s
+// RUN: %clang -### -S -fpgo-train -fcoverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-COVERAGE-AND-GEN %s
+// RUN: %clang -### -S -fpgo-train -fprofile-instr-generate %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-TRAIN-GEN %s
+// RUN: %clang -### -S -fpgo-train -fpgo-apply=file %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
 // CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang"
+// CHECK-PROFILE-GENERATE-LLVM: "-fprofile-instrument=llvm"
 // CHECK-PROFILE-GENERATE-DIR: "-fprofile-instrument-path=/some/dir{{/|}}default.profraw"
 // CHECK-PROFILE-GENERATE-FILE: "-fprofile-instrument-path=/tmp/somefile.profraw"
 // CHECK-NO-MIX-GEN-USE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}'
+// CHECK-NO-MIX-TRAIN-GEN: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}'
 // CHECK-DISABLE-GEN-NOT: "-fprofile-instrument=clang"
 // CHECK-DISABLE-USE-NOT: "-fprofile-instr-use"
 // CHECK-COVERAGE-AND-GEN: '-fcoverage-mapping' only allowed with '-fprofile-instr-generate'
+// CHECK-DEFAULT-AND-TRAIN: '-fpgo-train-output' only allowed with '-fpgo-train'
 // CHECK-DISABLE-COVERAGE-NOT: "-fcoverage-mapping"
 
 // RUN: %clang -### -S -fprofile-use %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE %s
 // RUN: %clang -### -S -fprofile-instr-use %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE %s
 // RUN: mkdir -p %t.d/some/dir
 // RUN: %clang -### -S -fprofile-use=%t.d/some/dir %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE-DIR %s
 // RUN: %clang -### -S -fprofile-instr-use=/tmp/somefile.prof %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE-FILE %s
+// RUN: %clang -### -S -fpgo-apply=/tmp/somefile.prof %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE-FILE %s
+// RUN: %clang -### -S -fpgo-train  -fpgo-apply=/tmp/somefile.prof %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE-FILE %s
+// RUN: %clang -### -S -fprofile-instr-use=/tmp/somefile.prof -fpgo-apply=/tmp/somefile.prof %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-APPLY-USE %s
 // CHECK-PROFILE-USE: "-fprofile-instrument-use-path=default.profdata"
 // CHECK-PROFILE-USE-DIR: "-fprofile-instrument-use-path={{.*}}.d/some/dir{{/|}}default.profdata"
 // CHECK-PROFILE-USE-FILE: "-fprofile-instrument-use-path=/tmp/somefile.prof"
+// CHECK-NO-MIX-APPLY-USE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}'
 
 // RUN: %clang -### -S -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
 // RUN: %clang -### -S -fno-vectorize -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3473,6 +3473,28 @@
 static void addPGOAndCoverageFlags(Compilation &C, const Driver &D,
const InputInfo &Output, const ArgList &Args,
ArgStringList &CmdArgs) {
+
+  auto *PGOTrainArg =
+  Args.getLastArg(options::OPT_fpgo_train,
+  options::OPT_fno_pgo_train);
+  if (PGOTrainArg &&
+  PGOTrainArg->getOption().matches(options::OPT_fno_pgo_train))
+PGOTrainArg = nullptr;
+
+  auto *PGOOutputArg =
+  Args.getLastArg(options::OPT_fpgo_train_output_EQ);
+
+  if (PGOOutputArg && !PGOTrainArg)
+D.Diag(diag::err_drv_argument_only_allowed_with)
+<< "-fpgo-train-output"
+<< "-fpgo-train";
+
+  if (PGOOutputArg)
+if (PGOOutputArg->getOption().matches(
+options::OPT_fpgo_train_output_EQ))
+  CmdArgs.push_back(Args.MakeArgString(Twine("-fprofile-instrument-path=") +
+   PGOOutputArg->getValue()));
+
   auto

Re: [PATCH] D21857: [Driver][OpenMP] Add support to create jobs for unbundling actions.

2016-07-08 Thread Samuel Antao via cfe-commits
sfantao added inline comments.


Comment at: lib/Driver/Driver.cpp:3108-3115
@@ +3107,10 @@
+
+// Now that we have all the results generated, select the one that should 
be
+// return for the current depending action.
+std::pair ActionTC = {
+A,
+GetTriplePlusArchString(TC, BoundArch, A->getOffloadingDeviceKind())};
+assert(CachedResults.find(ActionTC) != CachedResults.end() &&
+   "Result does not exist??");
+Result = CachedResults[ActionTC];
+  } else if (JA->getType() == types::TY_Nothing)

Hahnfeld wrote:
> I think `A->getOffloadingDeviceKind()` will always be `OFK_None` here because 
> `A` is of type `OffloadUnbundlingJobAction`. What we need here instead is the 
> `OffloadKind` that is building the job for the unbundling action.
> 
> The following patch fixes separate compilation with the same triple for me 
> (including the needed change mentioned in D21847#inline-187652)
> 
> ``` lines=15
> diff --git a/include/clang/Driver/Driver.h b/include/clang/Driver/Driver.h
> index 7abd9eb..72d19b2 100644
> --- a/include/clang/Driver/Driver.h
> +++ b/include/clang/Driver/Driver.h
> @@ -12,6 +12,7 @@
>  
>  #include "clang/Basic/Diagnostic.h"
>  #include "clang/Basic/LLVM.h"
> +#include "clang/Driver/Action.h"
>  #include "clang/Driver/Phases.h"
>  #include "clang/Driver/Types.h"
>  #include "clang/Driver/Util.h"
> @@ -44,7 +45,6 @@ class FileSystem;
>  
>  namespace driver {
>  
> -  class Action;
>class Command;
>class Compilation;
>class InputInfo;
> @@ -423,7 +423,7 @@ public:
>   const char *LinkingOutput,
>   std::map, 
> InputInfo>
>   &CachedResults,
> - bool BuildForOffloadDevice) const;
> + Action::OffloadKind BuildForOffloadKind) const;
>  
>/// Returns the default name for linked images (e.g., "a.out").
>const char *getDefaultImageName() const;
> @@ -491,7 +491,7 @@ private:
>const char *LinkingOutput,
>std::map, InputInfo>
>&CachedResults,
> -  bool BuildForOffloadDevice) const;
> +  Action::OffloadKind BuildForOffloadKind) const;
>  
>  public:
>/// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and
> diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
> index 6221a05..4d451f4 100644
> --- a/lib/Driver/Driver.cpp
> +++ b/lib/Driver/Driver.cpp
> @@ -2554,7 +2554,7 @@ void Driver::BuildJobs(Compilation &C) const {
> /*AtTopLevel*/ true,
> /*MultipleArchs*/ ArchNames.size() > 1,
> /*LinkingOutput*/ LinkingOutput, CachedResults,
> -   /*BuildForOffloadDevice*/ false);
> +   Action::OFK_None);
>}
>  
>// If the user passed -Qunused-arguments or there were errors, don't warn
> @@ -2904,9 +2904,9 @@ static std::string GetTriplePlusArchString(const 
> ToolChain *TC,
>if (BoundArch) {
>  TriplePlusArch += "-";
>  TriplePlusArch += BoundArch;
> -TriplePlusArch += "-";
> -TriplePlusArch += Action::GetOffloadKindName(OffloadKind);
>}
> +  TriplePlusArch += "-";
> +  TriplePlusArch += Action::GetOffloadKindName(OffloadKind);
>return TriplePlusArch;
>  }
>  
> @@ -2914,16 +2914,16 @@ InputInfo Driver::BuildJobsForAction(
>  Compilation &C, const Action *A, const ToolChain *TC, const char 
> *BoundArch,
>  bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,
>  std::map, InputInfo> 
> &CachedResults,
> -bool BuildForOffloadDevice) const {
> +Action::OffloadKind BuildForOffloadKind) const {
>std::pair ActionTC = {
> -  A, GetTriplePlusArchString(TC, BoundArch, 
> A->getOffloadingDeviceKind())};
> +  A, GetTriplePlusArchString(TC, BoundArch, BuildForOffloadKind)};
>auto CachedResult = CachedResults.find(ActionTC);
>if (CachedResult != CachedResults.end()) {
>  return CachedResult->second;
>}
>InputInfo Result = BuildJobsForActionNoCache(
>C, A, TC, BoundArch, AtTopLevel, MultipleArchs, LinkingOutput,
> -  CachedResults, BuildForOffloadDevice);
> +  CachedResults, BuildForOffloadKind);
>CachedResults[ActionTC] = Result;
>return Result;
>  }
> @@ -2932,9 +2932,12 @@ InputInfo Driver::BuildJobsForActionNoCache(
>  Compilation &C, const Action *A, const ToolChain *TC, const char 
> *BoundArch,
>  bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,
>  std::map, InputInfo> 
> &CachedResults,
> -bool BuildForOffloadDevice) const {
> +Action::OffloadKind BuildForOffloadKind) const {
>llvm::PrettyStackTraceString CrashInfo("Building compilation jobs");
>  
> +  bool BuildForOffloadDevice =
> +  BuildForOffloadKind != Action::OFK_None &&
> +  BuildForOffloadKind != Action::OFK_None;
>InputInfoList OffloadDependencesInputInfo;
>if (const OffloadAction *OA = dyn_cast(A)) {
>  /

r274956 - CodeGen: tweak CFString section for COFF, ELF

2016-07-08 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri Jul  8 20:59:51 2016
New Revision: 274956

URL: http://llvm.org/viewvc/llvm-project?rev=274956&view=rev
Log:
CodeGen: tweak CFString section for COFF, ELF

Place the structure data into `cfstring`.  This both isolates the structures to
permit coalescing in the future (by the linker) as well as ensures that it
doesnt get marked as read-only data.  The structures themselves are not
read-only, only the string contents.

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGen/CFStrings.c

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=274956&r1=274955&r2=274956&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Jul  8 20:59:51 2016
@@ -3209,10 +3209,8 @@ CodeGenModule::GetAddrOfConstantCFString
   case llvm::Triple::UnknownObjectFormat:
 llvm_unreachable("unknown file format");
   case llvm::Triple::COFF:
-GV->setSection(".rdata.cfstring");
-break;
   case llvm::Triple::ELF:
-GV->setSection(".rodata.cfstring");
+GV->setSection("cfstring");
 break;
   case llvm::Triple::MachO:
 GV->setSection("__DATA,__cfstring");

Modified: cfe/trunk/test/CodeGen/CFStrings.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/CFStrings.c?rev=274956&r1=274955&r2=274956&view=diff
==
--- cfe/trunk/test/CodeGen/CFStrings.c (original)
+++ cfe/trunk/test/CodeGen/CFStrings.c Fri Jul  8 20:59:51 2016
@@ -21,9 +21,9 @@ const CFStringRef two = (CFStringRef)__b
 // CHECK-ELF: @.str = private unnamed_addr constant [4 x i8] c"one\00", align 1
 // CHECK-MACHO: @.str = private unnamed_addr constant [4 x i8] c"one\00", 
section "__TEXT,__cstring,cstring_literals", align 1
 
-// CHECK-COFF: @_unnamed_cfstring_ = private constant 
%struct.__NSConstantString_tag { i32* getelementptr inbounds ([0 x i32], [0 x 
i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, i8* 
getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 3 }, 
section ".rdata.cfstring", align {{[48]}}
-// CHECK-ELF32: @_unnamed_cfstring_ = private constant 
%struct.__NSConstantString_tag { i32* getelementptr inbounds ([0 x i32], [0 x 
i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, i8* 
getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 3 }, 
section ".rodata.cfstring", align 4
-// CHECK-ELF64: @_unnamed_cfstring_ = private constant 
%struct.__NSConstantString_tag { i32* getelementptr inbounds ([0 x i32], [0 x 
i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, i8* 
getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i64 3 }, 
section ".rodata.cfstring", align 8
+// CHECK-COFF: @_unnamed_cfstring_ = private constant 
%struct.__NSConstantString_tag { i32* getelementptr inbounds ([0 x i32], [0 x 
i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, i8* 
getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 3 }, 
section "cfstring", align {{[48]}}
+// CHECK-ELF32: @_unnamed_cfstring_ = private constant 
%struct.__NSConstantString_tag { i32* getelementptr inbounds ([0 x i32], [0 x 
i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, i8* 
getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 3 }, 
section "cfstring", align 4
+// CHECK-ELF64: @_unnamed_cfstring_ = private constant 
%struct.__NSConstantString_tag { i32* getelementptr inbounds ([0 x i32], [0 x 
i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, i8* 
getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i64 3 }, 
section "cfstring", align 8
 // CHECK-MACHO32: @_unnamed_cfstring_ = private constant 
%struct.__NSConstantString_tag { i32* getelementptr inbounds ([0 x i32], [0 x 
i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, i8* 
getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 3 }, 
section "__DATA,__cfstring", align 4
 // CHECK-MACHO64: @_unnamed_cfstring_ = private constant 
%struct.__NSConstantString_tag { i32* getelementptr inbounds ([0 x i32], [0 x 
i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, i8* 
getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i64 3 }, 
section "__DATA,__cfstring", align 8
 
@@ -31,9 +31,9 @@ const CFStringRef two = (CFStringRef)__b
 // CHECK-ELF: @.str.1 = private unnamed_addr constant [7 x i16] [i16 -3, i16 
116, i16 -3, i16 119, i16 -3, i16 111, i16 0], align 2
 // CHECK-MACHO: @.str.1 = private unnamed_addr constant [7 x i16] [i16 -3, i16 
116, i16 -3, i16 119, i16 -3, i16 111, i16 0], section "__TEXT,__ustring", 
align 2
 
-// CHECK-COFF: @_unnamed_cfstring_.2 = private constant 
%struct.__NSConstantString_tag { i32* getelementptr inbounds ([0 x i32]

Re: [PATCH] D21954: [PM] Add some internal options for testing out the new PM.

2016-07-08 Thread Sean Silva via cfe-commits
silvas added a subscriber: cfe-commits.
silvas added a comment.

Actually add cfe-commits. Oops.

Thanks to Chandler for pointing out I had added llvm-commits instead.


http://reviews.llvm.org/D21954



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


r274965 - [X86] Uncomment the _mm_extract_ps test and add checks.

2016-07-08 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Fri Jul  8 23:38:17 2016
New Revision: 274965

URL: http://llvm.org/viewvc/llvm-project?rev=274965&view=rev
Log:
[X86] Uncomment the _mm_extract_ps test and add checks.

Modified:
cfe/trunk/test/CodeGen/sse41-builtins.c

Modified: cfe/trunk/test/CodeGen/sse41-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sse41-builtins.c?rev=274965&r1=274964&r2=274965&view=diff
==
--- cfe/trunk/test/CodeGen/sse41-builtins.c (original)
+++ cfe/trunk/test/CodeGen/sse41-builtins.c Fri Jul  8 23:38:17 2016
@@ -190,10 +190,11 @@ long long test_mm_extract_epi64(__m128i
   return _mm_extract_epi64(x, 1);
 }
 
-//TODO
-//int test_mm_extract_ps(__m128 x) {
-//  return _mm_extract_ps(_mm_add_ps(x,x), 1);
-//}
+int test_mm_extract_ps(__m128 x) {
+  // CHECK-LABEL: test_mm_extract_ps
+  // CHECK: extractelement <4 x float> %{{.*}}, i32 1
+  return _mm_extract_ps(x, 1);
+}
 
 __m128d test_mm_floor_pd(__m128d x) {
   // CHECK-LABEL: test_mm_floor_pd


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


r274968 - [X86] Use __builtin_ia32_vec_ext_v4hi and __builtin_ia32_vec_set_v4hi to implement pextrw/pinsertw MMX intrinsics instead of trying to use native IR.

2016-07-08 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sat Jul  9 00:30:41 2016
New Revision: 274968

URL: http://llvm.org/viewvc/llvm-project?rev=274968&view=rev
Log:
[X86] Use __builtin_ia32_vec_ext_v4hi and __builtin_ia32_vec_set_v4hi to 
implement pextrw/pinsertw MMX intrinsics instead of trying to use native IR.

Without this we end up generating code that doesn't use mmx registers and 
probably doesn't work well with other mmx intrinsics.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/xmmintrin.h
cfe/trunk/test/CodeGen/mmx-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=274968&r1=274967&r2=274968&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Sat Jul  9 00:30:41 2016
@@ -161,6 +161,8 @@ TARGET_BUILTIN(__builtin_ia32_pmovmskb,
 TARGET_BUILTIN(__builtin_ia32_pmulhuw, "V4sV4sV4s", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_psadbw, "V4sV8cV8c", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_pshufw, "V4sV4sIc", "", "sse")
+TARGET_BUILTIN(__builtin_ia32_vec_ext_v4hi, "iV4sIi", "", "sse")
+TARGET_BUILTIN(__builtin_ia32_vec_set_v4hi, "V4sV4siIi", "", "sse")
 
 // MMX+SSE2
 TARGET_BUILTIN(__builtin_ia32_cvtpd2pi, "V2iV2d", "", "sse2")

Modified: cfe/trunk/lib/Headers/xmmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/xmmintrin.h?rev=274968&r1=274967&r2=274968&view=diff
==
--- cfe/trunk/lib/Headers/xmmintrin.h (original)
+++ cfe/trunk/lib/Headers/xmmintrin.h Sat Jul  9 00:30:41 2016
@@ -2114,12 +2114,8 @@ _mm_sfence(void)
 ///2: Bits [47:32] are copied to the destination.
 ///3: Bits [63:48] are copied to the destination.
 /// \returns A 16-bit integer containing the extracted 16 bits of packed data.
-static __inline__ int __DEFAULT_FN_ATTRS
-_mm_extract_pi16(__m64 __a, int __n)
-{
-  __v4hi __b = (__v4hi)__a;
-  return (unsigned short)__b[__n & 3];
-}
+#define _mm_extract_pi16(a, n) __extension__ ({ \
+  (int)__builtin_ia32_vec_ext_v4hi((__m64)a, (int)n); })
 
 /// \brief Copies data from the 64-bit vector of [4 x i16] to the destination,
 ///and inserts the lower 16-bits of an integer operand at the 16-bit offset
@@ -2145,13 +2141,8 @@ _mm_extract_pi16(__m64 __a, int __n)
 ///bits in operand __a.
 /// \returns A 64-bit integer vector containing the copied packed data from the
 ///operands.
-static __inline__ __m64 __DEFAULT_FN_ATTRS
-_mm_insert_pi16(__m64 __a, int __d, int __n)
-{
-   __v4hi __b = (__v4hi)__a;
-   __b[__n & 3] = __d;
-   return (__m64)__b;
-}
+#define _mm_insert_pi16(a, d, n) __extension__ ({ \
+  (__m64)__builtin_ia32_vec_set_v4hi((__m64)a, (int)d, (int)n); })
 
 /// \brief Compares each of the corresponding packed 16-bit integer values of
 ///the 64-bit integer vectors, and writes the greater value to the

Modified: cfe/trunk/test/CodeGen/mmx-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mmx-builtins.c?rev=274968&r1=274967&r2=274968&view=diff
==
--- cfe/trunk/test/CodeGen/mmx-builtins.c (original)
+++ cfe/trunk/test/CodeGen/mmx-builtins.c Sat Jul  9 00:30:41 2016
@@ -217,6 +217,12 @@ __m64 test_mm_cvttps_pi32(__m128 a) {
   return _mm_cvttps_pi32(a);
 }
 
+int test_mm_extract_pi16(__m64 a) {
+  // CHECK-LABEL: test_mm_extract_pi16
+  // CHECK: call i32 @llvm.x86.mmx.pextr.w
+  return _mm_extract_pi16(a, 2);
+}
+
 __m64 test_m_from_int(int a) {
   // CHECK-LABEL: test_m_from_int
   // CHECK: insertelement <2 x i32>
@@ -265,6 +271,12 @@ __m64 test_mm_hsubs_pi16(__m64 a, __m64
   return _mm_hsubs_pi16(a, b);
 }
 
+__m64 test_mm_insert_pi16(__m64 a, int d) {
+  // CHECK-LABEL: test_mm_insert_pi16
+  // CHECK: call x86_mmx @llvm.x86.mmx.pinsr.w
+  return _mm_insert_pi16(a, d, 2);
+}
+
 __m64 test_mm_madd_pi16(__m64 a, __m64 b) {
   // CHECK-LABEL: test_mm_madd_pi16
   // CHECK: call x86_mmx @llvm.x86.mmx.pmadd.wd


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


  1   2   >