Re: [PATCH] D12031: Const std::move() argument ClangTidy check

2015-11-20 Thread Vadym Doroshenko via cfe-commits
dvadym updated this revision to Diff 40751.
dvadym marked 3 inline comments as done.
dvadym added a comment.

New in this upload:
1.Adding checking that language is C++
2.Not consider calls of std::move in template instantation 
3.Creating CharSourceRange for removal
4.Using Lexer::makeFileCharRange( for processing move call in macros


http://reviews.llvm.org/D12031

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/MoveConstantArgumentCheck.cpp
  clang-tidy/misc/MoveConstantArgumentCheck.h
  test/clang-tidy/move-const-arg.cpp

Index: test/clang-tidy/move-const-arg.cpp
===
--- test/clang-tidy/move-const-arg.cpp
+++ test/clang-tidy/move-const-arg.cpp
@@ -0,0 +1,68 @@
+// RUN: %check_clang_tidy %s misc-move-const-arg %t -- -- -std=c++11
+
+namespace std {
+template  struct remove_reference;
+
+template  struct remove_reference { typedef _Tp type; };
+
+template  struct remove_reference<_Tp &> { typedef _Tp type; };
+
+template  struct remove_reference<_Tp &&> { typedef _Tp type; };
+
+template 
+constexpr typename std::remove_reference<_Tp>::type &(_Tp &&__t);
+
+} // namespace std
+
+class A {
+public:
+  A() {}
+  A(const A ) {}
+  A(A &) {}
+};
+
+int f1() {
+  return std::move(42);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the expression of
+  // trivially-copyable type has no effect; remove std::move().
+  // CHECK-FIXES: return 42;
+}
+
+int f2(int x2) {
+  return std::move(x2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the variable of
+  // trivially-copyable type has no effect; remove std::move().
+  // CHECK-FIXES: return x2;
+}
+
+int *f3(int *x3) {
+  return std::move(x3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the variable of
+  // trivially-copyable type has no effect; remove std::move().
+  // CHECK-FIXES: return x3;
+}
+
+A f4(A x4) { return std::move(x4); }
+
+A f5(const A x5) {
+  return std::move(x5);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the const variable
+  // has no effect; remove std::move().
+  // CHECK-FIXES: return x5;
+}
+
+template  T f6(const T x6) { return std::move(x6); }
+
+void f7() { int a = f6(10); }
+
+#define M1(x) x
+void f8() {
+  const A a;
+  M1(A b = std::move(a);)
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: std::move of the const variable
+  // has no effect; remove std::move().
+  // CHECK-FIXES: M1(A b = a;)
+}
+
+#define M2(x) std::move(x)
+int f9() { return M2(1); }
Index: clang-tidy/misc/MoveConstantArgumentCheck.h
===
--- clang-tidy/misc/MoveConstantArgumentCheck.h
+++ clang-tidy/misc/MoveConstantArgumentCheck.h
@@ -0,0 +1,31 @@
+//===--- MoveConstandArgumentCheck.h - clang-tidy -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONTANTARGUMENTCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONTANTARGUMENTCHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+class MoveConstantArgumentCheck : public ClangTidyCheck {
+public:
+  MoveConstantArgumentCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace misc
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONTANTARGUMENTCHECK_H
Index: clang-tidy/misc/MoveConstantArgumentCheck.cpp
===
--- clang-tidy/misc/MoveConstantArgumentCheck.cpp
+++ clang-tidy/misc/MoveConstantArgumentCheck.cpp
@@ -0,0 +1,70 @@
+//===--- MoveConstandArgumentCheck.cpp - clang-tidy ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "MoveConstantArgumentCheck.h"
+
+#include 
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+using namespace ast_matchers;
+
+void MoveConstantArgumentCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+  Finder->addMatcher(callExpr(unless(isInTemplateInstantiation()),
+  callee(functionDecl(hasName("::std::move"
+ .bind("call-move"),
+ this);
+}
+
+void MoveConstantArgumentCheck::check(const MatchFinder::MatchResult ) {
+  

[PATCH] D14872: PR25575: Make GCC 4.4+ comatible layout for packed bit-fileds of char type

2015-11-20 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin created this revision.
DmitryPolukhin added a reviewer: aaron.ballman.
DmitryPolukhin added a subscriber: cfe-commits.

This CL is for discussion how to better fix bit-filed layout compatibility 
issue with GCC (see PR25575 for test case and more details). Current clang 
behavior is compatible with GCC 4.1-4.3 series but it was fixed in 4.4+. 
Ignoring packed attribute looks very odd and because it was also fixed in GCC 
4.4+, it makes sense also fix it in clang.

Open questions:

1. Should we add warning about changes in layout for packed bit-fileds of char 
type? GCC has it "note: offset of packed bit-field ‘b’ has changed in GCC 4.4" 
will add if needed.

2. This CL completely removes warning "packed attribute ignored for field of 
type char". Should we keep it but apply only to normal fields (i.e. not 
bit-fields)?

This CL removes the warning because IMHO it makes no sense if we fix bit-field 
case to match GCC 4.4+. Packed attribute was actually ignored only for 
bit-field. For all other cases it is not ignored but reported only when 
alignment is already fulfilled (i.e. attribute just is not required and doesn't 
change anything). But there are tons of cases when packed attribute doesn't 
change anything but warning is not emitted, for example:
struct S1 {
  char a;
  char b __attribute((packed)); // warning: 'packed' attribute ignored for 
field of type 'char'
  char c;
};

extern int a[sizeof(struct S1) == 3 ? 1 : -1];
extern int b[__alignof(struct S1) == 1 ? 1 : -1];

struct S2 {
  short a;
  short b __attribute((packed)); // no warning
  short c;
};

extern int c[sizeof(struct S2) == 6 ? 1 : -1];
extern int d[__alignof(struct S2) == 2 ? 1 : -1];

In both cases you can remove __attribute((packed)) and program behavior will 
not change. But warning is generated only in the first case.

http://reviews.llvm.org/D14872

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/struct-packed-align.c

Index: test/Sema/struct-packed-align.c
===
--- test/Sema/struct-packed-align.c
+++ test/Sema/struct-packed-align.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify
+// RUN: %clang_cc1 %s -fsyntax-only -triple=x86_64-windows-coff -verify
 // expected-no-diagnostics
 
 // Packed structs.
@@ -138,3 +139,23 @@
 extern int n1[sizeof(struct nS) == 9 ? 1 : -1];
 extern int n2[__alignof(struct nS) == 1 ? 1 : -1];
 #endif
+
+// Packed attribute shouldn't be ignored for bit-field of char types.
+// Note from GCC reference manual: The 4.1, 4.2 and 4.3 series of GCC ignore
+// the packed attribute on bit-fields of type char. This has been fixed in
+// GCC 4.4 but the change can lead to differences in the structure layout.
+// See the documentation of -Wpacked-bitfield-compat for more information.
+struct packed_chars {
+  char a:4;
+  char b:8 __attribute__ ((packed));
+  char c:4;
+};
+
+#if defined(_WIN32)
+// On Windows clang ignores uses MSVC compatible layout in this case.
+extern int o1[sizeof(struct packed_chars) == 3 ? 1 : -1];
+extern int o2[__alignof(struct packed_chars) == 1 ? 1 : -1];
+#else
+extern int o1[sizeof(struct packed_chars) == 2 ? 1 : -1];
+extern int o2[__alignof(struct packed_chars) == 1 ? 1 : -1];
+#endif
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -1032,22 +1032,10 @@
 }
 
 static void handlePackedAttr(Sema , Decl *D, const AttributeList ) {
-  if (TagDecl *TD = dyn_cast(D))
-TD->addAttr(::new (S.Context) PackedAttr(Attr.getRange(), S.Context,
-Attr.getAttributeSpellingListIndex()));
-  else if (FieldDecl *FD = dyn_cast(D)) {
-// If the alignment is less than or equal to 8 bits, the packed attribute
-// has no effect.
-if (!FD->getType()->isDependentType() &&
-!FD->getType()->isIncompleteType() &&
-S.Context.getTypeAlign(FD->getType()) <= 8)
-  S.Diag(Attr.getLoc(), diag::warn_attribute_ignored_for_field_of_type)
-<< Attr.getName() << FD->getType();
-else
-  FD->addAttr(::new (S.Context)
-  PackedAttr(Attr.getRange(), S.Context,
- Attr.getAttributeSpellingListIndex()));
-  } else
+  if (isa(D) || isa(D))
+D->addAttr(::new (S.Context) PackedAttr(
+Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+  else
 S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
 }
 
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2777,9 +2777,6 @@
   "cast to %1 from smaller integer type %0">,
   InGroup;
 
-def warn_attribute_ignored_for_field_of_type : Warning<
-  "%0 attribute ignored for field of type %1">,
-  InGroup;

Re: [PATCH] D14286: ASTImporter: expressions, pt.1

2015-11-20 Thread Aleksei Sidorin via cfe-commits
a.sidorin removed rL LLVM as the repository for this revision.
a.sidorin updated this revision to Diff 40769.
a.sidorin added a comment.
Herald added a subscriber: klimek.

Seems like I have found a way to test ASTImporter. What about some unit-tests? 
A sample test using AST matcher is attached. If it is OK, I'll write more tests 
with it.


http://reviews.llvm.org/D14286

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterTest.cpp
  unittests/AST/CMakeLists.txt
  unittests/AST/MatchVerifier.h

Index: unittests/AST/MatchVerifier.h
===
--- unittests/AST/MatchVerifier.h
+++ unittests/AST/MatchVerifier.h
@@ -62,6 +62,9 @@
  std::vector& Args,
  Language L);
 
+  template 
+  testing::AssertionResult match(const Decl *D, const MatcherType );
+
 protected:
   void run(const MatchFinder::MatchResult ) override;
   virtual void verify(const MatchFinder::MatchResult ,
@@ -127,6 +130,22 @@
   return testing::AssertionSuccess();
 }
 
+/// \brief Runs a matcher over some AST, and returns the result of the
+/// verifier for the matched node.
+template  template 
+testing::AssertionResult MatchVerifier::match(
+const Decl *D, const MatcherType ) {
+  MatchFinder Finder;
+  Finder.addMatcher(AMatcher.bind(""), this);
+
+  setFailure("Could not find match");
+  Finder.match(*D, D->getASTContext());
+
+  if (!Verified)
+return testing::AssertionFailure() << VerifyResult;
+  return testing::AssertionSuccess();
+}
+
 template 
 void MatchVerifier::run(const MatchFinder::MatchResult ) {
   const NodeType *Node = Result.Nodes.getNodeAs("");
Index: unittests/AST/CMakeLists.txt
===
--- unittests/AST/CMakeLists.txt
+++ unittests/AST/CMakeLists.txt
@@ -4,6 +4,7 @@
 
 add_clang_unittest(ASTTests
   ASTContextParentMapTest.cpp
+  ASTImporterTest.cpp
   ASTTypeTraitsTest.cpp
   ASTVectorTest.cpp
   CommentLexer.cpp
Index: unittests/AST/ASTImporterTest.cpp
===
--- /dev/null
+++ unittests/AST/ASTImporterTest.cpp
@@ -0,0 +1,84 @@
+//===- unittest/AST/ASTImporterTest.cpp - AST node import test ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Tests for the correct import of AST nodes from one AST context to another.
+//
+//===--===//
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTImporter.h"
+#include "MatchVerifier.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace ast_matchers {
+
+using clang::tooling::newFrontendActionFactory;
+using clang::tooling::runToolOnCodeWithArgs;
+using clang::tooling::FrontendActionFactory;
+
+typedef std::vector StringVector;
+
+template
+testing::AssertionResult
+testImport(const std::string , Language FromLang,
+   const std::string , Language ToLang,
+   MatchVerifier ,
+   const MatcherType ) {
+  StringVector FromArgs, ToArgs;
+
+  std::unique_ptr
+  FromAST = tooling::buildASTFromCodeWithArgs(FromCode, FromArgs),
+  ToAST = tooling::buildASTFromCodeWithArgs(ToCode, ToArgs);
+
+  ASTContext  = FromAST->getASTContext(),
+   = ToAST->getASTContext();
+
+  ASTImporter Importer(FromCtx, FromAST->getFileManager(),
+   ToCtx, ToAST->getFileManager(), false);
+
+  IdentifierInfo *ImportedII = ("declToImport");
+  assert(ImportedII && "Declaration with 'declToImport' name"
+   "should be specified in test!");
+  DeclarationName ImportDeclName(ImportedII);
+  SmallVector FoundDecls;
+  FromCtx.getTranslationUnitDecl()->localUncachedLookup(
+ImportDeclName, FoundDecls);
+
+  assert(FoundDecls.size() == 1 &&
+ "Tests for multiple declarations are not supported yet!");
+
+  auto Imported = Importer.Import(*FoundDecls.begin());
+
+  // This should dump source locations and assert if some source locations
+  // were not imported
+  llvm::raw_null_ostream ToNothing;
+  ToCtx.getTranslationUnitDecl()->print(ToNothing);
+
+  return Verifier.match(Imported, AMatcher);
+}
+
+TEST(ImportExpr, ImportStringLiteral) {
+  MatchVerifier Verifier;
+  EXPECT_TRUE(testImport("void declToImport() { \"foo\"; }",
+ Lang_CXX, "", Lang_CXX, Verifier,
+ functionDecl(
+   hasBody(
+ compoundStmt(
+   has(
+ stringLiteral(
+ 

r253667 - clang-format: [Proto] Support extending message.

2015-11-20 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Fri Nov 20 08:32:54 2015
New Revision: 253667

URL: http://llvm.org/viewvc/llvm-project?rev=253667=rev
Log:
clang-format: [Proto] Support extending message.

Before:
  extend.foo.Bar {
  }

After:
  extend .foo.Bar {
  }

Modified:
cfe/trunk/lib/Format/FormatToken.h
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestProto.cpp

Modified: cfe/trunk/lib/Format/FormatToken.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=253667=253666=253667=diff
==
--- cfe/trunk/lib/Format/FormatToken.h (original)
+++ cfe/trunk/lib/Format/FormatToken.h Fri Nov 20 08:32:54 2015
@@ -553,6 +553,7 @@ struct AdditionalKeywords {
 
 kw_mark = ("mark");
 
+kw_extend = ("extend");
 kw_option = ("option");
 kw_optional = ("optional");
 kw_repeated = ("repeated");
@@ -597,6 +598,7 @@ struct AdditionalKeywords {
   IdentifierInfo *kw_mark;
 
   // Proto keywords.
+  IdentifierInfo *kw_extend;
   IdentifierInfo *kw_option;
   IdentifierInfo *kw_optional;
   IdentifierInfo *kw_repeated;

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=253667=253666=253667=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Nov 20 08:32:54 2015
@@ -1949,7 +1949,7 @@ bool TokenAnnotator::spaceRequiredBefore
   } else if (Style.Language == FormatStyle::LK_Proto) {
 if (Right.is(tok::period) &&
 Left.isOneOf(Keywords.kw_optional, Keywords.kw_required,
- Keywords.kw_repeated))
+ Keywords.kw_repeated, Keywords.kw_extend))
   return true;
 if (Right.is(tok::l_paren) &&
 Left.isOneOf(Keywords.kw_returns, Keywords.kw_option))

Modified: cfe/trunk/unittests/Format/FormatTestProto.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestProto.cpp?rev=253667=253666=253667=diff
==
--- cfe/trunk/unittests/Format/FormatTestProto.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestProto.cpp Fri Nov 20 08:32:54 2015
@@ -162,5 +162,10 @@ TEST_F(FormatTestProto, FormatsService)
"};");
 }
 
+TEST_F(FormatTestProto, ExtendingMessage) {
+  verifyFormat("extend .foo.Bar {\n"
+   "}");
+}
+
 } // end namespace tooling
 } // end namespace clang


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


Re: [PATCH] D14286: ASTImporter: expressions, pt.1

2015-11-20 Thread Aleksei Sidorin via cfe-commits
a.sidorin updated this revision to Diff 40775.
a.sidorin added a comment.

Add language-related arguments for compilation.


http://reviews.llvm.org/D14286

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterTest.cpp
  unittests/AST/CMakeLists.txt
  unittests/AST/MatchVerifier.h

Index: unittests/AST/MatchVerifier.h
===
--- unittests/AST/MatchVerifier.h
+++ unittests/AST/MatchVerifier.h
@@ -62,6 +62,9 @@
  std::vector& Args,
  Language L);
 
+  template 
+  testing::AssertionResult match(const Decl *D, const MatcherType );
+
 protected:
   void run(const MatchFinder::MatchResult ) override;
   virtual void verify(const MatchFinder::MatchResult ,
@@ -127,6 +130,22 @@
   return testing::AssertionSuccess();
 }
 
+/// \brief Runs a matcher over some AST, and returns the result of the
+/// verifier for the matched node.
+template  template 
+testing::AssertionResult MatchVerifier::match(
+const Decl *D, const MatcherType ) {
+  MatchFinder Finder;
+  Finder.addMatcher(AMatcher.bind(""), this);
+
+  setFailure("Could not find match");
+  Finder.match(*D, D->getASTContext());
+
+  if (!Verified)
+return testing::AssertionFailure() << VerifyResult;
+  return testing::AssertionSuccess();
+}
+
 template 
 void MatchVerifier::run(const MatchFinder::MatchResult ) {
   const NodeType *Node = Result.Nodes.getNodeAs("");
Index: unittests/AST/CMakeLists.txt
===
--- unittests/AST/CMakeLists.txt
+++ unittests/AST/CMakeLists.txt
@@ -4,6 +4,7 @@
 
 add_clang_unittest(ASTTests
   ASTContextParentMapTest.cpp
+  ASTImporterTest.cpp
   ASTTypeTraitsTest.cpp
   ASTVectorTest.cpp
   CommentLexer.cpp
Index: unittests/AST/ASTImporterTest.cpp
===
--- /dev/null
+++ unittests/AST/ASTImporterTest.cpp
@@ -0,0 +1,106 @@
+//===- unittest/AST/ASTImporterTest.cpp - AST node import test ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Tests for the correct import of AST nodes from one AST context to another.
+//
+//===--===//
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTImporter.h"
+#include "MatchVerifier.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace ast_matchers {
+
+using clang::tooling::newFrontendActionFactory;
+using clang::tooling::runToolOnCodeWithArgs;
+using clang::tooling::FrontendActionFactory;
+
+typedef std::vector StringVector;
+
+void getLangArgs(Language Lang, StringVector ) {
+  switch (Lang) {
+  case Lang_C:
+Args.push_back("-std=c99");
+break;
+  case Lang_C89:
+Args.push_back("-std=c89");
+break;
+  case Lang_CXX:
+Args.push_back("-std=c++98");
+break;
+  case Lang_CXX11:
+Args.push_back("-std=c++11");
+break;
+  case Lang_OpenCL:
+  case Lang_OBJCXX:
+break;
+  }
+}
+
+template
+testing::AssertionResult
+testImport(const std::string , Language FromLang,
+   const std::string , Language ToLang,
+   MatchVerifier ,
+   const MatcherType ) {
+  StringVector FromArgs, ToArgs;
+  getLangArgs(FromLang, FromArgs);
+  getLangArgs(ToLang, ToArgs);
+
+  std::unique_ptr
+  FromAST = tooling::buildASTFromCodeWithArgs(FromCode, FromArgs),
+  ToAST = tooling::buildASTFromCodeWithArgs(ToCode, ToArgs);
+
+  ASTContext  = FromAST->getASTContext(),
+   = ToAST->getASTContext();
+
+  ASTImporter Importer(FromCtx, FromAST->getFileManager(),
+   ToCtx, ToAST->getFileManager(), false);
+
+  IdentifierInfo *ImportedII = ("declToImport");
+  assert(ImportedII && "Declaration with 'declToImport' name"
+   "should be specified in test!");
+  DeclarationName ImportDeclName(ImportedII);
+  SmallVector FoundDecls;
+  FromCtx.getTranslationUnitDecl()->localUncachedLookup(
+ImportDeclName, FoundDecls);
+
+  assert(FoundDecls.size() == 1 &&
+ "Tests for multiple declarations are not supported yet!");
+
+  auto Imported = Importer.Import(*FoundDecls.begin());
+
+  // This should dump source locations and assert if some source locations
+  // were not imported
+  llvm::raw_null_ostream ToNothing;
+  ToCtx.getTranslationUnitDecl()->print(ToNothing);
+
+  return Verifier.match(Imported, AMatcher);
+}
+
+TEST(ImportExpr, ImportStringLiteral) {
+  MatchVerifier Verifier;
+  EXPECT_TRUE(testImport("void declToImport() { \"foo\"; }",
+ Lang_CXX, 

Re: [PATCH] D14134: [OpenMP] Parsing and sema support for map clause

2015-11-20 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


http://reviews.llvm.org/D14134



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


Re: [PATCH] D14653: [libcxx] Introduce the mechanism for fixing -fno-exceptions test failures.

2015-11-20 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 40767.
rmaprath added a comment.

Addressing review comments:

- Fixed a couple of typos.
- Made the use of the thread-local storage specifier a bit more flexible to 
allow testing on few other configurations.


http://reviews.llvm.org/D14653

Files:
  include/__config
  include/__noexcept
  include/array
  test/std/containers/sequences/array/at.pass.cpp
  test/support/noexcept.h

Index: test/support/noexcept.h
===
--- /dev/null
+++ test/support/noexcept.h
@@ -0,0 +1,48 @@
+// -*- C++ -*-
+//===- noexcept.h -===//
+//
+// 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.
+//
+//===--===//
+#ifdef _LIBCPP_NO_EXCEPTIONS
+
+#include 
+#include 
+#include 
+#include "test_macros.h"
+
+#ifndef _LIBCPP_HAS_NO_THREADS
+# if TEST_STD_VER >= 11
+#   define TLS_SPEC thread_local
+# elif defined(_LIBCPP_MSVC)
+#   define TLS_SPEC __declspec(thread)
+# else
+#   define TLS_SPEC __thread
+# endif
+#else
+# define TLS_SPEC
+#endif
+
+// some tests launch multiple threads, in which case we need to make sure that
+// try_buf is maintained per-thread, otherwise setjmp()/longjmp() will attempt
+// to jump between threads!
+TLS_SPEC jmp_buf try_buf;
+#undef TLS_SPEC
+
+// Re-write try/catch with if/else to mimic a similar control flow when testing
+// the no-exceptions library variant. The idea is to save as much of the usual
+// with-exceptions assertions as possible. This of course does not work when
+// there are multiple catch statements, in those cases we have to use the
+// _LIBCPP_NO_EXCEPTIONS macro as appropriate; such cases are rare.
+#define try if(!setjmp(try_buf))
+#define catch(ex) else
+
+// Jump back to the catch (now else) clause.
+void __libcxx_noexceptions_abort(void) {
+  longjmp(try_buf, 1);
+}
+
+#endif // _LIBCPP_NO_EXCEPTIONS
Index: test/std/containers/sequences/array/at.pass.cpp
===
--- test/std/containers/sequences/array/at.pass.cpp
+++ test/std/containers/sequences/array/at.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // reference operator[] (size_type)
@@ -19,6 +18,7 @@
 #include 
 
 #include "test_macros.h"
+#include "noexcept.h"
 
 // std::array is explicitly allowed to be initialized with A a = { init-list };.
 // Disable the missing braces warning for this reason.
Index: include/array
===
--- include/array
+++ include/array
@@ -110,6 +110,7 @@
 #if defined(_LIBCPP_NO_EXCEPTIONS)
 #include 
 #endif
+#include <__noexcept>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -201,11 +202,7 @@
 array<_Tp, _Size>::at(size_type __n)
 {
 if (__n >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-throw out_of_range("array::at");
-#else
-assert(!"array::at out_of_range");
-#endif
+   __throw_helper(out_of_range("array::at out_of_range"));
 return __elems_[__n];
 }
 
@@ -215,11 +212,7 @@
 array<_Tp, _Size>::at(size_type __n) const
 {
 if (__n >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-throw out_of_range("array::at");
-#else
-assert(!"array::at out_of_range");
-#endif
+__throw_helper(out_of_range("array::at out_of_range"));
 return __elems_[__n];
 }
 
Index: include/__noexcept
===
--- /dev/null
+++ include/__noexcept
@@ -0,0 +1,45 @@
+// -*- C++ -*-
+//===-- __noexcept ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCPP_NOEXCEPT_H
+#define _LIBCPP_NOEXCEPT_H
+
+#include <__config>
+
+#ifdef _LIBCPP_NO_EXCEPTIONS
+#include 
+#include 
+
+void _LIBCPP_WEAK __libcxx_noexceptions_abort();
+#endif // _LIBCPP_NO_EXCEPTIONS
+
+template
+inline void __throw_helper(T t, const char *msg = nullptr)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+throw t;
+#else
+if (msg) // explicit error message provided
+  fprintf(stderr, "%s\n", msg);
+// FIXME: instead of using the default what() string of the std::exception
+// class, make all the exception classes return a meaningful error message.
+else if (t.what())
+  fprintf(stderr, "%s\n", t.what());
+else // use a generic error message
+  fprintf(stderr, "exception raised, cannot propagate. Aborting.\n");
+

Re: [PATCH] D12031: Const std::move() argument ClangTidy check

2015-11-20 Thread Vadym Doroshenko via cfe-commits
dvadym added a comment.

Thanks for comments! PTAL
Since it's added checking of trivially copyable arguments of move, it's needed 
to rename this check, what do you think about MoveNoEffectCheck?



Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:11
@@ +10,3 @@
+#include "MoveConstantArgumentCheck.h"
+
+namespace clang {

aaron.ballman wrote:
> > I didn't find how it can be done, could you please advice?
> 
> This is the usual way we do it (in the registerMatchers() function):
> ```
>   if (!getLangOpts().CPlusPlus)
> return;
> ```
> 
Thanks


Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:23
@@ +22,3 @@
+}
+
+void MoveConstantArgumentCheck::check(const MatchFinder::MatchResult ) {

alexfh wrote:
> The problem is that each template class or function can have several 
> representations in the AST: one for the template definition and one for each 
> instantiation. Usually, we don't need to even look at the instantiations, 
> when we want to reason about the code in the general case. You can filter out 
> expressions belonging to template instantiations using this narrowing 
> matcher: `unless(isInTemplateInstantiation())`. And for template definitions 
> the type will be marked as dependent.
Great, thank you. It works


Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:40
@@ +39,3 @@
+diag(CallMove->getLocStart(), "std::move of the %select{|const "
+  "}0%select{expression|variable}1 %select{|of 
"
+  "trivially-copyable type }2has no effect; "

alexfh wrote:
> dvadym wrote:
> > Could you please advice how can I correctly make removal? 
> > I expected that 
> > FixItHint::CreateRemoval(SourceRange(CallMove->getLocStart(), 
> > Arg->getLocStart())) removes "std::move(" but it removes 
> > "std::move(varname", so from a "move" call only ")" is left
> `FixItHint::CreateRemoval` and many other methods accept `CharSourceRange` 
> instead of `SourceRange`. The former is a `SourceRange` + a flag telling 
> whether the range should be treated as a character range or a token range. By 
> default, `SourceRange` is converted to a `CharSourceRange` marked as a token 
> range. So your current code creates a `FixItHint` that removes tokens from 
> `std` to `varname` inclusive. If you want to delete everything from `std` to 
> just before `varname`, you can create a character range from 
> `CallMove->getLocStart()` to `Arg->getLocStart().getLocWithOffset(-1)`.
> 
> However, when there's something between `std::move(` and `varname` 
> (whitespace and/or comment(s)), might want to delete just `std::move(`. In 
> this case you can take `CallMove->getCallee()' (which will correspond to 
> `std::move`), and then find the first '(' token after it's end location. It's 
> probably a rare case though, so let's go for the simpler solution for now 
> (with `getLocWithOffset` and character ranges).
Thanks, creating CharSourceRange makes the trick. Also as we talked offline 
I've added a call of Lexer::makeFileCharRange( for processing move call in 
macros. Please have a look.


http://reviews.llvm.org/D12031



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


[PATCH] D14864: [X86] Support for C calling convention only for MCU target.

2015-11-20 Thread Alexey Bataev via cfe-commits
ABataev created this revision.
ABataev added reviewers: rjmccall, DavidKreitzer, mkuper.
ABataev added a subscriber: cfe-commits.

For MCU only C calling convention is allowed, all other calling conventions are 
not supported.

http://reviews.llvm.org/D14864

Files:
  lib/Basic/Targets.cpp
  test/Sema/callingconv-iamcu.c

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2503,6 +2503,9 @@
   bool setFPMath(StringRef Name) override;
 
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
+// On MCU we support only C calling convention.
+if (getTriple().isOSIAMCU())
+  return CC == CC_C ? CCCR_OK : CCCR_Warning;
 // We accept all non-ARM calling conventions
 return (CC == CC_X86ThisCall ||
 CC == CC_X86FastCall ||
Index: test/Sema/callingconv-iamcu.c
===
--- test/Sema/callingconv-iamcu.c
+++ test/Sema/callingconv-iamcu.c
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 %s -fsyntax-only -triple i686-intel-elfiamcu -verify
+
+void __attribute__((fastcall)) foo(float *a) { // expected-warning {{calling 
convention 'fastcall' ignored for this target}}
+}
+
+void __attribute__((stdcall)) bar(float *a) { // expected-warning {{calling 
convention 'stdcall' ignored for this target}}
+}
+
+void __attribute__((fastcall(1))) baz(float *a) { // expected-error 
{{'fastcall' attribute takes no arguments}}
+}
+
+void __attribute__((fastcall)) test2(int a, ...) { // expected-warning 
{{calling convention 'fastcall' ignored for this target}}
+}
+void __attribute__((stdcall)) test3(int a, ...) { // expected-warning 
{{calling convention 'stdcall' ignored for this target}}
+}
+void __attribute__((thiscall)) test4(int a, ...) { // expected-warning 
{{calling convention 'thiscall' ignored for this target}}
+}
+
+void __attribute__((cdecl)) ctest0() {}
+
+void __attribute__((cdecl(1))) ctest1(float x) {} // expected-error {{'cdecl' 
attribute takes no arguments}}
+
+void (__attribute__((fastcall)) *pfoo)(float*) = foo; // expected-warning 
{{calling convention 'fastcall' ignored for this target}}
+
+void (__attribute__((stdcall)) *pbar)(float*) = bar; // expected-warning 
{{calling convention 'stdcall' ignored for this target}}
+
+void (*pctest0)() = ctest0;
+
+void ctest2() {}
+void (__attribute__((cdecl)) *pctest2)() = ctest2;
+
+typedef void (__attribute__((fastcall)) *Handler) (float *); // 
expected-warning {{calling convention 'fastcall' ignored for this target}}
+Handler H = foo;
+
+int __attribute__((pcs("aapcs", "aapcs"))) pcs1(void); // expected-error 
{{'pcs' attribute takes one argument}}
+int __attribute__((pcs())) pcs2(void); // expected-error {{'pcs' attribute 
takes one argument}}
+int __attribute__((pcs(pcs1))) pcs3(void); // expected-error {{'pcs' attribute 
requires a string}} \
+   // expected-error {{invalid PCS 
type}}
+int __attribute__((pcs(0))) pcs4(void); // expected-error {{'pcs' attribute 
requires a string}}
+/* These are ignored because the target is i386 and not ARM */
+int __attribute__((pcs("aapcs"))) pcs5(void); // expected-warning {{calling 
convention 'pcs' ignored for this target}}
+int __attribute__((pcs("aapcs-vfp"))) pcs6(void); // expected-warning 
{{calling convention 'pcs' ignored for this target}}
+int __attribute__((pcs("foo"))) pcs7(void); // expected-error {{invalid PCS 
type}}
+
+void ctest3();
+void __attribute__((cdecl)) ctest3() {}
+
+typedef __attribute__((stdcall)) void (*PROC)(); // expected-warning {{calling 
convention 'stdcall' ignored for this target}}
+PROC __attribute__((cdecl)) ctest4(const char *x) {}
+
+void __attribute__((intel_ocl_bicc)) inteloclbifunc(float *a) {} // 
expected-warning {{calling convention 'intel_ocl_bicc' ignored for this target}}
+
+struct type_test {} __attribute__((stdcall)); // expected-warning {{calling 
convention 'stdcall' ignored for this target}} expected-warning {{'stdcall' 
attribute only applies to functions and methods}}


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2503,6 +2503,9 @@
   bool setFPMath(StringRef Name) override;
 
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
+// On MCU we support only C calling convention.
+if (getTriple().isOSIAMCU())
+  return CC == CC_C ? CCCR_OK : CCCR_Warning;
 // We accept all non-ARM calling conventions
 return (CC == CC_X86ThisCall ||
 CC == CC_X86FastCall ||
Index: test/Sema/callingconv-iamcu.c
===
--- test/Sema/callingconv-iamcu.c
+++ test/Sema/callingconv-iamcu.c
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 %s -fsyntax-only -triple i686-intel-elfiamcu -verify
+
+void __attribute__((fastcall)) foo(float *a) { // 

Re: [PATCH] D9600: Add scan-build python implementation

2015-11-20 Thread Jonathan Roelofs via cfe-commits
jroelofs added inline comments.


Comment at: tools/scan-build-py/libear/__init__.py:1
@@ +1,2 @@
+# -*- coding: utf-8 -*-
+# The LLVM Compiler Infrastructure

rizsotto.mailinglist wrote:
> dcoughlin wrote:
> > How does this file fit into the overall build picture? Will this file go 
> > away once scan-build-py is built with the common clang cmake?
> this is quiet confusing me. previously you were asking make it work without 
> installation. this file makes it possible to compile the `ear` library 
> compiled before the build runs to use as preloaded library. the thing which 
> is not needed is the CMakefile actually.
I think the best way forward would be to teach the CMake build how to run 
`setup.py`.  Then this would work both with and without installation, and it'd 
use the same code paths for both.


Comment at: tools/scan-build-py/libscanbuild/driver.py:67
@@ +66,3 @@
+except Exception:
+logging.exception("Something unexpected had happened.")
+return 127

rizsotto.mailinglist wrote:
> dcoughlin wrote:
> > I think this error message can be improved. Perhaps "Unexpected error 
> > running intercept-build"?
> this line is printed as:
> 
>   intercept-build: ERROR: Something unexpected had happened.
>   (and the stack-trace)
> 
> because the logging formating. so, 'intercept-build' and 'error' will be part 
> of the message anyway.
Is there a pythonic way of doing llvm crash handlers? I.e. the "here's the 
steps to reproduce this, a stack trace, and a bug report url" things that clang 
spits out.


http://reviews.llvm.org/D9600



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


Re: [PATCH] D9600: Add scan-build python implementation

2015-11-20 Thread Laszlo Nagy via cfe-commits
rizsotto.mailinglist marked 13 inline comments as done.
rizsotto.mailinglist added a comment.

thanks Devin for your comments. made some changes already (will upload it 
tonight after some tests).



Comment at: tools/scan-build-py/CHANGES.txt:1
@@ +1,1 @@
+v,  -- Initial release.

dcoughlin wrote:
> Is this one needed too?
in order to make this code a standalone python tool tool, we need this file. 
(see llvm/utils/lit directory for example.)


Comment at: tools/scan-build-py/MANIFEST.in:1
@@ +1,2 @@
+include README.md
+include *.txt

dcoughlin wrote:
> How about this one? Is it needed in clang trunk?
in order to make this code a standalone python tool tool, we need this file. 
(see llvm/utils/lit directory for example.)


Comment at: tools/scan-build-py/libear/__init__.py:1
@@ +1,2 @@
+# -*- coding: utf-8 -*-
+# The LLVM Compiler Infrastructure

dcoughlin wrote:
> How does this file fit into the overall build picture? Will this file go away 
> once scan-build-py is built with the common clang cmake?
this is quiet confusing me. previously you were asking make it work without 
installation. this file makes it possible to compile the `ear` library compiled 
before the build runs to use as preloaded library. the thing which is not 
needed is the CMakefile actually.


Comment at: tools/scan-build-py/libear/__init__.py:99
@@ +98,3 @@
+def dl_libraries(self):
+pass
+

dcoughlin wrote:
> I gather the intent is that subclasses will override to provide their own 
> versions of these methods? If so, these methods need to be documented so that 
> people adding new support for additional platforms know what they should 
> provide in their subclasses.
> 
> If there are reasonable defaults (for example., `[]` for `dl_libraries`), 
> those should be returned here rather than `pass`. If not, these should 
> probably raise an exception indicating they must be implemented rather than 
> silently doing nothing.
now rise `NotImplementedError` runtime exception.


Comment at: tools/scan-build-py/libear/__init__.py:166
@@ +165,3 @@
+self.ctx = context
+self.results = {'APPLE': sys.platform == 'darwin'}
+

dcoughlin wrote:
> What does this do? Why is it hard-coded?
this is added to mimic `cmake` behaviour. it is used in the `config.h.in` file.


Comment at: tools/scan-build-py/libscanbuild/command.py:20
@@ +19,3 @@
+
+def classify_parameters(command):
+""" Parses the command line arguments of the given invocation. """

dcoughlin wrote:
> I think it would be good to document the keys and meaning of the returned 
> dictionary. Or perhaps it would be better represented as class?
now documented when create the return value. (creating class would not bring 
much to the kitchen i think.)


Comment at: tools/scan-build-py/libscanbuild/command.py:23
@@ +22,3 @@
+
+ignored = {
+'-g': 0,

dcoughlin wrote:
> I think it would good to document what the value in this mapping means 
> (number of expected parameters). I realize ccc-analyzer in the original 
> scan-build is similarly un-documented, but we should do better here!
> 
> Also: should this include all the arguments `IgnoredOptionMap` in 
> ccc-analyzer? It is missing `-u' and adds '-g'. Or are these changes 
> intentional?
`-u` is part of ignored linker flags. (see a few line above)
`-g` is added to mimic the `ccc-analyzer` results.
comment about key, value is added.


Comment at: tools/scan-build-py/libscanbuild/driver.py:1
@@ +1,2 @@
+# -*- coding: utf-8 -*-
+# The LLVM Compiler Infrastructure

dcoughlin wrote:
> Why is this file called "driver"?
any recommendation? it was the only entry point before the interposition was 
introduced. so it was the driver of the libscanbuild library.


Comment at: tools/scan-build-py/libscanbuild/driver.py:34
@@ +33,3 @@
+def main(bin_dir):
+""" Entry point for 'scan-build'. """
+

dcoughlin wrote:
> Should this be 'intercept-build'?
can be anything, but would make it rhyme with the module name...


Comment at: tools/scan-build-py/libscanbuild/driver.py:67
@@ +66,3 @@
+except Exception:
+logging.exception("Something unexpected had happened.")
+return 127

dcoughlin wrote:
> I think this error message can be improved. Perhaps "Unexpected error running 
> intercept-build"?
this line is printed as:

  intercept-build: ERROR: Something unexpected had happened.
  (and the stack-trace)

because the logging formating. so, 'intercept-build' and 'error' will be part 
of the message anyway.


Comment at: tools/scan-build-py/libscanbuild/intercept.py:98
@@ +97,3 @@
+
+if args.override_compiler or not ear_library_path:

Re: [PATCH] D14756: Handle ARMv6-J as an alias, instead of fake architecture

2015-11-20 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL253677: Handle ARMv6-J as an alias, instead of fake 
architecture (authored by askrobov).

Changed prior to commit:
  http://reviews.llvm.org/D14756?vs=40431=40789#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14756

Files:
  cfe/trunk/test/Driver/arm-cortex-cpus.c

Index: cfe/trunk/test/Driver/arm-cortex-cpus.c
===
--- cfe/trunk/test/Driver/arm-cortex-cpus.c
+++ cfe/trunk/test/Driver/arm-cortex-cpus.c
@@ -57,11 +57,11 @@
 
 // FIXME %clang -target armv6j -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6J %s
 // RUN: %clang -target arm -march=armv6j -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6J %s
-// CHECK-V6J: "-cc1"{{.*}} "-triple" "armv6-{{.*}} "-target-cpu" "arm1136j-s"
+// CHECK-V6J: "-cc1"{{.*}} "-triple" "armv6-{{.*}} "-target-cpu" "arm1136jf-s"
 
 // FIXME %clang -target armv6j -mthumb -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6J-THUMB %s
 // RUN: %clang -target arm -march=armv6j -mthumb -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6J-THUMB %s
-// CHECK-V6J-THUMB: "-cc1"{{.*}} "-triple" "thumbv6-{{.*}} "-target-cpu" 
"arm1136j-s"
+// CHECK-V6J-THUMB: "-cc1"{{.*}} "-triple" "thumbv6-{{.*}} "-target-cpu" 
"arm1136jf-s"
 
 // FIXME %clang -target armv6z -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6Z %s
 // FIXME %clang -target arm -march=armv6z -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6Z %s


Index: cfe/trunk/test/Driver/arm-cortex-cpus.c
===
--- cfe/trunk/test/Driver/arm-cortex-cpus.c
+++ cfe/trunk/test/Driver/arm-cortex-cpus.c
@@ -57,11 +57,11 @@
 
 // FIXME %clang -target armv6j -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6J %s
 // RUN: %clang -target arm -march=armv6j -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6J %s
-// CHECK-V6J: "-cc1"{{.*}} "-triple" "armv6-{{.*}} "-target-cpu" "arm1136j-s"
+// CHECK-V6J: "-cc1"{{.*}} "-triple" "armv6-{{.*}} "-target-cpu" "arm1136jf-s"
 
 // FIXME %clang -target armv6j -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6J-THUMB %s
 // RUN: %clang -target arm -march=armv6j -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6J-THUMB %s
-// CHECK-V6J-THUMB: "-cc1"{{.*}} "-triple" "thumbv6-{{.*}} "-target-cpu" "arm1136j-s"
+// CHECK-V6J-THUMB: "-cc1"{{.*}} "-triple" "thumbv6-{{.*}} "-target-cpu" "arm1136jf-s"
 
 // FIXME %clang -target armv6z -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6Z %s
 // FIXME %clang -target arm -march=armv6z -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6Z %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D10802: [mips] Interrupt attribute support.

2015-11-20 Thread Simon Dardis via cfe-commits
sdardis updated this revision to Diff 40782.
sdardis marked 4 inline comments as done.
sdardis added a comment.

Updated comments, used cast as suggested, added mutual exclusion check for 
mips16+interrupt combination.

Extended mips16/nomips16 attribute handlers for mutual exclusion, add to 
pre-existing test.

Thanks.


http://reviews.llvm.org/D10802

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/mips-interrupt-attr.c
  test/Sema/mips-interrupt-attr.c
  test/Sema/mips16_attr_allowed.c

Index: test/Sema/mips16_attr_allowed.c
===
--- test/Sema/mips16_attr_allowed.c
+++ test/Sema/mips16_attr_allowed.c
@@ -19,6 +19,9 @@
 void __attribute__((nomips16(1, 2))) foo32b(); // expected-error {{'nomips16' attribute takes no arguments}}
 void __attribute__((mips16(1, 2))) foo16b(); // expected-error {{'mips16' attribute takes no arguments}}
 
+void __attribute__((mips16, nomips16)) foo16c(); // expected-error {{'mips16' and 'nomips16' attributes are not compatible}} \
+ // expected-note {{conflicting attribute is here}}
+
 
 __attribute((nomips16)) int a; // expected-error {{attribute only applies to functions}}
 
Index: test/Sema/mips-interrupt-attr.c
===
--- /dev/null
+++ test/Sema/mips-interrupt-attr.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 %s -triple mips-img-elf -verify -fsyntax-only
+struct a { int b; };
+
+struct a test __attribute__((interrupt)); // expected-warning {{'interrupt' attribute only applies to functions and methods}}
+
+__attribute__((interrupt("EIC"))) void foo1() {} // expected-warning {{'interrupt' attribute argument not supported: 'EIC'}}
+
+__attribute__((interrupt("eic", 1))) void foo2() {} // expected-error {{'interrupt' attribute takes no more than 1 argument}}
+
+__attribute__((interrupt("eic"))) void foo3() {}
+__attribute__((interrupt("vector=sw0"))) void foo4() {}
+__attribute__((interrupt("vector=hw0"))) void foo5() {}
+__attribute__((interrupt("vector=hw1"))) void foo6() {}
+__attribute__((interrupt("vector=hw2"))) void foo7() {}
+__attribute__((interrupt("vector=hw3"))) void foo8() {}
+__attribute__((interrupt("vector=hw4"))) void foo9() {}
+__attribute__((interrupt("vector=hw5"))) void fooa() {}
+__attribute__((interrupt(""))) void food() {}
+
+__attribute__((interrupt)) int foob() {return 0;} // expected-warning {{function 'foob' must have the 'void' return type for the 'interrupt' attribute for MIPS}}
+__attribute__((interrupt())) void fooc(int a) {} // expected-warning {{function 'fooc' must take no arguments for the 'interrupt' attribute for MIPS}}
+__attribute__((interrupt,mips16)) void fooe() {} // expected-error {{'interrupt' and 'mips16' attributes are not compatible}} \
+ // expected-note {{conflicting attribute is here}}
+__attribute__((mips16,interrupt)) void foof() {} // expected-error {{'mips16' and 'interrupt' attributes are not compatible}} \
+ // expected-note {{conflicting attribute is here}}
+__attribute__((interrupt)) __attribute__ ((mips16)) void foo10() {} // expected-error {{'interrupt' and 'mips16' attributes are not compatible}} \
+// expected-note {{conflicting attribute is here}}
+__attribute__((mips16)) __attribute ((interrupt)) void foo11() {} // expected-error {{'mips16' and 'interrupt' attributes are not compatible}} \
+  // expected-note {{conflicting attribute is here}}
Index: test/CodeGen/mips-interrupt-attr.c
===
--- /dev/null
+++ test/CodeGen/mips-interrupt-attr.c
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -triple mipsel-unknown-linux -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK
+
+void __attribute__ ((interrupt("vector=sw0")))
+isr_sw0 (void)
+{
+  // CHECK: define void @isr_sw0() [[SW0:#[0-9]+]]
+}
+
+void __attribute__ ((interrupt("vector=sw1")))
+isr_sw1 (void)
+{
+  // CHECK: define void @isr_sw1() [[SW1:#[0-9]+]]
+}
+
+void __attribute__ ((interrupt("vector=hw0")))
+isr_hw0 (void)
+{
+  // CHECK: define void @isr_hw0() [[HW0:#[0-9]+]]
+}
+
+void __attribute__ ((interrupt("vector=hw1")))
+isr_hw1 (void)
+{
+  // CHECK: define void @isr_hw1() [[HW1:#[0-9]+]]
+}
+
+void __attribute__ ((interrupt("vector=hw2")))
+isr_hw2 (void)
+{
+  // CHECK: define void @isr_hw2() [[HW2:#[0-9]+]]
+}
+
+void __attribute__ ((interrupt("vector=hw3")))
+isr_hw3 (void)
+{
+  // CHECK: define void @isr_hw3() [[HW3:#[0-9]+]]
+}
+
+void __attribute__ ((interrupt("vector=hw4")))
+isr_hw4 (void)
+{
+  // CHECK: define void @isr_hw4() [[HW4:#[0-9]+]]
+}
+
+void 

r253672 - clang-format: [JS] Properly add a space after "in" in for loops.

2015-11-20 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Fri Nov 20 10:18:42 2015
New Revision: 253672

URL: http://llvm.org/viewvc/llvm-project?rev=253672=rev
Log:
clang-format: [JS] Properly add a space after "in" in for loops.

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=253672=253671=253672=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Nov 20 10:18:42 2015
@@ -1955,7 +1955,8 @@ bool TokenAnnotator::spaceRequiredBefore
 Left.isOneOf(Keywords.kw_returns, Keywords.kw_option))
   return true;
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
-if (Left.isOneOf(Keywords.kw_let, Keywords.kw_var, TT_JsFatArrow))
+if (Left.isOneOf(Keywords.kw_let, Keywords.kw_var, TT_JsFatArrow,
+ Keywords.kw_in))
   return true;
 if (Right.isOneOf(TT_JsTypeColon, TT_JsTypeOptionalQuestion))
   return false;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=253672=253671=253672=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Fri Nov 20 10:18:42 2015
@@ -545,6 +545,11 @@ TEST_F(FormatTestJS, ReturnStatements) {
"}");
 }
 
+TEST_F(FormatTestJS, ForLoops) {
+  verifyFormat("for (var i in [2, 3]) {\n"
+   "}");
+}
+
 TEST_F(FormatTestJS, AutomaticSemicolonInsertion) {
   // The following statements must not wrap, as otherwise the program meaning
   // would change due to automatic semicolon insertion.


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


r253677 - Handle ARMv6-J as an alias, instead of fake architecture

2015-11-20 Thread Artyom Skrobov via cfe-commits
Author: askrobov
Date: Fri Nov 20 10:47:05 2015
New Revision: 253677

URL: http://llvm.org/viewvc/llvm-project?rev=253677=rev
Log:
Handle ARMv6-J as an alias, instead of fake architecture

Summary: Clang-side update, corresponding to D14755

Reviewers: rengolin, bogden, compnerd

Subscribers: aemerson, rengolin, cfe-commits

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

Modified:
cfe/trunk/test/Driver/arm-cortex-cpus.c

Modified: cfe/trunk/test/Driver/arm-cortex-cpus.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-cortex-cpus.c?rev=253677=253676=253677=diff
==
--- cfe/trunk/test/Driver/arm-cortex-cpus.c (original)
+++ cfe/trunk/test/Driver/arm-cortex-cpus.c Fri Nov 20 10:47:05 2015
@@ -57,11 +57,11 @@
 
 // FIXME %clang -target armv6j -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6J %s
 // RUN: %clang -target arm -march=armv6j -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6J %s
-// CHECK-V6J: "-cc1"{{.*}} "-triple" "armv6-{{.*}} "-target-cpu" "arm1136j-s"
+// CHECK-V6J: "-cc1"{{.*}} "-triple" "armv6-{{.*}} "-target-cpu" "arm1136jf-s"
 
 // FIXME %clang -target armv6j -mthumb -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6J-THUMB %s
 // RUN: %clang -target arm -march=armv6j -mthumb -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6J-THUMB %s
-// CHECK-V6J-THUMB: "-cc1"{{.*}} "-triple" "thumbv6-{{.*}} "-target-cpu" 
"arm1136j-s"
+// CHECK-V6J-THUMB: "-cc1"{{.*}} "-triple" "thumbv6-{{.*}} "-target-cpu" 
"arm1136jf-s"
 
 // FIXME %clang -target armv6z -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6Z %s
 // FIXME %clang -target arm -march=armv6z -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6Z %s


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


r253669 - clang-format: Don't use incorrect space in macro calls with operators.

2015-11-20 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Fri Nov 20 09:26:50 2015
New Revision: 253669

URL: http://llvm.org/viewvc/llvm-project?rev=253669=rev
Log:
clang-format: Don't use incorrect space in macro calls with operators.

Before:
  MACRO(> );

After:
  MACRO(>);

Not overly important, but easy and good for symmetry reasons :-).

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=253669=253668=253669=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Nov 20 09:26:50 2015
@@ -2047,7 +2047,8 @@ bool TokenAnnotator::spaceRequiredBefore
   if ((Left.is(TT_TemplateOpener)) != (Right.is(TT_TemplateCloser)))
 return Style.SpacesInAngles;
   if ((Right.is(TT_BinaryOperator) && !Left.is(tok::l_paren)) ||
-  Left.isOneOf(TT_BinaryOperator, TT_ConditionalExpr))
+  (Left.isOneOf(TT_BinaryOperator, TT_ConditionalExpr) &&
+   !Right.is(tok::r_paren)))
 return true;
   if (Left.is(TT_TemplateCloser) && Right.is(tok::l_paren) &&
   Right.isNot(TT_FunctionTypeLParen))

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=253669=253668=253669=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Nov 20 09:26:50 2015
@@ -2927,6 +2927,8 @@ TEST_F(FormatTest, MacroCallsWithoutTrai
"  EXCLUSIVE_LOCK_FUNCTION(mu_);\n"
"};",
getLLVMStyleWithColumns(40)));
+
+  verifyFormat("MACRO(>)");
 }
 
 TEST_F(FormatTest, LayoutMacroDefinitionsStatementsSpanningBlocks) {


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


r253674 - clang-format: [JS] Make AllowShortFunctionsOnASingle line value "Empty"

2015-11-20 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Fri Nov 20 10:44:28 2015
New Revision: 253674

URL: http://llvm.org/viewvc/llvm-project?rev=253674=rev
Log:
clang-format: [JS] Make AllowShortFunctionsOnASingle line value "Empty"
work properly.

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=253674=253673=253674=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Nov 20 10:44:28 2015
@@ -2104,6 +2104,7 @@ bool TokenAnnotator::mustBreakBefore(con
 !Left.Children.empty())
   // Support AllowShortFunctionsOnASingleLine for JavaScript.
   return Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_None ||
+ Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_Empty 
||
  (Left.NestingLevel == 0 && Line.Level == 0 &&
   Style.AllowShortFunctionsOnASingleLine ==
   FormatStyle::SFS_Inline);

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=253674=253673=253674=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Fri Nov 20 10:44:28 2015
@@ -448,6 +448,12 @@ TEST_F(FormatTestJS, InliningFunctionLit
"  }\n"
"}",
Style);
+
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
+  verifyFormat("var func = function() {\n"
+   "  return 1;\n"
+   "};",
+   Style);
 }
 
 TEST_F(FormatTestJS, MultipleFunctionLiterals) {


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


r253680 - [DebugInfo] Look through type sugar on union types when casting

2015-11-20 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Nov 20 11:41:12 2015
New Revision: 253680

URL: http://llvm.org/viewvc/llvm-project?rev=253680=rev
Log:
[DebugInfo] Look through type sugar on union types when casting

Fixes PR25584.

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/CodeGenCXX/debug-info-anon-union-vars.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=253680=253679=253680=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Nov 20 11:41:12 2015
@@ -3329,7 +3329,7 @@ void CGDebugInfo::EmitGlobalVariable(llv
   // variable for each member of the anonymous union so that it's possible
   // to find the name of any field in the union.
   if (T->isUnionType() && DeclName.empty()) {
-const RecordDecl *RD = cast(T)->getDecl();
+const RecordDecl *RD = T->castAs()->getDecl();
 assert(RD->isAnonymousStructOrUnion() &&
"unnamed non-anonymous struct or union?");
 GV = CollectAnonRecordDecls(RD, Unit, LineNo, LinkageName, Var, DContext);

Modified: cfe/trunk/test/CodeGenCXX/debug-info-anon-union-vars.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-anon-union-vars.cpp?rev=253680=253679=253680=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-anon-union-vars.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-anon-union-vars.cpp Fri Nov 20 
11:41:12 2015
@@ -29,11 +29,28 @@ void foo() {
   i = 8;
 }
 
+// A funky reinterpret cast idiom that we used to crash on.
+template 
+unsigned char *buildBytes(const T v) {
+  static union {
+unsigned char result[sizeof(T)];
+T value;
+  };
+  value = v;
+  return result;
+}
+
+void instantiate(int x) {
+  buildBytes(x);
+}
+
 // CHECK: [[FILE:.*]] = !DIFile(filename: 
"{{.*}}debug-info-anon-union-vars.cpp",
 // CHECK: !DIGlobalVariable(name: "c",{{.*}} file: [[FILE]], line: 6,{{.*}} 
isLocal: true, isDefinition: true
 // CHECK: !DIGlobalVariable(name: "d",{{.*}} file: [[FILE]], line: 6,{{.*}} 
isLocal: true, isDefinition: true
 // CHECK: !DIGlobalVariable(name: "a",{{.*}} file: [[FILE]], line: 6,{{.*}} 
isLocal: true, isDefinition: true
 // CHECK: !DIGlobalVariable(name: "b",{{.*}} file: [[FILE]], line: 6,{{.*}} 
isLocal: true, isDefinition: true
+// CHECK: !DIGlobalVariable(name: "result", {{.*}} isLocal: false, 
isDefinition: true
+// CHECK: !DIGlobalVariable(name: "value", {{.*}} isLocal: false, 
isDefinition: true
 // CHECK: !DILocalVariable(name: "i", {{.*}}, flags: DIFlagArtificial
 // CHECK: !DILocalVariable(name: "c", {{.*}}, flags: DIFlagArtificial
 // CHECK: !DILocalVariable(


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


Re: [PATCH] D14215: Disable frame pointer elimination when using -pg

2015-11-20 Thread Stefan Kempf via cfe-commits
sisnkemp updated this revision to Diff 40794.

http://reviews.llvm.org/D14215

Files:
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/x86_64-profiling-keep-fp.c

Index: test/CodeGen/x86_64-profiling-keep-fp.c
===
--- /dev/null
+++ test/CodeGen/x86_64-profiling-keep-fp.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -O3 -pg -S -o - %s | \
+// RUN:   FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -O3 
-momit-leaf-frame-pointer -pg -S -o - %s | \
+// RUN:   FileCheck %s
+
+// Test that the frame pointer is kept when compiling with
+// profiling.
+
+//CHECK: pushq %rbp
+int main(void)
+{
+  return 0;
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -453,7 +453,8 @@
   Opts.CXXCtorDtorAliases = Args.hasArg(OPT_mconstructor_aliases);
   Opts.CodeModel = getCodeModel(Args, Diags);
   Opts.DebugPass = Args.getLastArgValue(OPT_mdebug_pass);
-  Opts.DisableFPElim = Args.hasArg(OPT_mdisable_fp_elim);
+  Opts.DisableFPElim =
+  (Args.hasArg(OPT_mdisable_fp_elim) || Args.hasArg(OPT_pg));
   Opts.DisableFree = Args.hasArg(OPT_disable_free);
   Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);
   Opts.FloatABI = Args.getLastArgValue(OPT_mfloat_abi);
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2794,6 +2794,8 @@
   if (Arg *A = Args.getLastArg(options::OPT_fno_omit_frame_pointer,
options::OPT_fomit_frame_pointer))
 return A->getOption().matches(options::OPT_fno_omit_frame_pointer);
+  if (Args.hasArg(options::OPT_pg))
+return true;
 
   return shouldUseFramePointerForTarget(Args, Triple);
 }
@@ -2803,6 +2805,8 @@
   if (Arg *A = Args.getLastArg(options::OPT_mno_omit_leaf_frame_pointer,
options::OPT_momit_leaf_frame_pointer))
 return A->getOption().matches(options::OPT_mno_omit_leaf_frame_pointer);
+  if (Args.hasArg(options::OPT_pg))
+return true;
 
   if (Triple.isPS4CPU())
 return false;


Index: test/CodeGen/x86_64-profiling-keep-fp.c
===
--- /dev/null
+++ test/CodeGen/x86_64-profiling-keep-fp.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -O3 -pg -S -o - %s | \
+// RUN:   FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -O3 -momit-leaf-frame-pointer -pg -S -o - %s | \
+// RUN:   FileCheck %s
+
+// Test that the frame pointer is kept when compiling with
+// profiling.
+
+//CHECK: pushq %rbp
+int main(void)
+{
+  return 0;
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -453,7 +453,8 @@
   Opts.CXXCtorDtorAliases = Args.hasArg(OPT_mconstructor_aliases);
   Opts.CodeModel = getCodeModel(Args, Diags);
   Opts.DebugPass = Args.getLastArgValue(OPT_mdebug_pass);
-  Opts.DisableFPElim = Args.hasArg(OPT_mdisable_fp_elim);
+  Opts.DisableFPElim =
+  (Args.hasArg(OPT_mdisable_fp_elim) || Args.hasArg(OPT_pg));
   Opts.DisableFree = Args.hasArg(OPT_disable_free);
   Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);
   Opts.FloatABI = Args.getLastArgValue(OPT_mfloat_abi);
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2794,6 +2794,8 @@
   if (Arg *A = Args.getLastArg(options::OPT_fno_omit_frame_pointer,
options::OPT_fomit_frame_pointer))
 return A->getOption().matches(options::OPT_fno_omit_frame_pointer);
+  if (Args.hasArg(options::OPT_pg))
+return true;
 
   return shouldUseFramePointerForTarget(Args, Triple);
 }
@@ -2803,6 +2805,8 @@
   if (Arg *A = Args.getLastArg(options::OPT_mno_omit_leaf_frame_pointer,
options::OPT_momit_leaf_frame_pointer))
 return A->getOption().matches(options::OPT_mno_omit_leaf_frame_pointer);
+  if (Args.hasArg(options::OPT_pg))
+return true;
 
   if (Triple.isPS4CPU())
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14629: [analyzer] Configuration file for scan-build.

2015-11-20 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

Are you aware of http://reviews.llvm.org/D9600 ?


http://reviews.llvm.org/D14629



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


Re: [PATCH] D14737: Convert some ObjC msgSends to runtime calls

2015-11-20 Thread Pete Cooper via cfe-commits
pete updated this revision to Diff 40790.
pete added a comment.

Added a couple of tests for retain returning types other than id.  Returning a 
pointer should still be converted to a call, while returning a non-pointer such 
as float will get a message instead.

I walked through the code in the debugger to check on the return cast.  Turns 
out it is handled at the very end of emitARCValueOperation as follows:

  // Cast the result back to the original type.
  return CGF.Builder.CreateBitCast(call, origType);


http://reviews.llvm.org/D14737

Files:
  include/clang/Basic/ObjCRuntime.h
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.h
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenObjC/convert-messages-to-runtime-calls.m
  test/Driver/objc-convert-messages-to-runtime-calls.m

Index: test/Driver/objc-convert-messages-to-runtime-calls.m
===
--- /dev/null
+++ test/Driver/objc-convert-messages-to-runtime-calls.m
@@ -0,0 +1,7 @@
+// RUN: %clang %s -### -o %t.o 2>&1 -fsyntax-only -fobjc-convert-messages-to-runtime-calls -fno-objc-convert-messages-to-runtime-calls -target x86_64-apple-macosx10.10.0 | FileCheck  %s --check-prefix=DISABLE
+// RUN: %clang %s -### -o %t.o 2>&1 -fsyntax-only -fno-objc-convert-messages-to-runtime-calls -fobjc-convert-messages-to-runtime-calls -target x86_64-apple-macosx10.10.0 | FileCheck  %s --check-prefix=ENABLE
+
+// Check that we pass fobjc-convert-messages-to-runtime-calls only when supported, and not explicitly disabled.
+
+// DISABLE: "-fno-objc-convert-messages-to-runtime-calls"
+// ENABLE-NOT: "-fno-objc-convert-messages-to-runtime-calls"
Index: test/CodeGenObjC/convert-messages-to-runtime-calls.m
===
--- /dev/null
+++ test/CodeGenObjC/convert-messages-to-runtime-calls.m
@@ -0,0 +1,109 @@
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.10.0 -emit-llvm -o - %s -fno-objc-convert-messages-to-runtime-calls | FileCheck %s --check-prefix=MSGS
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.10.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CALLS
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.9.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=MSGS
+// RUN: %clang_cc1 -fobjc-runtime=macosx-fragile-10.10.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=MSGS
+// Make sure we don't do calls to retain/release when using GC.
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.10.0 -emit-llvm -o - %s -fobjc-gc | FileCheck %s --check-prefix=GC
+// RUN: %clang_cc1 -fobjc-runtime=ios-8.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CALLS
+// RUN: %clang_cc1 -fobjc-runtime=ios-7.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=MSGS
+// Note: This line below is for tvos for which the driver passes through to use the ios9.0 runtime.
+// RUN: %clang_cc1 -fobjc-runtime=ios-9.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CALLS
+// RUN: %clang_cc1 -fobjc-runtime=watchos-2.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CALLS
+
+@interface NSObject
++ (id)alloc;
++ (id)alloc2;
+- (id)init;
+- (id)retain;
+- (void)release;
+- (id)autorelease;
+@end
+
+@interface NSString : NSObject
++ (void)retain_self;
+- (void)retain_super;
+@end
+
+// CHECK-LABEL: define {{.*}}void @test1
+void test1(id x) {
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_alloc}}
+  // CALLS: {{call.*@objc_retain}}
+  // CALLS: {{call.*@objc_release}}
+  // CALLS: {{call.*@objc_autorelease}}
+  // GC: {{call.*@objc_alloc}}
+  // GC: {{call.*@objc_msgSend}}
+  // GC: {{call.*@objc_msgSend}}
+  // GC: {{call.*@objc_msgSend}}
+  [NSObject alloc];
+  [x retain];
+  [x release];
+  [x autorelease];
+}
+
+// CHECK-LABEL: define {{.*}}void @test2
+void test2() {
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_msgSend}}
+  // GC: {{call.*@objc_msgSend}}
+  // Make sure alloc has the correct name and number of types.
+  [NSObject alloc2];
+}
+
+@class A;
+@interface B
+- (A*) retain;
+@end
+
+// Make sure we get a bitcast on the return type as the
+// objc_retain call will return i8* which we have to cast
+// to A*
+// CHECK-LABEL: define {{.*}}void @test_return_bitcast
+A* test_return_bitcast(B *b) {
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_retain}}
+  // CALLS-NEXT: bitcast i8*
+  // GC: {{call.*@objc_msgSend}}
+  return [b retain];
+}
+
+@interface C
+- (float) retain;
+@end
+
+// Make sure we use a message and not a call as the return type is
+// not a pointer type.
+// CHECK-LABEL: define {{.*}}void @test_cannot_message_return_float
+float test_cannot_message_return_float(C *c) {
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_msgSend}}
+  // GC: {{call.*@objc_msgSend}}
+  return [c retain];

Re: [PATCH] D14824: [PATCH] Add clang-tidy check for static or thread_local objects where construction may throw

2015-11-20 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

Btw, here are some statistics as to the rate at which this diagnostic is 
triggered:

LLVM: 21255 warnings (about 18000 warnings were due to two AST matcher 
constructors; adding noexcept to those brings the count to 2895 warnings, most 
of which are cl::opt-related and can be similarly silenced) (2.1MM LoC)
Qt: 0 warnings (4.4MM LoC)
rethinkdb: 44 warnings (5.7MM LoC)
cocos2d: 1339 warnings (984k LoC)
opencv: 203 warnings (657k LoC)

As best I can tell from random sampling, all of the diagnostics are true 
positives in that the compiler is unaware of whether the constructor will throw 
or not. However, many of these true positives come from user-provided 
constructors where the initializer list does all the work, and the constructor 
body is empty. In the samples I looked at, the constructors do not throw and 
can be marked noexcept to silence the warning. However, a few of the 
constructors can throw and this is a definite true positive instead of a 
practical false positive.

One possible heuristic to silence more of the warnings is to not warn when the 
constructor called is the default constructor accepting no arguments and the 
constructor body is trivial, with the belief that default initialization 
generally does not throw. However, I don't think this diagnostic is chatty 
enough to warrant that measure when the user can simply add noexcept to the 
constructor in the event it truly does not throw.


http://reviews.llvm.org/D14824



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


Re: [PATCH] D14848: Add -disable-llvm-passes for frontend debug info tests.

2015-11-20 Thread Dehao Chen via cfe-commits
danielcdh marked an inline comment as done.
danielcdh added a comment.

http://reviews.llvm.org/D14848



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


Re: [PATCH] D14215: Disable frame pointer elimination when using -pg

2015-11-20 Thread Stefan Kempf via cfe-commits
sisnkemp updated this revision to Diff 40793.
sisnkemp added a comment.

Added a test with -momit-leaf-frame-pointer as requested by davidxl.


http://reviews.llvm.org/D14215

Files:
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/x86_64-profiling-keep-fp-1.c
  test/CodeGen/x86_64-profiling-keep-fp-2.c

Index: test/CodeGen/x86_64-profiling-keep-fp-2.c
===
--- /dev/null
+++ test/CodeGen/x86_64-profiling-keep-fp-2.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -O3 
-momit-leaf-frame-pointer -pg -S -o - %s | \
+// RUN:   FileCheck %s
+
+// Test that the frame pointer is kept when compiling with
+// profiling.
+
+//CHECK: pushq %rbp
+int main(void)
+{
+  return 0;
+}
Index: test/CodeGen/x86_64-profiling-keep-fp-1.c
===
--- /dev/null
+++ test/CodeGen/x86_64-profiling-keep-fp-1.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -O3 -pg -S -o - %s | \
+// RUN:   FileCheck %s
+
+// Test that the frame pointer is kept when compiling with
+// profiling.
+
+//CHECK: pushq %rbp
+int main(void)
+{
+  return 0;
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -453,7 +453,8 @@
   Opts.CXXCtorDtorAliases = Args.hasArg(OPT_mconstructor_aliases);
   Opts.CodeModel = getCodeModel(Args, Diags);
   Opts.DebugPass = Args.getLastArgValue(OPT_mdebug_pass);
-  Opts.DisableFPElim = Args.hasArg(OPT_mdisable_fp_elim);
+  Opts.DisableFPElim =
+  (Args.hasArg(OPT_mdisable_fp_elim) || Args.hasArg(OPT_pg));
   Opts.DisableFree = Args.hasArg(OPT_disable_free);
   Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);
   Opts.FloatABI = Args.getLastArgValue(OPT_mfloat_abi);
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2794,6 +2794,8 @@
   if (Arg *A = Args.getLastArg(options::OPT_fno_omit_frame_pointer,
options::OPT_fomit_frame_pointer))
 return A->getOption().matches(options::OPT_fno_omit_frame_pointer);
+  if (Args.hasArg(options::OPT_pg))
+return true;
 
   return shouldUseFramePointerForTarget(Args, Triple);
 }
@@ -2803,6 +2805,8 @@
   if (Arg *A = Args.getLastArg(options::OPT_mno_omit_leaf_frame_pointer,
options::OPT_momit_leaf_frame_pointer))
 return A->getOption().matches(options::OPT_mno_omit_leaf_frame_pointer);
+  if (Args.hasArg(options::OPT_pg))
+return true;
 
   if (Triple.isPS4CPU())
 return false;


Index: test/CodeGen/x86_64-profiling-keep-fp-2.c
===
--- /dev/null
+++ test/CodeGen/x86_64-profiling-keep-fp-2.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -O3 -momit-leaf-frame-pointer -pg -S -o - %s | \
+// RUN:   FileCheck %s
+
+// Test that the frame pointer is kept when compiling with
+// profiling.
+
+//CHECK: pushq %rbp
+int main(void)
+{
+  return 0;
+}
Index: test/CodeGen/x86_64-profiling-keep-fp-1.c
===
--- /dev/null
+++ test/CodeGen/x86_64-profiling-keep-fp-1.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -O3 -pg -S -o - %s | \
+// RUN:   FileCheck %s
+
+// Test that the frame pointer is kept when compiling with
+// profiling.
+
+//CHECK: pushq %rbp
+int main(void)
+{
+  return 0;
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -453,7 +453,8 @@
   Opts.CXXCtorDtorAliases = Args.hasArg(OPT_mconstructor_aliases);
   Opts.CodeModel = getCodeModel(Args, Diags);
   Opts.DebugPass = Args.getLastArgValue(OPT_mdebug_pass);
-  Opts.DisableFPElim = Args.hasArg(OPT_mdisable_fp_elim);
+  Opts.DisableFPElim =
+  (Args.hasArg(OPT_mdisable_fp_elim) || Args.hasArg(OPT_pg));
   Opts.DisableFree = Args.hasArg(OPT_disable_free);
   Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);
   Opts.FloatABI = Args.getLastArgValue(OPT_mfloat_abi);
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2794,6 +2794,8 @@
   if (Arg *A = Args.getLastArg(options::OPT_fno_omit_frame_pointer,
options::OPT_fomit_frame_pointer))
 return A->getOption().matches(options::OPT_fno_omit_frame_pointer);
+  if (Args.hasArg(options::OPT_pg))
+return true;
 
   return shouldUseFramePointerForTarget(Args, Triple);
 }
@@ -2803,6 +2805,8 @@
   if (Arg *A = Args.getLastArg(options::OPT_mno_omit_leaf_frame_pointer,

r253694 - Thread Safety Analysis: Fix DenseMap iterator invalidation UAF

2015-11-20 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Nov 20 13:08:30 2015
New Revision: 253694

URL: http://llvm.org/viewvc/llvm-project?rev=253694=rev
Log:
Thread Safety Analysis: Fix DenseMap iterator invalidation UAF

Rather than storing BeforeInfo in the DenseMap by value, this stores a
unique_ptr to it, so that we can keep a pointer to it live across
subsequent DenseMap insertions.

This change also removes the unique_ptr wrapper around BeforeVect
because now we're indirecting at a higher level.

Modified:
cfe/trunk/lib/Analysis/ThreadSafety.cpp

Modified: cfe/trunk/lib/Analysis/ThreadSafety.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ThreadSafety.cpp?rev=253694=253693=253694=diff
==
--- cfe/trunk/lib/Analysis/ThreadSafety.cpp (original)
+++ cfe/trunk/lib/Analysis/ThreadSafety.cpp Fri Nov 20 13:08:30 2015
@@ -258,16 +258,15 @@ private:
   typedef SmallVector  BeforeVect;
 
   struct BeforeInfo {
-BeforeInfo() : Vect(nullptr), Visited(false) { }
-BeforeInfo(BeforeInfo &)
-: Vect(std::move(O.Vect)), Visited(O.Visited)
-{}
+BeforeInfo() : Visited(0) {}
+BeforeInfo(BeforeInfo &) : Vect(std::move(O.Vect)), Visited(O.Visited) {}
 
-std::unique_ptr Vect;
-int Visited;
+BeforeVect Vect;
+int Visited;
   };
 
-  typedef llvm::DenseMap  BeforeMap;
+  typedef llvm::DenseMap>
+  BeforeMap;
   typedef llvm::DenseMapCycleMap;
 
 public:
@@ -276,6 +275,9 @@ public:
   BeforeInfo* insertAttrExprs(const ValueDecl* Vd,
   ThreadSafetyAnalyzer& Analyzer);
 
+  BeforeInfo *getBeforeInfoForDecl(const ValueDecl *Vd,
+   ThreadSafetyAnalyzer );
+
   void checkBeforeAfter(const ValueDecl* Vd,
 const FactSet& FSet,
 ThreadSafetyAnalyzer& Analyzer,
@@ -965,26 +967,27 @@ public:
 BeforeSet::BeforeInfo* BeforeSet::insertAttrExprs(const ValueDecl* Vd,
 ThreadSafetyAnalyzer& Analyzer) {
   // Create a new entry for Vd.
-  auto& Entry = BMap.FindAndConstruct(Vd);
-  BeforeInfo* Info = 
-  BeforeVect* Bv = nullptr;
+  BeforeInfo *Info = nullptr;
+  {
+// Keep InfoPtr in its own scope in case BMap is modified later and the
+// reference becomes invalid.
+std::unique_ptr  = BMap[Vd];
+if (!InfoPtr)
+  InfoPtr.reset(new BeforeInfo());
+Info = InfoPtr.get();
+  }
 
   for (Attr* At : Vd->attrs()) {
 switch (At->getKind()) {
   case attr::AcquiredBefore: {
 auto *A = cast(At);
 
-// Create a new BeforeVect for Vd if necessary.
-if (!Bv) {
-  Bv = new BeforeVect;
-  Info->Vect.reset(Bv);
-}
 // Read exprs from the attribute, and add them to BeforeVect.
 for (const auto *Arg : A->args()) {
   CapabilityExpr Cp =
 Analyzer.SxBuilder.translateAttrExpr(Arg, nullptr);
   if (const ValueDecl *Cpvd = Cp.valueDecl()) {
-Bv->push_back(Cpvd);
+Info->Vect.push_back(Cpvd);
 auto It = BMap.find(Cpvd);
 if (It == BMap.end())
   insertAttrExprs(Cpvd, Analyzer);
@@ -1001,20 +1004,8 @@ BeforeSet::BeforeInfo* BeforeSet::insert
 Analyzer.SxBuilder.translateAttrExpr(Arg, nullptr);
   if (const ValueDecl *ArgVd = Cp.valueDecl()) {
 // Get entry for mutex listed in attribute
-BeforeInfo* ArgInfo;
-auto It = BMap.find(ArgVd);
-if (It == BMap.end())
-  ArgInfo = insertAttrExprs(ArgVd, Analyzer);
-else
-  ArgInfo = >second;
-
-// Create a new BeforeVect if necessary.
-BeforeVect* ArgBv = ArgInfo->Vect.get();
-if (!ArgBv) {
-  ArgBv = new BeforeVect;
-  ArgInfo->Vect.reset(ArgBv);
-}
-ArgBv->push_back(Vd);
+BeforeInfo *ArgInfo = getBeforeInfoForDecl(ArgVd, Analyzer);
+ArgInfo->Vect.push_back(Vd);
   }
 }
 break;
@@ -1027,6 +1018,18 @@ BeforeSet::BeforeInfo* BeforeSet::insert
   return Info;
 }
 
+BeforeSet::BeforeInfo *
+BeforeSet::getBeforeInfoForDecl(const ValueDecl *Vd,
+ThreadSafetyAnalyzer ) {
+  auto It = BMap.find(Vd);
+  BeforeInfo *Info = nullptr;
+  if (It == BMap.end())
+Info = insertAttrExprs(Vd, Analyzer);
+  else
+Info = It->second.get();
+  assert(Info && "BMap contained nullptr?");
+  return Info;
+}
 
 /// Return true if any mutexes in FSet are in the acquired_before set of Vd.
 void BeforeSet::checkBeforeAfter(const ValueDecl* StartVd,
@@ -1041,12 +1044,7 @@ void BeforeSet::checkBeforeAfter(const V
 if (!Vd)
   return false;
 
-BeforeSet::BeforeInfo* Info;
-auto It = BMap.find(Vd);
-if (It == BMap.end())
-  Info = insertAttrExprs(Vd, Analyzer);
-else
-  Info = >second;
+BeforeSet::BeforeInfo *Info 

Re: [PATCH] D14858: Support building tsan on android.

2015-11-20 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

I vaguely recall that android runtime loader had some symbol lookup 
differencies with glibc and that prevented interceptors (when statically linked 
into the main executable) from working. Maybe it is not the case now.


http://reviews.llvm.org/D14858



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


r253706 - Fix test case function name checks

2015-11-20 Thread Bill Seurer via cfe-commits
Author: seurer
Date: Fri Nov 20 14:47:34 2015
New Revision: 253706

URL: http://llvm.org/viewvc/llvm-project?rev=253706=rev
Log:
Fix test case function name checks

This is similar to the earlier fix I did, r253702, expect that here it
is function names that are being searched for.  If the function name
matches part of the directory name it can cause an apparent test
case failure.


Modified:
cfe/trunk/test/CodeGen/captured-statements.c

Modified: cfe/trunk/test/CodeGen/captured-statements.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/captured-statements.c?rev=253706=253705=253706=diff
==
--- cfe/trunk/test/CodeGen/captured-statements.c (original)
+++ cfe/trunk/test/CodeGen/captured-statements.c Fri Nov 20 14:47:34 2015
@@ -21,7 +21,7 @@ void test1() {
   // CHECK-1: %struct.anon = type { i32* }
   // CHECK-1: {{.+}} global float 3.0
   //
-  // CHECK-1: test1
+  // CHECK-1: @test1(
   // CHECK-1: alloca %struct.anon
   // CHECK-1: getelementptr inbounds %struct.anon, %struct.anon*
   // CHECK-1: store i32* %i
@@ -43,7 +43,7 @@ void test2(int x) {
 for (i = 0; i < x; i++)
   foo();
   }
-  // CHECK-2: test2
+  // CHECK-2: @test2(
   // CHECK-2-NOT: %i
   // CHECK-2: call void @[[HelperName:__captured_stmt[\.0-9]+]]
 }
@@ -60,7 +60,7 @@ void test3(int size) {
   {
 arr[2] = vla_arr[size - 1];
   }
-  // CHECK-3: test3
+  // CHECK-3: @test3(
   // CHECK-3: alloca [5 x i32]
   // CHECK-3: call void @__captured_stmt
 }


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


Re: [PATCH] D14858: Support building tsan on android.

2015-11-20 Thread Dmitry Vyukov via cfe-commits
dvyukov added a comment.

> Yes, we should use shared runtime library on Android.


Note that tsan is different from all of asan/msan/ubsan in that it does 
zillions of calls into runtime, so the indirection will have non-zero runtime 
cost.
Is it possible to statically link it into something that has the bulk of 
verified code?


http://reviews.llvm.org/D14858



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


Re: [PATCH] D14779: Adding checker to detect excess padding in records

2015-11-20 Thread Ben Craig via cfe-commits
bcraig updated the summary for this revision.
bcraig updated this revision to Diff 40818.
bcraig added a comment.

Adding a test to validate non-trivial message components.
Adding recommendations to the diagnostic on how to fix and / or suppress the 
generated report.
Changing default padding allowance to reduce initial static analysis shock.
An analysis of llvm+clang+compiler-rt now only generates 16 excessive padding 
reports in index.html.


http://reviews.llvm.org/D14779

Files:
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
  test/Analysis/padding_c.c
  test/Analysis/padding_cpp.cpp
  test/Analysis/padding_message.cpp

Index: test/Analysis/padding_message.cpp
===
--- /dev/null
+++ test/Analysis/padding_message.cpp
@@ -0,0 +1,185 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -std=c++14 -analyze -analyzer-checker=performance -analyzer-config performance.Padding:AllowedPad=2 -verify %s
+
+// expected-warning@+1{{Excessive padding in 'struct IntSandwich' (6 padding bytes, where 2 is optimal)}}
+struct IntSandwich {
+  char c1;
+  int i;
+  char c2;
+};
+
+// expected-warning@+1{{Excessive padding in 'struct TurDuckHen' (6 padding bytes, where 2 is optimal)}}
+struct TurDuckHen {
+  char c1;
+  struct IntSandwich i;
+  char c2;
+};
+
+#pragma pack(push)
+#pragma pack(2)
+// expected-warning@+1{{Excessive padding in 'struct SmallIntSandwich' (4 padding bytes, where 0 is optimal)}}
+struct SmallIntSandwich {
+  char c1;
+  int i1;
+  char c2;
+  int i2;
+  char c3;
+  int i3;
+  char c4;
+};
+#pragma pack(pop)
+
+union SomeUnion { // no-warning
+  char c;
+  short s;
+  int i;
+};
+
+// expected-warning@+1{{Excessive padding in 'struct HoldsAUnion' (6 padding bytes, where 2 is optimal)}}
+struct HoldsAUnion {
+  char c1;
+  union SomeUnion u;
+  char c2;
+};
+
+struct SmallCharArray { // no-warning
+  char c[5];
+};
+
+struct MediumIntArray { // no-warning
+  int i[5];
+};
+
+// expected-warning@+1{{Excessive padding in 'struct StructSandwich' (6 padding bytes, where 2 is optimal)}}
+struct StructSandwich {
+  struct SmallCharArray s;
+  struct MediumIntArray m;
+  struct SmallCharArray s2;
+};
+
+// expected-warning@+1{{Excessive padding in 'TypedefSandwich' (6 padding bytes, where 2 is optimal)}}
+typedef struct {
+  char c1;
+  int i;
+  char c2;
+} TypedefSandwich;
+
+// expected-warning@+1{{Excessive padding in 'struct StructAttrAlign' (10 padding bytes, where 2 is optimal)}}
+struct StructAttrAlign {
+  char c1;
+  int i;
+  char c2;
+} __attribute__((aligned(8)));
+
+// expected-warning@+1{{Excessive padding in 'struct OverlyAlignedChar' (8185 padding bytes, where 4089 is optimal)}}
+struct OverlyAlignedChar {
+  char c1;
+  int x;
+  char c2;
+  char c __attribute__((aligned(4096)));
+};
+
+// expected-warning@+1{{Excessive padding in 'struct HoldsOverlyAlignedChar' (8190 padding bytes, where 4094 is optimal)}}
+struct HoldsOverlyAlignedChar {
+  char c1;
+  struct OverlyAlignedChar o;
+  char c2;
+};
+
+void internalStructFunc() {
+// expected-warning@+1{{Excessive padding in 'struct X' (6 padding bytes, where 2 is optimal)}}
+  struct X {
+char c1;
+int t;
+char c2;
+  };
+  struct X obj;
+}
+
+void typedefStructFunc() {
+// expected-warning@+1{{Excessive padding in 'S' (6 padding bytes, where 2 is optimal)}}
+  typedef struct {
+char c1;
+int t;
+char c2;
+  } S;
+  S obj;
+}
+
+// expected-warning@+1{{Excessive padding in 'struct DefaultAttrAlign' (22 padding bytes, where 6 is optimal)}}
+struct DefaultAttrAlign {
+  char c1;
+  long long i;
+  char c2;
+} __attribute__((aligned));
+
+// expected-warning@+1{{Excessive padding in 'struct SmallArrayShortSandwich' (2 padding bytes, where 0 is optimal)}}
+struct SmallArrayShortSandwich {
+  char c1;
+  short s;
+  char c2;
+} ShortArray[20];
+
+// expected-warning@+1{{Excessive padding in 'struct SmallArrayInFunc' (2 padding bytes, where 0 is optimal)}}
+struct SmallArrayInFunc {
+  char c1;
+  short s;
+  char c2;
+};
+
+void arrayHolder() {
+  struct SmallArrayInFunc Arr[15];
+}
+
+ // expected-warning@+1{{Excessive padding in 'class VirtualIntSandwich' (10 padding bytes, where 2 is optimal)}}
+ class VirtualIntSandwich {
+  virtual void foo() {}
+  char c1;
+  int i;
+  char c2;
+};
+
+// constructed so as not to have tail padding
+// expected-warning@+1{{Excessive padding in 'class InnerPaddedB' (6 padding bytes, where 2 is optimal)}}
+class InnerPaddedB {
+  char c1;
+  int i1;
+  char c2;
+  int i2;
+};
+
+class Empty {}; // no-warning
+
+// expected-warning@+1{{Excessive padding in 'class LotsOfSpace' (6 padding bytes, where 2 is optimal)}}
+class LotsOfSpace {
+  Empty e1;
+  int i;
+  Empty e2;
+};
+
+// expected-warning@+1{{Excessive padding in 'TypedefSandwich2' (6 padding bytes, where 2 is optimal)}}
+typedef struct {
+  char c1;
+  // 

[PATCH] D14877: Fix ICE on lowering of constexpr vector splats

2015-11-20 Thread George Burgess IV via cfe-commits
george.burgess.iv created this revision.
george.burgess.iv added a reviewer: rsmith.
george.burgess.iv added a subscriber: cfe-commits.

When evaluating constexpr vector splats, we weren't doing appropriate type 
conversions on the literal we were splatting, causing assertion failures in 
cases like:

```
void foo(vector float FloatInput, vector short ShortInput) {
  (void)(FloatInput == (vector float)0); // OK
  (void)(ShortInput == (vector short)0); // OK

  constexpr vector float Floats = (vector float)0;
  (void)(FloatInput == Floats); // ICE -- fcmp between [4 x i32] and [4 x f32]

  constexpr vector short Shorts = (vector short)0;
  (void)(ShortInput == Shorts); // ICE -- fcmp between vec of i16 and vec of i32
}
```

(The same issue applied for cases like `(vector short)0`; it would be lowered 
as a vector of `i32`.)

This patch fixes these in ExprConstant rather than CodeGen, because it allows 
us to more sanely model overflow/complain to the user/... in the evaluator. 

This patch also contains a few generic code cleanliness changes. I'm happy to 
drop any/all of them if we decide they're not helpful. :)

http://reviews.llvm.org/D14877

Files:
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGExprConstant.cpp
  test/CodeGenCXX/builtins-systemz-zvector.cpp

Index: test/CodeGenCXX/builtins-systemz-zvector.cpp
===
--- /dev/null
+++ test/CodeGenCXX/builtins-systemz-zvector.cpp
@@ -0,0 +1,52 @@
+// REQUIRES: systemz-registered-target
+// RUN: %clang_cc1 -target-cpu z13 -triple s390x-linux-gnu \
+// RUN: -fzvector -fno-lax-vector-conversions -std=c++11 \
+// RUN: -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck %s
+
+#include 
+
+bool gb;
+
+// There was an issue where we weren't properly converting constexprs to
+// vectors with elements of the appropriate width. (e.g.
+// (vector signed short)0 would be lowered as [4 x i32] in some cases)
+
+// CHECK-LABEL: @_Z8testIntsDv4_i
+void testInts(vector int VI) {
+  constexpr vector int CI1 = (vector int)0LL;
+  // CHECK: icmp
+  gb = (VI == CI1)[0];
+
+  // Likewise for float inits.
+  constexpr vector int CI2 = (vector int)char(0);
+  // CHECK: icmp
+  gb = (VI == CI2)[0];
+
+  constexpr vector int CF1 = (vector int)0.0;
+  // CHECK: icmp
+  gb = (VI == CF1)[0];
+
+  constexpr vector int CF2 = (vector int)0.0f;
+  // CHECK: icmp
+  gb = (VI == CF2)[0];
+}
+
+// CHECK-LABEL: @_Z10testFloatsDv2_d
+void testFloats(vector double VD) {
+  constexpr vector double CI1 = (vector double)0LL;
+  // CHECK: fcmp
+  gb = (VD == CI1)[0];
+
+  // Likewise for float inits.
+  constexpr vector double CI2 = (vector double)char(0);
+  // CHECK: fcmp
+  gb = (VD == CI2)[0];
+
+  constexpr vector double CF1 = (vector double)0.0;
+  // CHECK: fcmp
+  gb = (VD == CF1)[0];
+
+  constexpr vector double CF2 = (vector double)0.0f;
+  // CHECK: fcmp
+  gb = (VD == CF2)[0];
+}
Index: lib/CodeGen/CGExprConstant.cpp
===
--- lib/CodeGen/CGExprConstant.cpp
+++ lib/CodeGen/CGExprConstant.cpp
@@ -1350,15 +1350,17 @@
 return llvm::ConstantStruct::get(STy, Complex);
   }
   case APValue::Vector: {
-SmallVector Inits;
 unsigned NumElts = Value.getVectorLength();
+SmallVector Inits(NumElts);
 
-for (unsigned i = 0; i != NumElts; ++i) {
-  const APValue  = Value.getVectorElt(i);
+for (unsigned I = 0; I != NumElts; ++I) {
+  const APValue  = Value.getVectorElt(I);
   if (Elt.isInt())
-Inits.push_back(llvm::ConstantInt::get(VMContext, Elt.getInt()));
+Inits[I] = llvm::ConstantInt::get(VMContext, Elt.getInt());
+  else if (Elt.isFloat())
+Inits[I] = llvm::ConstantFP::get(VMContext, Elt.getFloat());
   else
-Inits.push_back(llvm::ConstantFP::get(VMContext, Elt.getFloat()));
+llvm_unreachable("unsupported vector element type");
 }
 return llvm::ConstantVector::get(Inits);
   }
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -1150,7 +1150,7 @@
 static bool EvaluateMemberPointer(const Expr *E, MemberPtr ,
   EvalInfo );
 static bool EvaluateTemporary(const Expr *E, LValue , EvalInfo );
-static bool EvaluateInteger(const Expr *E, APSInt  , EvalInfo );
+static bool EvaluateInteger(const Expr *E, APSInt , EvalInfo );
 static bool EvaluateIntegerOrLValue(const Expr *E, APValue ,
 EvalInfo );
 static bool EvaluateFloat(const Expr *E, APFloat , EvalInfo );
@@ -1575,7 +1575,7 @@
 
 static APSInt HandleIntToIntCast(EvalInfo , const Expr *E,
  QualType DestType, QualType SrcType,
- APSInt ) {
+ const APSInt ) {
   unsigned DestWidth = Info.Ctx.getIntWidth(DestType);
   APSInt Result = Value;
   // Figure out if this is a 

Re: [PATCH] D10802: [mips] Interrupt attribute support.

2015-11-20 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:256
@@ +255,3 @@
+def warn_mips_interrupt_attribute : Warning<
+   "function %0 must %select{take no arguments|have the \'void\' return type}1"
+   " for the 'interrupt' attribute for MIPS">,

No need for \'; you can use ' directly.

I think the wording is still a bit awkward. Function declarations generally 
don't "take arguments", but have parameters, and "the void return type" reads 
weird.  I think:

"MIPS 'interrupt' attribute only applies to functions with %select{no 
parameters|a 'void' return type}0"

would be an improvement.


Comment at: lib/Sema/SemaDeclAttr.cpp:4439
@@ +4438,3 @@
+S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type)
+<< "\'interrupt\'" << ExpectedFunctionOrMethod;
+return;

No need for \', you can use ' directly.


Comment at: lib/Sema/SemaDeclAttr.cpp:4462
@@ +4461,3 @@
+S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported)
+<< Attr.getName() << "\'" + std::string(Str) + "\'";
+return;

No need for \', can use ' directly.


Comment at: lib/Sema/SemaDeclAttr.cpp:4484
@@ +4483,3 @@
+static void handleMips16Attribute(Sema , Decl *D, const AttributeList ) 
{
+  if (checkAttrMutualExclusion(S, D, Attr.getRange(), 
Attr.getName()))
+return;

This is a good change, but should be as part of a separate patch since it has 
nothing to do with MIPS interrupt.


Comment at: lib/Sema/SemaDeclAttr.cpp:4495
@@ +4494,3 @@
+static void handleNoMips16Attribute(Sema , Decl *D, const AttributeList 
) {
+  if (checkAttrMutualExclusion(S, D, Attr.getRange(), 
Attr.getName()))
+return;

Same with this.


Comment at: test/Sema/mips16_attr_allowed.c:22
@@ -21,1 +21,3 @@
 
+void __attribute__((mips16, nomips16)) foo16c(); // expected-error {{'mips16' 
and 'nomips16' attributes are not compatible}} \
+ // expected-note 
{{conflicting attribute is here}}

This should be part of a separate patch.


http://reviews.llvm.org/D10802



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


Re: [PATCH] D14858: Support building tsan on android.

2015-11-20 Thread Dimitry Ivanov via cfe-commits
dimitry added a subscriber: dimitry.
dimitry added a comment.

In http://reviews.llvm.org/D14858#294082, @eugenis wrote:

> I vaguely recall that android runtime loader had some symbol lookup 
> differencies with glibc and that prevented interceptors (when statically 
> linked into the main executable) from working. Maybe it is not the case now.


This is no longer the case... There should be no difference in symbol lookup 
order between glibc and android linker. If you find any - please let me know. :)


http://reviews.llvm.org/D14858



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


Re: [PATCH] D14858: Support building tsan on android.

2015-11-20 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

In http://reviews.llvm.org/D14858#293651, @danalbert wrote:

> I assume we're going to actually want to go the other direction on this and 
> build a shared library for Android's TSAN (see eugenis' comment on 
> https://android-review.googlesource.com/#/c/120507/1/core/config_sanitizers.mk@68)


Yes, we should use shared runtime library on Android.
See AsanSharedRuntime in SanitizerArgs.h, we need something similar for TSan.


http://reviews.llvm.org/D14858



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


Re: [PATCH] D14858: Support building tsan on android.

2015-11-20 Thread Kostya Serebryany via cfe-commits
kcc added a comment.

performance is a very strong reason to have tsan linked statically. 
every memory access in the app is instrumented with a function call,
if we make this call go through PLT we'll get significant drop in performance.

This is not a blocker, but I want to explicitly mention it.


http://reviews.llvm.org/D14858



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


Re: [PATCH] D14858: Support building tsan on android.

2015-11-20 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

OK, it sounds like static runtime would work fine.
We would still need a way to switch to the shared runtime for the apps (the 
workflow when we LD_PRELOAD the runtime into the Zygote to run instrumented 
apps on a non-instrumented device). Something like -shared-libasan flag but for 
TSan. Does not have to be done now.

LGTM


http://reviews.llvm.org/D14858



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


r253707 - Driver: Defer computation of linker path until it is needed.

2015-11-20 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Fri Nov 20 14:49:39 2015
New Revision: 253707

URL: http://llvm.org/viewvc/llvm-project?rev=253707=rev
Log:
Driver: Defer computation of linker path until it is needed.

This allows us to construct Linux toolchains without a valid linker. This
is needed for example to build a CUDA device toolchain after r253385.

Modified:
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/mingw-useld.c

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=253707=253706=253707=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Fri Nov 20 14:49:39 2015
@@ -92,6 +92,7 @@ private:
 
 protected:
   MultilibSet Multilibs;
+  const char *DefaultLinker = "ld";
 
   ToolChain(const Driver , const llvm::Triple ,
 const llvm::opt::ArgList );

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=253707=253706=253707=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Fri Nov 20 14:49:39 2015
@@ -359,7 +359,7 @@ std::string ToolChain::GetLinkerPath() c
 return "";
   }
 
-  return GetProgramPath("ld");
+  return GetProgramPath(DefaultLinker);
 }
 
 types::ID ToolChain::LookupTypeForExtension(const char *Ext) const {

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=253707=253706=253707=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Nov 20 14:49:39 2015
@@ -2455,8 +2455,7 @@ MipsLLVMToolChain::MipsLLVMToolChain(con
   getFilePaths().push_back(computeSysRoot() + "/usr/lib" + LibSuffix);
 
   // Use LLD by default.
-  if (!Args.getLastArg(options::OPT_fuse_ld_EQ))
-Linker = GetProgramPath("lld");
+  DefaultLinker = "lld";
 }
 
 void MipsLLVMToolChain::AddClangSystemIncludeArgs(
@@ -2837,8 +2836,6 @@ NaClToolChain::NaClToolChain(const Drive
 break;
   }
 
-  // Use provided linker, not system linker
-  Linker = GetLinkerPath();
   NaClArmMacrosPath = GetFilePath("nacl-arm-macros.s");
 }
 
@@ -3693,8 +3690,6 @@ Linux::Linux(const Driver , const llvm
  GCCInstallation.getTriple().str() + "/bin")
.str());
 
-  Linker = GetLinkerPath();
-
   Distro Distro = DetectDistro(D, Arch);
 
   if (IsOpenSUSE(Distro) || IsUbuntu(Distro)) {

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=253707=253706=253707=diff
==
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Fri Nov 20 14:49:39 2015
@@ -796,7 +796,6 @@ public:
 llvm::opt::ArgStringList ) const override;
   virtual std::string computeSysRoot() const;
 
-  std::string Linker;
   std::vector ExtraOpts;
 
 protected:
@@ -921,7 +920,6 @@ public:
 
   std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList ,
   types::ID InputType) const override;
-  std::string Linker;
 
 protected:
   Tool *buildLinker() const override;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=253707=253706=253707=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Nov 20 14:49:39 2015
@@ -8500,7 +8500,8 @@ void gnutools::Linker::ConstructJob(Comp
   // handled somewhere else.
   Args.ClaimAllArgs(options::OPT_w);
 
-  if (llvm::sys::path::filename(ToolChain.Linker) == "lld") {
+  const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
+  if (llvm::sys::path::filename(Exec) == "lld") {
 CmdArgs.push_back("-flavor");
 CmdArgs.push_back("old-gnu");
 CmdArgs.push_back("-target");
@@ -8686,8 +8687,7 @@ void gnutools::Linker::ConstructJob(Comp
   } else if (Args.hasArg(options::OPT_rtlib_EQ))
 AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
 
-  C.addCommand(llvm::make_unique(JA, *this, ToolChain.Linker.c_str(),
-  CmdArgs, Inputs));
+  C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 
 // NaCl ARM assembly (inline or standalone) can be written with a set of macros
@@ -8858,8 +8858,8 @@ void nacltools::Linker::ConstructJob(Com

Re: [PATCH] D12700: [clang-tidy] install helper scripts in CMake build

2015-11-20 Thread Paul Robinson via cfe-commits
probinson added a subscriber: probinson.
probinson added a comment.

Not sure what the exact problem is, but we still have one bot using 
configure/make, and it dies with this on the install step unless we use -j1.  I 
know the hand-written Makefiles are deprecated and we've worked around it, but 
I thought I should mention it.


Repository:
  rL LLVM

http://reviews.llvm.org/D12700



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


[PATCH] D14887: Make tbm-builtins.c as X86 specific unit test

2015-11-20 Thread Sumanth Gundapaneni via cfe-commits
sgundapa created this revision.
sgundapa added reviewers: echristo, craig.topper.
sgundapa added a subscriber: cfe-commits.

This unit test need not be true on all the targets.

http://reviews.llvm.org/D14887

Files:
  test/CodeGen/tbm-builtins.c

Index: test/CodeGen/tbm-builtins.c
===
--- test/CodeGen/tbm-builtins.c
+++ test/CodeGen/tbm-builtins.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -O3 -triple=x86_64-unknown-unknown -target-feature +tbm 
-emit-llvm -o - | FileCheck %s
+// REQUIRES: x86-registered-target
 // FIXME: The code generation checks for add/sub and/or are depending on the 
optimizer.
 
 // Don't include mm_malloc.h, it's system specific.


Index: test/CodeGen/tbm-builtins.c
===
--- test/CodeGen/tbm-builtins.c
+++ test/CodeGen/tbm-builtins.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -O3 -triple=x86_64-unknown-unknown -target-feature +tbm -emit-llvm -o - | FileCheck %s
+// REQUIRES: x86-registered-target
 // FIXME: The code generation checks for add/sub and/or are depending on the optimizer.
 
 // Don't include mm_malloc.h, it's system specific.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14737: Convert some ObjC msgSends to runtime calls

2015-11-20 Thread John McCall via cfe-commits
rjmccall added a comment.

In http://reviews.llvm.org/D14737#293967, @pete wrote:

> Added a couple of tests for retain returning types other than id.  Returning 
> a pointer should still be converted to a call, while returning a non-pointer 
> such as float will get a message instead.
>
> I walked through the code in the debugger to check on the return cast.  Turns 
> out it is handled at the very end of emitARCValueOperation as follows:
>
>  
>   // Cast the result back to the original type.
>   return CGF.Builder.CreateBitCast(call, origType);


Right, that'll cast back to the original type.  That will be the type of the 
receiver of the message, which is not necessarily the type of the result of the 
message.


http://reviews.llvm.org/D14737



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


r253720 - [CMake] Fix handling of passing through semi-colon separated lists.

2015-11-20 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Fri Nov 20 16:09:03 2015
New Revision: 253720

URL: http://llvm.org/viewvc/llvm-project?rev=253720=rev
Log:
[CMake] Fix handling of passing through semi-colon separated lists.

When passing around CMake arguments as lists of arguments any arguments 
containing lists need to have their semi-colons escaped otherwise CMake will 
split the arguments in the middle.

Modified:
cfe/trunk/runtime/CMakeLists.txt

Modified: cfe/trunk/runtime/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/runtime/CMakeLists.txt?rev=253720=253719=253720=diff
==
--- cfe/trunk/runtime/CMakeLists.txt (original)
+++ cfe/trunk/runtime/CMakeLists.txt Fri Nov 20 16:09:03 2015
@@ -49,8 +49,9 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND E
   get_cmake_property(variableNames VARIABLES)
   foreach(varaibleName ${variableNames})
 if(varaibleName MATCHES "^COMPILER_RT")
+  string(REPLACE ";" "\;" value "${${varaibleName}}")
   list(APPEND COMPILER_RT_PASSTHROUGH_VARIABLES
--D${varaibleName}=${${varaibleName}})
+-D${varaibleName}=${${value}})
 endif()
   endforeach()
 


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


r253721 - [CMake] Add support for specifying arguments to the bootstrap build.

2015-11-20 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Fri Nov 20 16:09:06 2015
New Revision: 253721

URL: http://llvm.org/viewvc/llvm-project?rev=253721=rev
Log:
[CMake] Add support for specifying arguments to the bootstrap build.

This adds support for three types of argument specifications for bootstrap 
builds:

(1) Arguments prefixed with BOOTSTRAP_* will be passed through with the leading 
BOOTSTRAP_ removed.
(2) CLANG_BOOTSTRAP_PASSTHROUGH can specify a list of variables to be passed 
through as they are set.
(3) BOOTSTRAP_DEFAULT_PASSTHROUGH is a list of some default passthrough 
variables that are always passed through. Those variables include the version 
string and should only specify variables that are always expected to be the 
same between the stage1 and stage2

Modified:
cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=253721=253720=253721=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Fri Nov 20 16:09:06 2015
@@ -652,6 +652,36 @@ if (CLANG_ENABLE_BOOTSTRAP)
 set(verbose -DCMAKE_VERBOSE_MAKEFILE=On)
   endif()
 
+  set(BOOTSTRAP_DEFAULT_PASSTHROUGH
+PACKAGE_VERSION
+LLVM_VERSION_MAJOR
+LLVM_VERSION_MINOR
+LLVM_VERSION_PATCH
+LLVM_VERSION_SUFFIX
+CLANG_REPOSITORY_STRING
+CMAKE_MAKE_PROGRAM)
+
+  # Find all variables that start with BOOTSTRAP_ and populate a variable with
+  # them.
+  get_cmake_property(variableNames VARIABLES)
+  foreach(varaibleName ${variableNames})
+if(varaibleName MATCHES "^BOOTSTRAP_")
+  string(SUBSTRING ${varaibleName} 10 -1 varName)
+  string(REPLACE ";" "\;" value "${${varaibleName}}")
+  list(APPEND PASSTHROUGH_VARIABLES
+-D${varName}=${value})
+endif()
+  endforeach()
+
+  # Populate the passthrough variables
+  foreach(varaibleName ${CLANG_BOOTSTRAP_PASSTHROUGH} 
${BOOTSTRAP_DEFAULT_PASSTHROUGH})
+if(${varaibleName})
+  string(REPLACE ";" "\;" value ${${varaibleName}})
+  list(APPEND PASSTHROUGH_VARIABLES
+-D${varaibleName}=${value})
+endif()
+  endforeach()
+
   ExternalProject_Add(bootstrap
 DEPENDS clang ${LTO_DEP}
 PREFIX bootstrap
@@ -664,6 +694,7 @@ if (CLANG_ENABLE_BOOTSTRAP)
 # seem to work, so instead I'm passing this through
 -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
 ${CLANG_BOOTSTRAP_CMAKE_ARGS}
+${PASSTHROUGH_VARIABLES}
 -DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++
 -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
 -DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang


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


r253738 - [clang] Disable Unicode in asm files

2015-11-20 Thread Vinicius Tinti via cfe-commits
Author: tinti
Date: Fri Nov 20 17:42:39 2015
New Revision: 253738

URL: http://llvm.org/viewvc/llvm-project?rev=253738=rev
Log:
[clang] Disable Unicode in asm files

Clang should not convert tokens to Unicode when preprocessing assembly
files.

Fixes PR25558.

Added:
cfe/trunk/test/CodeGen/asm-unicode.S
cfe/trunk/test/CodeGen/c-unicode.c
Modified:
cfe/trunk/lib/Lex/Lexer.cpp

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=253738=253737=253738=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Fri Nov 20 17:42:39 2015
@@ -1354,7 +1354,9 @@ void Lexer::SkipBytes(unsigned Bytes, bo
 }
 
 static bool isAllowedIDChar(uint32_t C, const LangOptions ) {
-  if (LangOpts.CPlusPlus11 || LangOpts.C11) {
+  if (LangOpts.AsmPreprocessor) {
+return false;
+  } else if (LangOpts.CPlusPlus11 || LangOpts.C11) {
 static const llvm::sys::UnicodeCharSet C11AllowedIDChars(
 C11AllowedIDCharRanges);
 return C11AllowedIDChars.contains(C);
@@ -1371,7 +1373,9 @@ static bool isAllowedIDChar(uint32_t C,
 
 static bool isAllowedInitiallyIDChar(uint32_t C, const LangOptions ) {
   assert(isAllowedIDChar(C, LangOpts));
-  if (LangOpts.CPlusPlus11 || LangOpts.C11) {
+  if (LangOpts.AsmPreprocessor) {
+return false;
+  } else if (LangOpts.CPlusPlus11 || LangOpts.C11) {
 static const llvm::sys::UnicodeCharSet C11DisallowedInitialIDChars(
 C11DisallowedInitialIDCharRanges);
 return !C11DisallowedInitialIDChars.contains(C);

Added: cfe/trunk/test/CodeGen/asm-unicode.S
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/asm-unicode.S?rev=253738=auto
==
--- cfe/trunk/test/CodeGen/asm-unicode.S (added)
+++ cfe/trunk/test/CodeGen/asm-unicode.S Fri Nov 20 17:42:39 2015
@@ -0,0 +1,12 @@
+// RUN: %clang -S %s -o - | FileCheck %s
+.macro  my_macro, trace=1, uaccess=1
+.if \uaccess
+// CHECK: .if \uaccess
+// CHECK-NOT: .if 곎ss
+// CHECK: my_macro trace=1
+my_macro trace=1
+.endif
+.endm
+
+foo:
+my_macro trace=0

Added: cfe/trunk/test/CodeGen/c-unicode.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/c-unicode.c?rev=253738=auto
==
--- cfe/trunk/test/CodeGen/c-unicode.c (added)
+++ cfe/trunk/test/CodeGen/c-unicode.c Fri Nov 20 17:42:39 2015
@@ -0,0 +1,7 @@
+// RUN: %clang -S %s -o - | FileCheck %s -check-prefix=ALLOWED
+// RUN: not %clang -std=c89 -S %s -o - 2>&1 | FileCheck %s -check-prefix=DENIED
+int \uaccess = 0;
+// ALLOWED: "곎ss":
+// ALLOWED-NOT: "\uaccess":
+// DENIED: warning: universal character names are only valid in C99 or C++; 
treating as '\' followed by identifier [-Wunicode]
+// DENIED: error: expected identifier or '('


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


[PATCH] D14891: Replace assert with early-out in tryEmitFMulAdd

2015-11-20 Thread Steve Canon via cfe-commits
scanon created this revision.
scanon added reviewers: hfinkel, resistor, lhames.
scanon added a subscriber: cfe-commits.

r253269 exposed a pre-existing issue in tryEmitFMulAdd, where we would assert 
if a fusable operation had operands with multiple uses (we didn't see it 
previously because FP_CONTRACT was off by default).  Fix this issue by changing 
the assert into an early-out where we simply won't try to fuse.

Once this is done, we can try again at enabling FP_CONTRACT ON as a default.

http://reviews.llvm.org/D14891

Files:
  lib/CodeGen/CGExprScalar.cpp

Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -2563,22 +2563,19 @@
   if (CGF.CGM.getCodeGenOpts().getFPContractMode() != CodeGenOptions::FPC_On)
 return nullptr;
 
-  // We have a potentially fusable op. Look for a mul on one of the operands.
+  // We have a potentially fusable op. Look for a mul on one of the operands
+  // that does not have any other uses.
   if (llvm::BinaryOperator* LHSBinOp = dyn_cast(op.LHS)) 
{
-if (LHSBinOp->getOpcode() == llvm::Instruction::FMul) {
-  assert(LHSBinOp->getNumUses() == 0 &&
- "Operations with multiple uses shouldn't be contracted.");
+if (LHSBinOp->getOpcode() == llvm::Instruction::FMul &&
+LHSBinOp->hasNUses(0))
   return buildFMulAdd(LHSBinOp, op.RHS, CGF, Builder, false, isSub);
-}
-  } else if (llvm::BinaryOperator* RHSBinOp =
-   dyn_cast(op.RHS)) {
-if (RHSBinOp->getOpcode() == llvm::Instruction::FMul) {
-  assert(RHSBinOp->getNumUses() == 0 &&
- "Operations with multiple uses shouldn't be contracted.");
+  }
+  if (llvm::BinaryOperator* RHSBinOp = dyn_cast(op.RHS)) 
{
+if (RHSBinOp->getOpcode() == llvm::Instruction::FMul &&
+RHSBinOp->hasNUses(0))
   return buildFMulAdd(RHSBinOp, op.LHS, CGF, Builder, isSub, false);
-}
   }
-
+  
   return nullptr;
 }
 


Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -2563,22 +2563,19 @@
   if (CGF.CGM.getCodeGenOpts().getFPContractMode() != CodeGenOptions::FPC_On)
 return nullptr;
 
-  // We have a potentially fusable op. Look for a mul on one of the operands.
+  // We have a potentially fusable op. Look for a mul on one of the operands
+  // that does not have any other uses.
   if (llvm::BinaryOperator* LHSBinOp = dyn_cast(op.LHS)) {
-if (LHSBinOp->getOpcode() == llvm::Instruction::FMul) {
-  assert(LHSBinOp->getNumUses() == 0 &&
- "Operations with multiple uses shouldn't be contracted.");
+if (LHSBinOp->getOpcode() == llvm::Instruction::FMul &&
+LHSBinOp->hasNUses(0))
   return buildFMulAdd(LHSBinOp, op.RHS, CGF, Builder, false, isSub);
-}
-  } else if (llvm::BinaryOperator* RHSBinOp =
-   dyn_cast(op.RHS)) {
-if (RHSBinOp->getOpcode() == llvm::Instruction::FMul) {
-  assert(RHSBinOp->getNumUses() == 0 &&
- "Operations with multiple uses shouldn't be contracted.");
+  }
+  if (llvm::BinaryOperator* RHSBinOp = dyn_cast(op.RHS)) {
+if (RHSBinOp->getOpcode() == llvm::Instruction::FMul &&
+RHSBinOp->hasNUses(0))
   return buildFMulAdd(RHSBinOp, op.LHS, CGF, Builder, isSub, false);
-}
   }
-
+  
   return nullptr;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14629: [analyzer] Configuration file for scan-build.

2015-11-20 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

> And I really like how the clang-tidy guys were doing it.


It would be great if the clang static analyzer config file would be similar to 
the clang-tidy one. We would avoid user confusion if they are consistent. Is 
some reuse possible? Currently, when clang-tidy calls the analyzer, can it pass 
the arguments to it through the config file?


http://reviews.llvm.org/D14629



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


r253726 - [coroutines] Support braced-init-list as operand of co_yield expression.

2015-11-20 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Nov 20 16:47:10 2015
New Revision: 253726

URL: http://llvm.org/viewvc/llvm-project?rev=253726=rev
Log:
[coroutines] Support braced-init-list as operand of co_yield expression.

Modified:
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/test/SemaCXX/coroutines.cpp

Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=253726=253725=253726=diff
==
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Fri Nov 20 16:47:10 2015
@@ -1568,7 +1568,8 @@ ExprResult Parser::ParseCoyieldExpressio
   assert(Tok.is(tok::kw_co_yield) && "Not co_yield!");
 
   SourceLocation Loc = ConsumeToken();
-  ExprResult Expr = ParseAssignmentExpression();
+  ExprResult Expr = Tok.is(tok::l_brace) ? ParseBraceInitializer()
+ : ParseAssignmentExpression();
   if (!Expr.isInvalid())
 Expr = Actions.ActOnCoyieldExpr(getCurScope(), Loc, Expr.get());
   return Expr;

Modified: cfe/trunk/test/SemaCXX/coroutines.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutines.cpp?rev=253726=253725=253726=diff
==
--- cfe/trunk/test/SemaCXX/coroutines.cpp (original)
+++ cfe/trunk/test/SemaCXX/coroutines.cpp Fri Nov 20 16:47:10 2015
@@ -44,7 +44,7 @@ void undefined_promise() { // expected-e
   co_await a;
 }
 
-struct yielded_thing { int a, b, c; const char *p; };
+struct yielded_thing { const char *p; short a, b; };
 
 struct promise {
   awaitable yield_value(int); // expected-note {{candidate}}
@@ -53,7 +53,10 @@ struct promise {
 
 void yield() {
   co_yield 0;
-  co_yield {1, 2, 3, "foo"}; // FIXME expected-error {{expected expression}}
+  co_yield {"foo", 1, 2};
+  co_yield {1e100}; // expected-error {{cannot be narrowed}} expected-note 
{{explicit cast}} expected-warning {{changes value}} expected-warning {{braces 
around scalar}}
+  co_yield {"foo", __LONG_LONG_MAX__}; // expected-error {{cannot be 
narrowed}} expected-note {{explicit cast}} expected-warning {{changes value}}
+  co_yield {"foo"};
   co_yield "foo"; // expected-error {{no matching}}
 }
 


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


Re: [PATCH] D14887: Make tbm-builtins.c as X86 specific unit test

2015-11-20 Thread Eric Christopher via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

This is fine. One inline comment.

-eric



Comment at: test/CodeGen/tbm-builtins.c:2-3
@@ -1,3 +1,4 @@
 // RUN: %clang_cc1 %s -O3 -triple=x86_64-unknown-unknown -target-feature +tbm 
-emit-llvm -o - | FileCheck %s
+// REQUIRES: x86-registered-target
 // FIXME: The code generation checks for add/sub and/or are depending on the 
optimizer.
 

Go ahead and put the REQUIRES underneath the FIXME and add a note to the effect 
that the REQUIRES can be removed when the FIXME is complete.


http://reviews.llvm.org/D14887



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


Re: [PATCH] D14686: Protect against overloaded comma in random_shuffle and improve tests

2015-11-20 Thread Dmitri Gribenko via cfe-commits
gribozavr added inline comments.


Comment at: 
test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp:35
@@ -30,1 +34,3 @@
 }
+
+template 

gribozavr wrote:
> mclow.lists wrote:
> > This is not how I would rewrite this test.
> > I would write a routine that took two "iterators", and called 
> > `random_shuffle`, and then checked for the desired results.
> > 
> > Then call it with pointers. and RA iters, etc.
> > for example:
> > 
> > template 
> > void test(Iter first, Iter last, Iter resFirst, Iter resLast);
> > 
> > test(nullptr, nullptr, nullptr, nullptr);
> > int source[] = {1, 2, 3, 4};
> > int res  [] = {1, 2, 3, 4};
> > const unsigned size = sizeof(source)/sizeof(source[0]);
> > 
> > test(source, source + size, res, res+size); 
> > test(random_access_iterator(source)  );
> > 
> > 
> I actually thought about this, and it is hard to rewrite it like that for two 
> reasons.  First, `random_shuffle` mutates the elements, so one needs to 
> restore the original sequence between calls to `test()` (otherwise it is not 
> obvious that it was mutated).  Second, this overload of `random_shuffle` 
> takes randomness from global state, so one can't just specify one expected 
> result in the test.  That's why I first check for the initial shuffle 
> exactly, and then only check that the output is a permutation of input.
> 
Ping?


Repository:
  rL LLVM

http://reviews.llvm.org/D14686



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


r253725 - [coroutines] Synthesize yield_value call for co_yield.

2015-11-20 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Nov 20 16:40:06 2015
New Revision: 253725

URL: http://llvm.org/viewvc/llvm-project?rev=253725=rev
Log:
[coroutines] Synthesize yield_value call for co_yield.

Modified:
cfe/trunk/lib/Sema/SemaCoroutine.cpp
cfe/trunk/test/SemaCXX/coroutines.cpp

Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=253725=253724=253725=diff
==
--- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Fri Nov 20 16:40:06 2015
@@ -128,9 +128,12 @@ checkCoroutineContext(Sema , SourceLoc
 assert(ScopeInfo && "missing function scope for function");
 
 // If we don't have a promise variable, build one now.
-if (!ScopeInfo->CoroutinePromise && !FD->getType()->isDependentType()) {
+if (!ScopeInfo->CoroutinePromise) {
   QualType T =
-  lookupPromiseType(S, FD->getType()->castAs(), 
Loc);
+  FD->getType()->isDependentType()
+  ? S.Context.DependentTy
+  : lookupPromiseType(S, 
FD->getType()->castAs(),
+  Loc);
   if (T.isNull())
 return nullptr;
 
@@ -165,6 +168,23 @@ struct ReadySuspendResumeResult {
   Expr *Results[3];
 };
 
+static ExprResult buildMemberCall(Sema , Expr *Base, SourceLocation Loc,
+  StringRef Name,
+  MutableArrayRef Args) {
+  DeclarationNameInfo NameInfo(().get(Name), Loc);
+
+  // FIXME: Fix BuildMemberReferenceExpr to take a const CXXScopeSpec&.
+  CXXScopeSpec SS;
+  ExprResult Result = S.BuildMemberReferenceExpr(
+  Base, Base->getType(), Loc, /*IsPtr=*/false, SS,
+  SourceLocation(), nullptr, NameInfo, /*TemplateArgs=*/nullptr,
+  /*Scope=*/nullptr);
+  if (Result.isInvalid())
+return ExprError();
+
+  return S.ActOnCallExpr(nullptr, Result.get(), Loc, Args, Loc, nullptr);
+}
+
 /// Build calls to await_ready, await_suspend, and await_resume for a co_await
 /// expression.
 static ReadySuspendResumeResult buildCoawaitCalls(Sema , SourceLocation Loc,
@@ -174,22 +194,11 @@ static ReadySuspendResumeResult buildCoa
 
   const StringRef Funcs[] = {"await_ready", "await_suspend", "await_resume"};
   for (size_t I = 0, N = llvm::array_lengthof(Funcs); I != N; ++I) {
-DeclarationNameInfo NameInfo(().get(Funcs[I]), 
Loc);
-
 Expr *Operand = new (S.Context) OpaqueValueExpr(
 Loc, E->getType(), E->getValueKind(), E->getObjectKind(), E);
 
-// FIXME: Fix BuildMemberReferenceExpr to take a const CXXScopeSpec&.
-CXXScopeSpec SS;
-ExprResult Result = S.BuildMemberReferenceExpr(
-Operand, Operand->getType(), Loc, /*IsPtr=*/false, SS,
-SourceLocation(), nullptr, NameInfo, /*TemplateArgs=*/nullptr,
-/*Scope=*/nullptr);
-if (Result.isInvalid())
-  return Calls;
-
 // FIXME: Pass coroutine handle to await_suspend.
-Result = S.ActOnCallExpr(nullptr, Result.get(), Loc, None, Loc, nullptr);
+ExprResult Result = buildMemberCall(S, Operand, Loc, Funcs[I], None);
 if (Result.isInvalid())
   return Calls;
 Calls.Results[I] = Result.get();
@@ -236,11 +245,36 @@ ExprResult Sema::BuildCoawaitExpr(Source
   return Res;
 }
 
+static ExprResult buildYieldValueCall(Sema , FunctionScopeInfo *Coroutine,
+  SourceLocation Loc, Expr *E) {
+  assert(Coroutine->CoroutinePromise && "no promise for coroutine");
+
+  // Form a reference to the promise.
+  auto *Promise = Coroutine->CoroutinePromise;
+  ExprResult PromiseRef = S.BuildDeclRefExpr(
+  Promise, Promise->getType().getNonReferenceType(), VK_LValue, Loc);
+  if (PromiseRef.isInvalid())
+return ExprError();
+
+  // Call 'yield_value', passing in E.
+  return buildMemberCall(S, PromiseRef.get(), Loc, "yield_value", E);
+}
+
 ExprResult Sema::ActOnCoyieldExpr(Scope *S, SourceLocation Loc, Expr *E) {
-  // FIXME: Build yield_value call.
-  ExprResult Awaitable = buildOperatorCoawaitCall(*this, S, Loc, E);
+  auto *Coroutine = checkCoroutineContext(*this, Loc, "co_yield");
+  if (!Coroutine)
+return ExprError();
+
+  // Build yield_value call.
+  ExprResult Awaitable = buildYieldValueCall(*this, Coroutine, Loc, E);
   if (Awaitable.isInvalid())
 return ExprError();
+
+  // Build 'operator co_await' call.
+  Awaitable = buildOperatorCoawaitCall(*this, S, Loc, Awaitable.get());
+  if (Awaitable.isInvalid())
+return ExprError();
+
   return BuildCoyieldExpr(Loc, Awaitable.get());
 }
 ExprResult Sema::BuildCoyieldExpr(SourceLocation Loc, Expr *E) {

Modified: cfe/trunk/test/SemaCXX/coroutines.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutines.cpp?rev=253725=253724=253725=diff
==
--- cfe/trunk/test/SemaCXX/coroutines.cpp (original)
+++ 

Re: [PATCH] D14804: [clang] Disable Unicode in asm files

2015-11-20 Thread Vinicius Tinti via cfe-commits
tinti closed this revision.
tinti added a comment.

r253738


Repository:
  rL LLVM

http://reviews.llvm.org/D14804



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


Re: [PATCH] D12700: [clang-tidy] install helper scripts in CMake build

2015-11-20 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a comment.

I think will be good idea to ask specialist in configure build to look on make 
file. I used other Clang or LLVM make file as example. Frankly, I don't see 
anything bad with it.

However this fix was backported to 3.7.x and configure build is still supported 
there.

If root cause will not be found, it' OK for me to remove installation from 
configure build, since I use CMake one for my build.


Repository:
  rL LLVM

http://reviews.llvm.org/D12700



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


r253741 - Fix testcase when building on darwin

2015-11-20 Thread Matthias Braun via cfe-commits
Author: matze
Date: Fri Nov 20 18:56:41 2015
New Revision: 253741

URL: http://llvm.org/viewvc/llvm-project?rev=253741=rev
Log:
Fix testcase when building on darwin

Explicitely specify a target to avoid "_" prefixes on the names.

Modified:
cfe/trunk/test/CodeGen/c-unicode.c

Modified: cfe/trunk/test/CodeGen/c-unicode.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/c-unicode.c?rev=253741=253740=253741=diff
==
--- cfe/trunk/test/CodeGen/c-unicode.c (original)
+++ cfe/trunk/test/CodeGen/c-unicode.c Fri Nov 20 18:56:41 2015
@@ -1,5 +1,5 @@
-// RUN: %clang -S %s -o - | FileCheck %s -check-prefix=ALLOWED
-// RUN: not %clang -std=c89 -S %s -o - 2>&1 | FileCheck %s -check-prefix=DENIED
+// RUN: %clang --target=x86_64--linux-gnu -S %s -o - | FileCheck %s 
-check-prefix=ALLOWED
+// RUN: not %clang --target=x86_64--linux-gnu -std=c89 -S %s -o - 2>&1 | 
FileCheck %s -check-prefix=DENIED
 int \uaccess = 0;
 // ALLOWED: "곎ss":
 // ALLOWED-NOT: "\uaccess":


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


[libcxxabi] r253748 - Creating release candidate rc2 from release_371 branch

2015-11-20 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Fri Nov 20 19:32:08 2015
New Revision: 253748

URL: http://llvm.org/viewvc/llvm-project?rev=253748=rev
Log:
Creating release candidate rc2 from release_371 branch

Added:
libcxxabi/tags/RELEASE_371/rc2/   (props changed)
  - copied from r253747, libcxxabi/branches/release_37/

Propchange: libcxxabi/tags/RELEASE_371/rc2/
--
svn:mergeinfo = /libcxxabi/trunk:244004


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


[libcxx] r253747 - Creating release candidate rc2 from release_371 branch

2015-11-20 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Fri Nov 20 19:32:06 2015
New Revision: 253747

URL: http://llvm.org/viewvc/llvm-project?rev=253747=rev
Log:
Creating release candidate rc2 from release_371 branch

Added:
libcxx/tags/RELEASE_371/rc2/   (props changed)
  - copied from r253746, libcxx/branches/release_37/

Propchange: libcxx/tags/RELEASE_371/rc2/
--
--- svn:mergeinfo (added)
+++ svn:mergeinfo Fri Nov 20 19:32:06 2015
@@ -0,0 +1,2 @@
+/libcxx/branches/apple:136569-137939
+/libcxx/trunk:242377,242421,243530,243641,244003,244462


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


[libunwind] r253754 - Creating release candidate rc2 from release_371 branch

2015-11-20 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Fri Nov 20 19:32:21 2015
New Revision: 253754

URL: http://llvm.org/viewvc/llvm-project?rev=253754=rev
Log:
Creating release candidate rc2 from release_371 branch

Added:
libunwind/tags/RELEASE_371/rc2/   (props changed)
  - copied from r253753, libunwind/branches/release_37/

Propchange: libunwind/tags/RELEASE_371/rc2/
--
svn:mergeinfo = /libunwind/trunk:242642,243073,244005,244237


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


r253654 - Regenerate ASTMatchersReference without CRLF.

2015-11-20 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Nov 20 01:57:46 2015
New Revision: 253654

URL: http://llvm.org/viewvc/llvm-project?rev=253654=rev
Log:
Regenerate ASTMatchersReference without CRLF.

Modified:
cfe/trunk/docs/LibASTMatchersReference.html

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=253654=253653=253654=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Fri Nov 20 01:57:46 2015
@@ -1,103 +1,103 @@
-http://www.w3.org/TR/html4/strict.dtd;>
-
-
-AST Matcher Reference
-
-
-
-td {
-  padding: .33em;
-}
-td.doc {
-  display: none;
-  border-bottom: 1px solid black;
-}
-td.name:hover {
-  color: blue;
-  cursor: pointer;
-}
-
-
-function toggle(id) {
-  if (!id) return;
-  row = document.getElementById(id);
-  if (row.style.display != 'table-cell')
-row.style.display = 'table-cell';
-  else
-row.style.display = 'none';
-}
-
-
-
-
-
-
-
-
-AST Matcher Reference
-
-This document shows all currently implemented matchers. The matchers are 
grouped
-by category and node type they match. You can click on matcher names to show 
the
-matcher's source documentation.
-
-There are three different basic categories of matchers:
-
-Node Matchers: Matchers that match a specific 
type of AST node.
-Narrowing Matchers: Matchers that match 
attributes on AST nodes.
-Traversal Matchers: Matchers that allow 
traversal between AST nodes.
-
-
-
-Within each category the matchers are ordered by node type they match on.
-Note that if a matcher can match multiple node types, it will it will appear
-multiple times. This means that by searching for MatcherStmt you can
-find all matchers that can be used to match on Stmt nodes.
-
-The exception to that rule are matchers that can match on any node. Those
-are marked with a * and are listed in the beginning of each category.
-
-Note that the categorization of matchers is a great help when you combine
-them into matcher expressions. You will usually want to form matcher 
expressions
-that read like english sentences by alternating between node matchers and
-narrowing or traversal matchers, like this:
-
-recordDecl(hasDescendant(
-ifStmt(hasTrueExpression(
-expr(hasDescendant(
-ifStmt()))
-
-
-
-
-Node Matchers
-
-
-Node matchers are at the core of matcher expressions - they specify the type
-of node that is expected. Every match expression starts with a node matcher,
-which can then be further refined with a narrowing or traversal matcher. All
-traversal matchers take node matchers as their arguments.
-
-For convenience, all node matchers take an arbitrary number of arguments
-and implicitly act as allOf matchers.
-
-Node matchers are the only matchers that support the bind("id") call to
-bind the matched node to the given string, to be later retrieved from the
-match callback.
-
-It is important to remember that the arguments to node matchers are
-predicates on the same node, just with additional information about the type.
-This is often useful to make matcher expression more readable by inlining bind
-calls into redundant node matchers inside another node matcher:
-
-// This binds the CXXRecordDecl to "id", as the decl() matcher will stay on
-// the same node.
-recordDecl(decl().bind("id"), hasName("::MyClass"))
-
-
-
-
-Return 
typeNameParameters
+http://www.w3.org/TR/html4/strict.dtd;>
+
+
+AST Matcher Reference
+
+
+
+td {
+  padding: .33em;
+}
+td.doc {
+  display: none;
+  border-bottom: 1px solid black;
+}
+td.name:hover {
+  color: blue;
+  cursor: pointer;
+}
+
+
+function toggle(id) {
+  if (!id) return;
+  row = document.getElementById(id);
+  if (row.style.display != 'table-cell')
+row.style.display = 'table-cell';
+  else
+row.style.display = 'none';
+}
+
+
+
+
+
+
+
+
+AST Matcher Reference
+
+This document shows all currently implemented matchers. The matchers are 
grouped
+by category and node type they match. You can click on matcher names to show 
the
+matcher's source documentation.
+
+There are three different basic categories of matchers:
+
+Node Matchers: Matchers that match a specific 
type of AST node.
+Narrowing Matchers: Matchers that match 
attributes on AST nodes.
+Traversal Matchers: Matchers that allow 
traversal between AST nodes.
+
+
+
+Within each category the matchers are ordered by node type they match on.
+Note that if a matcher can match multiple node types, it will it will appear
+multiple times. This means that by searching for MatcherStmt you can
+find all matchers that can be used to match on Stmt nodes.
+
+The exception to that rule are matchers that can match on any node. Those
+are marked with a * and are listed in the beginning of each category.
+
+Note that the categorization of matchers is a great help when you combine
+them into matcher expressions. You will usually want 

r253758 - Fix c-unicode.c testcase again.

2015-11-20 Thread Matthias Braun via cfe-commits
Author: matze
Date: Fri Nov 20 20:13:29 2015
New Revision: 253758

URL: http://llvm.org/viewvc/llvm-project?rev=253758=rev
Log:
Fix c-unicode.c testcase again.

Specifying a fixed triple is not possible because that target may not
even be compiler. Go for a simpler fix by using a _? regex for the
prefix.

Modified:
cfe/trunk/test/CodeGen/c-unicode.c

Modified: cfe/trunk/test/CodeGen/c-unicode.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/c-unicode.c?rev=253758=253757=253758=diff
==
--- cfe/trunk/test/CodeGen/c-unicode.c (original)
+++ cfe/trunk/test/CodeGen/c-unicode.c Fri Nov 20 20:13:29 2015
@@ -1,7 +1,7 @@
-// RUN: %clang --target=x86_64--linux-gnu -S %s -o - | FileCheck %s 
-check-prefix=ALLOWED
-// RUN: not %clang --target=x86_64--linux-gnu -std=c89 -S %s -o - 2>&1 | 
FileCheck %s -check-prefix=DENIED
+// RUN: %clang -S %s -o - | FileCheck %s -check-prefix=ALLOWED
+// RUN: not %clang -std=c89 -S %s -o - 2>&1 | FileCheck %s -check-prefix=DENIED
 int \uaccess = 0;
-// ALLOWED: "곎ss":
+// ALLOWED: "{{_?}}곎ss":
 // ALLOWED-NOT: "\uaccess":
 // DENIED: warning: universal character names are only valid in C99 or C++; 
treating as '\' followed by identifier [-Wunicode]
 // DENIED: error: expected identifier or '('


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


Re: r253721 - [CMake] Add support for specifying arguments to the bootstrap build.

2015-11-20 Thread Sean Silva via cfe-commits
On Fri, Nov 20, 2015 at 2:09 PM, Chris Bieneman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: cbieneman
> Date: Fri Nov 20 16:09:06 2015
> New Revision: 253721
>
> URL: http://llvm.org/viewvc/llvm-project?rev=253721=rev
> Log:
> [CMake] Add support for specifying arguments to the bootstrap build.
>
> This adds support for three types of argument specifications for bootstrap
> builds:
>
> (1) Arguments prefixed with BOOTSTRAP_* will be passed through with the
> leading BOOTSTRAP_ removed.
> (2) CLANG_BOOTSTRAP_PASSTHROUGH can specify a list of variables to be
> passed through as they are set.
> (3) BOOTSTRAP_DEFAULT_PASSTHROUGH is a list of some default passthrough
> variables that are always passed through. Those variables include the
> version string and should only specify variables that are always expected
> to be the same between the stage1 and stage2
>
> Modified:
> cfe/trunk/CMakeLists.txt
>
> Modified: cfe/trunk/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=253721=253720=253721=diff
>
> ==
> --- cfe/trunk/CMakeLists.txt (original)
> +++ cfe/trunk/CMakeLists.txt Fri Nov 20 16:09:06 2015
> @@ -652,6 +652,36 @@ if (CLANG_ENABLE_BOOTSTRAP)
>  set(verbose -DCMAKE_VERBOSE_MAKEFILE=On)
>endif()
>
> +  set(BOOTSTRAP_DEFAULT_PASSTHROUGH
> +PACKAGE_VERSION
> +LLVM_VERSION_MAJOR
> +LLVM_VERSION_MINOR
> +LLVM_VERSION_PATCH
> +LLVM_VERSION_SUFFIX
> +CLANG_REPOSITORY_STRING
> +CMAKE_MAKE_PROGRAM)
> +
> +  # Find all variables that start with BOOTSTRAP_ and populate a variable
> with
> +  # them.
> +  get_cmake_property(variableNames VARIABLES)
> +  foreach(varaibleName ${variableNames})
> +if(varaibleName MATCHES "^BOOTSTRAP_")
> +  string(SUBSTRING ${varaibleName} 10 -1 varName)
> +  string(REPLACE ";" "\;" value "${${varaibleName}}")
> +  list(APPEND PASSTHROUGH_VARIABLES
> +-D${varName}=${value})
> +endif()
> +  endforeach()
> +
> +  # Populate the passthrough variables
> +  foreach(varaibleName ${CLANG_BOOTSTRAP_PASSTHROUGH}
> ${BOOTSTRAP_DEFAULT_PASSTHROUGH})
> +if(${varaibleName})
>

typo: "varaibleName".

I saw one in r253720 as well.

-- Sean Silva


> +  string(REPLACE ";" "\;" value ${${varaibleName}})
> +  list(APPEND PASSTHROUGH_VARIABLES
> +-D${varaibleName}=${value})
> +endif()
> +  endforeach()
> +
>ExternalProject_Add(bootstrap
>  DEPENDS clang ${LTO_DEP}
>  PREFIX bootstrap
> @@ -664,6 +694,7 @@ if (CLANG_ENABLE_BOOTSTRAP)
>  # seem to work, so instead I'm passing this through
>  -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
>  ${CLANG_BOOTSTRAP_CMAKE_ARGS}
> +${PASSTHROUGH_VARIABLES}
>  -DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++
>  -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
>  -DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
>
>
> ___
> 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


r253760 - Let's try to fix this test again with a fixed target triple

2015-11-20 Thread Matthias Braun via cfe-commits
Author: matze
Date: Fri Nov 20 20:28:42 2015
New Revision: 253760

URL: http://llvm.org/viewvc/llvm-project?rev=253760=rev
Log:
Let's try to fix this test again with a fixed target triple

Modified:
cfe/trunk/test/CodeGen/c-unicode.c

Modified: cfe/trunk/test/CodeGen/c-unicode.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/c-unicode.c?rev=253760=253759=253760=diff
==
--- cfe/trunk/test/CodeGen/c-unicode.c (original)
+++ cfe/trunk/test/CodeGen/c-unicode.c Fri Nov 20 20:28:42 2015
@@ -1,7 +1,8 @@
-// RUN: %clang -S %s -o - | FileCheck %s -check-prefix=ALLOWED
-// RUN: not %clang -std=c89 -S %s -o - 2>&1 | FileCheck %s -check-prefix=DENIED
+// REQUIRES: x86-registered-target
+// RUN: %clang --target=x86_64--linug-gnu -S %s -o - | FileCheck %s 
-check-prefix=ALLOWED
+// RUN: not %clang --target=x86_64--linux-gnu -std=c89 -S %s -o - 2>&1 | 
FileCheck %s -check-prefix=DENIED
 int \uaccess = 0;
-// ALLOWED: "{{_?}}곎ss":
+// ALLOWED: "곎ss":
 // ALLOWED-NOT: "\uaccess":
 // DENIED: warning: universal character names are only valid in C99 or C++; 
treating as '\' followed by identifier [-Wunicode]
 // DENIED: error: expected identifier or '('


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


Re: [PATCH] D10833: Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface

2015-11-20 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10833



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