r251693 - Add "equalsNode" for types and "isCopyAssignmentOperator" matchers.

2015-10-30 Thread Angel Garcia Gomez via cfe-commits
Author: angelgarcia
Date: Fri Oct 30 04:35:51 2015
New Revision: 251693

URL: http://llvm.org/viewvc/llvm-project?rev=251693&view=rev
Log:
Add "equalsNode" for types and "isCopyAssignmentOperator" matchers.

Summary: This matchers are going to be used in modernize-use-default, but are 
generic enough to be placed in ASTMatchers.h.

Reviewers: klimek

Subscribers: alexfh, cfe-commits, klimek

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

Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=251693&r1=251692&r2=251693&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Fri Oct 30 04:35:51 2015
@@ -3385,6 +3385,23 @@ AST_MATCHER(CXXMethodDecl, isConst) {
   return Node.isConst();
 }
 
+/// \brief Matches if the given method declaration declares a copy assignment
+/// operator.
+///
+/// Given
+/// \code
+/// struct A {
+///   A &operator=(const A &);
+///   A &operator=(A &&);
+/// };
+/// \endcode
+///
+/// cxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not
+/// the second one.
+AST_MATCHER(CXXMethodDecl, isCopyAssignmentOperator) {
+  return Node.isCopyAssignmentOperator();
+}
+
 /// \brief Matches if the given method declaration overrides another method.
 ///
 /// Given
@@ -4307,10 +4324,15 @@ AST_MATCHER_P_OVERLOAD(Decl, equalsNode,
 /// \brief Matches if a node equals another node.
 ///
 /// \c Stmt has pointer identity in the AST.
-///
 AST_MATCHER_P_OVERLOAD(Stmt, equalsNode, const Stmt*, Other, 1) {
   return &Node == Other;
 }
+/// \brief Matches if a node equals another node.
+///
+/// \c Type has pointer identity in the AST.
+AST_MATCHER_P_OVERLOAD(Type, equalsNode, const Type*, Other, 2) {
+return &Node == Other;
+}
 
 /// @}
 

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=251693&r1=251692&r2=251693&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Fri Oct 30 04:35:51 2015
@@ -1890,6 +1890,21 @@ TEST(Matcher, MatchesPureMethod) {
   EXPECT_TRUE(notMatches("class X { int f(); };", cxxMethodDecl(isPure(;
 }
 
+TEST(Matcher, MatchesCopyAssignmentOperator) {
+  EXPECT_TRUE(matches("class X { X &operator=(X); };",
+  cxxMethodDecl(isCopyAssignmentOperator(;
+  EXPECT_TRUE(matches("class X { X &operator=(X &); };",
+  cxxMethodDecl(isCopyAssignmentOperator(;
+  EXPECT_TRUE(matches("class X { X &operator=(const X &); };",
+  cxxMethodDecl(isCopyAssignmentOperator(;
+  EXPECT_TRUE(matches("class X { X &operator=(volatile X &); };",
+  cxxMethodDecl(isCopyAssignmentOperator(;
+  EXPECT_TRUE(matches("class X { X &operator=(const volatile X &); };",
+  cxxMethodDecl(isCopyAssignmentOperator(;
+  EXPECT_TRUE(notMatches("class X { X &operator=(X &&); };",
+  cxxMethodDecl(isCopyAssignmentOperator(;
+}
+
 TEST(Matcher, MatchesConstMethod) {
   EXPECT_TRUE(
   matches("struct A { void foo() const; };", cxxMethodDecl(isConst(;
@@ -4671,6 +4686,16 @@ public:
  decl(has(decl(equalsNode(TypedNode.bind(""))),
  *Node, Context)) != nullptr;
   }
+  bool verify(const BoundNodes &Nodes, ASTContext &Context, const Type *Node) {
+// Use the original typed pointer to verify we can pass pointers to 
subtypes
+// to equalsNode.
+const T *TypedNode = cast(Node);
+const auto *Dec = Nodes.getNodeAs("decl");
+return selectFirst(
+   "", match(fieldDecl(hasParent(decl(has(fieldDecl(
+ 
hasType(type(equalsNode(TypedNode)).bind(""))),
+ *Dec, Context)) != nullptr;
+  }
 };
 
 TEST(IsEqualTo, MatchesNodesByIdentity) {
@@ -4680,6 +4705,10 @@ TEST(IsEqualTo, MatchesNodesByIdentity)
   EXPECT_TRUE(matchAndVerifyResultTrue(
   "void f() { if (true) if(true) {} }", ifStmt().bind(""),
   new VerifyAncestorHasChildIsEqual()));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "class X { class Y {} y; };",
+  fieldDecl(hasName("y"), hasType(type().bind(""))).bind("decl"),
+  new VerifyAncestorHasChildIsEqual()));
 }
 
 TEST(MatchFinder, CheckProfiling) {


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


Re: [PATCH] D13673: Add initial support for the MUSL C library.

2015-10-30 Thread Vasileios Kalintiris via cfe-commits
vkalintiris updated this revision to Diff 38788.
vkalintiris added a comment.

s/__NetBSD_\)/__NetBSD__\)/


http://reviews.llvm.org/D13673

Files:
  CMakeLists.txt
  include/__config
  include/__config_site.in
  include/__locale
  include/support/musl/xlocale.h
  src/locale.cpp

Index: src/locale.cpp
===
--- src/locale.cpp
+++ src/locale.cpp
@@ -812,7 +812,8 @@
 {
 #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
 return isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c;
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
+  defined(__NetBSD__) || defined(_LIBCPP_HAS_MUSL_LIBC)
 return isascii(c) ? ctype::__classic_upper_table()[c] : c;
 #else
 return (isascii(c) && iswlower_l(c, _LIBCPP_GET_C_LOCALE)) ? c-L'a'+L'A' : c;
@@ -825,7 +826,8 @@
 for (; low != high; ++low)
 #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
 *low = isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low;
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
+  defined(__NetBSD__) || defined(_LIBCPP_HAS_MUSL_LIBC)
 *low = isascii(*low) ? ctype::__classic_upper_table()[*low]
  : *low;
 #else
@@ -839,7 +841,8 @@
 {
 #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
 return isascii(c) ? _DefaultRuneLocale.__maplower[c] : c;
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
+  defined(__NetBSD__) || defined(_LIBCPP_HAS_MUSL_LIBC)
 return isascii(c) ? ctype::__classic_lower_table()[c] : c;
 #else
 return (isascii(c) && isupper_l(c, _LIBCPP_GET_C_LOCALE)) ? c-L'A'+'a' : c;
@@ -852,7 +855,8 @@
 for (; low != high; ++low)
 #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
 *low = isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low;
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
+  defined(__NetBSD__) || defined(_LIBCPP_HAS_MUSL_LIBC)
 *low = isascii(*low) ? ctype::__classic_lower_table()[*low]
  : *low;
 #else
@@ -921,8 +925,8 @@
   static_cast(_DefaultRuneLocale.__mapupper[static_cast(c)]) : c;
 #elif defined(__NetBSD__)
 return static_cast(__classic_upper_table()[static_cast(c)]);
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__)
-return isascii(c) ? 
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(_LIBCPP_HAS_MUSL_LIBC)
+return isascii(c) ?
   static_cast(__classic_upper_table()[static_cast(c)]) : c;
 #else
 return (isascii(c) && islower_l(c, _LIBCPP_GET_C_LOCALE)) ? c-'a'+'A' : c;
@@ -938,7 +942,7 @@
   static_cast(_DefaultRuneLocale.__mapupper[static_cast(*low)]) : *low;
 #elif defined(__NetBSD__)
 *low = static_cast(__classic_upper_table()[static_cast(*low)]);
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(_LIBCPP_HAS_MUSL_LIBC)
 *low = isascii(*low) ?
   static_cast(__classic_upper_table()[static_cast(*low)]) : *low;
 #else
@@ -955,7 +959,7 @@
   static_cast(_DefaultRuneLocale.__maplower[static_cast(c)]) : c;
 #elif defined(__NetBSD__)
 return static_cast(__classic_lower_table()[static_cast(c)]);
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(_LIBCPP_HAS_MUSL_LIBC)
 return isascii(c) ?
   static_cast(__classic_lower_table()[static_cast(c)]) : c;
 #else
@@ -971,7 +975,7 @@
 *low = isascii(*low) ? static_cast(_DefaultRuneLocale.__maplower[static_cast(*low)]) : *low;
 #elif defined(__NetBSD__)
 *low = static_cast(__classic_lower_table()[static_cast(*low)]);
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(_LIBCPP_HAS_MUSL_LIBC)
 *low = isascii(*low) ? static_cast(__classic_lower_table()[static_cast(*low)]) : *low;
 #else
 *low = (isascii(*low) && isupper_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low-'A'+'a' : *low;
@@ -1012,7 +1016,7 @@
 return low;
 }
 
-#ifdef __EMSCRIPTEN__
+#if defined(__EMSCRIPTEN__) || defined(_LIBCPP_HAS_MUSL_LIBC)
 extern "C" const unsigned short ** __ctype_b_loc();
 extern "C" const int ** __ctype_tolower_loc();
 extern "C" const int ** __ctype_toupper_loc();
@@ -1114,7 +1118,7 @@
 return _ctype+1; // internal ctype mask table defined in msvcrt.dll
 // This is assumed to be safe, which is a nonsense assumption because we're
 // going to end up dereferencing it later...
-#elif defined(__EMSCRIPTEN__)
+#elif defined(__EMSCRIPTEN__) || defined(_LIBCPP_HAS_MUSL_LIBC)
 return *__ctype_b_loc();
 #elif defined(_NEWLIB_VERSION)
 // Newlib has a 257-entry table in ctype_.c, wher

[clang-tools-extra] r251694 - Only copy small types in modernize-loop-convert.

2015-10-30 Thread Angel Garcia Gomez via cfe-commits
Author: angelgarcia
Date: Fri Oct 30 04:37:57 2015
New Revision: 251694

URL: http://llvm.org/viewvc/llvm-project?rev=251694&view=rev
Log:
Only copy small types in modernize-loop-convert.

Summary: If the size of the type is above a certain bound, we'll take a const 
reference. This bound can be set as an option. For now, the default value is 16 
bytes.

Reviewers: klimek

Subscribers: alexfh, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.h
clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp

clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-loop-convert/structures.h
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp?rev=251694&r1=251693&r2=251694&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp Fri Oct 
30 04:37:57 2015
@@ -230,18 +230,18 @@ StatementMatcher makePseudoArrayLoopMatc
   // FIXME: Also, a record doesn't necessarily need begin() and end(). Free
   // functions called begin() and end() taking the container as an argument
   // are also allowed.
-  TypeMatcher RecordWithBeginEnd = qualType(
-  anyOf(qualType(isConstQualified(),
- hasDeclaration(cxxRecordDecl(
- hasMethod(cxxMethodDecl(hasName("begin"), isConst())),
- hasMethod(cxxMethodDecl(hasName("end"),
- isConst() // 
hasDeclaration
- ),// qualType
-qualType(unless(isConstQualified()),
- hasDeclaration(
- cxxRecordDecl(hasMethod(hasName("begin")),
+  TypeMatcher RecordWithBeginEnd = qualType(anyOf(
+  qualType(isConstQualified(),
+   hasDeclaration(cxxRecordDecl(
+   hasMethod(cxxMethodDecl(hasName("begin"), isConst())),
+   hasMethod(cxxMethodDecl(hasName("end"),
+   isConst() // hasDeclaration
+   ),// qualType
+  qualType(
+  unless(isConstQualified()),
+  hasDeclaration(cxxRecordDecl(hasMethod(hasName("begin")),
hasMethod(hasName("end") // qualType
-));
+  ));
 
   StatementMatcher SizeCallMatcher = cxxMemberCallExpr(
   argumentCountIs(0),
@@ -409,6 +409,7 @@ LoopConvertCheck::RangeDescriptor::Range
 
 LoopConvertCheck::LoopConvertCheck(StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context), TUInfo(new TUTrackingInfo),
+  MaxCopySize(std::stoull(Options.get("MaxCopySize", "16"))),
   MinConfidence(StringSwitch(
 Options.get("MinConfidence", "reasonable"))
 .Case("safe", Confidence::CL_Safe)
@@ -422,6 +423,7 @@ LoopConvertCheck::LoopConvertCheck(Strin
   .Default(VariableNamer::NS_CamelCase)) {}
 
 void LoopConvertCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "MaxCopySize", std::to_string(MaxCopySize));
   SmallVector Confs{"risky", "reasonable", "safe"};
   Options.store(Opts, "MinConfidence", Confs[static_cast(MinConfidence)]);
 
@@ -561,18 +563,20 @@ void LoopConvertCheck::doConversion(
   // If the new variable name is from the aliased variable, then the reference
   // type for the new variable should only be used if the aliased variable was
   // declared as a reference.
-  bool IsTriviallyCopyable =
+  bool IsCheapToCopy =
   !Descriptor.ElemType.isNull() &&
-  Descriptor.ElemType.isTriviallyCopyableType(*Context);
+  Descriptor.ElemType.isTriviallyCopyableType(*Context) &&
+  // TypeInfo::Width is in bits.
+  Context->getTypeInfo(Descriptor.ElemType).Width <= 8 * MaxCopySize;
   bool UseCopy =
   CanCopy && ((VarNameFromAlias && !AliasVarIsRef) ||
-  (Descriptor.DerefByConstRef && IsTriviallyCopyable));
+  (Descriptor.DerefByConstRef && IsCheapToCopy));
 
   if (!UseCopy) {
 if (Descriptor.DerefByConstRef) {
   Type = Context->getLValueReferenceType(Context->getConstType(Type));
 } else if (Descriptor.DerefByValue) {
-  if (!IsTriviallyCopyable)
+  if (!IsCheapToCopy)
 Type = Context->getRValueReferenceType(Type);
 } else {
   Type = Context->getLValueReferenceType(Type);

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.h
URL: 
http:

Re: [PATCH] D14176: Only copy small types in modernize-loop-convert.

2015-10-30 Thread Angel Garcia via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL251694: Only copy small types in modernize-loop-convert. 
(authored by angelgarcia).

Changed prior to commit:
  http://reviews.llvm.org/D14176?vs=38736&id=38789#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14176

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.h
  clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
  
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-loop-convert/structures.h
  clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-loop-convert/structures.h
===
--- clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-loop-convert/structures.h
+++ clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-loop-convert/structures.h
@@ -23,6 +23,11 @@
   int X;
 };
 
+struct TriviallyCopyableButBig {
+  int X;
+  char Array[16];
+};
+
 struct S {
   typedef MutableVal *iterator;
   typedef const MutableVal *const_iterator;
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
@@ -113,6 +113,14 @@
   // CHECK-FIXES: for (const auto & Elem : NonCopy)
   // CHECK-FIXES-NEXT: printf("2 * %d = %d\n", Elem.X, Elem.X + Elem.X);
 
+  const TriviallyCopyableButBig Big[N]{};
+  for (int I = 0; I < N; ++I) {
+printf("2 * %d = %d\n", Big[I].X, Big[I].X + Big[I].X);
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (const auto & Elem : Big)
+  // CHECK-FIXES-NEXT: printf("2 * %d = %d\n", Elem.X, Elem.X + Elem.X);
+
   bool Something = false;
   for (int I = 0; I < N; ++I) {
 if (Something)
Index: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
@@ -47,6 +47,10 @@
   ClangTidyOptions getModuleOptions() override {
 ClangTidyOptions Options;
 auto &Opts = Options.CheckOptions;
+// For types whose size in bytes is above this threshold, we prefer taking a
+// const-reference than making a copy.
+Opts["modernize-loop-convert.MaxCopySize"] = "16";
+
 Opts["modernize-loop-convert.MinConfidence"] = "reasonable";
 Opts["modernize-loop-convert.NamingStyle"] = "CamelCase";
 Opts["modernize-pass-by-value.IncludeStyle"] = "llvm";// Also: "google".
Index: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.h
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.h
@@ -66,6 +66,7 @@
  const ForStmt *Loop, LoopFixerKind FixerKind);
 
   std::unique_ptr TUInfo;
+  const unsigned long long MaxCopySize;
   const Confidence::Level MinConfidence;
   const VariableNamer::NamingStyle NamingStyle;
 };
Index: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -230,18 +230,18 @@
   // FIXME: Also, a record doesn't necessarily need begin() and end(). Free
   // functions called begin() and end() taking the container as an argument
   // are also allowed.
-  TypeMatcher RecordWithBeginEnd = qualType(
-  anyOf(qualType(isConstQualified(),
- hasDeclaration(cxxRecordDecl(
- hasMethod(cxxMethodDecl(hasName("begin"), isConst())),
- hasMethod(cxxMethodDecl(hasName("end"),
- isConst() // hasDeclaration
- ),// qualType
-qualType(unless(isConstQualified()),
- hasDeclaration(
- cxxRecordDecl(hasMethod(hasName("begin")),
+  TypeMatcher RecordWithBeginEnd = qualType(anyOf(
+  qualType(isConstQualified(),
+   hasDeclaration(cxxRecordDecl(
+   hasMethod(cxxMethodDecl(hasName("begin"), isConst())),
+   hasMethod(cxxMethodDecl(hasName("end"),
+   isConst() // hasDeclaration
+   ),// qualType
+  qualType(
+  unless(isConstQualified()),

r251695 - Try to run and investigate the mips-mti-linux.c test failure on ARM buildbots.

2015-10-30 Thread Vasileios Kalintiris via cfe-commits
Author: vkalintiris
Date: Fri Oct 30 05:35:38 2015
New Revision: 251695

URL: http://llvm.org/viewvc/llvm-project?rev=251695&view=rev
Log:
Try to run and investigate the mips-mti-linux.c test failure on ARM buildbots.

This should be a NFC for every toolchain other than mips-mti-linux (where we
print the list of directories searched for crt files). It will soon be
reverted once we hit the clang-cmake-armv7-a15-selfhost-neon buildbot.

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/mips-mti-linux.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=251695&r1=251694&r2=251695&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Oct 30 05:35:38 2015
@@ -8469,6 +8469,19 @@ void gnutools::Linker::ConstructJob(Comp
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crt1)));
 
   CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crti.o")));
+
+  if (ToolChain.getTriple().getVendor() == llvm::Triple::MipsTechnologies 
&&
+  !ToolChain.getTriple().hasEnvironment()) {
+// Print look-up paths for crt files.
+llvm::errs() << "Looked for crti.o in: ";
+llvm::errs() << " PrefixDirs  - ";
+for (const std::string &Dir : D.PrefixDirs)
+  llvm::errs() << "Dir: " << Dir << ", ";
+llvm::errs() << " TC.getFilePaths()  - ";
+for (const std::string &Dir : ToolChain.getFilePaths())
+  llvm::errs() << "Dir: " << Dir << ",";
+llvm::errs() << "\n";
+  }
 }
 
 const char *crtbegin;

Modified: cfe/trunk/test/Driver/mips-mti-linux.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-mti-linux.c?rev=251695&r1=251694&r2=251695&view=diff
==
--- cfe/trunk/test/Driver/mips-mti-linux.c (original)
+++ cfe/trunk/test/Driver/mips-mti-linux.c Fri Oct 30 05:35:38 2015
@@ -5,14 +5,15 @@
 //Ideally, we'd like to have an --llvm-toolchain option similar to
 //the --gcc-toolchain one.
 
-// RUN: false
-// XFAIL: *
+// XFAIL: i386, i686, x86_64, win32, win64, powerpc64, s390x, r600, xcore, 
hexagon, sparc, darwin, asan, msan
 
 // = Big-endian, mips32r2, hard float
-// R!N: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// R!N: --target=mips-mti-linux -mips32r2 -mhard-float \
-// R!N: --sysroot=%S/Inputs/mips_mti_linux/sysroot \
-// R!N:   | FileCheck --check-prefix=CHECK-BE-HF-32R2 %s
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=mips-mti-linux -mips32r2 -mhard-float \
+// RUN: --sysroot=%S/Inputs/mips_mti_linux/sysroot \
+// RUN:   | FileCheck --check-prefix=CHECK-BE-HF-32R2 %s
+//
+// CHECK-BE-HF-32R2: Looked for crt1.o
 //
 // CHECK-BE-HF-32R2: "{{[^"]*}}clang{{[^"]*}}" {{.*}} "-triple" 
"mips-mti-linux"
 // CHECK-BE-HF-32R2-SAME: "-fuse-init-array" "-target-cpu" "mips32r2"


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


Re: r251695 - Try to run and investigate the mips-mti-linux.c test failure on ARM buildbots.

2015-10-30 Thread Renato Golin via cfe-commits
On 30 October 2015 at 10:35, Vasileios Kalintiris via cfe-commits
 wrote:
> Author: vkalintiris
> Date: Fri Oct 30 05:35:38 2015
> New Revision: 251695
>
> URL: http://llvm.org/viewvc/llvm-project?rev=251695&view=rev
> Log:
> Try to run and investigate the mips-mti-linux.c test failure on ARM buildbots.

Hi Vasileios,

Please, don't do this. If you need investigation, you can ask the bot
owner (me) to help you.

For now, if you haven't fixed the issue yet, please revert this and
your previous commit.

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


r251696 - Revert "Try to run and investigate the mips-mti-linux.c test failure on ARM buildbots."

2015-10-30 Thread Renato Golin via cfe-commits
Author: rengolin
Date: Fri Oct 30 06:12:36 2015
New Revision: 251696

URL: http://llvm.org/viewvc/llvm-project?rev=251696&view=rev
Log:
Revert "Try to run and investigate the mips-mti-linux.c test failure on ARM 
buildbots."

This reverts commit r251695. Debug is meant to be done off tree, not use the 
buildbots
experiments. I'll help investigate this problem off trunk.

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/mips-mti-linux.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=251696&r1=251695&r2=251696&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Oct 30 06:12:36 2015
@@ -8469,19 +8469,6 @@ void gnutools::Linker::ConstructJob(Comp
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crt1)));
 
   CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crti.o")));
-
-  if (ToolChain.getTriple().getVendor() == llvm::Triple::MipsTechnologies 
&&
-  !ToolChain.getTriple().hasEnvironment()) {
-// Print look-up paths for crt files.
-llvm::errs() << "Looked for crti.o in: ";
-llvm::errs() << " PrefixDirs  - ";
-for (const std::string &Dir : D.PrefixDirs)
-  llvm::errs() << "Dir: " << Dir << ", ";
-llvm::errs() << " TC.getFilePaths()  - ";
-for (const std::string &Dir : ToolChain.getFilePaths())
-  llvm::errs() << "Dir: " << Dir << ",";
-llvm::errs() << "\n";
-  }
 }
 
 const char *crtbegin;

Modified: cfe/trunk/test/Driver/mips-mti-linux.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-mti-linux.c?rev=251696&r1=251695&r2=251696&view=diff
==
--- cfe/trunk/test/Driver/mips-mti-linux.c (original)
+++ cfe/trunk/test/Driver/mips-mti-linux.c Fri Oct 30 06:12:36 2015
@@ -5,15 +5,14 @@
 //Ideally, we'd like to have an --llvm-toolchain option similar to
 //the --gcc-toolchain one.
 
-// XFAIL: i386, i686, x86_64, win32, win64, powerpc64, s390x, r600, xcore, 
hexagon, sparc, darwin, asan, msan
+// RUN: false
+// XFAIL: *
 
 // = Big-endian, mips32r2, hard float
-// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=mips-mti-linux -mips32r2 -mhard-float \
-// RUN: --sysroot=%S/Inputs/mips_mti_linux/sysroot \
-// RUN:   | FileCheck --check-prefix=CHECK-BE-HF-32R2 %s
-//
-// CHECK-BE-HF-32R2: Looked for crt1.o
+// R!N: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// R!N: --target=mips-mti-linux -mips32r2 -mhard-float \
+// R!N: --sysroot=%S/Inputs/mips_mti_linux/sysroot \
+// R!N:   | FileCheck --check-prefix=CHECK-BE-HF-32R2 %s
 //
 // CHECK-BE-HF-32R2: "{{[^"]*}}clang{{[^"]*}}" {{.*}} "-triple" 
"mips-mti-linux"
 // CHECK-BE-HF-32R2-SAME: "-fuse-init-array" "-target-cpu" "mips32r2"


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


r251697 - Revert r251621 "[Analyzer] Widening loops which do not exit" (bot failure)

2015-10-30 Thread Sean Eveson via cfe-commits
Author: seaneveson
Date: Fri Oct 30 06:13:07 2015
New Revision: 251697

URL: http://llvm.org/viewvc/llvm-project?rev=251697&view=rev
Log:
Revert r251621 "[Analyzer] Widening loops which do not exit" (bot failure)

Seems to be causing clang-cmake-mips build bot to fail (timeout)

http://lab.llvm.org:8011/builders/clang-cmake-mips/builds/10299

Removed:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h
cfe/trunk/lib/StaticAnalyzer/Core/LoopWidening.cpp
cfe/trunk/test/Analysis/loop-widening.c
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/Analysis/analyzer-config.c
cfe/trunk/test/Analysis/analyzer-config.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h?rev=251697&r1=251696&r2=251697&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Fri Oct 30 
06:13:07 2015
@@ -262,9 +262,6 @@ private:
   /// \sa shouldInlineLambdas
   Optional InlineLambdas;
 
-  /// \sa shouldWidenLoops
-  Optional WidenLoops;
-
   /// A helper function that retrieves option for a given full-qualified
   /// checker name.
   /// Options for checkers can be specified via 'analyzer-config' command-line
@@ -529,10 +526,6 @@ public:
   /// generated each time a LambdaExpr is visited.
   bool shouldInlineLambdas();
 
-  /// Returns true if the analysis should try to widen loops.
-  /// This is controlled by the 'widen-loops' config option.
-  bool shouldWidenLoops();
-
 public:
   AnalyzerOptions() :
 AnalysisStoreOpt(RegionStoreModel),

Removed: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h?rev=251696&view=auto
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h 
(removed)
@@ -1,37 +0,0 @@
-//===--- LoopWidening.h - Instruction class definition --*- C++ 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-///
-/// This header contains the declarations of functions which are used to widen
-/// loops which do not otherwise exit. The widening is done by invalidating
-/// anything which might be modified by the body of the loop.
-///
-//===--===//
-
-#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_LOOPWIDENING_H
-#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_LOOPWIDENING_H
-
-#include "clang/Analysis/CFG.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
-
-namespace clang {
-namespace ento {
-
-/// \brief Get the states that result from widening the loop.
-///
-/// Widen the loop by invalidating anything that might be modified
-/// by the loop body in any iteration.
-ProgramStateRef getWidenedLoopState(ProgramStateRef PrevState,
-const LocationContext *LCtx,
-unsigned BlockCount,
-const Stmt *LoopStmt);
-
-} // end namespace ento
-} // end namespace clang
-
-#endif

Modified: cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp?rev=251697&r1=251696&r2=251697&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp Fri Oct 30 06:13:07 
2015
@@ -338,9 +338,3 @@ bool AnalyzerOptions::shouldInlineLambda
 InlineLambdas = getBooleanOption("inline-lambdas", /*Default=*/true);
   return InlineLambdas.getValue();
 }
-
-bool AnalyzerOptions::shouldWidenLoops() {
-  if (!WidenLoops.hasValue())
-WidenLoops = getBooleanOption("widen-loops", /*Default=*/false);
-  return WidenLoops.getValue();
-}

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt?rev=251697&r1=251696&r2=251697&view=diff
==
--- cfe/trunk/lib/Sta

r251698 - Revert "[mips] Add support for the new mips-mti-linux toolchain."

2015-10-30 Thread Vasileios Kalintiris via cfe-commits
Author: vkalintiris
Date: Fri Oct 30 06:28:39 2015
New Revision: 251698

URL: http://llvm.org/viewvc/llvm-project?rev=251698&view=rev
Log:
Revert "[mips] Add support for the new mips-mti-linux toolchain."

This reverts commits r251633. I'll investigate the test failure off trunk in
order to keep the buildbots clean.

Removed:

cfe/trunk/test/Driver/Inputs/mips_mti_linux/lib/clang/3.8.0/mips-r2-hard-musl/lib/linux/libclang_rt.builtins-mips.a

cfe/trunk/test/Driver/Inputs/mips_mti_linux/lib/clang/3.8.0/mips-r2-hard-musl/lib/linux/libclang_rt.builtins-mips.so

cfe/trunk/test/Driver/Inputs/mips_mti_linux/lib/clang/3.8.0/mipsel-r2-hard-musl/lib/linux/libclang_rt.builtins-mipsel.a

cfe/trunk/test/Driver/Inputs/mips_mti_linux/lib/clang/3.8.0/mipsel-r2-hard-musl/lib/linux/libclang_rt.builtins-mipsel.so

cfe/trunk/test/Driver/Inputs/mips_mti_linux/sysroot/mips-r2-hard-musl/usr/lib/crt1.o

cfe/trunk/test/Driver/Inputs/mips_mti_linux/sysroot/mips-r2-hard-musl/usr/lib/crti.o

cfe/trunk/test/Driver/Inputs/mips_mti_linux/sysroot/mips-r2-hard-musl/usr/lib/crtn.o

cfe/trunk/test/Driver/Inputs/mips_mti_linux/sysroot/mipsel-r2-hard-musl/usr/lib/crt1.o

cfe/trunk/test/Driver/Inputs/mips_mti_linux/sysroot/mipsel-r2-hard-musl/usr/lib/crti.o

cfe/trunk/test/Driver/Inputs/mips_mti_linux/sysroot/mipsel-r2-hard-musl/usr/lib/crtn.o
cfe/trunk/test/Driver/mips-mti-linux.c
Modified:
cfe/trunk/lib/Driver/Driver.cpp
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/lib/Driver/Tools.h

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=251698&r1=251697&r2=251698&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Oct 30 06:28:39 2015
@@ -2153,11 +2153,6 @@ void Driver::generatePrefixedToolNames(
   // FIXME: Needs a better variable than DefaultTargetTriple
   Names.emplace_back(DefaultTargetTriple + "-" + Tool);
   Names.emplace_back(Tool);
-
-  // Allow the discovery of tools prefixed with LLVM's default target triple.
-  std::string LLVMDefaultTargetTriple = llvm::sys::getDefaultTargetTriple();
-  if (LLVMDefaultTargetTriple != DefaultTargetTriple)
-Names.emplace_back(LLVMDefaultTargetTriple + "-" + Tool);
 }
 
 static bool ScanDirForExecutable(SmallString<128> &Dir,
@@ -2253,9 +2248,6 @@ const ToolChain &Driver::getToolChain(co
 case llvm::Triple::Linux:
   if (Target.getArch() == llvm::Triple::hexagon)
 TC = new toolchains::HexagonToolChain(*this, Target, Args);
-  else if ((Target.getVendor() == llvm::Triple::MipsTechnologies) &&
-   !Target.hasEnvironment())
-TC = new toolchains::MipsLLVMToolChain(*this, Target, Args);
   else
 TC = new toolchains::Linux(*this, Target, Args);
   break;

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=251698&r1=251697&r2=251698&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Fri Oct 30 06:28:39 2015
@@ -333,6 +333,7 @@ Tool *ToolChain::SelectTool(const JobAct
 
 std::string ToolChain::GetFilePath(const char *Name) const {
   return D.GetFilePath(Name, *this);
+
 }
 
 std::string ToolChain::GetProgramPath(const char *Name) const {

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=251698&r1=251697&r2=251698&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Oct 30 06:28:39 2015
@@ -1294,9 +1294,8 @@ bool Generic_GCC::GCCInstallationDetecto
   "i586-linux-gnu"};
 
   static const char *const MIPSLibDirs[] = {"/lib"};
-  static const char *const MIPSTriples[] = {"mips-linux-gnu", "mips-mti-linux",
-"mips-mti-linux-gnu",
-"mips-img-linux-gnu"};
+  static const char *const MIPSTriples[] = {
+  "mips-linux-gnu", "mips-mti-linux-gnu", "mips-img-linux-gnu"};
   static const char *const MIPSELLibDirs[] = {"/lib"};
   static const char *const MIPSELTriples[] = {
   "mipsel-linux-gnu", "mipsel-linux-android", "mips-img-linux-gnu"};
@@ -1687,32 +1686,6 @@ static bool findMIPSMultilibs(const Driv
 });
   }
 
-  // Check for Musl toolchain multilibs
-  MultilibSet MuslMipsMultilibs;
-  {
-auto MArchMipsR2 = makeMultilib("")
-   .osSuffix("/mips-r2-hard-musl")
-   .flag("+EB")
-   .flag("-EL")
-   

Re: [PATCH] D14184: [clang] Add initial support for -meabi flag

2015-10-30 Thread Renato Golin via cfe-commits
rengolin added reviewers: jroelofs, t.p.northover.
rengolin added subscribers: jroelofs, t.p.northover.
rengolin added a comment.

You forgot to add the context. It makes a big difference in the driver code. :)

But overall, looks good to me.

@jroelofs @compnerd @t.p.northover, can you see anything that might impact your 
workloads?

cheers,
--renato


Repository:
  rL LLVM

http://reviews.llvm.org/D14184



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


RE: r251695 - Try to run and investigate the mips-mti-linux.c test failure on ARM buildbots.

2015-10-30 Thread Vasileios Kalintiris via cfe-commits
Hi Renato,

> Please, don't do this. If you need investigation, you can ask the bot owner 
> (me) to help you.

I'm sorry for any inconvenience I might have caused. I was waiting to commit 
this early in the morning, near the end of the week, when the commit activity 
is low.

> For now, if you haven't fixed the issue yet, please revert this and your 
> previous commit.

I reverted the previous commit. I'd appreciate your help with this issue, I'll 
send you an email later to explain the problem and I'll try to come up with a 
patch that prints as many debug info as possible.

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


Re: r251695 - Try to run and investigate the mips-mti-linux.c test failure on ARM buildbots.

2015-10-30 Thread Renato Golin via cfe-commits
On 30 October 2015 at 11:42, Vasileios Kalintiris
 wrote:
> I'm sorry for any inconvenience I might have caused. I was waiting to commit 
> this early in the morning, near the end of the week, when the commit activity 
> is low.

This shouldn't be done even during weekends or low commit activity.

Your new commit broke all the other bots, not just the one that was
broken, and that could have caused a chain reaction of breakages and
I'd have to clean it up. I have had to deal with problems like these
quite a few times this year, so I'd appreciate if we didn't create
that intentionally.


> I reverted the previous commit. I'd appreciate your help with this issue, 
> I'll send you an email later to explain the problem and I'll try to come up 
> with a patch that prints as many debug info as possible.

No worries, I'll be waiting your email.

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


[PATCH] D14198: Make the modernize-loop-convert's const-detection smarter.

2015-10-30 Thread Angel Garcia via cfe-commits
angelgarcia created this revision.
angelgarcia added a reviewer: klimek.
angelgarcia added subscribers: alexfh, cfe-commits.

Now, it detects that several kinds of usages are can't modify the elements. 
Examples:
-When an usage is a call to a const member function or operator of the element.
-If the element is used as an argument to a function or constructor that takes 
a const-reference or a value.
-LValue to RValue conversion, if the element is a fundamental type (which 
allows the use of most of the builtin operators).

http://reviews.llvm.org/D14198

Files:
  clang-tidy/modernize/LoopConvertCheck.cpp
  test/clang-tidy/modernize-loop-convert-basic.cpp
  test/clang-tidy/modernize-loop-convert-camelback.cpp
  test/clang-tidy/modernize-loop-convert-const.cpp
  test/clang-tidy/modernize-loop-convert-extra.cpp
  test/clang-tidy/modernize-loop-convert-lowercase.cpp
  test/clang-tidy/modernize-loop-convert-uppercase.cpp

Index: test/clang-tidy/modernize-loop-convert-uppercase.cpp
===
--- test/clang-tidy/modernize-loop-convert-uppercase.cpp
+++ test/clang-tidy/modernize-loop-convert-uppercase.cpp
@@ -14,61 +14,61 @@
 printf("%d\n", ARR[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead [modernize-loop-convert]
-  // CHECK-FIXES: for (int & ELEM : ARR)
+  // CHECK-FIXES: for (int ELEM : ARR)
   // CHECK-FIXES-NEXT: printf("%d\n", ELEM);
 
   for (int I = 0; I < N; ++I) {
 printf("%d\n", NUMS[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & NUM : NUMS)
+  // CHECK-FIXES: for (int NUM : NUMS)
   // CHECK-FIXES-NEXT: printf("%d\n", NUM);
 
   for (int I = 0; I < N; ++I) {
 printf("%d\n", NUMS_[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & NUM : NUMS_)
+  // CHECK-FIXES: for (int NUM : NUMS_)
   // CHECK-FIXES-NEXT: printf("%d\n", NUM);
 
   int NUM = 0;
   for (int I = 0; I < N; ++I) {
 printf("%d\n", NUMS[I] + NUM);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & ELEM : NUMS)
+  // CHECK-FIXES: for (int ELEM : NUMS)
   // CHECK-FIXES-NEXT: printf("%d\n", ELEM + NUM);
 
   int ELEM = 0;
   for (int I = 0; I < N; ++I) {
 printf("%d\n", NUMS[I] + NUM + ELEM);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & NUMS_I : NUMS)
+  // CHECK-FIXES: for (int NUMS_I : NUMS)
   // CHECK-FIXES-NEXT: printf("%d\n", NUMS_I + NUM + ELEM);
 
   int NUMS_I = 0;
   for (int I = 0; I < N; ++I) {
 printf("%d\n", NUMS[I] + NUM + ELEM + NUMS_I);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & NUMS_ELEM : NUMS)
+  // CHECK-FIXES: for (int NUMS_ELEM : NUMS)
   // CHECK-FIXES-NEXT: printf("%d\n", NUMS_ELEM + NUM + ELEM + NUMS_I);
 
   int NUMS_ELEM = 0;
   for (int I = 0; I < N; ++I) {
 printf("%d\n", NUMS[I] + NUM + ELEM + NUMS_I + NUMS_ELEM);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & GIVE_ME_NAME_0 : NUMS)
+  // CHECK-FIXES: for (int GIVE_ME_NAME_0 : NUMS)
   // CHECK-FIXES-NEXT: printf("%d\n", GIVE_ME_NAME_0 + NUM + ELEM + NUMS_I + NUMS_ELEM);
 
   int GIVE_ME_NAME_0 = 0;
   for (int I = 0; I < N; ++I) {
 printf("%d\n", NUMS[I] + NUM + ELEM + NUMS_I + NUMS_ELEM + GIVE_ME_NAME_0);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & GIVE_ME_NAME_1 : NUMS)
+  // CHECK-FIXES: for (int GIVE_ME_NAME_1 : NUMS)
   // CHECK-FIXES-NEXT: printf("%d\n", GIVE_ME_NAME_1 + NUM + ELEM + NUMS_I + NUMS_ELEM + GIVE_ME_NAME_0);
 
   int NUMS_J = 0;
@@ -79,7 +79,7 @@
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
   // CHECK-MESSAGES: :[[@LINE-5]]:5: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int & GIVE_ME_NAME_0 : NUMS)
-  // CHECK-FIXES: for (int & GIVE_ME_NAME_1 : NUMS)
+  // CHECK-FIXES: for (int GIVE_ME_NAME_0 : NUMS)
+  // CHECK-FIXES: for (int GIVE_ME_NAME_1 : NUMS)
   // CHECK-FIXES-NEXT: printf("%d\n", GIVE_ME_NAME_0 + GIVE_ME_NAME_1 + NUM + ELEM + NUMS_I + NUMS_J + NUMS_ELEM);
 }
Index: test/clang-tidy/modernize-loop-convert-lowercase.cpp
===
--- test/clang-tidy/modernize-loop-convert-lowercase.cpp
+++ test/clang-tidy/modernize-loop-convert-lowercase.cpp
@@ -14,61 +14,61 @@
 printf("%d\n", arr[i]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead [modernize-loop-convert]
-  // CHECK-FIXES: for (int & elem : arr)
+  // CHECK-FIXES: for (int elem : arr)
   // CHECK-FIXES-NEXT: printf("%d\n", elem);
 
   for (int i = 0; i < n; ++i) {
 printf("%d\n", nums[i]);
   }
   // CHECK-MESSAG

Re: [PATCH] D14184: [clang] Add initial support for -meabi flag

2015-10-30 Thread Vinicius Tinti via cfe-commits
tinti removed rL LLVM as the repository for this revision.
tinti updated this revision to Diff 38803.
tinti added a comment.

Add context


http://reviews.llvm.org/D14184

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/BackendUtil.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/arm-eabi.c
  test/Driver/eabi.c

Index: test/Driver/eabi.c
===
--- /dev/null
+++ test/Driver/eabi.c
@@ -0,0 +1,15 @@
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-DEFAULT %s
+// RUN: %clang %s -meabi default -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-DEFAULT %s
+// RUN: %clang %s -meabi 4 -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-EABI4 %s
+// RUN: %clang %s -meabi 5 -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-EABI5 %s
+// RUN: %clang %s -meabi gnu -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-GNUEABI %s
+
+// CHECK-DEFAULT: "-meabi" "default"
+// CHECK-EABI4: "-meabi" "4"
+// CHECK-EABI5: "-meabi" "5"
+// CHECK-GNUEABI: "-meabi" "gnu"
Index: test/CodeGen/arm-eabi.c
===
--- /dev/null
+++ test/CodeGen/arm-eabi.c
@@ -0,0 +1,20 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang -target arm-none-eabi -S -o - %s | FileCheck -check-prefix=CHECK-EABI %s
+// RUN: %clang -target arm-none-eabi -S -meabi gnu -o - %s | FileCheck -check-prefix=CHECK-GNUEABI %s
+// RUN: %clang -target arm-none-eabihf -S -o - %s | FileCheck -check-prefix=CHECK-EABI %s
+// RUN: %clang -target arm-none-eabihf -S -meabi gnu -o - %s | FileCheck -check-prefix=CHECK-GNUEABI %s
+// RUN: %clang -target arm-none-gnueabi -S -o - %s | FileCheck -check-prefix=CHECK-GNUEABI %s
+// RUN: %clang -target arm-none-gnueabi -S -meabi 5 -o - %s | FileCheck -check-prefix=CHECK-EABI %s
+// RUN: %clang -target arm-none-gnueabihf -S -o - %s | FileCheck -check-prefix=CHECK-GNUEABI %s
+// RUN: %clang -target arm-none-gnueabihf -S -meabi 5 -o - %s | FileCheck -check-prefix=CHECK-EABI %s
+
+struct my_s {
+  unsigned long a[18];
+};
+
+// CHECK-LABEL: foo
+// CHECK-EABI: bl __aeabi_memcpy4
+// CHECK-GNUEABI: bl memcpy
+void foo(unsigned long *t) {
+  *(struct my_s *)t = *((struct my_s *)(1UL));
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -453,6 +453,20 @@
   Opts.DisableFree = Args.hasArg(OPT_disable_free);
   Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);
   Opts.FloatABI = Args.getLastArgValue(OPT_mfloat_abi);
+  if (Arg *A = Args.getLastArg(OPT_meabi)) {
+StringRef Value = A->getValue();
+bool Valid = llvm::StringSwitch(Value)
+  .Case("default", true)
+  .Case("gnu", true)
+  .Case("4",   true)
+  .Case("5",   true)
+  .Default(false);
+if (!Valid)
+  Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args)
+  << Value;
+else
+  Opts.EABIVersion = Value;
+  }
   Opts.LessPreciseFPMAD = Args.hasArg(OPT_cl_mad_enable);
   Opts.LimitFloatPrecision = Args.getLastArgValue(OPT_mlimit_float_precision);
   Opts.NoInfsFPMath = (Args.hasArg(OPT_menable_no_infinities) ||
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3385,6 +3385,12 @@
 }
   }
 
+  CmdArgs.push_back("-meabi");
+  if (Arg *A = Args.getLastArg(options::OPT_meabi))
+CmdArgs.push_back(A->getValue());
+  else
+CmdArgs.push_back("default");
+
   CmdArgs.push_back("-mthread-model");
   if (Arg *A = Args.getLastArg(options::OPT_mthread_model))
 CmdArgs.push_back(A->getValue());
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -515,6 +515,15 @@
   Options.UseInitArray = CodeGenOpts.UseInitArray;
   Options.DisableIntegratedAS = CodeGenOpts.DisableIntegratedAS;
   Options.CompressDebugSections = CodeGenOpts.CompressDebugSections;
+
+  // Set EABI version.
+  Options.EABIVersion =
+llvm::StringSwitch(CodeGenOpts.EABIVersion)
+  .Case("4",   llvm::EABI::Eabi4)
+  .Case("5",   llvm::EABI::Eabi5)
+  .Case("gnu", llvm::EABI::Gnu)
+  .Default(llvm::EABI::Default);
+
   Options.LessPreciseFPMADOption = CodeGenOpts.LessPreciseFPMAD;
   Options.NoInfsFPMath = CodeGenOpts.NoInfsFPMath;
   Options.NoNaNsFPMath = CodeGenOpts.NoNaNsFPMath;
Index: include/clang/Frontend/CodeGenOptions.h
===
--- include/clang/Frontend/CodeGenOptions.h
+++ include/clang/Frontend/CodeGenOptions.h
@@ -167,6 +167,9 @@
   /// Name of the profile file to use as input for -fprofile-instr-use
   std::string I

Re: [PATCH] D14184: [clang] Add initial support for -meabi flag

2015-10-30 Thread Saleem Abdulrasool via cfe-commits
compnerd added a comment.

This looks like what I had in mind wrt use of `-meabi`.



Comment at: lib/CodeGen/BackendUtil.cpp:524
@@ +523,3 @@
+  .Case("5",   llvm::EABI::Eabi5)
+  .Case("gnu", llvm::EABI::Gnu)
+  .Default(llvm::EABI::Default);

I'd really rather see this written in the LLVM Style:

EABI4, EABI5, GNU

since all of them are initialisms.

BTW, please clang-format this change.


Comment at: lib/Frontend/CompilerInvocation.cpp:458
@@ +457,3 @@
+StringRef Value = A->getValue();
+bool Valid = llvm::StringSwitch(Value)
+  .Case("default", true)

If `llvm::EABI::EABIVersionType` had an `Invalid` value in the enumeration, you 
could convert directly to the value here, and report the error if the value was 
`Invalid`.


http://reviews.llvm.org/D14184



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


Re: [PATCH] D14188: Format: support inline namespaces

2015-10-30 Thread Saleem Abdulrasool via cfe-commits
compnerd closed this revision.
compnerd added a comment.

SVN r251690 with the mod.


http://reviews.llvm.org/D14188



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


r251701 - clang/module.modulemap: Exclude Frontend/PCHContainerOperations.h in Clang_Frontend.

2015-10-30 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Fri Oct 30 10:14:55 2015
New Revision: 251701

URL: http://llvm.org/viewvc/llvm-project?rev=251701&view=rev
Log:
clang/module.modulemap: Exclude Frontend/PCHContainerOperations.h in 
Clang_Frontend.

FIXME: It should be dissolved to interface and impl.

Modified:
cfe/trunk/include/clang/module.modulemap

Modified: cfe/trunk/include/clang/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/module.modulemap?rev=251701&r1=251700&r2=251701&view=diff
==
--- cfe/trunk/include/clang/module.modulemap (original)
+++ cfe/trunk/include/clang/module.modulemap Fri Oct 30 10:14:55 2015
@@ -90,6 +90,9 @@ module Clang_Frontend {
   textual header "Frontend/LangStandards.def"
 
   module * { export * }
+
+  // FIXME: This violates layers.
+  exclude header "Frontend/PCHContainerOperations.h"
 }
 
 module Clang_FrontendTool { requires cplusplus umbrella "FrontendTool" module 
* { export * } }


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


r251702 - Reapply r251621 "[Analyzer] Widening loops which do not exit"

2015-10-30 Thread Sean Eveson via cfe-commits
Author: seaneveson
Date: Fri Oct 30 10:23:57 2015
New Revision: 251702

URL: http://llvm.org/viewvc/llvm-project?rev=251702&view=rev
Log:
Reapply r251621 "[Analyzer] Widening loops which do not exit"

It was not the cause of the build bot failure.

Added:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h
  - copied unchanged from r251696, 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h
cfe/trunk/lib/StaticAnalyzer/Core/LoopWidening.cpp
  - copied unchanged from r251696, 
cfe/trunk/lib/StaticAnalyzer/Core/LoopWidening.cpp
cfe/trunk/test/Analysis/loop-widening.c
  - copied unchanged from r251696, cfe/trunk/test/Analysis/loop-widening.c
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/Analysis/analyzer-config.c
cfe/trunk/test/Analysis/analyzer-config.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h?rev=251702&r1=251701&r2=251702&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Fri Oct 30 
10:23:57 2015
@@ -262,6 +262,9 @@ private:
   /// \sa shouldInlineLambdas
   Optional InlineLambdas;
 
+  /// \sa shouldWidenLoops
+  Optional WidenLoops;
+
   /// A helper function that retrieves option for a given full-qualified
   /// checker name.
   /// Options for checkers can be specified via 'analyzer-config' command-line
@@ -526,6 +529,10 @@ public:
   /// generated each time a LambdaExpr is visited.
   bool shouldInlineLambdas();
 
+  /// Returns true if the analysis should try to widen loops.
+  /// This is controlled by the 'widen-loops' config option.
+  bool shouldWidenLoops();
+
 public:
   AnalyzerOptions() :
 AnalysisStoreOpt(RegionStoreModel),

Modified: cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp?rev=251702&r1=251701&r2=251702&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp Fri Oct 30 10:23:57 
2015
@@ -338,3 +338,9 @@ bool AnalyzerOptions::shouldInlineLambda
 InlineLambdas = getBooleanOption("inline-lambdas", /*Default=*/true);
   return InlineLambdas.getValue();
 }
+
+bool AnalyzerOptions::shouldWidenLoops() {
+  if (!WidenLoops.hasValue())
+WidenLoops = getBooleanOption("widen-loops", /*Default=*/false);
+  return WidenLoops.getValue();
+}

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt?rev=251702&r1=251701&r2=251702&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt Fri Oct 30 10:23:57 2015
@@ -28,6 +28,7 @@ add_clang_library(clangStaticAnalyzerCor
   ExprEngineObjC.cpp
   FunctionSummary.cpp
   HTMLDiagnostics.cpp
+  LoopWidening.cpp
   MemRegion.cpp
   PathDiagnostic.cpp
   PlistDiagnostics.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=251702&r1=251701&r2=251702&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Fri Oct 30 10:23:57 2015
@@ -26,6 +26,7 @@
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h"
 #include "llvm/ADT/ImmutableList.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/raw_ostream.h"
@@ -1395,8 +1396,25 @@ void ExprEngine::processCFGBlockEntrance
  ExplodedNode *Pred) {
   PrettyStackTraceLocationContext CrashInfo(Pred->getLocationContext());
 
+  // If this block is terminated by a loop and it has already been visited the
+  // maximum number of times, widen the loop.
+  unsigned int BlockCount = nodeBuilder.getContext().blockCount();
+  if (BlockCount == AMgr.options.maxBlockVisitOnPath - 1 &&
+  AMgr.options.shouldWidenLoops()) {
+const Stmt *Term = nodeBuilder.getContext().getBlock()->getTerminator();
+if (!(Term &&
+  (is

[PATCH] D14203: [analyzer] Improve pointer arithmetic checker.

2015-10-30 Thread Gábor Horváth via cfe-commits
xazax.hun created this revision.
xazax.hun added reviewers: zaks.anna, dcoughlin.
xazax.hun added subscribers: cfe-commits, dkrupp.

This patch is intended to improve pointer arithmetic checker.

>From now on it tries to only warn, when the pointer arithmetic is likely to 
>cause an error. For example when the pointer points to a single object, or an 
>array of derived types.

Note that this check does not free the stored information right now, because it 
caused some trouble when I was checking the following code.

struct trie {
  struct trie* next;
};

struct kwset {
  struct trie *trie;
  unsigned char y[10];
  struct trie* next[10];
  int d;
};

typedef struct trie trie_t;
typedef struct kwset kwset_t;

void f(kwset_t *kws, char const *p, char const *q) {
  struct trie const *trie;
  struct trie * const *next = kws->next;
  register unsigned char c;
  register char const *end = p;
  register char const *lim = q;
  register int d = 1;
  register unsigned char const *y = kws->y;

  d = y[c = (end+=d)[-1]];
  trie = next[c]; // Here the analyzer tought that kws->next is a dead region, 
so the stored information was unavailable for the array. adding a kws = 0 or 
similar line to the end of the function fixed the problem. Is this a bug in 
liveness analysis fo regions?
}


http://reviews.llvm.org/D14203

Files:
  PointerArithm.patch
  lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp
  test/Analysis/PR24184.cpp
  test/Analysis/fields.c
  test/Analysis/ptr-arith.c
  test/Analysis/ptr-arith.cpp
  test/Analysis/rdar-6442306-1.m

Index: test/Analysis/rdar-6442306-1.m
===
--- test/Analysis/rdar-6442306-1.m
+++ test/Analysis/rdar-6442306-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core %s -analyzer-store=region -verify
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-disable-checker=alpha.core.PointerArithm %s -analyzer-store=region -verify
 // expected-no-diagnostics
 
 typedef int bar_return_t;
Index: test/Analysis/ptr-arith.cpp
===
--- test/Analysis/ptr-arith.cpp
+++ test/Analysis/ptr-arith.cpp
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify %s
-// expected-no-diagnostics
+// RUN: %clang_cc1 -Wno-unused-value -std=c++14 -analyze -analyzer-checker=core,debug.ExprInspection,alpha.core.PointerArithm -verify %s
 struct X {
   int *p;
   int zero;
@@ -20,3 +19,74 @@
   return 5/littleX.zero; // no-warning
 }
 
+
+class Base {};
+class Derived : public Base {};
+
+void checkPolymorphicUse() {
+  Derived d[10];
+
+  Base *p = d;
+  ++p; // expected-warning{{Pointer arithmetic does not account for polymorphic object sizes and attempting to}}
+}
+
+void checkBitCasts() {
+  long l;
+  char *p = (char*)&l;
+  p = p+2;
+}
+
+void checkBasicarithmetic() {
+  int t[10];
+  int *p = t;
+  ++p;
+  int a = 5;
+  p = &a;
+  ++p; // expected-warning{{Pointer arithmetic done on non-array variables means reliance on memory layout, which is dangerous}}
+  p = p + 2; // expected-warning{{}}
+  p = 2 + p; // expected-warning{{}}
+  p += 2; // expected-warning{{}}
+  a += p[2]; // expected-warning{{}}
+}
+
+void checkArithOnSymbolic(int*p) {
+  ++p;
+  p = p + 2;
+  p = 2 + p;
+  p += 2;
+  (void)p[2];
+}
+
+struct S {
+  int t[10];
+};
+
+void arrayInStruct() {
+  S s;
+  int * p = s.t;
+  ++p;
+  S *sp = new S;
+  p = sp->t;
+  ++p;
+  delete sp;
+}
+
+void InitState(int* state) {
+state[1] = 1; // expected-warning{{}}
+}
+
+int* getArray(int size) {
+if (size == 0)
+  return new int;
+return new int[5];
+}
+
+void checkConditionalArray() {
+int* maybeArray = getArray(0);
+InitState(maybeArray);
+}
+
+void checkMultiDimansionalArray() {
+  int a[5][5];
+   *(*(a+1)+2) = 2;
+}
Index: test/Analysis/ptr-arith.c
===
--- test/Analysis/ptr-arith.c
+++ test/Analysis/ptr-arith.c
@@ -75,7 +75,7 @@
   clang_analyzer_eval(&a != 0); // expected-warning{{TRUE}}
   clang_analyzer_eval(&a >= 0); // expected-warning{{TRUE}}
   clang_analyzer_eval(&a > 0); // expected-warning{{TRUE}}
-  clang_analyzer_eval((&a - 0) != 0); // expected-warning{{TRUE}} expected-warning{{Pointer arithmetic done on non-array variables}}
+  clang_analyzer_eval((&a - 0) != 0); // expected-warning{{TRUE}}
 
   // LHS is NULL, RHS is non-symbolic
   // The same code is used for labels and non-symbolic values.
Index: test/Analysis/fields.c
===
--- test/Analysis/fields.c
+++ test/Analysis/fields.c
@@ -16,7 +16,7 @@
 
 void f() {
   struct s a;
-  int *p = &(a.n) + 1;
+  int *p = &(a.n) + 1; // expected-warning{{Pointer arithmetic done}}
 }
 
 typedef struct {
Index: test/Analysis/PR24184.cpp
===
--- test/Analysis/PR24184.cpp
+++ te

[PATCH] D14205: [x86] Front-end part of MCU psABI support

2015-10-30 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added reviewers: rnk, DavidKreitzer, mkuper.
andreybokhanko added a subscriber: cfe-commits.

This patch implements front-end parts of MCU psABI 
(https://docs.google.com/viewer?a=v&pid=sites&srcid=ZGVmYXVsdGRvbWFpbnx4MzJhYml8Z3g6NzFhMGYzMjUzZDQzODllMw)
 support:

1) "long double type is the same as double."
2) "New predefined C/C++ pre-processor symbols: __iamcu and __iamcu__.

http://reviews.llvm.org/D14205

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/x86_32-arguments-iamcu.c
  test/Preprocessor/elfiamcu-predefines.c

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2319,7 +2319,8 @@
 public:
   X86TargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) {
 BigEndian = false;
-LongDoubleFormat = &llvm::APFloat::x87DoubleExtended;
+LongDoubleFormat = Triple.isOSIAMCU() ? &llvm::APFloat::IEEEdouble
+  : &llvm::APFloat::x87DoubleExtended;
   }
   unsigned getFloatEvalMethod() const override {
 // X87 evaluates with 80 bits "long double" precision.
@@ -3354,6 +3355,11 @@
   }
   if (CPU >= CK_i586)
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
+
+  if (getTriple().isOSIAMCU()) {
+Builder.defineMacro("__iamcu");
+Builder.defineMacro("__iamcu__");
+  }
 }
 
 bool X86TargetInfo::hasFeature(StringRef Feature) const {
Index: test/CodeGen/x86_32-arguments-iamcu.c
===
--- test/CodeGen/x86_32-arguments-iamcu.c
+++ test/CodeGen/x86_32-arguments-iamcu.c
@@ -56,3 +56,7 @@
 // insane.
 // CHECK-LABEL: define i32 @varArgs(i32 inreg %i1, ...)
 int varArgs(int i1, ...) { return i1; }
+
+// CHECK-LABEL: define double @longDoubleArg(double %ld1)
+long double longDoubleArg(long double ld1) { return ld1; }
+
Index: test/Preprocessor/elfiamcu-predefines.c
===
--- test/Preprocessor/elfiamcu-predefines.c
+++ test/Preprocessor/elfiamcu-predefines.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -E -dM -triple i586-intel-elfiamcu | FileCheck %s
+
+// CHECK: #define __iamcu
+// CHECK: #define __iamcu__
+


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2319,7 +2319,8 @@
 public:
   X86TargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) {
 BigEndian = false;
-LongDoubleFormat = &llvm::APFloat::x87DoubleExtended;
+LongDoubleFormat = Triple.isOSIAMCU() ? &llvm::APFloat::IEEEdouble
+  : &llvm::APFloat::x87DoubleExtended;
   }
   unsigned getFloatEvalMethod() const override {
 // X87 evaluates with 80 bits "long double" precision.
@@ -3354,6 +3355,11 @@
   }
   if (CPU >= CK_i586)
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
+
+  if (getTriple().isOSIAMCU()) {
+Builder.defineMacro("__iamcu");
+Builder.defineMacro("__iamcu__");
+  }
 }
 
 bool X86TargetInfo::hasFeature(StringRef Feature) const {
Index: test/CodeGen/x86_32-arguments-iamcu.c
===
--- test/CodeGen/x86_32-arguments-iamcu.c
+++ test/CodeGen/x86_32-arguments-iamcu.c
@@ -56,3 +56,7 @@
 // insane.
 // CHECK-LABEL: define i32 @varArgs(i32 inreg %i1, ...)
 int varArgs(int i1, ...) { return i1; }
+
+// CHECK-LABEL: define double @longDoubleArg(double %ld1)
+long double longDoubleArg(long double ld1) { return ld1; }
+
Index: test/Preprocessor/elfiamcu-predefines.c
===
--- test/Preprocessor/elfiamcu-predefines.c
+++ test/Preprocessor/elfiamcu-predefines.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -E -dM -triple i586-intel-elfiamcu | FileCheck %s
+
+// CHECK: #define __iamcu
+// CHECK: #define __iamcu__
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D14204: Fix crash in redundant-void-arg check.

2015-10-30 Thread Angel Garcia via cfe-commits
angelgarcia created this revision.
angelgarcia added reviewers: klimek, LegalizeAdulthood.
angelgarcia added subscribers: alexfh, cfe-commits.

When applying this check to the unit tests, it would hit an assertion:
llvm/tools/clang/lib/Lex/Lexer.cpp:1056: clang::SourceLocation 
clang::Lexer::getSourceLocation(const char*, unsigned int) const: Assertion `PP 
&& "This doesn't work on raw lexers"' failed.

http://reviews.llvm.org/D14204

Files:
  clang-tidy/modernize/RedundantVoidArgCheck.cpp
  test/clang-tidy/modernize-redundant-void-arg.cpp

Index: test/clang-tidy/modernize-redundant-void-arg.cpp
===
--- test/clang-tidy/modernize-redundant-void-arg.cpp
+++ test/clang-tidy/modernize-redundant-void-arg.cpp
@@ -417,3 +417,13 @@
   // CHECK-MESSAGES: [[@LINE-2]]:45: warning: {{.*}} in lambda expression
   // CHECK-FIXES: {{^  }}auto void_returner = []() -> void (*)() { return f1; 
};{{$}}
 }
+
+#define F(A, B)\
+  struct F_##A##_##B { \
+F_##A##_##B(void); \
+  };   \
+  F_##A##_##B::F_##A##_##B(void)
+
+F(Foo, Bar) {
+
+}
Index: clang-tidy/modernize/RedundantVoidArgCheck.cpp
===
--- clang-tidy/modernize/RedundantVoidArgCheck.cpp
+++ clang-tidy/modernize/RedundantVoidArgCheck.cpp
@@ -128,6 +128,9 @@
 void RedundantVoidArgCheck::removeVoidArgumentTokens(
 const ast_matchers::MatchFinder::MatchResult &Result, SourceRange Range,
 StringRef GrammarLocation) {
+  if (Range.getBegin().isMacroID() || Range.getEnd().isMacroID())
+return;
+
   std::string DeclText =
   Lexer::getSourceText(CharSourceRange::getTokenRange(Range),
*Result.SourceManager,


Index: test/clang-tidy/modernize-redundant-void-arg.cpp
===
--- test/clang-tidy/modernize-redundant-void-arg.cpp
+++ test/clang-tidy/modernize-redundant-void-arg.cpp
@@ -417,3 +417,13 @@
   // CHECK-MESSAGES: [[@LINE-2]]:45: warning: {{.*}} in lambda expression
   // CHECK-FIXES: {{^  }}auto void_returner = []() -> void (*)() { return f1; };{{$}}
 }
+
+#define F(A, B)\
+  struct F_##A##_##B { \
+F_##A##_##B(void); \
+  };   \
+  F_##A##_##B::F_##A##_##B(void)
+
+F(Foo, Bar) {
+
+}
Index: clang-tidy/modernize/RedundantVoidArgCheck.cpp
===
--- clang-tidy/modernize/RedundantVoidArgCheck.cpp
+++ clang-tidy/modernize/RedundantVoidArgCheck.cpp
@@ -128,6 +128,9 @@
 void RedundantVoidArgCheck::removeVoidArgumentTokens(
 const ast_matchers::MatchFinder::MatchResult &Result, SourceRange Range,
 StringRef GrammarLocation) {
+  if (Range.getBegin().isMacroID() || Range.getEnd().isMacroID())
+return;
+
   std::string DeclText =
   Lexer::getSourceText(CharSourceRange::getTokenRange(Range),
*Result.SourceManager,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r251703 - Modules: Add a declaration in clang/Serialization/GlobalModuleIndex.h.

2015-10-30 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Fri Oct 30 10:54:34 2015
New Revision: 251703

URL: http://llvm.org/viewvc/llvm-project?rev=251703&view=rev
Log:
Modules: Add a declaration in clang/Serialization/GlobalModuleIndex.h.

Modified:
cfe/trunk/include/clang/Serialization/GlobalModuleIndex.h

Modified: cfe/trunk/include/clang/Serialization/GlobalModuleIndex.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/GlobalModuleIndex.h?rev=251703&r1=251702&r2=251703&view=diff
==
--- cfe/trunk/include/clang/Serialization/GlobalModuleIndex.h (original)
+++ cfe/trunk/include/clang/Serialization/GlobalModuleIndex.h Fri Oct 30 
10:54:34 2015
@@ -36,6 +36,7 @@ class FileEntry;
 class FileManager;
 class IdentifierIterator;
 class PCHContainerOperations;
+class PCHContainerReader;
 
 namespace serialization {
   class ModuleFile;


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


Re: [PATCH] D12793: Three new overflow builtins with generic argument types

2015-10-30 Thread David Grayson via cfe-commits
DavidEGrayson added a comment.

Thanks, John!  Looks like it's actually committed in rL251651 
.   Thanks for handling the volatile pointers 
correctly (I didn't know I had to do something special for them) and giving me 
credit in the commit message!


http://reviews.llvm.org/D12793



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


r251707 - Preprocessor: define correct tvOS and watchOS version macros

2015-10-30 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Fri Oct 30 11:30:30 2015
New Revision: 251707

URL: http://llvm.org/viewvc/llvm-project?rev=251707&view=rev
Log:
Preprocessor: define correct tvOS and watchOS version macros

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Frontend/darwin-version.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=251707&r1=251706&r2=251707&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Oct 30 11:30:30 2015
@@ -162,7 +162,22 @@ static void getDarwinDefines(MacroBuilde
 Str[3] = '0' + (Rev / 10);
 Str[4] = '0' + (Rev % 10);
 Str[5] = '\0';
-Builder.defineMacro("__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__", Str);
+if (Triple.isTvOS())
+  Builder.defineMacro("__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__", Str);
+else
+  Builder.defineMacro("__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__",
+  Str);
+
+  } else if (Triple.isWatchOS()) {
+assert(Maj < 10 && Min < 100 && Rev < 100 && "Invalid version!");
+char Str[6];
+Str[0] = '0' + Maj;
+Str[1] = '0' + (Min / 10);
+Str[2] = '0' + (Min % 10);
+Str[3] = '0' + (Rev / 10);
+Str[4] = '0' + (Rev % 10);
+Str[5] = '\0';
+Builder.defineMacro("__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__", Str);
   } else if (Triple.isMacOSX()) {
 // Note that the Driver allows versions which aren't representable in the
 // define (because we only get a single digit for the minor and micro

Modified: cfe/trunk/test/Frontend/darwin-version.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/darwin-version.c?rev=251707&r1=251706&r2=251707&view=diff
==
--- cfe/trunk/test/Frontend/darwin-version.c (original)
+++ cfe/trunk/test/Frontend/darwin-version.c Fri Oct 30 11:30:30 2015
@@ -13,6 +13,8 @@
 // RUN: %clang_cc1 -triple i386-apple-macosx10.4.0 -dM -E -o %t %s
 // RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1040' 
| count 1
 // RUN: not grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t
+// RUN: not grep '__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__' %t
+// RUN: not grep '__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__' %t
 // RUN: %clang_cc1 -triple i386-apple-macosx10.4.10 -dM -E -o %t %s
 // RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1049' 
| count 1
 // RUN: not grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t
@@ -25,3 +27,23 @@
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.10.0 -dM -E -o %t %s
 // RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep 
'101000' | count 1
 // RUN: not grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t
+
+// RUN: %clang_cc1 -triple arm64-apple-tvos8.3 -dM -E -o %t %s
+// RUN: grep '__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__' %t | grep '80300' | 
count 1
+// RUN: not grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t
+// RUN: not grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t
+
+// RUN: %clang_cc1 -triple x86_64-apple-tvos8.3 -dM -E -o %t %s
+// RUN: grep '__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__' %t | grep '80300' | 
count 1
+// RUN: not grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t
+// RUN: not grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t
+
+// RUN: %clang_cc1 -triple armv7k-apple-watchos2.1 -dM -E -o %t %s
+// RUN: grep '__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__' %t | grep '20100' 
| count 1
+// RUN: not grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t
+// RUN: not grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t
+
+// RUN: %clang_cc1 -triple i386-apple-watchos2.1 -dM -E -o %t %s
+// RUN: grep '__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__' %t | grep '20100' 
| count 1
+// RUN: not grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t
+// RUN: not grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t


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


r251709 - Disable SjLj exceptions for watchOS

2015-10-30 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Fri Oct 30 11:30:41 2015
New Revision: 251709

URL: http://llvm.org/viewvc/llvm-project?rev=251709&view=rev
Log:
Disable SjLj exceptions for watchOS

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

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=251709&r1=251708&r2=251709&view=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Fri Oct 30 11:30:41 2015
@@ -304,7 +304,9 @@ public:
   virtual bool GetDefaultStandaloneDebug() const { return false; }
 
   /// UseSjLjExceptions - Does this tool chain use SjLj exceptions.
-  virtual bool UseSjLjExceptions() const { return false; }
+  virtual bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const {
+return false;
+  }
 
   /// getThreadModel() - Which thread model does this target use?
   virtual std::string getThreadModel() const { return "posix"; }

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=251709&r1=251708&r2=251709&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Oct 30 11:30:41 2015
@@ -1037,10 +1037,18 @@ bool MachO::UseDwarfDebugFlags() const {
   return false;
 }
 
-bool Darwin::UseSjLjExceptions() const {
+bool Darwin::UseSjLjExceptions(const ArgList &Args) const {
   // Darwin uses SjLj exceptions on ARM.
-  return (getTriple().getArch() == llvm::Triple::arm ||
-  getTriple().getArch() == llvm::Triple::thumb);
+  if (getTriple().getArch() != llvm::Triple::arm &&
+  getTriple().getArch() != llvm::Triple::thumb)
+return false;
+
+  // We can't check directly for watchOS here. ComputeLLVMTriple only
+  // fills in the ArchName correctly.
+  llvm::Triple Triple(ComputeLLVMTriple(Args));
+  return !(Triple.getArchName() == "armv7k" ||
+   Triple.getArchName() == "thumbv7k");
+
 }
 
 bool MachO::isPICDefault() const { return true; }
@@ -2952,7 +2960,7 @@ Tool *FreeBSD::buildAssembler() const {
 
 Tool *FreeBSD::buildLinker() const { return new tools::freebsd::Linker(*this); 
}
 
-bool FreeBSD::UseSjLjExceptions() const {
+bool FreeBSD::UseSjLjExceptions(const ArgList &Args) const {
   // FreeBSD uses SjLj exceptions on ARM oabi.
   switch (getTriple().getEnvironment()) {
   case llvm::Triple::GNUEABIHF:

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=251709&r1=251708&r2=251709&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Fri Oct 30 11:30:41 2015
@@ -339,7 +339,9 @@ public:
 
   bool UseDwarfDebugFlags() const override;
 
-  bool UseSjLjExceptions() const override { return false; }
+  bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override {
+return false;
+  }
 
   /// }
 };
@@ -528,7 +530,7 @@ public:
 
   void CheckObjCARC() const override;
 
-  bool UseSjLjExceptions() const override;
+  bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override;
 
   SanitizerMask getSupportedSanitizers() const override;
 };
@@ -714,7 +716,7 @@ public:
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
 
-  bool UseSjLjExceptions() const override;
+  bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override;
   bool isPIEDefault() const override;
   SanitizerMask getSupportedSanitizers() const override;
   unsigned GetDefaultDwarfVersion() const override { return 2; }

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=251709&r1=251708&r2=251709&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Oct 30 11:30:41 2015
@@ -4824,7 +4824,7 @@ void Clang::ConstructJob(Compilation &C,
 addExceptionArgs(Args, InputType, getToolChain(), KernelOrKext, 
objcRuntime,
  CmdArgs);
 
-  if (getToolChain().UseSjLjExceptions())
+  if (getToolChain().UseSjLjExceptions(Args))
 CmdArgs.push_back("-fsjlj-exceptions");
 
   // C++ "sane" operator new.

Modified: cfe/trunk/test/Driver/arch-armv7k.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arch-armv7k.c?rev=251709&r1=251708&r2=251709&view=diff
==
--- cfe/trunk/test/Driver/arch-a

r251706 - Support watchOS and tvOS driver options

2015-10-30 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Fri Oct 30 11:30:27 2015
New Revision: 251706

URL: http://llvm.org/viewvc/llvm-project?rev=251706&view=rev
Log:
Support watchOS and tvOS driver options

This patch should add support for almost all command-line options and
driver tinkering necessary to produce a correct "clang -cc1"
invocation for watchOS and tvOS.

Added:
cfe/trunk/test/Driver/arch-armv7k.c
cfe/trunk/test/Modules/modules.idx
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
cfe/trunk/test/Driver/apple-kext-mkernel.c
cfe/trunk/test/Driver/darwin-ld.c
cfe/trunk/test/Driver/darwin-version.c
cfe/trunk/test/Driver/pic.c
cfe/trunk/test/Preprocessor/arm-target-features.c
cfe/trunk/test/SemaObjC/opaque-is-access-warn.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=251706&r1=251705&r2=251706&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Oct 30 11:30:27 
2015
@@ -102,6 +102,8 @@ def err_drv_cc_print_options_failure : E
 "unable to open CC_PRINT_OPTIONS file: %0">;
 def err_drv_preamble_format : Error<
 "incorrect format for -preamble-bytes=N,END">;
+def err_drv_conflicting_deployment_targets : Error<
+  "conflicting deployment targets, both '%0' and '%1' are present in 
environment">;
 def err_drv_objc_gc_arr : Error<
   "cannot specify both '-fobjc-arc' and '%0'">;
 def err_arc_unsupported_on_runtime : Error<

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=251706&r1=251705&r2=251706&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Oct 30 11:30:27 2015
@@ -1227,6 +1227,13 @@ def malign_functions_EQ : Joined<["-"],
 def malign_loops_EQ : Joined<["-"], "malign-loops=">, 
Group;
 def malign_jumps_EQ : Joined<["-"], "malign-jumps=">, 
Group;
 def mfancy_math_387 : Flag<["-"], "mfancy-math-387">, 
Group;
+def mtvos_version_min_EQ : Joined<["-"], "mtvos-version-min=">, Group;
+def mappletvos_version_min_EQ : Joined<["-"], "mappletvos-version-min=">, 
Alias;
+def mtvos_simulator_version_min_EQ : Joined<["-"], 
"mtvos-simulator-version-min=">, Alias;
+def mappletvsimulator_version_min_EQ : Joined<["-"], 
"mappletvsimulator-version-min=">, Alias;
+def mwatchos_version_min_EQ : Joined<["-"], "mwatchos-version-min=">, 
Group;
+def mwatchos_simulator_version_min_EQ : Joined<["-"], 
"mwatchos-simulator-version-min=">, Alias;
+def mwatchsimulator_version_min_EQ : Joined<["-"], 
"mwatchsimulator-version-min=">, Alias;
 def march_EQ : Joined<["-"], "march=">, Group;
 def masm_EQ : Joined<["-"], "masm=">, Group, Flags<[DriverOption]>;
 def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group;

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=251706&r1=251705&r2=251706&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Oct 30 11:30:27 2015
@@ -2225,6 +2225,8 @@ const ToolChain &Driver::getToolChain(co
 case llvm::Triple::Darwin:
 case llvm::Triple::MacOSX:
 case llvm::Triple::IOS:
+case llvm::Triple::TvOS:
+case llvm::Triple::WatchOS:
   TC = new toolchains::DarwinClang(*this, Target, Args);
   break;
 case llvm::Triple::DragonFly:

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=251706&r1=251705&r2=251706&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Oct 30 11:30:27 2015
@@ -67,6 +67,10 @@ bool MachO::HasNativeLLVMSupport() const
 
 /// Darwin provides an ARC runtime starting in MacOS X 10.7 and iOS 5.0.
 ObjCRuntime Darwin::getDefaultObjCRuntime(bool isNonFragile) const {
+  if (isTargetWatchOSBased())
+// FIXME: not quite iOS because of version mismatch. Choose something for
+// now.
+return ObjCRuntime(ObjCRuntime::iOS, TargetVersion);
   if (isTargetIOSBased())
 return ObjCRuntime(ObjCRuntime::iOS, TargetVersion);
   if (isNonFragile)
@@ -76,7 +80,9 @@ ObjCRuntime Darwin::getDefaultObjCRuntim
 
 /// Darwin provides a blocks runtime starting in Mac

r251711 - Support tvOS and watchOS availability attributes

2015-10-30 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Fri Oct 30 11:30:49 2015
New Revision: 251711

URL: http://llvm.org/viewvc/llvm-project?rev=251711&view=rev
Log:
Support tvOS and watchOS availability attributes

Added:
cfe/trunk/test/Sema/attr-availability-tvos.c
cfe/trunk/test/Sema/attr-availability-watchos.c
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=251711&r1=251710&r2=251711&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Fri Oct 30 11:30:49 2015
@@ -456,8 +456,12 @@ def Availability : InheritableAttr {
  .Case("android", "Android")
  .Case("ios", "iOS")
  .Case("macosx", "OS X")
+ .Case("tvos", "tvOS")
+ .Case("watchos", "watchOS")
  .Case("ios_app_extension", "iOS (App Extension)")
  .Case("macosx_app_extension", "OS X (App Extension)")
+ .Case("tvos_app_extension", "tvOS (App Extension)")
+ .Case("watchos_app_extension", "watchOS (App Extension)")
  .Default(llvm::StringRef());
 } }];
   let HasCustomParsing = 1;

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=251711&r1=251710&r2=251711&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Fri Oct 30 11:30:49 2015
@@ -580,6 +580,14 @@ are:
   Apple's Mac OS X operating system.  The minimum deployment target is
   specified by the ``-mmacosx-version-min=*version*`` command-line argument.
 
+``tvos``
+  Apple's tvOS operating system.  The minimum deployment target is specified by
+  the ``-mtvos-version-min=*version*`` command-line argument.
+
+``watchos``
+  Apple's watchOS operating system.  The minimum deployment target is 
specified by
+  the ``-mwatchos-version-min=*version*`` command-line argument.
+
 A declaration can be used even when deploying back to a platform version prior
 to when the declaration was introduced.  When this happens, the declaration is
 `weakly linked

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=251711&r1=251710&r2=251711&view=diff
==
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Fri Oct 30 11:30:49 2015
@@ -1062,6 +1062,8 @@ static bool HasFeature(const Preprocesso
   .Case("attribute_availability_with_message", true)
   .Case("attribute_availability_app_extension", true)
   .Case("attribute_availability_with_version_underscores", true)
+  .Case("attribute_availability_tvos", true)
+  .Case("attribute_availability_watchos", true)
   .Case("attribute_cf_returns_not_retained", true)
   .Case("attribute_cf_returns_retained", true)
   .Case("attribute_cf_returns_on_parameters", true)

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=251711&r1=251710&r2=251711&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Oct 30 11:30:49 2015
@@ -1863,6 +1863,22 @@ AvailabilityAttr *Sema::mergeAvailabilit
 continue;
   }
 
+  // If there is an existing availability attribute for this platform that
+  // is explicit and the new one is implicit use the explicit one and
+  // discard the new implicit attribute.
+  if (OldAA->getRange().isValid() && Range.isInvalid()) {
+return nullptr;
+  }
+
+  // If there is an existing attribute for this platform that is implicit
+  // and the new attribute is explicit then erase the old one and
+  // continue processing the attributes.
+  if (Range.isValid() && OldAA->getRange().isInvalid()) {
+Attrs.erase(Attrs.begin() + i);
+--e;
+continue;
+  }
+
   FoundAny = true;
   VersionTuple OldIntroduced = OldAA->getIntroduced();
   VersionTuple OldDeprecated = OldAA->getDeprecated();
@@ -2000,6 +2016,74 @@ static void handleAvailabilityAttr(Sema
   Index);
   if (NewAttr)
 D->addAttr(NewAttr);
+
+  // Transcribe "ios" to "watchos" (and add a new attribute) if the versioning
+  // matches before the start of the watchOS platform.
+  if (S.Context.getTargetInfo().getTriple().isWatchO

r251710 - ARMv7k: implement ABI changes for watchOS from standard iOS.

2015-10-30 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Fri Oct 30 11:30:45 2015
New Revision: 251710

URL: http://llvm.org/viewvc/llvm-project?rev=251710&view=rev
Log:
ARMv7k: implement ABI changes for watchOS from standard iOS.

Added:
cfe/trunk/test/CodeGen/armv7k-abi.c
cfe/trunk/test/CodeGenCXX/armv7k.cpp
cfe/trunk/test/Driver/appletvos-version-min.c
cfe/trunk/test/Driver/watchos-version-min.c
cfe/trunk/test/Preprocessor/init-v7k-compat.c
cfe/trunk/test/SemaObjC/bool-type.m
Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGen/complex-math.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=251710&r1=251709&r2=251710&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Oct 30 11:30:45 2015
@@ -3702,6 +3702,11 @@ public:
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
 SuitableAlign = 128;
+MaxVectorAlign = 256;
+// The watchOS simulator uses the builtin bool type for Objective-C.
+llvm::Triple T = llvm::Triple(Triple);
+if (T.isWatchOS())
+  UseSignedCharForObjCBool = false;
 SizeType = UnsignedLong;
 IntPtrType = SignedLong;
 DataLayoutString = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128";
@@ -4243,12 +4248,15 @@ class ARMTargetInfo : public TargetInfo
 // FIXME: Enumerated types are variable width in straight AAPCS.
   }
 
-  void setABIAPCS() {
+  void setABIAPCS(bool IsAAPCS16) {
 const llvm::Triple &T = getTriple();
 
 IsAAPCS = false;
 
-DoubleAlign = LongLongAlign = LongDoubleAlign = SuitableAlign = 32;
+if (IsAAPCS16)
+  DoubleAlign = LongLongAlign = LongDoubleAlign = SuitableAlign = 64;
+else
+  DoubleAlign = LongLongAlign = LongDoubleAlign = SuitableAlign = 32;
 
 // size_t is unsigned int on FreeBSD.
 if (T.getOS() == llvm::Triple::FreeBSD)
@@ -4268,7 +4276,10 @@ class ARMTargetInfo : public TargetInfo
 /// gcc.
 ZeroLengthBitfieldBoundary = 32;
 
-if (T.isOSBinFormatMachO())
+if (T.isOSBinFormatMachO() && IsAAPCS16) {
+  assert(!BigEndian && "AAPCS16 does not support big-endian");
+  DataLayoutString = "e-m:o-p:32:32-i64:64-a:0:32-n32-S128";
+} else if (T.isOSBinFormatMachO())
   DataLayoutString =
   BigEndian
   ? "E-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
@@ -4413,6 +4424,8 @@ public:
   Triple.getOS() == llvm::Triple::UnknownOS ||
   StringRef(CPU).startswith("cortex-m")) {
 setABI("aapcs");
+  } else if (Triple.isWatchOS()) {
+setABI("aapcs16");
   } else {
 setABI("apcs-gnu");
   }
@@ -4465,10 +4478,8 @@ public:
 //
 // FIXME: We need support for -meabi... we could just mangle it into the
 // name.
-// FIXME: aapcs16 isn't really the same as APCS, this allows tests to pass
-// until the real ABI is committed.
 if (Name == "apcs-gnu" || Name == "aapcs16") {
-  setABIAPCS();
+  setABIAPCS(Name == "aapcs16");
   return true;
 }
 if (Name == "aapcs" || Name == "aapcs-vfp" || Name == "aapcs-linux") {
@@ -4625,6 +4636,12 @@ public:
 
 // Target properties.
 Builder.defineMacro("__REGISTER_PREFIX__", "");
+
+// Unfortunately, __ARM_ARCH_7K__ is now more of an ABI descriptor. The CPU
+// happens to be Cortex-A7 though, so it should still get __ARM_ARCH_7A__.
+if (getTriple().isWatchOS())
+  Builder.defineMacro("__ARM_ARCH_7K__", "2");
+
 if (!CPUAttr.empty())
   Builder.defineMacro("__ARM_ARCH_" + CPUAttr + "__");
 
@@ -4806,7 +4823,10 @@ public:
   }
   bool isCLZForZeroUndef() const override { return false; }
   BuiltinVaListKind getBuiltinVaListKind() const override {
-return IsAAPCS ? AAPCSABIBuiltinVaList : TargetInfo::VoidPtrBuiltinVaList;
+return IsAAPCS
+   ? AAPCSABIBuiltinVaList
+   : (getTriple().isWatchOS() ? TargetInfo::CharPtrBuiltinVaList
+  : TargetInfo::VoidPtrBuiltinVaList);
   }
   ArrayRef getGCCRegNames() const override;
   ArrayRef getGCCRegAliases() const override;
@@ -5147,8 +5167,18 @@ public:
 // ARMleTargetInfo.
 MaxAtomicInlineWidth = 64;
 
-// Darwin on iOS uses a variant of the ARM C++ ABI.
-TheCXXABI.set(TargetCXXABI::iOS);
+if (Triple.isWatchOS()) {
+  // Darwin on iOS uses a variant of the ARM C++ ABI.
+  TheCXXABI.set(TargetCXXABI::WatchOS);
+
+  // The 32-bit ABI is silent on what ptrdiff_t should be, but given that
+  // size_t is long, it's a bit weird for it to be int.
+  PtrDiffType = SignedLong;
+
+  // BOOL should be a real boolean on the new ABI
+  UseSignedCharForObjCBool = false;
+} else
+  TheCXXABI.set(TargetCXXABI::iOS);
   }
 };
 
@@ -5204,7 +5234,7 @@ public:
 // contributes to the alignment

Re: [PATCH] D14204: Fix crash in redundant-void-arg check.

2015-10-30 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/modernize/RedundantVoidArgCheck.cpp:131
@@ -130,1 +130,3 @@
 StringRef GrammarLocation) {
+  if (Range.getBegin().isMacroID() || Range.getEnd().isMacroID())
+return;

What happens if instead you pass the range through `Lexer::makeFileCharRange`? 
This might be a way to enable fixes at least in some trivial cases involving 
macros.


http://reviews.llvm.org/D14204



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


r251712 - Support watchOS and tvOS in compiler-rt builds

2015-10-30 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Fri Oct 30 11:30:51 2015
New Revision: 251712

URL: http://llvm.org/viewvc/llvm-project?rev=251712&view=rev
Log:
Support watchOS and tvOS in compiler-rt builds

Hopefully autotools will be deprecated soon and this entire file can go away,
but until then...

Modified:
cfe/trunk/runtime/compiler-rt/Makefile

Modified: cfe/trunk/runtime/compiler-rt/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/runtime/compiler-rt/Makefile?rev=251712&r1=251711&r2=251712&view=diff
==
--- cfe/trunk/runtime/compiler-rt/Makefile (original)
+++ cfe/trunk/runtime/compiler-rt/Makefile Fri Oct 30 11:30:51 2015
@@ -83,6 +83,25 @@ RuntimeLibrary.darwin.Configs := \
 
 IOS_SDK := $(shell xcrun --show-sdk-path -sdk iphoneos 2> /dev/null)
 IOSSIM_SDK := $(shell xcrun --show-sdk-path -sdk iphonesimulator 2> /dev/null)
+TVOS_SDK := $(shell xcrun --show-sdk-path -sdk appletvos 2> /dev/null)
+TVOSSIM_SDK := $(shell xcrun --show-sdk-path -sdk appletvsimulator 2> 
/dev/null)
+WATCHOS_SDK := $(shell xcrun --show-sdk-path -sdk watchos 2> /dev/null)
+WATCHOSSIM_SDK := $(shell xcrun --show-sdk-path -sdk watchsimulator 2> 
/dev/null)
+
+LinkerSupportedArches = \
+  $(shell \
+result=""; \
+for arch in $1; do \
+  if $(LD) -v 2>&1 | grep "configured to support" | tr ' ' '\n' | grep 
"^$$arch$$" >/dev/null 2>/dev/null; then \
+result="$$result$$arch "; \
+  fi; \
+done; \
+echo $$result)
+
+
+RuntimeLibrary.macho_embedded.Configs := \
+   hard_static.a hard_pic.a
+ifneq (,$(findstring ARM,$(TARGETS_TO_BUILD)))
 
 ifneq ($(IOS_SDK)$(IOSSIM_SDK),)
 RuntimeLibrary.darwin.Configs += ios.a profile_ios.a
@@ -99,9 +118,23 @@ RuntimeLibrary.darwin.Configs += asan_io
  ubsan_iossim_dynamic.dylib
 endif
 
-RuntimeLibrary.macho_embedded.Configs := \
-   hard_static.a hard_pic.a
-ifneq (,$(findstring ARM,$(TARGETS_TO_BUILD)))
+
+ifneq ($(TVOS_SDK)$(TVOSSIM_SDK),)
+RuntimeLibrary.darwin.Configs += tvos.a profile_tvos.a
+endif
+
+ifneq ($(TVOS_SDK),)
+RuntimeLibrary.darwin.Configs += cc_kext_tvos.a
+endif
+
+ifneq ($(WATCHOS_SDK)$(WATCHOSSIM_SDK),)
+RuntimeLibrary.darwin.Configs += watchos.a profile_watchos.a
+endif
+
+ifneq ($(WATCHOS_SDK),)
+RuntimeLibrary.darwin.Configs += cc_kext_watchos.a
+endif
+
 RuntimeLibrary.macho_embedded.Configs += \
soft_static.a soft_pic.a
 endif


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


r251708 - Watch and TV OS: wire up basic ABI choices

2015-10-30 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Fri Oct 30 11:30:36 2015
New Revision: 251708

URL: http://llvm.org/viewvc/llvm-project?rev=251708&view=rev
Log:
Watch and TV OS: wire up basic ABI choices

This sets the mostly expected Darwin default ABI options for these two
platforms. Active changes from these defaults for watchOS are in a later patch.

Modified:
cfe/trunk/include/clang/Basic/ObjCRuntime.h
cfe/trunk/include/clang/Basic/TargetCXXABI.h
cfe/trunk/lib/ARCMigrate/ARCMT.cpp
cfe/trunk/lib/ARCMigrate/Transforms.cpp
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Basic/ObjCRuntime.cpp
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/ios-simulator-arcruntime.c

Modified: cfe/trunk/include/clang/Basic/ObjCRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/ObjCRuntime.h?rev=251708&r1=251707&r2=251708&view=diff
==
--- cfe/trunk/include/clang/Basic/ObjCRuntime.h (original)
+++ cfe/trunk/include/clang/Basic/ObjCRuntime.h Fri Oct 30 11:30:36 2015
@@ -41,6 +41,10 @@ public:
 /// version of iOS.
 iOS,
 
+/// 'watchos' is a variant of iOS for Apple's watchOS. The version
+/// is a release version of watchOS.
+WatchOS,
+
 /// 'gcc' is the Objective-C runtime shipped with GCC, implementing a
 /// fragile Objective-C ABI
 GCC,
@@ -81,6 +85,7 @@ public:
 case GNUstep: return true;
 case ObjFW: return true;
 case iOS: return true;
+case WatchOS: return true;
 }
 llvm_unreachable("bad kind");
   }
@@ -114,6 +119,7 @@ public:
 case FragileMacOSX:
 case MacOSX:
 case iOS:
+case WatchOS:
   return false;
 case GCC:
 case GNUstep:
@@ -138,6 +144,7 @@ public:
   return getVersion() >= VersionTuple(10, 7);
 case MacOSX: return true;
 case iOS: return true;
+case WatchOS: return true;
 case GCC: return false;
 case GNUstep: return true;
 case ObjFW: return true;
@@ -155,6 +162,7 @@ public:
 case FragileMacOSX: return getVersion() >= VersionTuple(10, 7);
 case MacOSX: return getVersion() >= VersionTuple(10, 7);
 case iOS: return getVersion() >= VersionTuple(5);
+case WatchOS: return true;
 
 case GCC: return false;
 case GNUstep: return getVersion() >= VersionTuple(1, 6);
@@ -170,6 +178,8 @@ public:
 return getVersion() >= VersionTuple(10, 8);
   case iOS:
 return (getVersion() >= VersionTuple(6));
+  case WatchOS:
+return true;
   case GNUstep:
 return getVersion() >= VersionTuple(1, 7);
 
@@ -199,6 +209,7 @@ public:
 case FragileMacOSX: return false;
 case MacOSX: return getVersion() >= VersionTuple(10, 8);
 case iOS: return getVersion() >= VersionTuple(6);
+case WatchOS: return true;
 
 // This is really a lie, because some implementations and versions
 // of the runtime do not support ARC.  Probably -fgnu-runtime
@@ -226,6 +237,7 @@ public:
   return true;
 case MacOSX:
 case iOS:
+case WatchOS:
 case GNUstep:
 case ObjFW:
   return false;
@@ -247,6 +259,7 @@ public:
 case FragileMacOSX: return getVersion() >= VersionTuple(10, 8);
 case MacOSX: return getVersion() >= VersionTuple(10, 8);
 case iOS: return getVersion() >= VersionTuple(5);
+case WatchOS: return true;
 case GCC: return false;
 case GNUstep: return false;
 case ObjFW: return false;
@@ -259,6 +272,7 @@ public:
 switch (getKind()) {
 case MacOSX: return true;
 case iOS: return true;
+case WatchOS: return true;
 case FragileMacOSX: return false;
 case GCC: return true;
 case GNUstep: return true;
@@ -272,6 +286,7 @@ public:
 switch (getKind()) {
 case MacOSX: return true;
 case iOS: return true;
+case WatchOS: return true;
 case FragileMacOSX: return false;
 case GCC: return true;
 case GNUstep: return true;
@@ -285,6 +300,7 @@ public:
 case FragileMacOSX:
 case MacOSX:
 case iOS:
+case WatchOS:
   return true;
 case GNUstep:
   return getVersion() >= VersionTuple(1, 7);

Modified: cfe/trunk/include/clang/Basic/TargetCXXABI.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetCXXABI.h?rev=251708&r1=251707&r2=251708&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetCXXABI.h (original)
+++ cfe/trunk/include/clang/Basic/TargetCXXABI.h Fri Oct 30 11:30:36 2015
@@ -71,6 +71,11 @@ public:
 ///  /help/topic/com.arm.doc.ihi0059a/IHI0059A_cppabi64.pdf
 iOS64,
 
+/// WatchOS is a modernisation of 

r251713 - CGExprConstant.cpp: Appease Modules.

2015-10-30 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Fri Oct 30 11:37:27 2015
New Revision: 251713

URL: http://llvm.org/viewvc/llvm-project?rev=251713&view=rev
Log:
CGExprConstant.cpp: Appease Modules.

Modified:
cfe/trunk/lib/CodeGen/CGExprConstant.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=251713&r1=251712&r2=251713&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Fri Oct 30 11:37:27 2015
@@ -1038,7 +1038,7 @@ public:
   unsigned Type = cast(E)->getIdentType();
   if (CGF) {
 LValue Res = CGF->EmitPredefinedLValue(cast(E));
-return cast(Res.getAddress());
+return llvm::cast(Res.getAddress());
   } else if (Type == PredefinedExpr::PrettyFunction) {
 return CGM.GetAddrOfConstantCString("top level", ".tmp");
   }


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


Re: r251713 - CGExprConstant.cpp: Appease Modules.

2015-10-30 Thread Richard Smith via cfe-commits
On Oct 30, 2015 6:39 AM, "NAKAMURA Takumi via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:
>
> Author: chapuni
> Date: Fri Oct 30 11:37:27 2015
> New Revision: 251713
>
> URL: http://llvm.org/viewvc/llvm-project?rev=251713&view=rev
> Log:
> CGExprConstant.cpp: Appease Modules.

Why? Please don't work around modules bugs to make the buildbot green; the
purpose of the bot is to find those bugs.

> Modified:
> cfe/trunk/lib/CodeGen/CGExprConstant.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
> URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=251713&r1=251712&r2=251713&view=diff
>
==
> --- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Fri Oct 30 11:37:27 2015
> @@ -1038,7 +1038,7 @@ public:
>unsigned Type = cast(E)->getIdentType();
>if (CGF) {
>  LValue Res = CGF->EmitPredefinedLValue(cast(E));
> -return cast(Res.getAddress());
> +return llvm::cast(Res.getAddress());
>} else if (Type == PredefinedExpr::PrettyFunction) {
>  return CGM.GetAddrOfConstantCString("top level", ".tmp");
>}
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14184: [clang] Add initial support for -meabi flag

2015-10-30 Thread Vinicius Tinti via cfe-commits
tinti added inline comments.


Comment at: lib/CodeGen/BackendUtil.cpp:524
@@ +523,3 @@
+  .Case("5",   llvm::EABI::Eabi5)
+  .Case("gnu", llvm::EABI::Gnu)
+  .Default(llvm::EABI::Default);

compnerd wrote:
> I'd really rather see this written in the LLVM Style:
> 
> EABI4, EABI5, GNU
> 
> since all of them are initialisms.
> 
> BTW, please clang-format this change.
Agreed.


Comment at: lib/Frontend/CompilerInvocation.cpp:458
@@ +457,3 @@
+StringRef Value = A->getValue();
+bool Valid = llvm::StringSwitch(Value)
+  .Case("default", true)

compnerd wrote:
> If `llvm::EABI::EABIVersionType` had an `Invalid` value in the enumeration, 
> you could convert directly to the value here, and report the error if the 
> value was `Invalid`.
I chose this way because none of the other target options have it [1].

Do you prefer with it?

[1] 
https://github.com/llvm-mirror/llvm/blob/master/include/llvm/Target/TargetOptions.h#L27


http://reviews.llvm.org/D14184



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


Re: r251713 - CGExprConstant.cpp: Appease Modules.

2015-10-30 Thread NAKAMURA Takumi via cfe-commits
I know. The builder was red for weeks (or months).
Please be patient for my work. It's green now.

I'll file bugs, two issues,  when I got a slack time.

2015年10月30日(金) 9:44 Richard Smith :

> On Oct 30, 2015 6:39 AM, "NAKAMURA Takumi via cfe-commits" <
> cfe-commits@lists.llvm.org> wrote:
> >
> > Author: chapuni
> > Date: Fri Oct 30 11:37:27 2015
> > New Revision: 251713
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=251713&view=rev
> > Log:
> > CGExprConstant.cpp: Appease Modules.
>
> Why? Please don't work around modules bugs to make the buildbot green; the
> purpose of the bot is to find those bugs.
>
> > Modified:
> > cfe/trunk/lib/CodeGen/CGExprConstant.cpp
> >
> > Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=251713&r1=251712&r2=251713&view=diff
> >
> ==
> > --- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
> > +++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Fri Oct 30 11:37:27 2015
> > @@ -1038,7 +1038,7 @@ public:
> >unsigned Type = cast(E)->getIdentType();
> >if (CGF) {
> >  LValue Res = CGF->EmitPredefinedLValue(cast(E));
> > -return cast(Res.getAddress());
> > +return llvm::cast(Res.getAddress());
> >} else if (Type == PredefinedExpr::PrettyFunction) {
> >  return CGM.GetAddrOfConstantCString("top level", ".tmp");
> >}
> >
> >
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14184: [clang] Add initial support for -meabi flag

2015-10-30 Thread Vinicius Tinti via cfe-commits
tinti added inline comments.


Comment at: lib/Frontend/CompilerInvocation.cpp:458
@@ +457,3 @@
+StringRef Value = A->getValue();
+bool Valid = llvm::StringSwitch(Value)
+  .Case("default", true)

tinti wrote:
> compnerd wrote:
> > If `llvm::EABI::EABIVersionType` had an `Invalid` value in the enumeration, 
> > you could convert directly to the value here, and report the error if the 
> > value was `Invalid`.
> I chose this way because none of the other target options have it [1].
> 
> Do you prefer with it?
> 
> [1] 
> https://github.com/llvm-mirror/llvm/blob/master/include/llvm/Target/TargetOptions.h#L27
Looks like that in LLVM the Invalid is not defined but in Clang there are 
target specific enums that define them [1].

[1] https://github.com/llvm-mirror/clang/blob/master/lib/Driver/Tools.h#L263


http://reviews.llvm.org/D14184



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


[PATCH] D14212: Make hasLHS and hasRHS matchers available for ArraySubscriptExpr

2015-10-30 Thread Alexander Kornienko via cfe-commits
alexfh created this revision.
alexfh added a reviewer: klimek.
alexfh added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

The hasBase and hasIndex don't tell anything about the position of the
base and the index in the code, so we need hasLHS and hasRHS in some cases.

http://reviews.llvm.org/D14212

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -2357,6 +2357,11 @@
   EXPECT_TRUE(matches("void x() { true || false; }", OperatorTrueFalse));
   EXPECT_TRUE(matches("void x() { true && false; }", OperatorTrueFalse));
   EXPECT_TRUE(notMatches("void x() { false || true; }", OperatorTrueFalse));
+
+  StatementMatcher OperatorIntPointer = arraySubscriptExpr(
+  hasLHS(hasType(isInteger())), hasRHS(hasType(pointsTo(qualType();
+  EXPECT_TRUE(matches("void x() { 1[\"abc\"]; }", OperatorIntPointer));
+  EXPECT_TRUE(notMatches("void x() { \"abc\"[1]; }", OperatorIntPointer));
 }
 
 TEST(MatchBinaryOperator, HasEitherOperand) {
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3127,9 +3127,11 @@
 /// \code
 ///   a || b
 /// \endcode
-AST_MATCHER_P(BinaryOperator, hasLHS,
-  internal::Matcher, InnerMatcher) {
-  Expr *LeftHandSide = Node.getLHS();
+AST_POLYMORPHIC_MATCHER_P(hasLHS,
+  AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator,
+  ArraySubscriptExpr),
+  internal::Matcher, InnerMatcher) {
+  const Expr *LeftHandSide = Node.getLHS();
   return (LeftHandSide != nullptr &&
   InnerMatcher.matches(*LeftHandSide, Finder, Builder));
 }
@@ -3140,9 +3142,11 @@
 /// \code
 ///   a || b
 /// \endcode
-AST_MATCHER_P(BinaryOperator, hasRHS,
-  internal::Matcher, InnerMatcher) {
-  Expr *RightHandSide = Node.getRHS();
+AST_POLYMORPHIC_MATCHER_P(hasRHS,
+  AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator,
+  ArraySubscriptExpr),
+  internal::Matcher, InnerMatcher) {
+  const Expr *RightHandSide = Node.getRHS();
   return (RightHandSide != nullptr &&
   InnerMatcher.matches(*RightHandSide, Finder, Builder));
 }
@@ -3246,7 +3250,7 @@
 /// \endcode
 AST_MATCHER_P(ConditionalOperator, hasTrueExpression,
   internal::Matcher, InnerMatcher) {
-  Expr *Expression = Node.getTrueExpr();
+  const Expr *Expression = Node.getTrueExpr();
   return (Expression != nullptr &&
   InnerMatcher.matches(*Expression, Finder, Builder));
 }
@@ -3259,7 +3263,7 @@
 /// \endcode
 AST_MATCHER_P(ConditionalOperator, hasFalseExpression,
   internal::Matcher, InnerMatcher) {
-  Expr *Expression = Node.getFalseExpr();
+  const Expr *Expression = Node.getFalseExpr();
   return (Expression != nullptr &&
   InnerMatcher.matches(*Expression, Finder, Builder));
 }
@@ -4253,7 +4257,7 @@
 AST_MATCHER_P_OVERLOAD(NestedNameSpecifier, hasPrefix,
internal::Matcher, InnerMatcher,
0) {
-  NestedNameSpecifier *NextNode = Node.getPrefix();
+  const NestedNameSpecifier *NextNode = Node.getPrefix();
   if (!NextNode)
 return false;
   return InnerMatcher.matches(*NextNode, Finder, Builder);


Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -2357,6 +2357,11 @@
   EXPECT_TRUE(matches("void x() { true || false; }", OperatorTrueFalse));
   EXPECT_TRUE(matches("void x() { true && false; }", OperatorTrueFalse));
   EXPECT_TRUE(notMatches("void x() { false || true; }", OperatorTrueFalse));
+
+  StatementMatcher OperatorIntPointer = arraySubscriptExpr(
+  hasLHS(hasType(isInteger())), hasRHS(hasType(pointsTo(qualType();
+  EXPECT_TRUE(matches("void x() { 1[\"abc\"]; }", OperatorIntPointer));
+  EXPECT_TRUE(notMatches("void x() { \"abc\"[1]; }", OperatorIntPointer));
 }
 
 TEST(MatchBinaryOperator, HasEitherOperand) {
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3127,9 +3127,11 @@
 /// \code
 ///   a || b
 /// \endcode
-AST_MATCHER_P(BinaryOperator, hasLHS,
-  internal::Matcher, InnerMatcher) {
-  Expr *LeftHandSide = Node.getLHS();
+AST_POLYMORPHIC_MATCHER_P(hasLHS,
+  AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator,
+   

Re: r251712 - Support watchOS and tvOS in compiler-rt builds

2015-10-30 Thread Alexey Samsonov via cfe-commits
Do we need to port this to CMake as well?

On Fri, Oct 30, 2015 at 9:30 AM, Tim Northover via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: tnorthover
> Date: Fri Oct 30 11:30:51 2015
> New Revision: 251712
>
> URL: http://llvm.org/viewvc/llvm-project?rev=251712&view=rev
> Log:
> Support watchOS and tvOS in compiler-rt builds
>
> Hopefully autotools will be deprecated soon and this entire file can go
> away,
> but until then...
>
> Modified:
> cfe/trunk/runtime/compiler-rt/Makefile
>
> Modified: cfe/trunk/runtime/compiler-rt/Makefile
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/runtime/compiler-rt/Makefile?rev=251712&r1=251711&r2=251712&view=diff
>
> ==
> --- cfe/trunk/runtime/compiler-rt/Makefile (original)
> +++ cfe/trunk/runtime/compiler-rt/Makefile Fri Oct 30 11:30:51 2015
> @@ -83,6 +83,25 @@ RuntimeLibrary.darwin.Configs := \
>
>  IOS_SDK := $(shell xcrun --show-sdk-path -sdk iphoneos 2> /dev/null)
>  IOSSIM_SDK := $(shell xcrun --show-sdk-path -sdk iphonesimulator 2>
> /dev/null)
> +TVOS_SDK := $(shell xcrun --show-sdk-path -sdk appletvos 2> /dev/null)
> +TVOSSIM_SDK := $(shell xcrun --show-sdk-path -sdk appletvsimulator 2>
> /dev/null)
> +WATCHOS_SDK := $(shell xcrun --show-sdk-path -sdk watchos 2> /dev/null)
> +WATCHOSSIM_SDK := $(shell xcrun --show-sdk-path -sdk watchsimulator 2>
> /dev/null)
> +
> +LinkerSupportedArches = \
> +  $(shell \
> +result=""; \
> +for arch in $1; do \
> +  if $(LD) -v 2>&1 | grep "configured to support" | tr ' ' '\n' |
> grep "^$$arch$$" >/dev/null 2>/dev/null; then \
> +result="$$result$$arch "; \
> +  fi; \
> +done; \
> +echo $$result)
> +
> +
> +RuntimeLibrary.macho_embedded.Configs := \
> +   hard_static.a hard_pic.a
> +ifneq (,$(findstring ARM,$(TARGETS_TO_BUILD)))
>
>  ifneq ($(IOS_SDK)$(IOSSIM_SDK),)
>  RuntimeLibrary.darwin.Configs += ios.a profile_ios.a
> @@ -99,9 +118,23 @@ RuntimeLibrary.darwin.Configs += asan_io
>   ubsan_iossim_dynamic.dylib
>  endif
>
> -RuntimeLibrary.macho_embedded.Configs := \
> -   hard_static.a hard_pic.a
> -ifneq (,$(findstring ARM,$(TARGETS_TO_BUILD)))
> +
> +ifneq ($(TVOS_SDK)$(TVOSSIM_SDK),)
> +RuntimeLibrary.darwin.Configs += tvos.a profile_tvos.a
> +endif
> +
> +ifneq ($(TVOS_SDK),)
> +RuntimeLibrary.darwin.Configs += cc_kext_tvos.a
> +endif
> +
> +ifneq ($(WATCHOS_SDK)$(WATCHOSSIM_SDK),)
> +RuntimeLibrary.darwin.Configs += watchos.a profile_watchos.a
> +endif
> +
> +ifneq ($(WATCHOS_SDK),)
> +RuntimeLibrary.darwin.Configs += cc_kext_watchos.a
> +endif
> +
>  RuntimeLibrary.macho_embedded.Configs += \
> soft_static.a soft_pic.a
>  endif
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>



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


r251729 - Sema: correct typo recovery with blocks

2015-10-30 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri Oct 30 19:39:15 2015
New Revision: 251729

URL: http://llvm.org/viewvc/llvm-project?rev=251729&view=rev
Log:
Sema: correct typo recovery with blocks

Handle blocks in the tree transform for the typo correction as otherwise, the
capture may miss.  This would trigger an assertion.  Thanks to Doug Gregor for
the help with this!

Fixes PR25001.

Added:
cfe/trunk/test/SemaCXX/typo-correction-blocks.c
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=251729&r1=251728&r2=251729&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Oct 30 19:39:15 2015
@@ -6545,6 +6545,8 @@ public:
 
   ExprResult TransformLambdaExpr(LambdaExpr *E) { return Owned(E); }
 
+  ExprResult TransformBlockExpr(BlockExpr *E) { return Owned(E); }
+
   ExprResult Transform(Expr *E) {
 ExprResult Res;
 while (true) {

Added: cfe/trunk/test/SemaCXX/typo-correction-blocks.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction-blocks.c?rev=251729&view=auto
==
--- cfe/trunk/test/SemaCXX/typo-correction-blocks.c (added)
+++ cfe/trunk/test/SemaCXX/typo-correction-blocks.c Fri Oct 30 19:39:15 2015
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple i386-apple-macosx -fblocks -fsyntax-only -verify %s
+
+extern int h(int *);
+extern void g(int, void (^)(void));
+extern int fuzzys;  // expected-note {{'fuzzys' declared here}}
+
+static void f(void *v) {
+  g(fuzzy, ^{   // expected-error {{did you mean 'fuzzys'}}
+int i = h(v);
+  });
+}
+


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


Re: r251041 - Define weak and __weak to mean ARC-style weak references, even in MRC.

2015-10-30 Thread John McCall via cfe-commits
> On Oct 30, 2015, at 5:39 PM, Nico Weber  wrote:
> Hi John,
> 
> this breaks programs that use __weak and target 10.6, like so:
> 
> $ cat test.m
> #import 
> @interface I : NSObject {
>   __weak NSObject* foo_;
> }
> - (NSObject*)foo;
> @end
> 
> @implementation I
> - (NSObject *)foo {
>   return foo_;
> }
> @end
> $ clang -c test.m -mmacosx-version-min=10.6  # works with Xcode's clang
> $ ~/src/llvm-build/bin/clang -c test.m -isysroot $(xcrun -show-sdk-path) 
> -mmacosx-version-min=10.6
> test.m:10:10: error: 'foo_' is unavailable: cannot use weak references 
> because the current deployment target does not support them
>   return foo_;
>  ^
> test.m:3:20: note: unsupported declaration here
>   __weak NSObject* foo_;
>^
> test.m:3:20: error: cannot create __weak reference because the current 
> deployment target does not support weak references
>   __weak NSObject* foo_;
>^
> 2 errors generated.
> 
> 
> We target 10.6 (and don't use ARC) and some library we use has __weak ivars. 
> After this change, we can't build it any longer. This isn't a huge issue: we 
> can change the library to use a WEAK macro that expands to nothing for us and 
> __weak if ARC is enabled, but it sounded like you're interested in hearing 
> about this.

This is intended behavior.  We are changing __weak in non-ARC, non-GC TUs (i.e. 
MRC) to mean ARC-style __weak references.  Since, previously, __weak was 
accepted but silently ignored in MRC, there will be a period of time during 
which __weak will simply be rejected by the compiler in this mode.  The 
compiler does try to be conservative about variables that are actually defined 
in other translation units, but in this case you are defining (and using) the 
ivar in the current TU, and you need to be aware that the semantics of that are 
changing.

If the library is quite old, it may be using __weak in the GC sense, in which 
case you can probably just remove it.  If the library is new, and it really 
wants an ARC weak reference, then you may want your macro to expand to 
__unsafe_unretained, just in case there are files in that project that do use 
ARC.

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


Re: [PATCH] D14149: __builtin_signbit fix for ppcf128 type

2015-10-30 Thread John McCall via cfe-commits
rjmccall added a comment.

LGTM, thanks!


Repository:
  rL LLVM

http://reviews.llvm.org/D14149



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


r251734 - [CodeGen] Call SetInternalFunctionAttributes to attach function

2015-10-30 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Fri Oct 30 20:28:07 2015
New Revision: 251734

URL: http://llvm.org/viewvc/llvm-project?rev=251734&view=rev
Log:
[CodeGen] Call SetInternalFunctionAttributes to attach function
attributes to internal functions.

This patch fixes CodeGenModule::CreateGlobalInitOrDestructFunction to
use SetInternalFunctionAttributes instead of SetLLVMFunctionAttributes
to attach function attributes to internal functions.

Also, make sure the correct CGFunctionInfo is passed instead of always
passing what arrangeNullaryFunction returns.

rdar://problem/20828324

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

Added:
cfe/trunk/test/CodeGenCXX/funcattrs-global-ctor-dtor.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp

Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=251734&r1=251733&r2=251734&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Fri Oct 30 20:28:07 2015
@@ -193,13 +193,15 @@ llvm::Constant *CodeGenFunction::createA
 llvm::raw_svector_ostream Out(FnName);
 CGM.getCXXABI().getMangleContext().mangleDynamicAtExitDestructor(&VD, Out);
   }
+
+  const CGFunctionInfo &FI = CGM.getTypes().arrangeNullaryFunction();
   llvm::Function *fn = CGM.CreateGlobalInitOrDestructFunction(ty, FnName.str(),
+  FI,
   
VD.getLocation());
 
   CodeGenFunction CGF(CGM);
 
-  CGF.StartFunction(&VD, CGM.getContext().VoidTy, fn,
-CGM.getTypes().arrangeNullaryFunction(), 
FunctionArgList());
+  CGF.StartFunction(&VD, CGM.getContext().VoidTy, fn, FI, FunctionArgList());
 
   llvm::CallInst *call = CGF.Builder.CreateCall(dtor, addr);
  
@@ -247,7 +249,8 @@ void CodeGenFunction::EmitCXXGuardedInit
 }
 
 llvm::Function *CodeGenModule::CreateGlobalInitOrDestructFunction(
-llvm::FunctionType *FTy, const Twine &Name, SourceLocation Loc, bool TLS) {
+llvm::FunctionType *FTy, const Twine &Name, const CGFunctionInfo &FI,
+SourceLocation Loc, bool TLS) {
   llvm::Function *Fn =
 llvm::Function::Create(FTy, llvm::GlobalValue::InternalLinkage,
Name, &getModule());
@@ -257,7 +260,7 @@ llvm::Function *CodeGenModule::CreateGlo
   Fn->setSection(Section);
   }
 
-  SetLLVMFunctionAttributes(nullptr, getTypes().arrangeNullaryFunction(), Fn);
+  SetInternalFunctionAttributes(nullptr, Fn, FI);
 
   Fn->setCallingConv(getRuntimeCC());
 
@@ -315,7 +318,9 @@ CodeGenModule::EmitCXXGlobalVarDeclInitF
 
   // Create a variable initialization function.
   llvm::Function *Fn =
-  CreateGlobalInitOrDestructFunction(FTy, FnName.str(), D->getLocation());
+  CreateGlobalInitOrDestructFunction(FTy, FnName.str(),
+ getTypes().arrangeNullaryFunction(),
+ D->getLocation());
 
   auto *ISA = D->getAttr();
   CodeGenFunction(*this).GenerateCXXGlobalVarDeclInitFunc(Fn, D, Addr,
@@ -390,7 +395,7 @@ CodeGenModule::EmitCXXGlobalInitFunc() {
 return;
 
   llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
-
+  const CGFunctionInfo &FI = getTypes().arrangeNullaryFunction();
 
   // Create our global initialization function.
   if (!PrioritizedCXXGlobalInits.empty()) {
@@ -414,7 +419,7 @@ CodeGenModule::EmitCXXGlobalInitFunc() {
   // Priority is always <= 65535 (enforced by sema).
   PrioritySuffix = std::string(6-PrioritySuffix.size(), 
'0')+PrioritySuffix;
   llvm::Function *Fn = CreateGlobalInitOrDestructFunction(
-  FTy, "_GLOBAL__I_" + PrioritySuffix);
+  FTy, "_GLOBAL__I_" + PrioritySuffix, FI);
 
   for (; I < PrioE; ++I)
 LocalCXXGlobalInits.push_back(I->second);
@@ -444,7 +449,7 @@ CodeGenModule::EmitCXXGlobalInitFunc() {
   }
 
   llvm::Function *Fn = CreateGlobalInitOrDestructFunction(
-  FTy, llvm::Twine("_GLOBAL__sub_I_", FileName));
+  FTy, llvm::Twine("_GLOBAL__sub_I_", FileName), FI);
 
   CodeGenFunction(*this).GenerateCXXGlobalInitFunc(Fn, CXXGlobalInits);
   AddGlobalCtor(Fn);
@@ -459,7 +464,9 @@ void CodeGenModule::EmitCXXGlobalDtorFun
   llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
 
   // Create our global destructor function.
-  llvm::Function *Fn = CreateGlobalInitOrDestructFunction(FTy, "_GLOBAL__D_a");
+  const CGFunctionInfo &FI = getTypes().arrangeNullaryFunction();
+  llvm::Function *Fn =
+  CreateGlobalInitOrDestructFunction(FTy, "_GLOBAL__D_a", FI);
 
   CodeGenFunction(*this).GenerateCXXGlobalDtorsFunc(Fn, CXXGlobalDtors);
   AddGlobalDtor(Fn);
@@ -584,7 +591,7 @@ llv

Re: [PATCH] D13610: [CodeGen] Fix CodeGenModule::CreateGlobalInitOrDestructFunction

2015-10-30 Thread Akira Hatanaka via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL251734: [CodeGen] Call SetInternalFunctionAttributes to 
attach function (authored by ahatanak).

Changed prior to commit:
  http://reviews.llvm.org/D13610?vs=37001&id=38835#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13610

Files:
  cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.h
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
  cfe/trunk/test/CodeGenCXX/funcattrs-global-ctor-dtor.cpp

Index: cfe/trunk/test/CodeGenCXX/funcattrs-global-ctor-dtor.cpp
===
--- cfe/trunk/test/CodeGenCXX/funcattrs-global-ctor-dtor.cpp
+++ cfe/trunk/test/CodeGenCXX/funcattrs-global-ctor-dtor.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin -S -stack-protector 2 -emit-llvm -o - | FileCheck %s
+
+class A {
+ public:
+  virtual ~A() {}
+};
+
+A g;
+
+// CHECK: define internal void @__cxx_global_var_init() [[ATTR0:#[0-9]+]]
+// CHECK: define internal void @_GLOBAL__sub_I_funcattrs_global_ctor_dtor.cpp() [[ATTR0]]
+// CHECK: attributes [[ATTR0]] = {{{.*}} sspstrong {{.*}}}
Index: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -2214,8 +2214,8 @@
 llvm::FunctionType *FTy =
 llvm::FunctionType::get(CGM.VoidTy, /*isVarArg=*/false);
 llvm::Function *InitFunc = CGM.CreateGlobalInitOrDestructFunction(
-FTy, "__tls_init", SourceLocation(),
-/*TLS=*/true);
+FTy, "__tls_init", CGM.getTypes().arrangeNullaryFunction(),
+SourceLocation(), /*TLS=*/true);
 CodeGenFunction(CGM).GenerateCXXGlobalInitFunc(InitFunc, NonComdatInits);
 
 AddToXDU(InitFunc);
Index: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1104,7 +1104,7 @@
   /*isVariadic=*/false);
   auto FTy = CGM.getTypes().GetFunctionType(FI);
   auto Fn = CGM.CreateGlobalInitOrDestructFunction(
-  FTy, ".__kmpc_global_ctor_.", Loc);
+  FTy, ".__kmpc_global_ctor_.", FI, Loc);
   CtorCGF.StartFunction(GlobalDecl(), CGM.getContext().VoidPtrTy, Fn, FI,
 Args, SourceLocation());
   auto ArgVal = CtorCGF.EmitLoadOfScalar(
@@ -1136,7 +1136,7 @@
   /*isVariadic=*/false);
   auto FTy = CGM.getTypes().GetFunctionType(FI);
   auto Fn = CGM.CreateGlobalInitOrDestructFunction(
-  FTy, ".__kmpc_global_dtor_.", Loc);
+  FTy, ".__kmpc_global_dtor_.", FI, Loc);
   DtorCGF.StartFunction(GlobalDecl(), CGM.getContext().VoidTy, Fn, FI, Args,
 SourceLocation());
   auto ArgVal = DtorCGF.EmitLoadOfScalar(
@@ -1174,7 +1174,8 @@
   auto InitFunctionTy =
   llvm::FunctionType::get(CGM.VoidTy, /*isVarArg*/ false);
   auto InitFunction = CGM.CreateGlobalInitOrDestructFunction(
-  InitFunctionTy, ".__omp_threadprivate_init_.");
+  InitFunctionTy, ".__omp_threadprivate_init_.",
+  CGM.getTypes().arrangeNullaryFunction());
   CodeGenFunction InitCGF(CGM);
   FunctionArgList ArgList;
   InitCGF.StartFunction(GlobalDecl(), CGM.getContext().VoidTy, InitFunction,
Index: cfe/trunk/lib/CodeGen/CodeGenModule.h
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.h
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h
@@ -686,6 +686,7 @@
 
   llvm::Function *
   CreateGlobalInitOrDestructFunction(llvm::FunctionType *ty, const Twine &name,
+ const CGFunctionInfo &FI,
  SourceLocation Loc = SourceLocation(),
  bool TLS = false);
 
Index: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
===
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2209,7 +2209,8 @@
 // Generate a guarded initialization function.
 llvm::FunctionType *FTy =
 llvm::FunctionType::get(CGM.VoidTy, /*isVarArg=*/false);
-InitFunc = CGM.CreateGlobalInitOrDestructFunction(FTy, "__tls_init",
+const CGFunctionInfo &FI = CGM.getTypes().arrangeNullaryFunction();
+InitFunc = CGM.CreateGlobalInitOrDestructFunction(FTy, "__tls_init", FI,
   SourceLocation(),
   /*TLS=*/true);
 llvm::GlobalVariable *Guard = new llvm::GlobalVariable(
Index: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
===
--- cfe/trunk/li

Re: Implict casts disappeared from syntactic init list expressions in C++

2015-10-30 Thread Abramo Bagnara via cfe-commits
Ping (I still need your feedback so that I can open a properly
documented issue on bugzilla).

Il 09/10/2015 09:58, Abramo Bagnara ha scritto:
> Il 08/10/2015 23:36, Richard Smith ha scritto:
>> There are some other open problems in this area:
>>
>> - RecursiveASTVisitor on nested InitListExprs is currently worst-case
>> exponential time because it walks the syntactic and semantic forms
>> separately
>> - Tools such as "find all references to this function" need the semantic
>> form of every initializer, whether or not that initializer is actually
>> used for the initialization (it might be overridden through the use of a
>> designator)
>> - ...
>>
>> Having thought about this for a while, I think the right answer is this:
>>
>> The only difference between the syntactic and semantic forms of an
>> InitListExpr should be designated initializers and brace elision. In all
>> other respects, the syntactic and semantic forms should be identical --
>> in particular, both should contain the results of performing the
>> relevant initialization sequences on the list elements, and we should
>> extend the syntactic form to include the implicit initializations for
>> trailing elements.
> 
> I suppose that you are proposing to include implicit initializations for
> trailing elements to have in syntactic form all the references.
> 
> Note however that what you suggest is not enough when extending C++ with
> designated initializers (like gcc and clang do, at least partially).
> 
> This is an example:
> 
> struct f1 {
>   f1();
> };
> struct f2 {
>   f2();
> };
> 
> struct s {
>   f1 x;
>   f2 y;
> };
> 
> s v = { .x = f1() };
> 
> You can easily imagine a similar example where the same effect is
> obtained with an array (three elements, first and third are explicitly
> initialized).
> 
> IMHO it is better to avoid to add implicit fields/array elements
> initialization in syntactic form and let tools that need to collect
> implicit constructor reference to find a different way, e.g. scanning
> semantic form for ImplicitValueInitExpr children of InitListExpr
> (unfortunately currently not present (by mistake I guess, but I'd like
> to hear your opinion) as you can observe from -ast-dump output of
> previous example).
> 
>> With that in hand, we should make RecursiveASTVisitor visit /only/ the
>> syntactic form. The semantic ("simplified") form should only be used in
>> places where we want to know the semantic effect of the initialization
>> (after applying the designated initialization overriding rules and
>> inserting the elided braces), and is always derivable in a fairly
>> straightforward fashion from the syntactic form.
>>
>> I think that's largely what you were suggesting below. Do you agree?
> 
> Apart the doubt about the detail above, your design matches perfectly my
> suggestions.
> 
> 


-- 
Abramo Bagnara

BUGSENG srl - http://bugseng.com
mailto:abramo.bagn...@bugseng.com
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits