[PATCH] D32700: [clang-tidy] Add bugprone-suspicious-memset-usage check.

2017-07-13 Thread Reka Kovacs via Phabricator via cfe-commits
rnkovacs updated this revision to Diff 106381.

https://reviews.llvm.org/D32700

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp
  clang-tidy/bugprone/SuspiciousMemsetUsageCheck.h
  clang-tidy/google/CMakeLists.txt
  clang-tidy/google/GoogleTidyModule.cpp
  clang-tidy/google/MemsetZeroLengthCheck.cpp
  clang-tidy/google/MemsetZeroLengthCheck.h
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-suspicious-memset-usage.rst
  docs/clang-tidy/checks/google-runtime-memset.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/bugprone-suspicious-memset-usage.cpp
  test/clang-tidy/google-runtime-memset-zero-length.cpp

Index: test/clang-tidy/google-runtime-memset-zero-length.cpp
===
--- test/clang-tidy/google-runtime-memset-zero-length.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-// RUN: %check_clang_tidy %s google-runtime-memset %t
-
-void *memset(void *, int, __SIZE_TYPE__);
-
-namespace std {
-  using ::memset;
-}
-
-template 
-void memtmpl() {
-  memset(0, sizeof(int), i);
-  memset(0, sizeof(T), sizeof(T));
-  memset(0, sizeof(T), 0);
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: memset of size zero, potentially swapped argument
-// CHECK-FIXES: memset(0, 0, sizeof(T));
-  memset(0, sizeof(int), 0);
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: memset of size zero, potentially swapped argument
-// CHECK-FIXES: memset(0, 0, sizeof(int));
-}
-
-void foo(void *a, int xsize, int ysize) {
-  memset(a, sizeof(int), 0);
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: memset of size zero, potentially swapped argument
-// CHECK-FIXES: memset(a, 0, sizeof(int));
-#define M memset(a, sizeof(int), 0);
-  M
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: memset of size zero, potentially swapped argument
-// CHECK-FIXES: #define M memset(a, sizeof(int), 0);
-  ::memset(a, xsize *
-   ysize, 0);
-// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: memset of size zero, potentially swapped argument
-// CHECK-FIXES: ::memset(a, 0, xsize *
-// CHECK-FIXES-NEXT: ysize);
-  std::memset(a, sizeof(int), 0x00);
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: memset of size zero, potentially swapped argument
-// CHECK-FIXES: std::memset(a, 0x00, sizeof(int));
-
-  const int v = 0;
-  memset(a, sizeof(int), v);
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: memset of size zero, potentially swapped argument
-// CHECK-FIXES: memset(a, v, sizeof(int));
-
-  memset(a, sizeof(int), v + v);
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: memset of size zero, potentially swapped argument
-// CHECK-FIXES: memset(a, v + v, sizeof(int));
-
-  memset(a, sizeof(int), v + 1);
-
-  memset(a, -1, sizeof(int));
-  memset(a, 0xcd, 1);
-
-  // Don't warn when the fill char and the length are both known to be
-  // zero.  No bug is possible.
-  memset(a, 0, v);
-  memset(a, v, 0);
-
-  // -1 is clearly not a length by virtue of being negative, so no warning
-  // despite v == 0.
-  memset(a, -1, v);
-
-  memtmpl<0, int>();
-}
Index: test/clang-tidy/bugprone-suspicious-memset-usage.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-suspicious-memset-usage.cpp
@@ -0,0 +1,77 @@
+// RUN: %check_clang_tidy %s bugprone-suspicious-memset-usage %t
+
+void *memset(void *, int, __SIZE_TYPE__);
+
+namespace std {
+  using ::memset;
+}
+
+template 
+void mtempl(int *ptr) {
+  memset(ptr, '0', sizeof(T));
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: memset fill value is char '0', potentially mistaken for int 0 [bugprone-suspicious-memset-usage]
+// CHECK-FIXES: memset(ptr, 0, sizeof(T));
+  memset(ptr, 256, sizeof(T));
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: memset fill value is out of unsigned character range, gets truncated [bugprone-suspicious-memset-usage]
+  memset(0, sizeof(T), 0);
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: memset of size zero, potentially swapped arguments [bugprone-suspicious-memset-usage]
+// CHECK-FIXES: memset(0, 0, sizeof(T));
+  memset(0, sizeof(int), 0);
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: memset of size zero, potentially swapped arguments [bugprone-suspicious-memset-usage]
+// CHECK-FIXES: memset(0, 0, sizeof(int));
+}
+
+void foo(int xsize, int ysize) {
+  int i[5] = {1, 2, 3, 4, 5};
+  char ca[3] = {'a', 'b', 'c'};
+  int *p = i;
+  int l = 5;
+  char z = '1';
+  char *c = &z;
+  int v = 0;
+
+  memset(p, '0', l);
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: memset fill value is char '0', potentially mistaken for int 0 [bugprone-suspicious-memset-usage]
+// CHECK-FIXES: memset(p, 0, l);
+
+  memset(p, 0xabcd, l);
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: memset fill value is out of unsigned character range, gets truncated [bugprone-suspicious-memset-usage]
+
+  memset(p, sizeof(int), 

[PATCH] D32700: [clang-tidy] Add bugprone-suspicious-memset-usage check.

2017-07-13 Thread Reka Kovacs via Phabricator via cfe-commits
rnkovacs marked an inline comment as done.
rnkovacs added inline comments.



Comment at: docs/clang-tidy/checks/bugprone-suspicious-memset-usage.rst:10
+
+**Case 1: Fill value is a character '0'**
+

whisperity wrote:
> Shouldn't this `'0'` be enclosed within backticks?
Fixed that and the too short title underline.


https://reviews.llvm.org/D32700



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


[PATCH] D35190: __builtin_constant_p should consider the parameter of a constexpr function as constant

2017-07-13 Thread Olivier Goffart via Phabricator via cfe-commits
ogoffart added a comment.

Thanks for the link to the bug report.
This patch mostly address the evaluation within a constexpr, which is 
orthogonal to the changes in the backend suggered in that bug report.


https://reviews.llvm.org/D35190



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


[PATCH] D35000: [OpenCL] Added extended tests on metadata generation for half data type and arrays.

2017-07-13 Thread Egor Churaev via Phabricator via cfe-commits
echuraev added a comment.

In https://reviews.llvm.org/D35000#801132, @Anastasia wrote:

> In https://reviews.llvm.org/D35000#799705, @Anastasia wrote:
>
> > Btw, is there any reason to add testing specifically for half? Is there 
> > anything specific to half in the implementation of this?
>
>
> Trying to understand the reason for this change though...


Sorry for a delay in response. No it is not any reason to add testing 
specifically for half. We can also do the same tests for other data types. Here 
we just check that it is no any qualifiers in metadata.


https://reviews.llvm.org/D35000



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


[PATCH] D35118: [AArch64] Add support for handling the +sve target feature

2017-07-13 Thread Amara Emerson via Phabricator via cfe-commits
aemerson added a comment.

In https://reviews.llvm.org/D35118#806730, @rengolin wrote:

> @jmolloy Can you check this change, please?


I'm not really removing FPUMode, I'm just converting an enum to a bit field. 
FPUMode, i.e. no NEON, after this change is now represented by simply having 
all bits be 0. See the equivalent implementation for ARM which does the same 
thing.


Repository:
  rL LLVM

https://reviews.llvm.org/D35118



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


[PATCH] D33440: clang-format: better handle statement and namespace macros

2017-07-13 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

ping?


https://reviews.llvm.org/D33440



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


[PATCH] D35118: [AArch64] Add support for handling the +sve target feature

2017-07-13 Thread Renato Golin via Phabricator via cfe-commits
rengolin added a comment.

In https://reviews.llvm.org/D35118#807712, @aemerson wrote:

> In https://reviews.llvm.org/D35118#806730, @rengolin wrote:
>
> > @jmolloy Can you check this change, please?
>
>
> I'm not really removing FPUMode, I'm just converting an enum to a bit field. 
> FPUMode, i.e. no NEON, after this change is now represented by simply having 
> all bits be 0. See the equivalent implementation for ARM which does the same 
> thing.


That's not really a bit field, but the point is that you're removing the 
explicit categorisation, which helps people understand what it all means and 
why it was there in the first place.

There is no reason to remove FPUMode. You can just add "SveMode" to that list 
and make it (1 << 1) to make it explicit that this is bit pattern enum.


Repository:
  rL LLVM

https://reviews.llvm.org/D35118



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


r307898 - [refactor][rename] Use a single base class for class that finds

2017-07-13 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Jul 13 03:36:33 2017
New Revision: 307898

URL: http://llvm.org/viewvc/llvm-project?rev=307898&view=rev
Log:
[refactor][rename] Use a single base class for class that finds
a declaration at location and for class that searches for all occurrences of
a specific declaration

This commit uses a single RecursiveSymbolVisitor class for both
USRLocFindingASTVisitor and NamedDeclOccurrenceFindingVisitor to avoid duplicate
traversal code. It also traverses nested name specifier locs in the new class
and remove the separate matching step.

Differential Revision: https://reviews.llvm.org/D34949

Added:
cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
Modified:
cfe/trunk/include/clang/Tooling/Refactoring/Rename/USRFinder.h
cfe/trunk/include/clang/module.modulemap
cfe/trunk/lib/Tooling/Refactoring/Rename/USRFinder.cpp
cfe/trunk/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp

Added: cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h?rev=307898&view=auto
==
--- cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h (added)
+++ cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h Thu 
Jul 13 03:36:33 2017
@@ -0,0 +1,124 @@
+//===--- RecursiveSymbolVisitor.h - Clang refactoring library 
-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// \brief A wrapper class around \c RecursiveASTVisitor that visits each
+/// occurrences of a named symbol.
+///
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLING_REFACTOR_RECURSIVE_SYMBOL_VISITOR_H
+#define LLVM_CLANG_TOOLING_REFACTOR_RECURSIVE_SYMBOL_VISITOR_H
+
+#include "clang/AST/AST.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace llvm;
+
+namespace clang {
+namespace tooling {
+
+/// Traverses the AST and visits the occurrence of each named symbol in the
+/// given nodes.
+template 
+class RecursiveSymbolVisitor
+: public RecursiveASTVisitor> {
+  using BaseType = RecursiveASTVisitor>;
+
+public:
+  RecursiveSymbolVisitor(const SourceManager &SM, const LangOptions &LangOpts)
+  : SM(SM), LangOpts(LangOpts) {}
+
+  bool visitSymbolOccurrence(const NamedDecl *ND,
+ ArrayRef NameRanges) {
+return true;
+  }
+
+  // Declaration visitors:
+
+  bool VisitNamedDecl(const NamedDecl *D) {
+return isa(D) ? true : visit(D, D->getLocation());
+  }
+
+  bool VisitCXXConstructorDecl(const CXXConstructorDecl *CD) {
+for (const auto *Initializer : CD->inits()) {
+  // Ignore implicit initializers.
+  if (!Initializer->isWritten())
+continue;
+  if (const FieldDecl *FD = Initializer->getMember()) {
+if (!visit(FD, Initializer->getSourceLocation(),
+   Lexer::getLocForEndOfToken(Initializer->getSourceLocation(),
+  0, SM, LangOpts)))
+  return false;
+  }
+}
+return true;
+  }
+
+  // Expression visitors:
+
+  bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
+return visit(Expr->getFoundDecl(), Expr->getLocation());
+  }
+
+  bool VisitMemberExpr(const MemberExpr *Expr) {
+return visit(Expr->getFoundDecl().getDecl(), Expr->getMemberLoc());
+  }
+
+  // Other visitors:
+
+  bool VisitTypeLoc(const TypeLoc Loc) {
+const SourceLocation TypeBeginLoc = Loc.getBeginLoc();
+const SourceLocation TypeEndLoc =
+Lexer::getLocForEndOfToken(TypeBeginLoc, 0, SM, LangOpts);
+if (const auto *TemplateTypeParm =
+dyn_cast(Loc.getType())) {
+  if (!visit(TemplateTypeParm->getDecl(), TypeBeginLoc, TypeEndLoc))
+return false;
+}
+if (const auto *TemplateSpecType =
+dyn_cast(Loc.getType())) {
+  if (!visit(TemplateSpecType->getTemplateName().getAsTemplateDecl(),
+ TypeBeginLoc, TypeEndLoc))
+return false;
+}
+return visit(Loc.getType()->getAsCXXRecordDecl(), TypeBeginLoc, 
TypeEndLoc);
+  }
+
+  bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS) {
+// The base visitor will visit NNSL prefixes, so we should only look at
+// the current NNS.
+if (NNS) {
+  const NamespaceDecl *ND = NNS.getNestedNameSpecifier()->getAsNamespace();
+  if (!visit(ND, NNS.getLocalBeginLoc(), NNS.getLocalEndLoc()))
+return false;
+}
+return BaseType::TraverseNestedNameSpecifierLoc(NNS);
+  }
+
+private:
+  const SourceManager &SM;
+  const LangOptions &LangOpts;
+
+  bool visit(const Nam

[PATCH] D34949: [refactor][rename] Use a single base class for class that finds a declaration at location and for class that searches for all occurrences of a specific declaration

2017-07-13 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL307898: [refactor][rename] Use a single base class for class 
that finds (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D34949?vs=105084&id=106388#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34949

Files:
  cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
  cfe/trunk/include/clang/Tooling/Refactoring/Rename/USRFinder.h
  cfe/trunk/include/clang/module.modulemap
  cfe/trunk/lib/Tooling/Refactoring/Rename/USRFinder.cpp
  cfe/trunk/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp

Index: cfe/trunk/lib/Tooling/Refactoring/Rename/USRFinder.cpp
===
--- cfe/trunk/lib/Tooling/Refactoring/Rename/USRFinder.cpp
+++ cfe/trunk/lib/Tooling/Refactoring/Rename/USRFinder.cpp
@@ -18,139 +18,46 @@
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Index/USRGeneration.h"
 #include "clang/Lex/Lexer.h"
+#include "clang/Tooling/Refactoring/RecursiveSymbolVisitor.h"
 #include "llvm/ADT/SmallVector.h"
 
 using namespace llvm;
 
 namespace clang {
 namespace tooling {
 
-// NamedDeclFindingASTVisitor recursively visits each AST node to find the
-// symbol underneath the cursor.
-// FIXME: move to separate .h/.cc file if this gets too large.
 namespace {
-class NamedDeclFindingASTVisitor
-: public clang::RecursiveASTVisitor {
+
+/// Recursively visits each AST node to find the symbol underneath the cursor.
+class NamedDeclOccurrenceFindingVisitor
+: public RecursiveSymbolVisitor {
 public:
   // \brief Finds the NamedDecl at a point in the source.
   // \param Point the location in the source to search for the NamedDecl.
-  explicit NamedDeclFindingASTVisitor(const SourceLocation Point,
-  const ASTContext &Context)
-  : Result(nullptr), Point(Point), Context(Context) {}
-
-  // \brief Finds the NamedDecl for a name in the source.
-  // \param Name the fully qualified name.
-  explicit NamedDeclFindingASTVisitor(const std::string &Name,
-  const ASTContext &Context)
-  : Result(nullptr), Name(Name), Context(Context) {}
-
-  // Declaration visitors:
-
-  // \brief Checks if the point falls within the NameDecl. This covers every
-  // declaration of a named entity that we may come across. Usually, just
-  // checking if the point lies within the length of the name of the declaration
-  // and the start location is sufficient.
-  bool VisitNamedDecl(const NamedDecl *Decl) {
-return dyn_cast(Decl)
-   ? true
-   : setResult(Decl, Decl->getLocation(),
-   Decl->getNameAsString().length());
-  }
-
-  // Expression visitors:
-
-  bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
-const NamedDecl *Decl = Expr->getFoundDecl();
-return setResult(Decl, Expr->getLocation(),
- Decl->getNameAsString().length());
-  }
-
-  bool VisitMemberExpr(const MemberExpr *Expr) {
-const NamedDecl *Decl = Expr->getFoundDecl().getDecl();
-return setResult(Decl, Expr->getMemberLoc(),
- Decl->getNameAsString().length());
-  }
-
-  // Other visitors:
-
-  bool VisitTypeLoc(const TypeLoc Loc) {
-const SourceLocation TypeBeginLoc = Loc.getBeginLoc();
-const SourceLocation TypeEndLoc = Lexer::getLocForEndOfToken(
-TypeBeginLoc, 0, Context.getSourceManager(), Context.getLangOpts());
-if (const auto *TemplateTypeParm =
-dyn_cast(Loc.getType()))
-  return setResult(TemplateTypeParm->getDecl(), TypeBeginLoc, TypeEndLoc);
-if (const auto *TemplateSpecType =
-dyn_cast(Loc.getType())) {
-  return setResult(TemplateSpecType->getTemplateName().getAsTemplateDecl(),
-   TypeBeginLoc, TypeEndLoc);
-}
-return setResult(Loc.getType()->getAsCXXRecordDecl(), TypeBeginLoc,
- TypeEndLoc);
-  }
-
-  bool VisitCXXConstructorDecl(clang::CXXConstructorDecl *ConstructorDecl) {
-for (const auto *Initializer : ConstructorDecl->inits()) {
-  // Ignore implicit initializers.
-  if (!Initializer->isWritten())
-continue;
-  if (const clang::FieldDecl *FieldDecl = Initializer->getMember()) {
-const SourceLocation InitBeginLoc = Initializer->getSourceLocation(),
- InitEndLoc = Lexer::getLocForEndOfToken(
- InitBeginLoc, 0, Context.getSourceManager(),
- Context.getLangOpts());
-if (!setResult(FieldDecl, InitBeginLoc, InitEndLoc))
-  return false;
-  }
-}
-return true;
-  }
-
-  // Other:
-
-  const NamedDecl *getNamedDecl() { return Result; }
-
-  // \brief Determines if a namespace qualifier contains the point.
-  // \returns false on success and sets Result.
-  void handleNestedNameSpecifierLoc(NestedNameSpecifierLoc NameLoc) {
-  

[PATCH] D35118: [AArch64] Add support for handling the +sve target feature

2017-07-13 Thread Amara Emerson via Phabricator via cfe-commits
aemerson updated this revision to Diff 106386.
aemerson added a comment.

The reason it's removed is because it's not actually used anywhere, just as a 
default value. I'm not going to debate it further though so I've put it back in.


Repository:
  rL LLVM

https://reviews.llvm.org/D35118

Files:
  lib/Basic/Targets.cpp
  test/Preprocessor/aarch64-target-features.c


Index: test/Preprocessor/aarch64-target-features.c
===
--- test/Preprocessor/aarch64-target-features.c
+++ test/Preprocessor/aarch64-target-features.c
@@ -37,6 +37,7 @@
 // CHECK-NOT: __ARM_PCS_VFP 1
 // CHECK-NOT: __ARM_SIZEOF_MINIMAL_ENUM 1
 // CHECK-NOT: __ARM_SIZEOF_WCHAR_T 2
+// CHECK-NOT: __ARM_FEATURE_SVE
 
 // RUN: %clang -target aarch64_be-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-BIGENDIAN
 // CHECK-BIGENDIAN: __ARM_BIG_ENDIAN 1
@@ -84,6 +85,10 @@
 // CHECK-GENERIC: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon"
 
 // RUN: %clang -target aarch64 -mtune=cyclone -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MTUNE-CYCLONE %s
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+sve -x c -E -dM 
%s -o - | FileCheck --check-prefix=CHECK-SVE %s
+// CHECK-SVE: __ARM_FEATURE_SVE 1
+
 // == Check whether -mtune accepts mixed-case features.
 // RUN: %clang -target aarch64 -mtune=CYCLONE -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MTUNE-CYCLONE %s
 // CHECK-MTUNE-CYCLONE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+neon" "-target-feature" "+zcm" "-target-feature" "+zcz"
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -6243,7 +6243,8 @@
 
   enum FPUModeEnum {
 FPUMode,
-NeonMode
+NeonMode = (1 << 0),
+SveMode = (1 << 1)
   };
 
   unsigned FPU;
@@ -6377,12 +6378,15 @@
 Builder.defineMacro("__ARM_SIZEOF_MINIMAL_ENUM",
 Opts.ShortEnums ? "1" : "4");
 
-if (FPU == NeonMode) {
+if (FPU & NeonMode) {
   Builder.defineMacro("__ARM_NEON", "1");
   // 64-bit NEON supports half, single and double precision operations.
   Builder.defineMacro("__ARM_NEON_FP", "0xE");
 }
 
+if (FPU & SveMode)
+  Builder.defineMacro("__ARM_FEATURE_SVE", "1");
+
 if (CRC)
   Builder.defineMacro("__ARM_FEATURE_CRC32", "1");
 
@@ -6418,7 +6422,8 @@
 return Feature == "aarch64" ||
   Feature == "arm64" ||
   Feature == "arm" ||
-  (Feature == "neon" && FPU == NeonMode);
+  (Feature == "neon" && (FPU & NeonMode)) ||
+  (Feature == "sve" && (FPU & SveMode));
   }
 
   bool handleTargetFeatures(std::vector &Features,
@@ -6432,7 +6437,9 @@
 
 for (const auto &Feature : Features) {
   if (Feature == "+neon")
-FPU = NeonMode;
+FPU |= NeonMode;
+  if (Feature == "+sve")
+FPU |= SveMode;
   if (Feature == "+crc")
 CRC = 1;
   if (Feature == "+crypto")


Index: test/Preprocessor/aarch64-target-features.c
===
--- test/Preprocessor/aarch64-target-features.c
+++ test/Preprocessor/aarch64-target-features.c
@@ -37,6 +37,7 @@
 // CHECK-NOT: __ARM_PCS_VFP 1
 // CHECK-NOT: __ARM_SIZEOF_MINIMAL_ENUM 1
 // CHECK-NOT: __ARM_SIZEOF_WCHAR_T 2
+// CHECK-NOT: __ARM_FEATURE_SVE
 
 // RUN: %clang -target aarch64_be-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-BIGENDIAN
 // CHECK-BIGENDIAN: __ARM_BIG_ENDIAN 1
@@ -84,6 +85,10 @@
 // CHECK-GENERIC: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon"
 
 // RUN: %clang -target aarch64 -mtune=cyclone -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MTUNE-CYCLONE %s
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+sve -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE %s
+// CHECK-SVE: __ARM_FEATURE_SVE 1
+
 // == Check whether -mtune accepts mixed-case features.
 // RUN: %clang -target aarch64 -mtune=CYCLONE -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MTUNE-CYCLONE %s
 // CHECK-MTUNE-CYCLONE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+zcm" "-target-feature" "+zcz"
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -6243,7 +6243,8 @@
 
   enum FPUModeEnum {
 FPUMode,
-NeonMode
+NeonMode = (1 << 0),
+SveMode = (1 << 1)
   };
 
   unsigned FPU;
@@ -6377,12 +6378,15 @@
 Builder.defineMacro("__ARM_SIZEOF_MINIMAL_ENUM",
 Opts.ShortEnums ? "1" : "4");
 
-if (FPU == NeonMode) {
+if (FPU & NeonMode) {
   Builder.defineMacro("__ARM_NEON", "1");
   // 64-bit NEON supports half, single and double precision operations.
   Builder.defineMacro("__ARM_NEON_FP", "0xE");
 }
 
+if (FPU & SveMode)
+  Builder.defineMacro("__AR

r307901 - [index] Objective-C method declarations and message sends with

2017-07-13 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Jul 13 03:50:21 2017
New Revision: 307901

URL: http://llvm.org/viewvc/llvm-project?rev=307901&view=rev
Log:
[index] Objective-C method declarations and message sends with
an empty first selector piece should store the location of the first ':'

rdar://33188656

Modified:
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/test/Index/Core/index-source.m

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=307901&r1=307900&r2=307901&view=diff
==
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Thu Jul 13 03:50:21 2017
@@ -1007,6 +1007,10 @@ IdentifierInfo *Parser::ParseObjCSelecto
   switch (Tok.getKind()) {
   default:
 return nullptr;
+  case tok::colon:
+// Empty selector piece uses the location of the ':'.
+SelectorLoc = Tok.getLocation();
+return nullptr;
   case tok::ampamp:
   case tok::ampequal:
   case tok::amp:

Modified: cfe/trunk/test/Index/Core/index-source.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.m?rev=307901&r1=307900&r2=307901&view=diff
==
--- cfe/trunk/test/Index/Core/index-source.m (original)
+++ cfe/trunk/test/Index/Core/index-source.m Thu Jul 13 03:50:21 2017
@@ -438,3 +438,28 @@ void testImplicitProperties(ImplicitProp
 // CHECK: [[@LINE-1]]:22 | class-method/ObjC | classImplicit | 
c:objc(cs)ImplicitProperties(cm)classImplicit | +[ImplicitProperties 
classImplicit] | Ref,Call,RelCall,RelCont | rel: 1
 // CHECK-NEXT: RelCall,RelCont | testImplicitProperties | 
c:@F@testImplicitProperties
 }
+
+@interface EmptySelectors
+
+- (int):(int)_; // CHECK: [[@LINE]]:8 | instance-method/ObjC | : | 
c:objc(cs)EmptySelectors(im): | -[EmptySelectors :]
+- (void)test: (int)x :(int)y; // CHECK: [[@LINE]]:9 | instance-method/ObjC | 
test:: | c:objc(cs)EmptySelectors(im)test:: | -[EmptySelectors test::]
+- (void):(int)_ :(int)m:(int)z; // CHECK: [[@LINE]]:9 | instance-method/ObjC | 
::: | c:objc(cs)EmptySelectors(im)::: | -[EmptySelectors :::]
+
+@end
+
+@implementation EmptySelectors
+
+- (int):(int)_ { // CHECK: [[@LINE]]:8 | instance-method/ObjC | : | 
c:objc(cs)EmptySelectors(im): | -[EmptySelectors :]
+  [self :2]; // CHECK: [[@LINE]]:9 | instance-method/ObjC | : | 
c:objc(cs)EmptySelectors(im): | -[EmptySelectors :]
+  return 0;
+}
+
+- (void)test: (int)x :(int)y { // CHECK: [[@LINE]]:9 | instance-method/ObjC | 
test:: | c:objc(cs)EmptySelectors(im)test:: | -[EmptySelectors test::]
+}
+
+- (void) :(int)_ :(int)m :(int)z { // CHECK: [[@LINE]]:10 | 
instance-method/ObjC | ::: | c:objc(cs)EmptySelectors(im)::: | -[EmptySelectors 
:::]
+  [self test:0:1]; // CHECK: [[@LINE]]:9 | instance-method/ObjC | test:: | 
c:objc(cs)EmptySelectors(im)test:: | -[EmptySelectors test::]
+  [self: 0: 1: 2]; // CHECK: [[@LINE]]:8 | instance-method/ObjC | ::: | 
c:objc(cs)EmptySelectors(im)::: | -[EmptySelectors :::]
+}
+
+@end


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


[PATCH] D35118: [AArch64] Add support for handling the +sve target feature

2017-07-13 Thread Renato Golin via Phabricator via cfe-commits
rengolin accepted this revision.
rengolin added a comment.
This revision is now accepted and ready to land.

Thanks. LGTM.


Repository:
  rL LLVM

https://reviews.llvm.org/D35118



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


[PATCH] D35268: [ObjC] Ambiguous property synthesis should pick the 'readwrite' property and check for incompatible attributes

2017-07-13 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL307903: [ObjC] Pick a 'readwrite' property when synthesizing 
ambiguous (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D35268?vs=106060&id=106394#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35268

Files:
  cfe/trunk/include/clang/AST/DeclObjC.h
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/AST/DeclObjC.cpp
  cfe/trunk/lib/Sema/SemaObjCProperty.cpp
  cfe/trunk/test/CodeGenObjC/arc-property.m
  cfe/trunk/test/SemaObjC/arc-property-decl-attrs.m
  cfe/trunk/test/SemaObjC/property-ambiguous-synthesis.m

Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -808,8 +808,10 @@
   "property type %0 is incompatible with type %1 inherited from %2">,
   InGroup>;
 def warn_protocol_property_mismatch : Warning<
-  "property of type %0 was selected for synthesis">,
+  "property %select{of type %1|with attribute '%1'|without attribute '%1'|with "
+  "getter %1|with setter %1}0 was selected for synthesis">,
   InGroup>;
+def err_protocol_property_mismatch: Error;
 def err_undef_interface : Error<"cannot find interface declaration for %0">;
 def err_category_forward_interface : Error<
   "cannot define %select{category|class extension}0 for undefined class %1">;
@@ -1088,7 +1090,9 @@
 def note_property_declare : Note<
   "property declared here">;
 def note_protocol_property_declare : Note<
-  "it could also be property of type %0 declared here">;
+  "it could also be property "
+  "%select{of type %1|without attribute '%1'|with attribute '%1'|with getter "
+  "%1|with setter %1}0 declared here">;
 def note_property_synthesize : Note<
   "property synthesized here">;
 def err_synthesize_category_decl : Error<
Index: cfe/trunk/include/clang/AST/DeclObjC.h
===
--- cfe/trunk/include/clang/AST/DeclObjC.h
+++ cfe/trunk/include/clang/AST/DeclObjC.h
@@ -1039,10 +1039,9 @@
   typedef llvm::DenseMap,
  ObjCPropertyDecl*> PropertyMap;
-  
-  typedef llvm::DenseMap
-ProtocolPropertyMap;
-  
+
+  typedef llvm::SmallDenseSet ProtocolPropertySet;
+
   typedef llvm::SmallVector PropertyDeclOrder;
   
   /// This routine collects list of properties to be implemented in the class.
@@ -2159,7 +2158,8 @@
 PropertyDeclOrder &PO) const override;
 
   void collectInheritedProtocolProperties(const ObjCPropertyDecl *Property,
-  ProtocolPropertyMap &PM) const;
+  ProtocolPropertySet &PS,
+  PropertyDeclOrder &PO) const;
 
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) { return K == ObjCProtocol; }
Index: cfe/trunk/test/CodeGenObjC/arc-property.m
===
--- cfe/trunk/test/CodeGenObjC/arc-property.m
+++ cfe/trunk/test/CodeGenObjC/arc-property.m
@@ -131,4 +131,24 @@
 - (void) setCopyMachine: (id) x {}
 @end
 
+// rdar://31579994
+// When synthesizing a property that's declared in multiple protocols, ensure
+// that the setter is emitted if any of these declarations is readwrite.
+@protocol ABC
+@property (copy, nonatomic,  readonly) Test3 *someId;
+@end
+@protocol ABC__Mutable 
+@property (copy, nonatomic, readwrite) Test3 *someId;
+@end
+
+@interface ABC_Class 
+@end
+
+@implementation ABC_Class
+@synthesize someId = _someId;
+// CHECK:  define internal %{{.*}}* @"\01-[ABC_Class someId]"
+// CHECK:  define internal void @"\01-[ABC_Class setSomeId:]"(
+@end
+
+
 // CHECK: attributes [[NUW]] = { nounwind }
Index: cfe/trunk/test/SemaObjC/property-ambiguous-synthesis.m
===
--- cfe/trunk/test/SemaObjC/property-ambiguous-synthesis.m
+++ cfe/trunk/test/SemaObjC/property-ambiguous-synthesis.m
@@ -2,7 +2,7 @@
 // rdar://13075400
 
 @protocol FooAsID
-@property (copy) id foo; // expected-note 2 {{it could also be property of type 'id' declared here}} \\
+@property (assign) id foo; // expected-note 2 {{it could also be property of type 'id' declared here}} \\
 			 // expected-warning {{property of type 'id' was selected for synthesis}}
 @end
 
Index: cfe/trunk/test/SemaObjC/arc-property-decl-attrs.m
===
--- cfe/trunk/test/SemaObjC/arc-property-decl-attrs.m
+++ cfe/trunk/test/SemaObjC/arc-property-decl-attrs.m
@@ -121,3 +121,107 @@
 @implementation I2
 @synthesize prop;
 @end
+
+// rdar://31579994
+// Verify that the all of the property declarations in inherited protocols are
+// compatible when synthesing a property f

r307903 - [ObjC] Pick a 'readwrite' property when synthesizing ambiguous

2017-07-13 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Jul 13 04:06:22 2017
New Revision: 307903

URL: http://llvm.org/viewvc/llvm-project?rev=307903&view=rev
Log:
[ObjC] Pick a 'readwrite' property when synthesizing ambiguous
property and check for incompatible attributes

This commit changes the way ambiguous property synthesis (i.e. when synthesizing
a property that's declared in multiple protocols) is performed. Previously,
Clang synthesized the first property that was found. This lead to problems when
the property was synthesized in a class that conformed to two protocols that
declared that property and a second protocols had a 'readwrite' declaration -
the setter was not synthesized so the class didn't really conform to the second
protocol and user's code would crash at runtime when they would try to set the
property.

This commit ensures that a first readwrite property is selected. This is a
semantic change that changes users code in this manner:

```
@protocol P @property(readonly) int p; @end
@protocol P2 @property(readwrite) id p; @end
@interface I  @end
@implementation I
@syntesize p; // Users previously got a warning here, and Clang synthesized
  // readonly 'int p' here. Now Clang synthesizes readwrite 'id' p..
@end
```

To ensure that this change is safe, the warning about incompatible types is
promoted to an error when this kind of readonly/readwrite ambiguity is detected
in the @implementation. This will ensure that previous code that had this subtle
bug and ignored the warning now will fail to compile with an error, and users
should not get suprises at runtime once they resolve the error.

The commit also extends the ambiguity checker, and now it can detect conflicts
among the different property attributes. An error diagnostic is used for
conflicting attributes, to ensure that the user won't get "suprises" at runtime.

ProtocolPropertyMap is removed in favour of a a set + vector because the map's
order of iteration is non-deterministic, so it couldn't be used to select the
readwrite property.

rdar://31579994

Differential Revision: https://reviews.llvm.org/D35268

Modified:
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/AST/DeclObjC.cpp
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/test/CodeGenObjC/arc-property.m
cfe/trunk/test/SemaObjC/arc-property-decl-attrs.m
cfe/trunk/test/SemaObjC/property-ambiguous-synthesis.m

Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=307903&r1=307902&r2=307903&view=diff
==
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Thu Jul 13 04:06:22 2017
@@ -1039,10 +1039,9 @@ public:
   typedef llvm::DenseMap,
  ObjCPropertyDecl*> PropertyMap;
-  
-  typedef llvm::DenseMap
-ProtocolPropertyMap;
-  
+
+  typedef llvm::SmallDenseSet ProtocolPropertySet;
+
   typedef llvm::SmallVector PropertyDeclOrder;
   
   /// This routine collects list of properties to be implemented in the class.
@@ -2159,7 +2158,8 @@ public:
 PropertyDeclOrder &PO) const override;
 
   void collectInheritedProtocolProperties(const ObjCPropertyDecl *Property,
-  ProtocolPropertyMap &PM) const;
+  ProtocolPropertySet &PS,
+  PropertyDeclOrder &PO) const;
 
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) { return K == ObjCProtocol; }

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=307903&r1=307902&r2=307903&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 13 04:06:22 
2017
@@ -808,8 +808,10 @@ def warn_property_types_are_incompatible
   "property type %0 is incompatible with type %1 inherited from %2">,
   InGroup>;
 def warn_protocol_property_mismatch : Warning<
-  "property of type %0 was selected for synthesis">,
+  "property %select{of type %1|with attribute '%1'|without attribute '%1'|with 
"
+  "getter %1|with setter %1}0 was selected for synthesis">,
   InGroup>;
+def err_protocol_property_mismatch: 
Error;
 def err_undef_interface : Error<"cannot find interface declaration for %0">;
 def err_category_forward_interface : Error<
   "cannot define %select{category|class extension}0 for undefined class %1">;
@@ -1088,7 +1090,9 @@ def err_category_property : Error<
 def note_property_declare : Note<
   "property declared here">;
 def note_protocol_property_declare : Note<
-  "it coul

[PATCH] D35337: [Solaris] gcc runtime dropped support for .ctors, switch to .init_array

2017-07-13 Thread Fedor Sergeev via Phabricator via cfe-commits
fedor.sergeev updated this revision to Diff 106392.
fedor.sergeev added a comment.

Added Solaris targets to clang driver test checking for -fuse-init-array.


https://reviews.llvm.org/D35337

Files:
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Solaris.cpp
  lib/Driver/ToolChains/Solaris.h
  test/Driver/constructors.c


Index: test/Driver/constructors.c
===
--- test/Driver/constructors.c
+++ test/Driver/constructors.c
@@ -74,3 +74,11 @@
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1   \
 // RUN: -target arm64-none-none-eabi \
 // RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1\
+// RUN: -target sparc-sun-solaris2.11 \
+// RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1\
+// RUN: -target i386-pc-solaris2.11 \
+// RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
Index: lib/Driver/ToolChains/Solaris.h
===
--- lib/Driver/ToolChains/Solaris.h
+++ lib/Driver/ToolChains/Solaris.h
@@ -50,7 +50,7 @@
 
 namespace toolchains {
 
-class LLVM_LIBRARY_VISIBILITY Solaris : public Generic_GCC {
+class LLVM_LIBRARY_VISIBILITY Solaris : public Generic_ELF {
 public:
   Solaris(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args);
Index: lib/Driver/ToolChains/Solaris.cpp
===
--- lib/Driver/ToolChains/Solaris.cpp
+++ lib/Driver/ToolChains/Solaris.cpp
@@ -126,7 +126,7 @@
 
 Solaris::Solaris(const Driver &D, const llvm::Triple &Triple,
  const ArgList &Args)
-: Generic_GCC(D, Triple, Args) {
+: Generic_ELF(D, Triple, Args) {
 
   GCCInstallation.init(Triple, Args);
 
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -2471,7 +2471,8 @@
(!V.isOlderThan(4, 7, 0) || getTriple().isAndroid())) ||
   getTriple().getOS() == llvm::Triple::NaCl ||
   (getTriple().getVendor() == llvm::Triple::MipsTechnologies &&
-   !getTriple().hasEnvironment());
+   !getTriple().hasEnvironment()) ||
+  getTriple().getOS() == llvm::Triple::Solaris;
 
   if (DriverArgs.hasFlag(options::OPT_fuse_init_array,
  options::OPT_fno_use_init_array, UseInitArrayDefault))


Index: test/Driver/constructors.c
===
--- test/Driver/constructors.c
+++ test/Driver/constructors.c
@@ -74,3 +74,11 @@
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1   \
 // RUN: -target arm64-none-none-eabi \
 // RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1\
+// RUN: -target sparc-sun-solaris2.11 \
+// RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1\
+// RUN: -target i386-pc-solaris2.11 \
+// RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
Index: lib/Driver/ToolChains/Solaris.h
===
--- lib/Driver/ToolChains/Solaris.h
+++ lib/Driver/ToolChains/Solaris.h
@@ -50,7 +50,7 @@
 
 namespace toolchains {
 
-class LLVM_LIBRARY_VISIBILITY Solaris : public Generic_GCC {
+class LLVM_LIBRARY_VISIBILITY Solaris : public Generic_ELF {
 public:
   Solaris(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args);
Index: lib/Driver/ToolChains/Solaris.cpp
===
--- lib/Driver/ToolChains/Solaris.cpp
+++ lib/Driver/ToolChains/Solaris.cpp
@@ -126,7 +126,7 @@
 
 Solaris::Solaris(const Driver &D, const llvm::Triple &Triple,
  const ArgList &Args)
-: Generic_GCC(D, Triple, Args) {
+: Generic_ELF(D, Triple, Args) {
 
   GCCInstallation.init(Triple, Args);
 
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -2471,7 +2471,8 @@
(!V.isOlderThan(4, 7, 0) || getTriple().isAndroid())) ||
   getTriple().getOS() == llvm::Triple::NaCl ||
   (getTriple().getVendor() == llvm::Triple::MipsTechnologies &&
-   !getTriple().hasEnvironment());
+   !getTriple().hasEnvironment()) ||
+  getTriple().getOS() == llvm::Triple::Solaris;
 
   if (DriverArgs.hasFlag(options::OPT_fuse_init_array,
  options::OPT_fno_use_init_array, UseInitArrayDefault))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/li

r307905 - Remove 'using namespace llvm' from the USRFinder.h header

2017-07-13 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Jul 13 04:27:12 2017
New Revision: 307905

URL: http://llvm.org/viewvc/llvm-project?rev=307905&view=rev
Log:
Remove 'using namespace llvm' from the USRFinder.h header

This should fix the modules build
(http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules-2/).

Modified:
cfe/trunk/include/clang/Tooling/Refactoring/Rename/USRFinder.h

Modified: cfe/trunk/include/clang/Tooling/Refactoring/Rename/USRFinder.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/Rename/USRFinder.h?rev=307905&r1=307904&r2=307905&view=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring/Rename/USRFinder.h (original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/Rename/USRFinder.h Thu Jul 13 
04:27:12 2017
@@ -21,8 +21,6 @@
 #include 
 #include 
 
-using namespace llvm;
-
 namespace clang {
 
 class ASTContext;


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


[PATCH] D34404: [Clang-Tidy] Preserve Message, FileOffset, FilePath in Clang-Tidy YAML output

2017-07-13 Thread Vladimir Plyashkun via Phabricator via cfe-commits
vladimir.plyashkun updated this revision to Diff 106402.
vladimir.plyashkun added a comment.

1. split revision into two
2. fix failing tests


Repository:
  rL LLVM

https://reviews.llvm.org/D34404

Files:
  include/clang/Tooling/DiagnosticsYaml.h
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/DiagnosticsYamlTest.cpp

Index: unittests/Tooling/DiagnosticsYamlTest.cpp
===
--- /dev/null
+++ unittests/Tooling/DiagnosticsYamlTest.cpp
@@ -0,0 +1,173 @@
+//===- unittests/Tooling/DiagnosticsYamlTest.cpp - Serialization tests ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Tests for serialization of Diagnostics.
+//
+//===--===//
+
+#include "clang/Tooling/Core/Diagnostic.h"
+#include "clang/Tooling/DiagnosticsYaml.h"
+#include "clang/Tooling/ReplacementsYaml.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace clang::tooling;
+
+static Diagnostic makeDiagnostic(StringRef DiagnosticName, 
+ const std::string &Message,
+ int FileOffset,
+ const std::string &FilePath,
+ const StringMap &Fix) {
+  DiagnosticMessage DiagMessage;
+  DiagMessage.Message = Message;
+  DiagMessage.FileOffset = FileOffset;
+  DiagMessage.FilePath = FilePath;
+  return Diagnostic(DiagnosticName, DiagMessage, Fix, {},
+Diagnostic::Warning, "path/to/build/directory");
+}
+
+TEST(DiagnosticsYamlTest, serializesDiagnostics) {
+  TranslationUnitDiagnostics TUD;
+  TUD.MainSourceFile = "path/to/source.cpp";
+
+  StringMap Fix1 = { 
+{ 
+  "path/to/source.cpp",  
+  Replacements({ "path/to/source.cpp", 100, 12, "replacement #1" }) 
+} 
+  };
+  TUD.Diagnostics.push_back(makeDiagnostic("diagnostic#1", "message #1", 55, 
+   "path/to/source.cpp", Fix1));
+  
+  StringMap Fix2 = {
+{ 
+  "path/to/header.h",
+  Replacements({ "path/to/header.h", 62, 2, "replacement #2" })
+} 
+  };
+  TUD.Diagnostics.push_back(makeDiagnostic("diagnostic#2", "message #2", 60, 
+   "path/to/header.h", Fix2));
+
+  TUD.Diagnostics.push_back(makeDiagnostic("diagnostic#3", "message #3", 72, 
+   "path/to/source2.cpp", {}));
+
+  std::string YamlContent;
+  raw_string_ostream YamlContentStream(YamlContent);
+
+  yaml::Output YAML(YamlContentStream);
+  YAML << TUD;
+
+  EXPECT_EQ("---\n"
+"MainSourceFile:  path/to/source.cpp\n"
+"Diagnostics: \n"
+"  - DiagnosticName:  'diagnostic#1\'\n"
+"Message: 'message #1'\n"
+"FileOffset:  55\n"
+"FilePath:path/to/source.cpp\n"
+"Replacements:\n"
+"  - FilePath:path/to/source.cpp\n"
+"Offset:  100\n"
+"Length:  12\n"
+"ReplacementText: 'replacement #1'\n"
+"  - DiagnosticName:  'diagnostic#2'\n"
+"Message: 'message #2'\n"
+"FileOffset:  60\n"
+"FilePath:path/to/header.h\n"
+"Replacements:\n"
+"  - FilePath:path/to/header.h\n"
+"Offset:  62\n"
+"Length:  2\n"
+"ReplacementText: 'replacement #2'\n"
+"  - DiagnosticName:  'diagnostic#3'\n"
+"Message: 'message #3'\n"
+"FileOffset:  72\n"
+"FilePath:path/to/source2.cpp\n"
+"Replacements:\n"
+"...\n",
+  YamlContentStream.str());
+}
+
+TEST(DiagnosticsYamlTest, deserializesDiagnostics) {
+std::string YamlContent = "---\n"
+  "MainSourceFile:  path/to/source.cpp\n"
+  "Diagnostics: \n"
+  "  - DiagnosticName:  'diagnostic#1'\n"
+  "Message: 'message #1'\n"
+  "FileOffset:  55\n"
+  "FilePath:path/to/source.cpp\n"
+  "Replacements:\n"
+  "  - FilePath:path/to/source.cpp\n"
+  "Offset:  100\n"
+  "Length:  12\n"
+  "ReplacementText: 'replacement #1'\n"
+  "  - DiagnosticName:  'diagnostic#2'\n"
+  "Message: 'message #2'\n"
+  "FileOffset:  60\n"
+  "FilePath:path/to/header.h\n"
+  "Replacements:\n"
+  "  - FilePath:path/to/header.h\n"
+  "Offset:  62\n"
+  "Length:  2\n"
+  "ReplacementText: 'replacement #2'\n"
+  "  - DiagnosticName:  'diagnostic#3'\n"
+  "Message: 'message #3'\n"
+  "Fil

[PATCH] D35349: [Clang-Tidy] Preserve Message, FileOffset, FilePath in Clang-Tidy YAML output

2017-07-13 Thread Vladimir Plyashkun via Phabricator via cfe-commits
vladimir.plyashkun created this revision.
vladimir.plyashkun added a project: clang-tools-extra.
Herald added subscribers: xazax.hun, JDevlieghere, mgorny.

To get properly integration Clang-Tidy with CLion IDE, next things were 
implemented:

- Preserve `Message`, `FileOffset`, `FilePath` in the clang-tidy output.
- Export all diagnostics, not just the ones with fixes
- Test-cases


Repository:
  rL LLVM

https://reviews.llvm.org/D35349

Files:
  test/clang-apply-replacements/Inputs/basic/file1.yaml
  test/clang-apply-replacements/Inputs/basic/file2.yaml
  test/clang-apply-replacements/Inputs/conflict/file1.yaml
  test/clang-apply-replacements/Inputs/conflict/file2.yaml
  test/clang-apply-replacements/Inputs/conflict/file3.yaml
  test/clang-apply-replacements/Inputs/crlf/file1.yaml
  test/clang-apply-replacements/Inputs/format/no.yaml
  test/clang-apply-replacements/Inputs/format/yes.yaml
  unittests/clang-apply-replacements/ApplyReplacementsTest.cpp
  unittests/clang-apply-replacements/CMakeLists.txt

Index: unittests/clang-apply-replacements/CMakeLists.txt
===
--- unittests/clang-apply-replacements/CMakeLists.txt
+++ unittests/clang-apply-replacements/CMakeLists.txt
@@ -8,6 +8,7 @@
   )
 
 add_extra_unittest(ClangApplyReplacementsTests
+  ApplyReplacementsTest.cpp
   ReformattingTest.cpp
   )
 
Index: unittests/clang-apply-replacements/ApplyReplacementsTest.cpp
===
--- /dev/null
+++ unittests/clang-apply-replacements/ApplyReplacementsTest.cpp
@@ -0,0 +1,49 @@
+//===- clang-apply-replacements/ApplyReplacementsTest.cpp --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang-apply-replacements/Tooling/ApplyReplacements.h"
+#include "gtest/gtest.h"
+
+using namespace clang::replace;
+using namespace llvm;
+
+namespace clang { 
+namespace tooling {
+
+static TUDiagnostics makeTUDiagnostics(const std::string &MainSourceFile,
+   StringRef DiagnosticName,
+   const DiagnosticMessage &Message,
+   const StringMap &Replacements,
+   StringRef BuildDirectory) {
+  TUDiagnostics TUs;
+  TUs.push_back({ MainSourceFile, 
+  { { DiagnosticName, Message, Replacements, {}, 
+  Diagnostic::Warning, BuildDirectory } } 
+  });
+  return TUs;
+}
+
+// Test to ensure diagnostics with no fixes, will be merged correctly 
+// before applying.
+TEST(ApplyReplacementsTest, mergeDiagnosticsWithNoFixes) {
+  IntrusiveRefCntPtr DiagOpts(new DiagnosticOptions());
+  DiagnosticsEngine Diagnostics(
+IntrusiveRefCntPtr(new DiagnosticIDs()), DiagOpts.get());
+  FileManager Files((FileSystemOptions()));
+  SourceManager SM(Diagnostics, Files);
+  TUDiagnostics TUs = makeTUDiagnostics("path/to/source.cpp", "diagnostic",
+{}, {}, "path/to");
+  FileToReplacementsMap ReplacementsMap;
+
+  EXPECT_TRUE(mergeAndDeduplicate(TUs, ReplacementsMap, SM));
+  EXPECT_TRUE(ReplacementsMap.empty());
+}
+
+} // end namespace tooling
+} // end namespace clang
Index: test/clang-apply-replacements/Inputs/format/yes.yaml
===
--- test/clang-apply-replacements/Inputs/format/yes.yaml
+++ test/clang-apply-replacements/Inputs/format/yes.yaml
@@ -4,6 +4,9 @@
 MainSourceFile:  yes.cpp
 Diagnostics: 
   - DiagnosticName:  test-yes
+Message: Fix
+FilePath: $(path)/yes.cpp
+FileOffset: 494
 Replacements:
   - FilePath:$(path)/yes.cpp
 Offset:  494
Index: test/clang-apply-replacements/Inputs/format/no.yaml
===
--- test/clang-apply-replacements/Inputs/format/no.yaml
+++ test/clang-apply-replacements/Inputs/format/no.yaml
@@ -2,6 +2,9 @@
 MainSourceFile:  no.cpp
 Diagnostics: 
   - DiagnosticName:  test-no
+Message: Fix
+FilePath: $(path)/no.cpp
+FileOffset: 94
 Replacements:
   - FilePath:$(path)/no.cpp
 Offset:  94
Index: test/clang-apply-replacements/Inputs/crlf/file1.yaml
===
--- test/clang-apply-replacements/Inputs/crlf/file1.yaml
+++ test/clang-apply-replacements/Inputs/crlf/file1.yaml
@@ -2,6 +2,9 @@
 MainSourceFile:  source1.cpp
 Diagnostics:
   - DiagnosticName:  test-crlf
+Message: Fix
+FilePath: $(path)/crlf.cpp
+FileOffset: 79
 Replacements:
   - FilePath:$(path)/crlf.cpp
 Offset:  79
Index: test/clang-apply-replac

[PATCH] D34404: [Clang-Tidy] Preserve Message, FileOffset, FilePath in Clang-Tidy YAML output

2017-07-13 Thread Vladimir Plyashkun via Phabricator via cfe-commits
vladimir.plyashkun added a comment.

I've splitted single revision into two different revisions:
https://reviews.llvm.org/D34404
https://reviews.llvm.org/D35349
Also, i fixed failing test-cases in clang-apply-replacements due to changes in 
output format (so they shouldn't be a problem anymore)


Repository:
  rL LLVM

https://reviews.llvm.org/D34404



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


[PATCH] D16403: Add scope information to CFG for If/While/For/Do/Compound/CXXRangeFor statements

2017-07-13 Thread Maxim Ostapenko via Phabricator via cfe-commits
m.ostapenko updated this revision to Diff 106408.
m.ostapenko retitled this revision from "Add scope information to CFG" to "Add 
scope information to CFG for If/While/For/Do/Compound/CXXRangeFor statements".
m.ostapenko added a comment.

Updating the diff. I've dropped SwitchStmt support, let's implement in 
separately as well as GotoStmt.


Repository:
  rL LLVM

https://reviews.llvm.org/D16403

Files:
  include/clang/Analysis/AnalysisContext.h
  include/clang/Analysis/CFG.h
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/Analysis/AnalysisDeclContext.cpp
  lib/Analysis/CFG.cpp
  lib/StaticAnalyzer/Core/AnalysisManager.cpp
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  test/Analysis/analyzer-config.c
  test/Analysis/analyzer-config.cpp
  test/Analysis/scopes-cfg-output.cpp

Index: test/Analysis/scopes-cfg-output.cpp
===
--- /dev/null
+++ test/Analysis/scopes-cfg-output.cpp
@@ -0,0 +1,1030 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=debug.DumpCFG -analyzer-config cfg-scopes=true %s > %t 2>&1
+// RUN: FileCheck --input-file=%t %s
+
+class A {
+public:
+// CHECK:  [B1 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+  A() {}
+
+// CHECK:  [B1 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+  ~A() {}
+
+// CHECK:  [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+// CHECK:  [B1]
+// CHECK-NEXT:   1: CFGScopeBegin(CompoundStmt)
+// CHECK-NEXT:   2: 1
+// CHECK-NEXT:   3: return [B1.2];
+// CHECK-NEXT:   4: CFGScopeEnd(ReturnStmt)
+// CHECK-NEXT:   Preds (1): B2
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+  operator int() const { return 1; }
+};
+
+int getX();
+extern const bool UV;
+
+// CHECK:  [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+// CHECK:  [B1]
+// CHECK-NEXT:   1: CFGScopeBegin(CompoundStmt)
+// CHECK-NEXT:   2:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   3: A a;
+// CHECK-NEXT:   4: a
+// CHECK-NEXT:   5: [B1.4] (ImplicitCastExpr, NoOp, const class A)
+// CHECK-NEXT:   6: const A &b = a;
+// CHECK-NEXT:   7: A() (CXXConstructExpr, class A)
+// CHECK-NEXT:   8: [B1.7] (BindTemporary)
+// CHECK-NEXT:   9: [B1.8] (ImplicitCastExpr, NoOp, const class A)
+// CHECK-NEXT:  10: [B1.9]
+// CHECK-NEXT:  11: const A &c = A();
+// CHECK-NEXT:  12: [B1.11].~A() (Implicit destructor)
+// CHECK-NEXT:  13: [B1.3].~A() (Implicit destructor)
+// CHECK-NEXT:  14: CFGScopeEnd(CompoundStmt)
+// CHECK-NEXT:   Preds (1): B2
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+void test_const_ref() {
+  A a;
+  const A& b = a;
+  const A& c = A();
+}
+
+// CHECK:  [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+// CHECK:  [B1]
+// CHECK-NEXT:   1: CFGScopeBegin(CompoundStmt)
+// CHECK-NEXT:   2:  (CXXConstructExpr, class A [2])
+// CHECK-NEXT:   3: A a[2];
+// CHECK-NEXT:   4:  (CXXConstructExpr, class A [0])
+// CHECK-NEXT:   5: A b[0];
+// CHECK-NEXT:   6: [B1.3].~A() (Implicit destructor)
+// CHECK-NEXT:   7: CFGScopeEnd(CompoundStmt)
+// CHECK-NEXT:   Preds (1): B2
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+void test_array() {
+  A a[2];
+  A b[0];
+}
+
+// CHECK:  [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+// CHECK:  [B1]
+// CHECK-NEXT:   1: CFGScopeBegin(CompoundStmt)
+// CHECK-NEXT:   2:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   3: A a;
+// CHECK-NEXT:   4: CFGScopeBegin(CompoundStmt)
+// CHECK-NEXT:   5:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   6: A c;
+// CHECK-NEXT:   7:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   8: A d;
+// CHECK-NEXT:   9: [B1.8].~A() (Implicit destructor)
+// CHECK-NEXT:  10: [B1.6].~A() (Implicit destructor)
+// CHECK-NEXT:  11:  (CXXConstructExpr, class A)
+// CHECK-NEXT:  12: A b;
+// CHECK-NEXT:  13: [B1.12].~A() (Implicit destructor)
+// CHECK-NEXT:  14: [B1.3].~A() (Implicit destructor)
+// CHECK-NEXT:  15: CFGScopeEnd(CompoundStmt)
+// CHECK-NEXT:  16: CFGScopeEnd(CompoundStmt)
+// CHECK-NEXT:   Preds (1): B2
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+void test_scope() {
+  A a;
+  { A c;
+A d;
+  }
+  A b;
+}
+
+// CHECK:  [B4 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B3
+// CHECK:  [B1]
+// CHECK-NEXT:   1:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   2: A c;
+// CHECK-NEXT:   3: [B1.2].~A() (Implicit destructor)
+// CHECK-NEXT:   4: [B3.5].~A() (Implicit destructor)
+// CHECK-NEXT:   5: [B3.3].~A() (Implicit destructor)
+// CHECK-NEXT:   6: CFGScopeEnd(CompoundStmt)
+// CHECK-NEXT:   Preds (1): B3
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B2]
+// CHECK-NEXT:   1: CFGScopeBegin(IfStmt)
+// CHECK-NEXT:   2: return;
+// CHECK-NEXT:   3: [B3.5].~A() (Implicit destructor)
+// CHECK-NEXT:   4: [B3.3].~A() (Implicit destructor)
+// CHECK-NEXT:   5: CFGScopeEnd(ReturnStmt)
+// C

[PATCH] D35349: [Clang-Tidy] Preserve Message, FileOffset, FilePath in Clang-Tidy YAML output

2017-07-13 Thread Vladimir Plyashkun via Phabricator via cfe-commits
vladimir.plyashkun added a comment.

This is second part of review: 
https://reviews.llvm.org/D34404
which is contains changes related to clang-tools-extra repository.


Repository:
  rL LLVM

https://reviews.llvm.org/D35349



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


[PATCH] D33589: clang-format: consider not splitting tokens in optimization

2017-07-13 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added inline comments.



Comment at: lib/Format/UnwrappedLineFormatter.cpp:723
   FormatDecision LastFormat = Node->State.NextToken->Decision;
   if (LastFormat == FD_Unformatted || LastFormat == FD_Continue)
+addNextStateToQueue(Penalty, Node, /*NewLine=*/false,

djasper wrote:
> This is almost certainly a no-go. It turns the algorithm from exploring a 
> state space with a branching factor of 2 into something with a branching 
> factor of 4.
> 
> Even assuming we can perfectly reuse results from computations (or in other 
> words hit the same state through different path using Dijkstra's algorithm), 
> the additional bool in StateNode doubles the number of states we are going to 
> visit. You don't even seem to make a distinction of whether the token under 
> investigation can possibly be split. You do look at NoLineBreak(InOperand), 
> but even if those are false, the vast majority of tokens will never be split.
> 
> However, even if you narrow that down, I am not convinced that fixing this 
> inconsistency around the formatting penalties is worth the runtime 
> performance hit. I am generally fine with changing the behavior in the way 
> you are proposing, but only if it has zero (negative) effect on performance.
Making the distinction to skip some path is done at the beginning of 
addNextStateToQueue(), though indeed not very precisely at the moment.

I can improve the check (i.e. by copying all the early return conditions from 
the beginning of `ContinuationIndenter::breakProtrudingToken()`, which will 
greatly reduce the number of possible state, but stilll have a small impact.

The alternative would be modify ContinuationIndenter::breakProtrudingToken(), 
so that it computes the penalty for reflowing as well as not-reflowing, and 
updates the LineState with the best solution. It would certainly have an impact 
on performance, but would not increase the size of the state space.

Another issue with that approach is that the information is not passed from the 
DRYRUN phase to the actual rewriting phase. I could store this information in 
the LineState, to re-use it in the reconstruction phase, but this seems really 
wrong (and would work only in the exact case of the optimizing line formatter).

What do you think? Should I keep the same structure but reduce the number of 
explored state; or move the decision into ContinuationIndenter, possibly 
storing the result in LineState?




Comment at: lib/Format/UnwrappedLineFormatter.cpp:764
   return;
+if (!BreakToken && !Indenter->canSplit(PreviousNode->State))
+  return;

djasper wrote:
> It's not clear to me why you'd return here.
This is needed to avoid trying to break when this is not supported: no point 
doing twice the same thing.


https://reviews.llvm.org/D33589



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


r307908 - Remove another 'using namespace llvm' from the

2017-07-13 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Jul 13 05:49:22 2017
New Revision: 307908

URL: http://llvm.org/viewvc/llvm-project?rev=307908&view=rev
Log:
Remove another 'using namespace llvm' from the
RecursiveSymbolVisitor.h header

This should fix the modules build
(http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules-2/).

Modified:
cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h

Modified: cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h?rev=307908&r1=307907&r2=307908&view=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h 
(original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h Thu 
Jul 13 05:49:22 2017
@@ -20,8 +20,6 @@
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Lex/Lexer.h"
 
-using namespace llvm;
-
 namespace clang {
 namespace tooling {
 


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


[PATCH] D35337: [Solaris] gcc runtime dropped support for .ctors, switch to .init_array

2017-07-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

This looks reasonable to me, but I am not overly familiar with this part of the 
toolchain. You should wait for another LG before committing.


https://reviews.llvm.org/D35337



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


[PATCH] D33589: clang-format: consider not splitting tokens in optimization

2017-07-13 Thread Francois Ferrand via Phabricator via cfe-commits
Typz marked 2 inline comments as done.
Typz added inline comments.



Comment at: lib/Format/UnwrappedLineFormatter.cpp:723
   FormatDecision LastFormat = Node->State.NextToken->Decision;
   if (LastFormat == FD_Unformatted || LastFormat == FD_Continue)
+addNextStateToQueue(Penalty, Node, /*NewLine=*/false,

Typz wrote:
> djasper wrote:
> > This is almost certainly a no-go. It turns the algorithm from exploring a 
> > state space with a branching factor of 2 into something with a branching 
> > factor of 4.
> > 
> > Even assuming we can perfectly reuse results from computations (or in other 
> > words hit the same state through different path using Dijkstra's 
> > algorithm), the additional bool in StateNode doubles the number of states 
> > we are going to visit. You don't even seem to make a distinction of whether 
> > the token under investigation can possibly be split. You do look at 
> > NoLineBreak(InOperand), but even if those are false, the vast majority of 
> > tokens will never be split.
> > 
> > However, even if you narrow that down, I am not convinced that fixing this 
> > inconsistency around the formatting penalties is worth the runtime 
> > performance hit. I am generally fine with changing the behavior in the way 
> > you are proposing, but only if it has zero (negative) effect on performance.
> Making the distinction to skip some path is done at the beginning of 
> addNextStateToQueue(), though indeed not very precisely at the moment.
> 
> I can improve the check (i.e. by copying all the early return conditions from 
> the beginning of `ContinuationIndenter::breakProtrudingToken()`, which will 
> greatly reduce the number of possible state, but stilll have a small impact.
> 
> The alternative would be modify ContinuationIndenter::breakProtrudingToken(), 
> so that it computes the penalty for reflowing as well as not-reflowing, and 
> updates the LineState with the best solution. It would certainly have an 
> impact on performance, but would not increase the size of the state space.
> 
> Another issue with that approach is that the information is not passed from 
> the DRYRUN phase to the actual rewriting phase. I could store this 
> information in the LineState, to re-use it in the reconstruction phase, but 
> this seems really wrong (and would work only in the exact case of the 
> optimizing line formatter).
> 
> What do you think? Should I keep the same structure but reduce the number of 
> explored state; or move the decision into ContinuationIndenter, possibly 
> storing the result in LineState?
> 
Actually, it seems it cannot be done inside 
ContinuationIndenter::breakProtrudingToken(), since this causes the whitespace 
manager to be called twice for the same token.


https://reviews.llvm.org/D33589



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


r307910 - [OPENMP] Generalization of codegen for reduction clauses.

2017-07-13 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Jul 13 06:36:14 2017
New Revision: 307910

URL: http://llvm.org/viewvc/llvm-project?rev=307910&view=rev
Log:
[OPENMP] Generalization of codegen for reduction clauses.

Reworked codegen for reduction clauses for future support of reductions
in task-based directives.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=307910&r1=307909&r2=307910&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Jul 13 06:36:14 2017
@@ -697,6 +697,400 @@ void RegionCodeGenTy::operator()(CodeGen
   }
 }
 
+/// Check if the combiner is a call to UDR combiner and if it is so return the
+/// UDR decl used for reduction.
+static const OMPDeclareReductionDecl *
+getReductionInit(const Expr *ReductionOp) {
+  if (auto *CE = dyn_cast(ReductionOp))
+if (auto *OVE = dyn_cast(CE->getCallee()))
+  if (auto *DRE =
+  dyn_cast(OVE->getSourceExpr()->IgnoreImpCasts()))
+if (auto *DRD = dyn_cast(DRE->getDecl()))
+  return DRD;
+  return nullptr;
+}
+
+static void emitInitWithReductionInitializer(CodeGenFunction &CGF,
+ const OMPDeclareReductionDecl 
*DRD,
+ const Expr *InitOp,
+ Address Private, Address Original,
+ QualType Ty) {
+  if (DRD->getInitializer()) {
+std::pair Reduction =
+CGF.CGM.getOpenMPRuntime().getUserDefinedReduction(DRD);
+auto *CE = cast(InitOp);
+auto *OVE = cast(CE->getCallee());
+const Expr *LHS = CE->getArg(/*Arg=*/0)->IgnoreParenImpCasts();
+const Expr *RHS = CE->getArg(/*Arg=*/1)->IgnoreParenImpCasts();
+auto *LHSDRE = cast(cast(LHS)->getSubExpr());
+auto *RHSDRE = cast(cast(RHS)->getSubExpr());
+CodeGenFunction::OMPPrivateScope PrivateScope(CGF);
+PrivateScope.addPrivate(cast(LHSDRE->getDecl()),
+[=]() -> Address { return Private; });
+PrivateScope.addPrivate(cast(RHSDRE->getDecl()),
+[=]() -> Address { return Original; });
+(void)PrivateScope.Privatize();
+RValue Func = RValue::get(Reduction.second);
+CodeGenFunction::OpaqueValueMapping Map(CGF, OVE, Func);
+CGF.EmitIgnoredExpr(InitOp);
+  } else {
+llvm::Constant *Init = CGF.CGM.EmitNullConstant(Ty);
+auto *GV = new llvm::GlobalVariable(
+CGF.CGM.getModule(), Init->getType(), /*isConstant=*/true,
+llvm::GlobalValue::PrivateLinkage, Init, ".init");
+LValue LV = CGF.MakeNaturalAlignAddrLValue(GV, Ty);
+RValue InitRVal;
+switch (CGF.getEvaluationKind(Ty)) {
+case TEK_Scalar:
+  InitRVal = CGF.EmitLoadOfLValue(LV, SourceLocation());
+  break;
+case TEK_Complex:
+  InitRVal =
+  RValue::getComplex(CGF.EmitLoadOfComplex(LV, SourceLocation()));
+  break;
+case TEK_Aggregate:
+  InitRVal = RValue::getAggregate(LV.getAddress());
+  break;
+}
+OpaqueValueExpr OVE(SourceLocation(), Ty, VK_RValue);
+CodeGenFunction::OpaqueValueMapping OpaqueMap(CGF, &OVE, InitRVal);
+CGF.EmitAnyExprToMem(&OVE, Private, Ty.getQualifiers(),
+ /*IsInitializer=*/false);
+  }
+}
+
+/// \brief Emit initialization of arrays of complex types.
+/// \param DestAddr Address of the array.
+/// \param Type Type of array.
+/// \param Init Initial expression of array.
+/// \param SrcAddr Address of the original array.
+static void EmitOMPAggregateInit(CodeGenFunction &CGF, Address DestAddr,
+ QualType Type, const Expr *Init,
+ Address SrcAddr = Address::invalid()) {
+  auto *DRD = getReductionInit(Init);
+  // Perform element-by-element initialization.
+  QualType ElementTy;
+
+  // Drill down to the base element type on both arrays.
+  auto ArrayTy = Type->getAsArrayTypeUnsafe();
+  auto NumElements = CGF.emitArrayLength(ArrayTy, ElementTy, DestAddr);
+  DestAddr =
+  CGF.Builder.CreateElementBitCast(DestAddr, DestAddr.getElementType());
+  if (DRD)
+SrcAddr =
+CGF.Builder.CreateElementBitCast(SrcAddr, DestAddr.getElementType());
+
+  llvm::Value *SrcBegin = nullptr;
+  if (DRD)
+SrcBegin = SrcAddr.getPointer();
+  auto DestBegin = DestAddr.getPointer();
+  // Cast from pointer to array type to pointer to single element.
+  auto DestEnd = CGF.Builder.CreateGEP(DestBegin, NumElements);
+  // The basic structure here is a while-do loop.
+  auto BodyBB = CGF.createBasicBlock("omp.a

[PATCH] D35081: [ThinLTO] Allow multiple summary entries.

2017-07-13 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In https://reviews.llvm.org/D35081#807497, @mehdi_amini wrote:

> In https://reviews.llvm.org/D35081#807172, @fhahn wrote:
>
> > It's @yunlian, so if the issue you described above covers his failure, than 
> > that's great. @tejohnson do you have time to work on a fix soon? Otherwise 
> > I could give it a try, I would probably need a few pointers though, as I am 
> > not really familiar with ThinLTO.
>
>
> A good starting point is `static const GlobalValueSummary *selectCallee()` in 
> llvm/lib/Transforms/IPO/FunctionImport.cpp ; but it is likely not trivial to 
> solve.


Not necessarily nontrivial from a coding perspective - but the question is how 
do we want to solve it? E.g. I have a very simple fix that addressed the 
problem in my test case, by always selecting the first one (assumes that the 
first is the prevailing, which is generally true).

Should we always select the prevailing copy? E.g. just return the first summary 
(which is likely to belong to the prevailing copy) if any summary in the list 
is under the threshold. In my test case and in Yunlian's, we ended up selecting 
the prevailing copy eventually. But it's possible that only one or more 
non-prevailing copies will ever be selected. We could just assume that if any 
copy is under the threshold, that the prevailing is still the best copy to 
import. But I suppose the prevailing copy could be significantly larger if the 
inlining during the compile step was very different.

Or, we could always import the copy with the smallest instruction count. But if 
we have profile data, that profile data likely was collected on the (same) 
prevailing copy and perhaps that copy was just more aggressively inlined (and 
might be the better optimized than a non-prevailing copy with a smaller 
instruction count, which might not have profile data if the early inlining was 
different leading to the profile not matching when compiling that copy).

Or, we could keep the same selection algorithm, and ensure that we stick with 
whatever was the first summary selected (in the test case, that was the smaller 
non-prevailing copy). I.e. keep track of which GUIDs/summaries are already 
imported for a module, and ensure we don't pick a different one (we do want to 
reprocess it though if we ever encounter a call to that GUID with a higher 
threshold, since we may decide to import more of its callees).

Or, we could go back later and see if we have selected more than one summary 
for a GUID, and pick one (the first one? that's what essentially ends up 
happening when we have multiple and are doing in-process ThinLTO backends, the 
IRLinker will likely just keep the first one and ignore the subsequent copies 
that we try to link in). But that requires some additional post-processing that 
would be good to avoid if possible.

Thoughts?


https://reviews.llvm.org/D35081



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


[PATCH] D35109: [Analyzer] SValBuilder Comparison Rearrangement

2017-07-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

I think we should exclude unsigned types completely. `A >= B` is converted to 
`A - B >= 0`, thus the range of `A - B` is `[0 .. INT_MAX]` which is the full 
range for the unsigned type. This implies that upon any conditional statement 
`if (A >= B) ...` the range for the `false` is an empty range so the `else` 
branch is never executed. The following test fails:

`void wrong(int m, int n) {

  if (m >= n)
return;
  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}

}`


https://reviews.llvm.org/D35109



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


[PATCH] D35355: Fix templated type alias completion when using global completion cache

2017-07-13 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan created this revision.

When we have enabled cache for global completions we did not have diagnostics 
for Bar and could not complete Ba as in provided code example.

template 
struct Foo { T member; };

template using Bar = Foo;

int main() {

  Ba

}


https://reviews.llvm.org/D35355

Files:
  lib/Frontend/ASTUnit.cpp
  lib/Parse/ParseTemplate.cpp


Index: lib/Parse/ParseTemplate.cpp
===
--- lib/Parse/ParseTemplate.cpp
+++ lib/Parse/ParseTemplate.cpp
@@ -197,10 +197,11 @@
   MaybeParseCXX11Attributes(prefixAttrs);
 
   if (Tok.is(tok::kw_using)) {
-// FIXME: We should return the DeclGroup to the caller.
-ParseUsingDirectiveOrDeclaration(Context, TemplateInfo, DeclEnd,
- prefixAttrs);
-return nullptr;
+auto usingDeclPtr = ParseUsingDirectiveOrDeclaration(Context, 
TemplateInfo, DeclEnd,
+ prefixAttrs);
+if (!usingDeclPtr)
+  return nullptr;
+return usingDeclPtr.get().getSingleDecl();
   }
 
   // Parse the declaration specifiers, stealing any diagnostics from
Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -243,7 +243,8 @@
   
   uint64_t Contexts = 0;
   if (isa(ND) || isa(ND) || 
-  isa(ND) || isa(ND)) {
+  isa(ND) || isa(ND) ||
+  isa(ND)) {
 // Types can appear in these contexts.
 if (LangOpts.CPlusPlus || !isa(ND))
   Contexts |= (1LL << CodeCompletionContext::CCC_TopLevel)


Index: lib/Parse/ParseTemplate.cpp
===
--- lib/Parse/ParseTemplate.cpp
+++ lib/Parse/ParseTemplate.cpp
@@ -197,10 +197,11 @@
   MaybeParseCXX11Attributes(prefixAttrs);
 
   if (Tok.is(tok::kw_using)) {
-// FIXME: We should return the DeclGroup to the caller.
-ParseUsingDirectiveOrDeclaration(Context, TemplateInfo, DeclEnd,
- prefixAttrs);
-return nullptr;
+auto usingDeclPtr = ParseUsingDirectiveOrDeclaration(Context, TemplateInfo, DeclEnd,
+ prefixAttrs);
+if (!usingDeclPtr)
+  return nullptr;
+return usingDeclPtr.get().getSingleDecl();
   }
 
   // Parse the declaration specifiers, stealing any diagnostics from
Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -243,7 +243,8 @@
   
   uint64_t Contexts = 0;
   if (isa(ND) || isa(ND) || 
-  isa(ND) || isa(ND)) {
+  isa(ND) || isa(ND) ||
+  isa(ND)) {
 // Types can appear in these contexts.
 if (LangOpts.CPlusPlus || !isa(ND))
   Contexts |= (1LL << CodeCompletionContext::CCC_TopLevel)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r307911 - [OPENMP] Fix reduction tests, NFC.

2017-07-13 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Jul 13 07:29:19 2017
New Revision: 307911

URL: http://llvm.org/viewvc/llvm-project?rev=307911&view=rev
Log:
[OPENMP] Fix reduction tests, NFC.

Modified:
cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp

Modified: cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_codegen.cpp?rev=307911&r1=307910&r2=307911&view=diff
==
--- cfe/trunk/test/OpenMP/for_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/for_reduction_codegen.cpp Thu Jul 13 07:29:19 2017
@@ -497,12 +497,13 @@ int main() {
 // CHECK: [[RED_LIST:%.+]] = alloca [4 x i8*],
 
 // CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** 
[[GTID_ADDR_ADDR:%.+]],
+// CHECK: store i{{[0-9]+}}* %{{.+}}, i{{[0-9]+}}**
+// CHECK: store i{{[0-9]+}}* %{{.+}}, i{{[0-9]+}}** [[ARR_ADDR:%.+]],
+// CHECK: [[ARR:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[ARR_ADDR]],
 
-// CHECK: [[IDX1:%.+]] = mul nsw i64 1, %{{.+}}
-// CHECK: [[LB1:%.+]] = getelementptr inbounds i32, i32* %{{.+}}, i64 [[IDX1]]
+// CHECK: [[LB1:%.+]] = getelementptr inbounds i32, i32* [[ARR]], i64
 // CHECK: [[LB1_0:%.+]] = getelementptr inbounds i32, i32* [[LB1]], i64 0
-// CHECK: [[IDX1:%.+]] = mul nsw i64 1, %{{.+}}
-// CHECK: [[UB1:%.+]] = getelementptr inbounds i32, i32* %{{.+}}, i64 [[IDX1]]
+// CHECK: [[UB1:%.+]] = getelementptr inbounds i32, i32* [[ARR]], i64
 // CHECK: [[UB1_UP:%.+]] = getelementptr inbounds i32, i32* [[UB1]], i64 %
 // CHECK: [[UB_CAST:%.+]] = ptrtoint i32* [[UB1_UP]] to i64
 // CHECK: [[LB_CAST:%.+]] = ptrtoint i32* [[LB1_0]] to i64

Modified: cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp?rev=307911&r1=307910&r2=307911&view=diff
==
--- cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp (original)
+++ cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp Thu Jul 13 07:29:19 2017
@@ -306,12 +306,13 @@ int main() {
 // CHECK: [[RED_LIST:%.+]] = alloca [4 x i8*],
 
 // CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** 
[[GTID_ADDR_ADDR:%.+]],
+// CHECK: store i{{[0-9]+}}* %{{.+}}, i{{[0-9]+}}**
+// CHECK: store i{{[0-9]+}}* %{{.+}}, i{{[0-9]+}}** [[ARR_ADDR:%.+]],
+// CHECK: [[ARR:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[ARR_ADDR]],
 
-// CHECK: [[IDX1:%.+]] = mul nsw i64 1, %{{.+}}
-// CHECK: [[LB1:%.+]] = getelementptr inbounds i32, i32* %{{.+}}, i64 [[IDX1]]
+// CHECK: [[LB1:%.+]] = getelementptr inbounds i32, i32* [[ARR]], i64
 // CHECK: [[LB1_0:%.+]] = getelementptr inbounds i32, i32* [[LB1]], i64 0
-// CHECK: [[IDX1:%.+]] = mul nsw i64 1, %{{.+}}
-// CHECK: [[UB1:%.+]] = getelementptr inbounds i32, i32* %{{.+}}, i64 [[IDX1]]
+// CHECK: [[UB1:%.+]] = getelementptr inbounds i32, i32* [[ARR]], i64
 // CHECK: [[UB1_UP:%.+]] = getelementptr inbounds i32, i32* [[UB1]], i64 %
 // CHECK: [[UB_CAST:%.+]] = ptrtoint i32* [[UB1_UP]] to i64
 // CHECK: [[LB_CAST:%.+]] = ptrtoint i32* [[LB1_0]] to i64


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


[PATCH] D35110: [Analyzer] Constraint Manager Negates Difference

2017-07-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added inline comments.



Comment at: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:511
+   SSE->getLHS()->getType()->isSignedIntegerOrEnumerationType() ||
+   SSE->getLHS()->getType()->isPointerType()) {
+  return negV->Negate(BV, F);

NoQ wrote:
> Pointer types are currently treated as unsigned, so i'm not sure you want 
> them here.
For me it seems that pointer differences are still pointer types and they are 
signed. (The range becomes negative upon negative assumption. From test 
`ptr-arith.c`:

```
void use_symbols(int *lhs, int *rhs) {
  clang_analyzer_eval(lhs < rhs); // expected-warning{{UNKNOWN}}
  if (lhs < rhs)
return;
  clang_analyzer_eval(lhs < rhs); // expected-warning{{FALSE}}

  clang_analyzer_eval(lhs - rhs); // expected-warning{{UNKNOWN}}
  if ((lhs - rhs) != 5)
return;
  clang_analyzer_eval((lhs - rhs) == 5); // expected-warning{{TRUE}}
}
```

If I put `clang_analyzer_printState()` into the empty line in the middle, I get 
the following range for the difference: `[-9223372036854775808, 0]`. If I 
replace `int*` with `unsigned`, this range becomes `[0, 0]`, so `int*` is 
handled as a signed type here.


https://reviews.llvm.org/D35110



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


[PATCH] D33333: Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier

2017-07-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

I tested the latest revision (this fronted patch already included) on my test 
file in https://reviews.llvm.org/D33537. Disregarding of the (not so important) 
check-specific parameters (`EnabledFunctions` and `IgnoredExceptions`) I do not 
get warnings for any indirect throws (`indirect_implicit()` and 
`indirect_explicit()`). So for me this frontend check does not seem to be using 
the CFG. Furthermore, I do not get warning for `throw_and_catch_some()` where 
`1.1` is a `double` thus `catch(int &)` should not catch it. The same happens 
in `throw_catch_rethrow_the_rest()`, where `catch(int &)` should not catch 
`1.1`, but `catch(...)` should catch and rethrow it. Is this latter one a bug?


Repository:
  rL LLVM

https://reviews.llvm.org/D3



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


[PATCH] D33537: [clang-tidy] Exception Escape Checker

2017-07-13 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D33537#801889, @baloghadamsoftware wrote:

> In https://reviews.llvm.org/D33537#771274, @aaron.ballman wrote:
>
> > The check in https://reviews.llvm.org/D3 is using a CFG, not just 
> > checking direct throws.
>
>
> I tested the latest revision (the fronted patch already included) on my test 
> file. Disregarding of the not so important parameters (`EnabledFunctions` and 
> `IgnoredExceptions`) I do not get warnings for any indirect throws 
> (`indirect_implicit()` and `indirect_explicit()`). So for me it does not seem 
> to be using the CFG. Furthermore, I do not get warning for 
> `throw_and_catch_some()` where `1.1` is a `double` thus `catch(int &)` should 
> not catch it. The same happens in `throw_catch_rethrow_the_rest()`, where 
> `catch(int &)` should not catch `1.1`, but `catch(...)` should catch and 
> rethrow it. This latter may be a bug.


Jen Yu can clarify, but I believe it was decided to put the implementation in 
the CFG, but not do a full analysis (leave that for a later implementation).  
It is not doing 'catch' analysis, and I don't believe they decided to do 
analysis on the function call itself, since the false-positive rate is massive 
thanks to the C headers.


https://reviews.llvm.org/D33537



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


r307912 - [OPENMP] Fix reduction tests, NFC.

2017-07-13 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Jul 13 07:54:42 2017
New Revision: 307912

URL: http://llvm.org/viewvc/llvm-project?rev=307912&view=rev
Log:
[OPENMP] Fix reduction tests, NFC.

Modified:
cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp

Modified: cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_codegen.cpp?rev=307912&r1=307911&r2=307912&view=diff
==
--- cfe/trunk/test/OpenMP/for_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/for_reduction_codegen.cpp Thu Jul 13 07:54:42 2017
@@ -501,12 +501,8 @@ int main() {
 // CHECK: store i{{[0-9]+}}* %{{.+}}, i{{[0-9]+}}** [[ARR_ADDR:%.+]],
 // CHECK: [[ARR:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[ARR_ADDR]],
 
-// CHECK: [[LB1:%.+]] = getelementptr inbounds i32, i32* [[ARR]], i64
-// CHECK: [[LB1_0:%.+]] = getelementptr inbounds i32, i32* [[LB1]], i64 0
-// CHECK: [[UB1:%.+]] = getelementptr inbounds i32, i32* [[ARR]], i64
-// CHECK: [[UB1_UP:%.+]] = getelementptr inbounds i32, i32* [[UB1]], i64 %
-// CHECK: [[UB_CAST:%.+]] = ptrtoint i32* [[UB1_UP]] to i64
-// CHECK: [[LB_CAST:%.+]] = ptrtoint i32* [[LB1_0]] to i64
+// CHECK: [[UB_CAST:%.+]] = ptrtoint i32* [[UB1_UP:%.+]] to i64
+// CHECK: [[LB_CAST:%.+]] = ptrtoint i32* [[LB1_0:%.+]] to i64
 // CHECK: [[DIFF:%.+]] = sub i64 [[UB_CAST]], [[LB_CAST]]
 // CHECK: [[SIZE_1:%.+]] = sdiv exact i64 [[DIFF]], ptrtoint (i32* 
getelementptr (i32, i32* null, i32 1) to i64)
 // CHECK: [[ARR_SIZE:%.+]] = add nuw i64 [[SIZE_1]], 1

Modified: cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp?rev=307912&r1=307911&r2=307912&view=diff
==
--- cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp (original)
+++ cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp Thu Jul 13 07:54:42 2017
@@ -310,12 +310,8 @@ int main() {
 // CHECK: store i{{[0-9]+}}* %{{.+}}, i{{[0-9]+}}** [[ARR_ADDR:%.+]],
 // CHECK: [[ARR:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[ARR_ADDR]],
 
-// CHECK: [[LB1:%.+]] = getelementptr inbounds i32, i32* [[ARR]], i64
-// CHECK: [[LB1_0:%.+]] = getelementptr inbounds i32, i32* [[LB1]], i64 0
-// CHECK: [[UB1:%.+]] = getelementptr inbounds i32, i32* [[ARR]], i64
-// CHECK: [[UB1_UP:%.+]] = getelementptr inbounds i32, i32* [[UB1]], i64 %
-// CHECK: [[UB_CAST:%.+]] = ptrtoint i32* [[UB1_UP]] to i64
-// CHECK: [[LB_CAST:%.+]] = ptrtoint i32* [[LB1_0]] to i64
+// CHECK: [[UB_CAST:%.+]] = ptrtoint i32* [[UB1_UP:%.+]] to i64
+// CHECK: [[LB_CAST:%.+]] = ptrtoint i32* [[LB1_0:%.+]] to i64
 // CHECK: [[DIFF:%.+]] = sub i64 [[UB_CAST]], [[LB_CAST]]
 // CHECK: [[SIZE_1:%.+]] = sdiv exact i64 [[DIFF]], ptrtoint (i32* 
getelementptr (i32, i32* null, i32 1) to i64)
 // CHECK: [[ARR_SIZE:%.+]] = add nuw i64 [[SIZE_1]], 1


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


r307914 - [OPENMP] Further reduction test fix, NFC.

2017-07-13 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Jul 13 08:02:27 2017
New Revision: 307914

URL: http://llvm.org/viewvc/llvm-project?rev=307914&view=rev
Log:
[OPENMP] Further reduction test fix, NFC.

Modified:
cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp

Modified: cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_codegen.cpp?rev=307914&r1=307913&r2=307914&view=diff
==
--- cfe/trunk/test/OpenMP/for_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/for_reduction_codegen.cpp Thu Jul 13 08:02:27 2017
@@ -892,16 +892,8 @@ int main() {
 // CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** 
[[GTID_ADDR_ADDR:%.+]],
 // CHECK: [[VAR2_ORIG:%.+]] = load [[S_FLOAT_TY]]***, [[S_FLOAT_TY]] 
[[VAR2_ORIG_ADDR]],
 
-// CHECK: load [[S_FLOAT_TY]]**, [[S_FLOAT_TY]]*** [[VAR2_ORIG]],
-// CHECK: getelementptr inbounds [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]** %{{.+}}, 
i64 0
-// CHECK: load [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]** %
-// CHECK: [[LOW:%.+]] = getelementptr inbounds [[S_FLOAT_TY]], [[S_FLOAT_TY]]* 
%{{.+}}, i64 1
-// CHECK: load [[S_FLOAT_TY]]**, [[S_FLOAT_TY]]*** [[VAR2_ORIG]],
-// CHECK: getelementptr inbounds [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]** %{{.+}}, 
i64 4
-// CHECK: load [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]** %
-// CHECK: getelementptr inbounds [[S_FLOAT_TY]], [[S_FLOAT_TY]]* %{{.+}}, i64 6
 // CHECK: [[LAST:%.+]] = ptrtoint [[S_FLOAT_TY]]* %{{.+}} to i64
-// CHECK: [[FIRST:%.+]] = ptrtoint [[S_FLOAT_TY]]* [[LOW]] to i64
+// CHECK: [[FIRST:%.+]] = ptrtoint [[S_FLOAT_TY]]* [[LOW:%.+]] to i64
 // CHECK: [[BYTE_DIF:%.+]] = sub i64 [[LAST]], [[FIRST]]
 // CHECK: [[DIF:%.+]] = sdiv exact i64 [[BYTE_DIF]], ptrtoint (float* 
getelementptr (float, float* null, i32 1) to i64)
 // CHECK: [[SIZE:%.+]] = add nuw i64 [[DIF]], 1

Modified: cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp?rev=307914&r1=307913&r2=307914&view=diff
==
--- cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp (original)
+++ cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp Thu Jul 13 08:02:27 2017
@@ -693,16 +693,8 @@ int main() {
 // CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** 
[[GTID_ADDR_ADDR:%.+]],
 // CHECK: [[VAR2_ORIG:%.+]] = load [[S_FLOAT_TY]]***, [[S_FLOAT_TY]] 
[[VAR2_ORIG_ADDR]],
 
-// CHECK: load [[S_FLOAT_TY]]**, [[S_FLOAT_TY]]*** [[VAR2_ORIG]],
-// CHECK: getelementptr inbounds [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]** %{{.+}}, 
i64 0
-// CHECK: load [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]** %
-// CHECK: [[LOW:%.+]] = getelementptr inbounds [[S_FLOAT_TY]], [[S_FLOAT_TY]]* 
%{{.+}}, i64 1
-// CHECK: load [[S_FLOAT_TY]]**, [[S_FLOAT_TY]]*** [[VAR2_ORIG]],
-// CHECK: getelementptr inbounds [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]** %{{.+}}, 
i64 4
-// CHECK: load [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]** %
-// CHECK: getelementptr inbounds [[S_FLOAT_TY]], [[S_FLOAT_TY]]* %{{.+}}, i64 6
 // CHECK: [[LAST:%.+]] = ptrtoint [[S_FLOAT_TY]]* %{{.+}} to i64
-// CHECK: [[FIRST:%.+]] = ptrtoint [[S_FLOAT_TY]]* [[LOW]] to i64
+// CHECK: [[FIRST:%.+]] = ptrtoint [[S_FLOAT_TY]]* [[LOW:%.+]] to i64
 // CHECK: [[BYTE_DIF:%.+]] = sub i64 [[LAST]], [[FIRST]]
 // CHECK: [[DIF:%.+]] = sdiv exact i64 [[BYTE_DIF]], ptrtoint ([[S_FLOAT_TY]]* 
getelementptr ([[S_FLOAT_TY]], [[S_FLOAT_TY]]* null, i32 1) to i64)
 // CHECK: [[SIZE:%.+]] = add nuw i64 [[DIF]], 1


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


r307915 - [OPENMP] Fix reduction tests, NFC.

2017-07-13 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Jul 13 08:09:05 2017
New Revision: 307915

URL: http://llvm.org/viewvc/llvm-project?rev=307915&view=rev
Log:
[OPENMP] Fix reduction tests, NFC.

Modified:
cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp

Modified: cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_codegen.cpp?rev=307915&r1=307914&r2=307915&view=diff
==
--- cfe/trunk/test/OpenMP/for_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/for_reduction_codegen.cpp Thu Jul 13 08:09:05 2017
@@ -921,7 +921,6 @@ int main() {
 // CHECK: [[VVAR2_ORIG:%.+]] = load [2 x [[S_FLOAT_TY]]]*, [2 x 
[[S_FLOAT_TY]]]** [[VVAR2_ORIG_ADDR]],
 
 // CHECK: [[LOW:%.+]] = getelementptr inbounds [2 x [[S_FLOAT_TY]]], [2 x 
[[S_FLOAT_TY]]]* [[VVAR2_ORIG]], i64 0, i64 0
-// CHECK: getelementptr inbounds [2 x [[S_FLOAT_TY]]], [2 x [[S_FLOAT_TY]]]* 
[[VVAR2_ORIG]], i64 0, i64 4
 // CHECK: [[LAST:%.+]] = ptrtoint [[S_FLOAT_TY]]* %{{.+}} to i64
 // CHECK: [[FIRST:%.+]] = ptrtoint [[S_FLOAT_TY]]* [[LOW]] to i64
 // CHECK: [[BYTE_DIF:%.+]] = sub i64 [[LAST]], [[FIRST]]

Modified: cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp?rev=307915&r1=307914&r2=307915&view=diff
==
--- cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp (original)
+++ cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp Thu Jul 13 08:09:05 2017
@@ -722,7 +722,6 @@ int main() {
 // CHECK: [[VVAR2_ORIG:%.+]] = load [2 x [[S_FLOAT_TY]]]*, [2 x 
[[S_FLOAT_TY]]]** [[VVAR2_ORIG_ADDR]],
 
 // CHECK: [[LOW:%.+]] = getelementptr inbounds [2 x [[S_FLOAT_TY]]], [2 x 
[[S_FLOAT_TY]]]* [[VVAR2_ORIG]], i64 0, i64 0
-// CHECK: getelementptr inbounds [2 x [[S_FLOAT_TY]]], [2 x [[S_FLOAT_TY]]]* 
[[VVAR2_ORIG]], i64 0, i64 4
 // CHECK: [[LAST:%.+]] = ptrtoint [[S_FLOAT_TY]]* %{{.+}} to i64
 // CHECK: [[FIRST:%.+]] = ptrtoint [[S_FLOAT_TY]]* [[LOW]] to i64
 // CHECK: [[BYTE_DIF:%.+]] = sub i64 [[LAST]], [[FIRST]]


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


r307916 - [OPENMP] Fix reduction tests, NFC.

2017-07-13 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Jul 13 08:15:25 2017
New Revision: 307916

URL: http://llvm.org/viewvc/llvm-project?rev=307916&view=rev
Log:
[OPENMP] Fix reduction tests, NFC.

Modified:
cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp

Modified: cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_codegen.cpp?rev=307916&r1=307915&r2=307916&view=diff
==
--- cfe/trunk/test/OpenMP/for_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/for_reduction_codegen.cpp Thu Jul 13 08:15:25 2017
@@ -948,12 +948,8 @@ int main() {
 
 // CHECK: [[VAR3_ORIG:%.+]] = load [2 x [[S_FLOAT_TY]]]*, [2 x 
[[S_FLOAT_TY]]]** [[VAR3_ORIG_ADDR]],
 // CHECK: store [2 x [[S_FLOAT_TY]]]* [[VAR3_ORIG]], [2 x [[S_FLOAT_TY]]]** 
[[VAR3_ORIG_ADDR:%.+]],
-// CHECK: [[VAR3_ORIG:%.+]] = load [2 x [[S_FLOAT_TY]]]*, [2 x 
[[S_FLOAT_TY]]]** [[VAR3_ORIG_ADDR]],
-// CHECK: [[LOW:%.+]] = getelementptr inbounds [2 x [[S_FLOAT_TY]]], [2 x 
[[S_FLOAT_TY]]]* [[VAR3_ORIG]], i64 0, i64 1
-// CHECK: [[VAR3_ORIG:%.+]] = load [2 x [[S_FLOAT_TY]]]*, [2 x 
[[S_FLOAT_TY]]]** [[VAR3_ORIG_ADDR]],
-// CHECK: getelementptr inbounds [2 x [[S_FLOAT_TY]]], [2 x [[S_FLOAT_TY]]]* 
[[VAR3_ORIG]], i64 0, i64 2
 // CHECK: [[LAST:%.+]] = ptrtoint [[S_FLOAT_TY]]* %{{.+}} to i64
-// CHECK: [[FIRST:%.+]] = ptrtoint [[S_FLOAT_TY]]* [[LOW]] to i64
+// CHECK: [[FIRST:%.+]] = ptrtoint [[S_FLOAT_TY]]* [[LOW:%.+]] to i64
 // CHECK: [[BYTE_DIF:%.+]] = sub i64 [[LAST]], [[FIRST]]
 // CHECK: [[DIF:%.+]] = sdiv exact i64 [[BYTE_DIF]], ptrtoint (float* 
getelementptr (float, float* null, i32 1) to i64)
 // CHECK: [[SIZE:%.+]] = add nuw i64 [[DIF]], 1

Modified: cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp?rev=307916&r1=307915&r2=307916&view=diff
==
--- cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp (original)
+++ cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp Thu Jul 13 08:15:25 2017
@@ -749,12 +749,8 @@ int main() {
 
 // CHECK: [[VAR3_ORIG:%.+]] = load [2 x [[S_FLOAT_TY]]]*, [2 x 
[[S_FLOAT_TY]]]** [[VAR3_ORIG_ADDR]],
 // CHECK: store [2 x [[S_FLOAT_TY]]]* [[VAR3_ORIG]], [2 x [[S_FLOAT_TY]]]** 
[[VAR3_ORIG_ADDR:%.+]],
-// CHECK: [[VAR3_ORIG:%.+]] = load [2 x [[S_FLOAT_TY]]]*, [2 x 
[[S_FLOAT_TY]]]** [[VAR3_ORIG_ADDR]],
-// CHECK: [[LOW:%.+]] = getelementptr inbounds [2 x [[S_FLOAT_TY]]], [2 x 
[[S_FLOAT_TY]]]* [[VAR3_ORIG]], i64 0, i64 1
-// CHECK: [[VAR3_ORIG:%.+]] = load [2 x [[S_FLOAT_TY]]]*, [2 x 
[[S_FLOAT_TY]]]** [[VAR3_ORIG_ADDR]],
-// CHECK: getelementptr inbounds [2 x [[S_FLOAT_TY]]], [2 x [[S_FLOAT_TY]]]* 
[[VAR3_ORIG]], i64 0, i64 2
 // CHECK: [[LAST:%.+]] = ptrtoint [[S_FLOAT_TY]]* %{{.+}} to i64
-// CHECK: [[FIRST:%.+]] = ptrtoint [[S_FLOAT_TY]]* [[LOW]] to i64
+// CHECK: [[FIRST:%.+]] = ptrtoint [[S_FLOAT_TY]]* [[LOW:%.+]] to i64
 // CHECK: [[BYTE_DIF:%.+]] = sub i64 [[LAST]], [[FIRST]]
 // CHECK: [[DIF:%.+]] = sdiv exact i64 [[BYTE_DIF]], ptrtoint ([[S_FLOAT_TY]]* 
getelementptr ([[S_FLOAT_TY]], [[S_FLOAT_TY]]* null, i32 1) to i64)
 // CHECK: [[SIZE:%.+]] = add nuw i64 [[DIF]], 1


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


[PATCH] D35337: [Solaris] gcc runtime dropped support for .ctors, switch to .init_array

2017-07-13 Thread Davide Italiano via Phabricator via cfe-commits
davide accepted this revision.
davide added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: lib/Driver/ToolChains/Gnu.cpp:2467
   const Generic_GCC::GCCVersion &V = GCCInstallation.getVersion();
   bool UseInitArrayDefault =
   getTriple().getArch() == llvm::Triple::aarch64 ||

this is really a mess.


https://reviews.llvm.org/D35337



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


[PATCH] D34588: Check for _MSC_VER before define _LIBCPP_MSVCRT

2017-07-13 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

In https://reviews.llvm.org/D34588#802533, @bruno wrote:

> > Thinking more about this, on Windows, is there a strong reason to default 
> > to a different libc by default on Windows?
>
> I'm mostly concerned with `-fms-extensions` + darwin, which doesn't apply to 
> this scenario, maybe someone else knows a better answer here.


Could something like _WIN32 && _MSC_VER make this better?  That would allow us 
to differentiate between the various environments.  It's kinda icky, but, does 
make sense in a round about way.

> 
> 
>> @bruno would reusing `-ffreestanding` work for you here?
> 
> I think forcing the use of `-ffreestanding` with Apple platforms just for 
> this is too restrictive.

Okay, was worth the shot anyways.

>> Or is there something else that we can identify about the target environment 
>> that can indicate that the MS CRT is unavailable?  I think that what is 
>> weird to me about this is that this is not about compatibility with Visual 
>> Studio but about the underlying libc.  It feels like it would be similar in 
>> spirit to say that libc++ defaults to libSystem as the underlying libc on 
>> Linux.
> 
> Right, makes total sense. I'm assuming that `-fms-extensions` for other 
> targets (Linux) will also rely in not using `_LIBCPP_MSVCRT`, however 
> #ifdefing for other platforms here doens't seem to add much because they 
> usually do not set `_MSC_VER` anyways. Additional ideas?

Another bad idea: -U_MSC_VER.  The undefine should come after the preprocessor 
is initialized and should have the same effect as not having it defined.


https://reviews.llvm.org/D34588



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


[PATCH] D34588: Check for _MSC_VER before define _LIBCPP_MSVCRT

2017-07-13 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

> Some non-windows targets using MS extensions define _WIN32 for compatibility 
> with Windows but do not have MSVC compatibility.

So, these hypothetical targets have the Win32 API available, but they do not 
use the MSVC CRT, correct? They could use musl, or some custom C runtime, but 
they don't want libc++ to aim for MSVCRT compatibility.

---

In any case, checking _MSC_VER is the best thing I can think of for guessing if 
the MSVC CRT is going to be present, so this looks good.


https://reviews.llvm.org/D34588



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


RE: D34588: Check for _MSC_VER before define _LIBCPP_MSVCRT

2017-07-13 Thread Erik Schwiebert via cfe-commits
These hypothetical targets aren’t so hypothetical.  Office for Mac and iOS uses 
code ported from Windows but actually targeted at running on the Apple (Darwin) 
platform. We don’t have the MSVC CRT there. 😊 

Schwieb

-Original Message-
From: Reid Kleckner via Phabricator [mailto:revi...@reviews.llvm.org] 
Sent: Thursday, July 13, 2017 8:31 AM
To: bruno.card...@gmail.com; e...@efcs.ca; mclow.li...@gmail.com; 
dexonsm...@apple.com; ben.cr...@gmail.com; smee...@fb.com; 
compn...@compnerd.org; david.majne...@gmail.com
Cc: geek4ci...@gmail.com; Erik Schwiebert ; 
cfe-commits@lists.llvm.org
Subject: [PATCH] D34588: Check for _MSC_VER before define _LIBCPP_MSVCRT

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

> Some non-windows targets using MS extensions define _WIN32 for compatibility 
> with Windows but do not have MSVC compatibility.

So, these hypothetical targets have the Win32 API available, but they do not 
use the MSVC CRT, correct? They could use musl, or some custom C runtime, but 
they don't want libc++ to aim for MSVCRT compatibility.

---

In any case, checking _MSC_VER is the best thing I can think of for guessing if 
the MSVC CRT is going to be present, so this looks good.


https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD34588&data=02%7C01%7Ceriksc%40microsoft.com%7C55099ebc746b4a80da4408d4ca042b95%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636355566643019338&sdata=n7xbFct8h7QlnsjjZifZYX72qqpzSG%2FpUAZEKbRbVY0%3D&reserved=0



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


r307919 - [AArch64] Add support for handling the +sve target feature.

2017-07-13 Thread Amara Emerson via cfe-commits
Author: aemerson
Date: Thu Jul 13 08:36:01 2017
New Revision: 307919

URL: http://llvm.org/viewvc/llvm-project?rev=307919&view=rev
Log:
[AArch64] Add support for handling the +sve target feature.

This also adds the appropriate predefine for SVE if enabled.

Differential Revision: https://reviews.llvm.org/D35118

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/aarch64-target-features.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=307919&r1=307918&r2=307919&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Jul 13 08:36:01 2017
@@ -6251,7 +6251,8 @@ class AArch64TargetInfo : public TargetI
 
   enum FPUModeEnum {
 FPUMode,
-NeonMode
+NeonMode = (1 << 0),
+SveMode = (1 << 1)
   };
 
   unsigned FPU;
@@ -6385,12 +6386,15 @@ public:
 Builder.defineMacro("__ARM_SIZEOF_MINIMAL_ENUM",
 Opts.ShortEnums ? "1" : "4");
 
-if (FPU == NeonMode) {
+if (FPU & NeonMode) {
   Builder.defineMacro("__ARM_NEON", "1");
   // 64-bit NEON supports half, single and double precision operations.
   Builder.defineMacro("__ARM_NEON_FP", "0xE");
 }
 
+if (FPU & SveMode)
+  Builder.defineMacro("__ARM_FEATURE_SVE", "1");
+
 if (CRC)
   Builder.defineMacro("__ARM_FEATURE_CRC32", "1");
 
@@ -6426,7 +6430,8 @@ public:
 return Feature == "aarch64" ||
   Feature == "arm64" ||
   Feature == "arm" ||
-  (Feature == "neon" && FPU == NeonMode);
+  (Feature == "neon" && (FPU & NeonMode)) ||
+  (Feature == "sve" && (FPU & SveMode));
   }
 
   bool handleTargetFeatures(std::vector &Features,
@@ -6440,7 +6445,9 @@ public:
 
 for (const auto &Feature : Features) {
   if (Feature == "+neon")
-FPU = NeonMode;
+FPU |= NeonMode;
+  if (Feature == "+sve")
+FPU |= SveMode;
   if (Feature == "+crc")
 CRC = 1;
   if (Feature == "+crypto")

Modified: cfe/trunk/test/Preprocessor/aarch64-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/aarch64-target-features.c?rev=307919&r1=307918&r2=307919&view=diff
==
--- cfe/trunk/test/Preprocessor/aarch64-target-features.c (original)
+++ cfe/trunk/test/Preprocessor/aarch64-target-features.c Thu Jul 13 08:36:01 
2017
@@ -37,6 +37,7 @@
 // CHECK-NOT: __ARM_PCS_VFP 1
 // CHECK-NOT: __ARM_SIZEOF_MINIMAL_ENUM 1
 // CHECK-NOT: __ARM_SIZEOF_WCHAR_T 2
+// CHECK-NOT: __ARM_FEATURE_SVE
 
 // RUN: %clang -target aarch64_be-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-BIGENDIAN
 // CHECK-BIGENDIAN: __ARM_BIG_ENDIAN 1
@@ -84,6 +85,10 @@
 // CHECK-GENERIC: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon"
 
 // RUN: %clang -target aarch64 -mtune=cyclone -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MTUNE-CYCLONE %s
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+sve -x c -E -dM 
%s -o - | FileCheck --check-prefix=CHECK-SVE %s
+// CHECK-SVE: __ARM_FEATURE_SVE 1
+
 // == Check whether -mtune accepts mixed-case features.
 // RUN: %clang -target aarch64 -mtune=CYCLONE -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MTUNE-CYCLONE %s
 // CHECK-MTUNE-CYCLONE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+neon" "-target-feature" "+zcm" "-target-feature" "+zcz"


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


[PATCH] D35118: [AArch64] Add support for handling the +sve target feature

2017-07-13 Thread Amara Emerson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL307919: [AArch64] Add support for handling the +sve target 
feature. (authored by aemerson).

Changed prior to commit:
  https://reviews.llvm.org/D35118?vs=106386&id=106432#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35118

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/Preprocessor/aarch64-target-features.c


Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -6251,7 +6251,8 @@
 
   enum FPUModeEnum {
 FPUMode,
-NeonMode
+NeonMode = (1 << 0),
+SveMode = (1 << 1)
   };
 
   unsigned FPU;
@@ -6385,12 +6386,15 @@
 Builder.defineMacro("__ARM_SIZEOF_MINIMAL_ENUM",
 Opts.ShortEnums ? "1" : "4");
 
-if (FPU == NeonMode) {
+if (FPU & NeonMode) {
   Builder.defineMacro("__ARM_NEON", "1");
   // 64-bit NEON supports half, single and double precision operations.
   Builder.defineMacro("__ARM_NEON_FP", "0xE");
 }
 
+if (FPU & SveMode)
+  Builder.defineMacro("__ARM_FEATURE_SVE", "1");
+
 if (CRC)
   Builder.defineMacro("__ARM_FEATURE_CRC32", "1");
 
@@ -6426,7 +6430,8 @@
 return Feature == "aarch64" ||
   Feature == "arm64" ||
   Feature == "arm" ||
-  (Feature == "neon" && FPU == NeonMode);
+  (Feature == "neon" && (FPU & NeonMode)) ||
+  (Feature == "sve" && (FPU & SveMode));
   }
 
   bool handleTargetFeatures(std::vector &Features,
@@ -6440,7 +6445,9 @@
 
 for (const auto &Feature : Features) {
   if (Feature == "+neon")
-FPU = NeonMode;
+FPU |= NeonMode;
+  if (Feature == "+sve")
+FPU |= SveMode;
   if (Feature == "+crc")
 CRC = 1;
   if (Feature == "+crypto")
Index: cfe/trunk/test/Preprocessor/aarch64-target-features.c
===
--- cfe/trunk/test/Preprocessor/aarch64-target-features.c
+++ cfe/trunk/test/Preprocessor/aarch64-target-features.c
@@ -37,6 +37,7 @@
 // CHECK-NOT: __ARM_PCS_VFP 1
 // CHECK-NOT: __ARM_SIZEOF_MINIMAL_ENUM 1
 // CHECK-NOT: __ARM_SIZEOF_WCHAR_T 2
+// CHECK-NOT: __ARM_FEATURE_SVE
 
 // RUN: %clang -target aarch64_be-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-BIGENDIAN
 // CHECK-BIGENDIAN: __ARM_BIG_ENDIAN 1
@@ -84,6 +85,10 @@
 // CHECK-GENERIC: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon"
 
 // RUN: %clang -target aarch64 -mtune=cyclone -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MTUNE-CYCLONE %s
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+sve -x c -E -dM 
%s -o - | FileCheck --check-prefix=CHECK-SVE %s
+// CHECK-SVE: __ARM_FEATURE_SVE 1
+
 // == Check whether -mtune accepts mixed-case features.
 // RUN: %clang -target aarch64 -mtune=CYCLONE -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MTUNE-CYCLONE %s
 // CHECK-MTUNE-CYCLONE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+neon" "-target-feature" "+zcm" "-target-feature" "+zcz"


Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -6251,7 +6251,8 @@
 
   enum FPUModeEnum {
 FPUMode,
-NeonMode
+NeonMode = (1 << 0),
+SveMode = (1 << 1)
   };
 
   unsigned FPU;
@@ -6385,12 +6386,15 @@
 Builder.defineMacro("__ARM_SIZEOF_MINIMAL_ENUM",
 Opts.ShortEnums ? "1" : "4");
 
-if (FPU == NeonMode) {
+if (FPU & NeonMode) {
   Builder.defineMacro("__ARM_NEON", "1");
   // 64-bit NEON supports half, single and double precision operations.
   Builder.defineMacro("__ARM_NEON_FP", "0xE");
 }
 
+if (FPU & SveMode)
+  Builder.defineMacro("__ARM_FEATURE_SVE", "1");
+
 if (CRC)
   Builder.defineMacro("__ARM_FEATURE_CRC32", "1");
 
@@ -6426,7 +6430,8 @@
 return Feature == "aarch64" ||
   Feature == "arm64" ||
   Feature == "arm" ||
-  (Feature == "neon" && FPU == NeonMode);
+  (Feature == "neon" && (FPU & NeonMode)) ||
+  (Feature == "sve" && (FPU & SveMode));
   }
 
   bool handleTargetFeatures(std::vector &Features,
@@ -6440,7 +6445,9 @@
 
 for (const auto &Feature : Features) {
   if (Feature == "+neon")
-FPU = NeonMode;
+FPU |= NeonMode;
+  if (Feature == "+sve")
+FPU |= SveMode;
   if (Feature == "+crc")
 CRC = 1;
   if (Feature == "+crypto")
Index: cfe/trunk/test/Preprocessor/aarch64-target-features.c
===
--- cfe/trunk/test/Preprocessor/aarch64-target-features.c
+++ cfe/trunk/test/Preprocessor/aarch64-target-features.c
@@ -37,6 +37,7 @@
 // CHECK-NOT: __ARM_PCS_VFP 1
 // CHECK-NOT: __ARM_SIZEOF_MINIMAL_ENUM 1
 // CHECK-NOT: __ARM_SIZEOF_WCHAR_T 2
+// CHECK-NOT:

[PATCH] D16403: Add scope information to CFG for If/While/For/Do/Compound/CXXRangeFor statements

2017-07-13 Thread Peter Szecsi via Phabricator via cfe-commits
szepet added a comment.

Hello Maxim!
Thanks for working on this!

> Ugh, yeah, SwitchStmt is tricky (thank you for pointing to Duff's device 
> example!). I've tried to resolve several issues with switch revealed by this 
> testcase, but didn't succeed for now :(. So, it was decided to remove 
> SwitchStmt support in this patch.

I think this is a great decision! It can build up incremental and the patch can 
be more easily reviewed. When do you plan to upload a patch wihtout casestmt 
support? (As far as I see there is switchstmt related code but maybe Im missing 
something.)


Repository:
  rL LLVM

https://reviews.llvm.org/D16403



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


[PATCH] D34331: func.wrap.func.con: Unset function before destroying anything

2017-07-13 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In https://reviews.llvm.org/D34331#803452, @EricWF wrote:

> In https://reviews.llvm.org/D34331#803105, @dexonsmith wrote:
>
> > In https://reviews.llvm.org/D34331#802747, @EricWF wrote:
> >
> > > @dexonsmith Mind if I hijack this and check in your changes to 
> > > `` with my tests?
> >
> >
> > Not at all.
> >
> > In https://reviews.llvm.org/D34331#802821, @EricWF wrote:
> >
> > > @dexonsmith I'm not sure it's sane to allow reentrant behavior. Could you 
> > > explain why you think it is?
> >
> >
> > It didn't seem sane to me at first either, despite this being supported by 
> > `std::unique_ptr` and `std::shared_ptr`.  I found our user fairly 
> > convincing, though:
> >
> > - They had an underlying reference counted object, so only the destruction 
> > of the last copy of A nulled out the pointer (mimicked that with the `bool 
> > cancel`).
> > - They had a callback function intended to be called once, and dropping 
> > that function on cancellation (mimicked that with a global variable). The 
> > cancel operation nulled out a `std::function`, but destroying the objects 
> > captured in the lambda in that std::function also separately decided to 
> > perform a cancel, which should have been OK. The cancel function just 
> > contained `callback = nullptr`.
>
>
> According to [reentrancy] it is implementation defined what STL functions are 
> allowed to be recursively reentered. I'm not opposed to providing reentrancy 
> where it's useful, but we would have to provide it well.
>  This is where I was running into problems while I was writing tests. There 
> are so many different ways you can reenter std::function's special members 
> that it makes it impossible for an implementation
>  to truly support reentrancy as the standard would require.
>
> If you consider that every possible copy construction or destruction of a 
> user type is a potential reentrancy point, the complexity of having 
> well-defined reentrant behavior starts to become clear.
>  Any time a copy constructor or destructor is invoked you have a potential 
> reentrancy point which, in order to provide well defined behavior, must also 
> act as a sort of _sequence point_ where the side effects of the current call 
> are visible to the reentrant callers (For example your patches use of 
> `operator=(nullptr_t)`).
>
> The methods fixed in this patch are seemingly improvements; It's clear that 
> `operator=(nullptr)` can safely be made reentrant. On the other hand consider 
> `operator=(function const& rhs)`, which is specified as equivalent to 
> `function(rhs).swap(*this)`.
>  I posit `swap` is not the kind of thing that can easily be made reentrant, 
> but that making `std::function` assignment reentrant in general clearly 
> requires it.
>
> If fixing this bug is sufficiently important I'm willing to accept that, but 
> I don't think it improves the status quo; We may have fixed a specific users 
> bug, but we haven't made these functions safely reentrant (in fact most of 
> the special members are likely still full of reentrancy bugs).


IMO, `function::operator=(nullptr_t)` is a clear, restricted subset of 
reentrancy: it's the cutely-named `std::function` equivalent of 
`unique_ptr::reset()`.  I think it's worth supporting reentrancy here.

After my own experimentation creating a testcase (and iterating with our 
internal users on motivation), I agree that supporting reentrancy for anything 
else would be untenable.


https://reviews.llvm.org/D34331



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


[PATCH] D33537: [clang-tidy] Exception Escape Checker

2017-07-13 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added a comment.

In https://reviews.llvm.org/D33537#771274, @aaron.ballman wrote:

> In https://reviews.llvm.org/D33537#771159, @baloghadamsoftware wrote:
>
> > In https://reviews.llvm.org/D33537#770264, @aaron.ballman wrote:
> >
> > > I think we should try to get as much of this functionality in 
> > > https://reviews.llvm.org/D3 as possible; there is a considerable 
> > > amount of overlap between that functionality and this functionality. This 
> > > check can then cover only the parts that are not reasonably handled by 
> > > the frontend check instead of duplicating diagnostics the user already 
> > > receives.
> >
> >
> > I suppose that the frontend check will not travarse the call-graph just 
> > check direct throws. Should we only check indirect throws then?
>
>
> The check in https://reviews.llvm.org/D3 is using a CFG, not just 
> checking direct throws.




In https://reviews.llvm.org/D33537#807997, @erichkeane wrote:

> In https://reviews.llvm.org/D33537#801889, @baloghadamsoftware wrote:
>
> > In https://reviews.llvm.org/D33537#771274, @aaron.ballman wrote:
> >
> > > The check in https://reviews.llvm.org/D3 is using a CFG, not just 
> > > checking direct throws.
> >
> >
> > I tested the latest revision (the fronted patch already included) on my 
> > test file. Disregarding of the not so important parameters 
> > (`EnabledFunctions` and `IgnoredExceptions`) I do not get warnings for any 
> > indirect throws (`indirect_implicit()` and `indirect_explicit()`). So for 
> > me it does not seem to be using the CFG. Furthermore, I do not get warning 
> > for `throw_and_catch_some()` where `1.1` is a `double` thus `catch(int &)` 
> > should not catch it. The same happens in `throw_catch_rethrow_the_rest()`, 
> > where `catch(int &)` should not catch `1.1`, but `catch(...)` should catch 
> > and rethrow it. This latter may be a bug.
>
>
> Jen Yu can clarify, but I believe it was decided to put the implementation in 
> the CFG, but not do a full analysis (leave that for a later implementation).  
> It is not doing 'catch' analysis, and I don't believe they decided to do 
> analysis on the function call itself, since the false-positive rate is 
> massive thanks to the C headers.


The catch  analys

In https://reviews.llvm.org/D33537#807997, @erichkeane wrote:

> In https://reviews.llvm.org/D33537#801889, @baloghadamsoftware wrote:
>
> > In https://reviews.llvm.org/D33537#771274, @aaron.ballman wrote:
> >
> > > The check in https://reviews.llvm.org/D3 is using a CFG, not just 
> > > checking direct throws.
> >
> >
> > I tested the latest revision (the fronted patch already included) on my 
> > test file. Disregarding of the not so important parameters 
> > (`EnabledFunctions` and `IgnoredExceptions`) I do not get warnings for any 
> > indirect throws (`indirect_implicit()` and `indirect_explicit()`). So for 
> > me it does not seem to be using the CFG. Furthermore, I do not get warning 
> > for `throw_and_catch_some()` where `1.1` is a `double` thus `catch(int &)` 
> > should not catch it. The same happens in `throw_catch_rethrow_the_rest()`, 
> > where `catch(int &)` should not catch `1.1`, but `catch(...)` should catch 
> > and rethrow it. This latter may be a bug.
>
>
> Jen Yu can clarify, but I believe it was decided to put the implementation in 
> the CFG, but not do a full analysis (leave that for a later implementation).  
> It is not doing 'catch' analysis, and I don't believe they decided to do 
> analysis on the function call itself, since the false-positive rate is 
> massive thanks to the C headers.




In https://reviews.llvm.org/D33537#801889, @baloghadamsoftware wrote:

> In https://reviews.llvm.org/D33537#771274, @aaron.ballman wrote:
>
> > The check in https://reviews.llvm.org/D3 is using a CFG, not just 
> > checking direct throws.
>
>
> I tested the latest revision (the fronted patch already included) on my test 
> file. Disregarding of the not so important parameters (`EnabledFunctions` and 
> `IgnoredExceptions`) I do not get warnings for any indirect throws 
> (`indirect_implicit()` and `indirect_explicit()`). So for me it does not seem 
> to be using the CFG. Furthermore, I do not get warning for 
> `throw_and_catch_some()` where `1.1` is a `double` thus `catch(int &)` should 
> not catch it. The same happens in `throw_catch_rethrow_the_rest()`, where 
> `catch(int &)` should not catch `1.1`, but `catch(...)` should catch and 
> rethrow it. This latter may be a bug.




In https://reviews.llvm.org/D33537#807997, @erichkeane wrote:

> In https://reviews.llvm.org/D33537#801889, @baloghadamsoftware wrote:
>
> > In https://reviews.llvm.org/D33537#771274, @aaron.ballman wrote:
> >
> > > The check in https://reviews.llvm.org/D3 is using a CFG, not just 
> > > checking direct throws.
> >
> >
> > I tested the latest revision (the fronted patch already included) on my 
> > test file. Disregarding of the not so important parameters 
> > (`EnabledFunctions` and `Ig

[PATCH] D16403: Add scope information to CFG for If/While/For/Do/Compound/CXXRangeFor statements

2017-07-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I think the remaining switch-related code seems to be about C++17 switch 
condition variables, i.e. `switch (int x = ...)`(?)


Repository:
  rL LLVM

https://reviews.llvm.org/D16403



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


[PATCH] D34440: [Clang] Expand response files before loading compilation database

2017-07-13 Thread Vladimir Plyashkun via Phabricator via cfe-commits
vladimir.plyashkun added inline comments.



Comment at: unittests/Tooling/CompilationDatabaseTest.cpp:638-652
+  ParseCompilationDatabaseFromResponseFileTest() {
+std::error_code EC = llvm::sys::fs::createUniqueDirectory("unittest", 
TestDir);
+EXPECT_TRUE(!EC);
+llvm::sys::path::append(ResponseFileName, TestDir, "resp");
+  }
+  void setResponseFileContent(const std::string &content) {
+std::ofstream File(ResponseFileName.c_str());

alexfh wrote:
> Can we do all this in the virtual file system 
> (include/clang/Basic/VirtualFileSystem.h) to avoid creating files from the 
> unit test?
Unfortunately, i don't see any options how to do it with VFS. 
All other tests related with response files expansion don't use VFS for some 
reasons, e.g. `unittests/Support/CommandLineTest.cpp`


Repository:
  rL LLVM

https://reviews.llvm.org/D34440



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


[PATCH] D16403: Add scope information to CFG for If/While/For/Do/Compound/CXXRangeFor statements

2017-07-13 Thread Maxim Ostapenko via Phabricator via cfe-commits
m.ostapenko added a comment.

In https://reviews.llvm.org/D16403#808104, @NoQ wrote:

> I think the remaining switch-related code seems to be about C++17 switch 
> condition variables, i.e. `switch (int x = ...)`(?)


Yeah, exactly. I can remove it from this patch if it looks confusing.


Repository:
  rL LLVM

https://reviews.llvm.org/D16403



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


[PATCH] D35081: [ThinLTO] Allow multiple summary entries.

2017-07-13 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

Teresa: can you describe a bit more how we end up importing two summaries for 
the same GUID? I would expect that after importing one, we don't even come to 
try to import another since we already have one.


https://reviews.llvm.org/D35081



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


[PATCH] D34440: [Clang] Expand response files before loading compilation database

2017-07-13 Thread Vladimir Plyashkun via Phabricator via cfe-commits
vladimir.plyashkun updated this revision to Diff 106436.
vladimir.plyashkun added a comment.

- trailing period
- moved test-cases to separate file


Repository:
  rL LLVM

https://reviews.llvm.org/D34440

Files:
  lib/Tooling/CommonOptionsParser.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/CommonOptionsParserTest.cpp

Index: unittests/Tooling/CommonOptionsParserTest.cpp
===
--- /dev/null
+++ unittests/Tooling/CommonOptionsParserTest.cpp
@@ -0,0 +1,72 @@
+//===- unittests/Tooling/CommonOptionsParserTest.cpp -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Tooling/CommonOptionsParser.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "gtest/gtest.h"
+
+#include 
+
+namespace clang {
+namespace tooling {
+
+class CommonOptionsParserTest : public testing::Test {
+public:
+  SmallString<128> TestDir;
+  SmallString<128> ResponseFileName;
+
+  CommonOptionsParserTest() {
+std::error_code EC = llvm::sys::fs::createUniqueDirectory("unittest", TestDir);
+EXPECT_TRUE(!EC);
+llvm::sys::path::append(ResponseFileName, TestDir, "resp");
+  }
+
+  void setResponseFileContent(const std::string &Content) {
+std::ofstream File(ResponseFileName.c_str());
+EXPECT_TRUE(File.is_open());
+File << Content;
+File.close();
+  }
+
+  ~CommonOptionsParserTest() override {
+llvm::sys::fs::remove(ResponseFileName);
+llvm::sys::fs::remove(TestDir);
+  }
+};
+
+TEST_F(CommonOptionsParserTest, ExpandResponseFilesBeforeLoadingCompilationDatabase) {
+  setResponseFileContent("-- -a=true -b");
+  SmallString<128> ResponseFileRef;
+  ResponseFileRef.append(1, '@');
+  ResponseFileRef.append(ResponseFileName.c_str());
+  int Argc = 3;
+  const char *Argv[] = { "1", "2", ResponseFileRef.c_str() };
+  llvm::cl::OptionCategory Category("options");
+  llvm::cl::opt option1("a", llvm::cl::desc(""), llvm::cl::init(false),
+  llvm::cl::cat(Category));
+  llvm::cl::opt option2("b", llvm::cl::desc(""), llvm::cl::init(false),
+  llvm::cl::cat(Category));
+  CommonOptionsParser Parser(Argc, Argv, Category);
+  CompilationDatabase &Database = Parser.getCompilations();
+  std::vector ActualCC = Database.getCompileCommands("source");
+  ASSERT_EQ(1u, ActualCC.size());
+  std::vector ExpectedCmd;
+  ExpectedCmd.push_back("clang-tool");
+  ExpectedCmd.push_back("-a=true");
+  ExpectedCmd.push_back("-b");
+  ExpectedCmd.push_back("source");
+
+  ASSERT_EQ(ExpectedCmd, ActualCC[0].CommandLine);
+}
+	
+} // end namespace tooling
+} // end namespace clang
Index: unittests/Tooling/CMakeLists.txt
===
--- unittests/Tooling/CMakeLists.txt
+++ unittests/Tooling/CMakeLists.txt
@@ -14,6 +14,7 @@
   CastExprTest.cpp
   CommentHandlerTest.cpp
   CompilationDatabaseTest.cpp
+  CommonOptionsParserTest.cpp
   DiagnosticsYamlTest.cpp
   FixItTest.cpp
   LookupTest.cpp
Index: lib/Tooling/CommonOptionsParser.cpp
===
--- lib/Tooling/CommonOptionsParser.cpp
+++ lib/Tooling/CommonOptionsParser.cpp
@@ -25,6 +25,7 @@
 //===--===//
 
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/StringSaver.h"
 #include "clang/Tooling/ArgumentsAdjusters.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
@@ -116,6 +117,14 @@
 
   cl::HideUnrelatedOptions(Category);
 
+  // Expand response files before loading compilation database from command line.
+  SmallVector NewArgv(argv, argv + argc);
+  BumpPtrAllocator A;
+  StringSaver Saver(A);
+  cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine, NewArgv);
+  argv = &NewArgv[0];
+  argc = static_cast(NewArgv.size());
+
   std::string ErrorMessage;
   Compilations =
   FixedCompilationDatabase::loadFromCommandLine(argc, argv, ErrorMessage);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35081: [ThinLTO] Allow multiple summary entries.

2017-07-13 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In https://reviews.llvm.org/D35081#808124, @mehdi_amini wrote:

> Teresa: can you describe a bit more how we end up importing two summaries for 
> the same GUID? I would expect that after importing one, we don't even come to 
> try to import another since we already have one.


Because of this:
http://llvm-cs.pcc.me.uk/lib/Transforms/IPO/FunctionImport.cpp#261

  /// Since the traversal of the call graph is DFS, we can revisit a function
  /// a second time with a higher threshold. In this case, it is added back to
  /// the worklist with the new threshold.

The goal is that if we revisit with a higher threshold (which we do in the test 
case), that we want to reconsider downstream callees again. E.g. if we have 
foo() calls bar() calls baz(), and we first decided to import bar() into foo's 
module, but the threshold was not high enough to import baz, if we later 
encounter this call from foo->bar again with a higher threshold (because we hit 
it on a path that was either hotter or shorter), we want to reconsider whether 
to import baz().

The issue here is that when we reconsider "foo" we pick a different copy 
(earlier in the list, but skipped initially due to having an instruction count 
above the first (lower) threshold).


https://reviews.llvm.org/D35081



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


[PATCH] D35337: [Solaris] gcc runtime dropped support for .ctors, switch to .init_array

2017-07-13 Thread Fedor Sergeev via Phabricator via cfe-commits
fedor.sergeev added inline comments.



Comment at: lib/Driver/ToolChains/Gnu.cpp:2467
   const Generic_GCC::GCCVersion &V = GCCInstallation.getVersion();
   bool UseInitArrayDefault =
   getTriple().getArch() == llvm::Triple::aarch64 ||

davide wrote:
> this is really a mess.
Any suggestions on how to improve? :)


https://reviews.llvm.org/D35337



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


[PATCH] D34440: [Clang] Expand response files before loading compilation database

2017-07-13 Thread Vladimir Plyashkun via Phabricator via cfe-commits
vladimir.plyashkun added a comment.

**To discuss:**
This patch is required for correct integration //Clang-Tidy// with //CLion 
IDE//.
By this moment, we unable to use //CompilationDatabase.json// from //CLion 
//side which is widely used in //Clang-Tidy// and in other common tools.
Anyway, there are possibility to pass compiler options directly through command 
line.
But we cannot pass compiler options directly through command-line, due to 
command-line-length restrictions.
So, we decided to pass compiler options through //@ResponseFile //mechanism.
But there are some problems with this approach.
Before this patch, ///clang/lib/Tooling/CommonOptionsParser.cpp// worked in 
this way:

1. Load compilation database from command-line
2. Expand response files
3. Parse all other command line arguments

I think it's strange behavior? 
Why we try to load compilation database first? 
Maybe it's better to expand response files and only after that try to load 
compilation database and parse another options?
It's hard to refactor //cl::ParseCommandLineOptions// and 
//cl::ExpandResponseFiles// functions, due to high number of usages, so i 
copied some block directly into ///clang/lib/Tooling/CommonOptionsParser.cpp//
I don't think that is a best solution, but i don't have another one.




Comment at: unittests/Tooling/CommonOptionsParserTest.cpp:41
+  ~CommonOptionsParserTest() override {
+llvm::sys::fs::remove(ResponseFileName);
+llvm::sys::fs::remove(TestDir);

I moved test-cases to separate file.
But as i mentioned before, i don't see any options how to use VFS here.
All other test-cases related with response files expansion also don't use VFS 
for some reasons, e.g. `unittests/Support/CommandLineTest.cpp`


Repository:
  rL LLVM

https://reviews.llvm.org/D34440



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


[PATCH] D35081: [ThinLTO] Allow multiple summary entries.

2017-07-13 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

Thanks, very clear :)

I would expect that if we reprocess a GUID we invalidate the previous import of 
the same GUID. Right now my impression is that the issue is that ` 
ImportList[ExportModulePath][VI.getGUID()]` is indexed on the importing module. 
So it'd require for every new import to loop over the ImportList map and delete 
the GUID on each inner map.

Alternatively (and likely preferably from a compile-time point of view to limit 
the list of import), we could keep a map of GUID->Summary and reuse it before 
trying to select a new callee.


https://reviews.llvm.org/D35081



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


[PATCH] D35000: [OpenCL] Added extended tests on metadata generation for half data type and arrays.

2017-07-13 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D35000#807674, @echuraev wrote:

> In https://reviews.llvm.org/D35000#801132, @Anastasia wrote:
>
> > In https://reviews.llvm.org/D35000#799705, @Anastasia wrote:
> >
> > > Btw, is there any reason to add testing specifically for half? Is there 
> > > anything specific to half in the implementation of this?
> >
> >
> > Trying to understand the reason for this change though...
>
>
> Sorry for a delay in response. No it is not any reason to add testing 
> specifically for half. We can also do the same tests for other data types. 
> Here we just check that it is no any qualifiers in metadata.


Btw, if I read the spec then it feels like we should put the qualifiers of the 
pointee type instead:

`CL_KERNEL_ARG_TYPE_VOLATILE` is returned if the argument is a pointer and the 
referenced type is declared with the `volatile` qualifier. For example, a 
kernel argument declared as `global int volatile *x` returns 
`CL_KERNEL_ARG_TYPE_VOLATILE` but a kernel argument declared as `global int 
*volatile x` does not. Similarly, `CL_KERNEL_ARG_TYPE_RESTRICT` or 
`CL_KERNEL_ARG_TYPE_CONST` is returned if the argument is a pointer and the 
referenced type is declared with the `restrict` or `const` qualifier. For 
example, a kernel argument declared as `global int const *x` returns 
`CL_KERNEL_ARG_TYPE_CONST` but a kernel argument declared as `global int *const 
x` does not.

It seems that the function `foo` is attempting to test that too. Perhaps we 
could unify the testing and create all combinations of pointer and non pointer 
types which would have qualifier and not.

I don't feel that we should test all possible types though...


https://reviews.llvm.org/D35000



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


[PATCH] D33589: clang-format: consider not splitting tokens in optimization

2017-07-13 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 106442.
Typz added a comment.

Move code out of optimizer, directly into 
ContinuationIndenter::breakProtrudingToken(), to minimize impact on performance.
Comment reflowing of breakable items which break the limit will be slightly 
slower, since we now consider the two options; however this change has no 
impact on the performance of processing non-breakable items, and may actually 
increase the operformance of processing breakable items which do not need to be 
reflowed.


https://reviews.llvm.org/D33589

Files:
  lib/Format/ContinuationIndenter.cpp
  lib/Format/ContinuationIndenter.h
  lib/Format/UnwrappedLineFormatter.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -9393,6 +9393,60 @@
   EXPECT_EQ("#pragma option -C -A", format("#pragmaoption   -C   -A"));
 }
 
+TEST_F(FormatTest, OptimizeBreakPenaltyVsExcess) {
+  FormatStyle Style = getLLVMStyle();
+  Style.ColumnLimit = 20;
+
+  verifyFormat("int a; // the\n"
+   "   // comment", Style);
+  EXPECT_EQ("int a; /* first line\n"
+"* second\n"
+"* line third\n"
+"* line\n"
+"*/",
+			format("int a; /* first line\n"
+   "* second\n"
+   "* line third\n"
+   "* line\n"
+   "*/", Style));
+  EXPECT_EQ("int a; // first line\n"
+"   // second\n"
+"   // line third\n"
+"   // line",
+format("int a; // first line\n"
+   "   // second line\n"
+   "   // third line",
+   Style));
+
+  Style.PenaltyExcessCharacter = 90;
+  verifyFormat("int a; // the comment", Style);
+  EXPECT_EQ("int a; // the\n"
+"   // comment aa",
+format("int a; // the comment aa", Style));
+  EXPECT_EQ("int a; /* first line\n"
+"* second line\n"
+"* third line\n"
+"*/",
+			format("int a; /* first line\n"
+	   "* second line\n"
+			   "* third line\n"
+	   "*/", Style));
+  EXPECT_EQ("int a; // first line\n"
+"   // second line\n"
+"   // third line",
+format("int a; // first line\n"
+   "   // second line\n"
+   "   // third line",
+   Style));
+  EXPECT_EQ("int a; /* first line\n"
+"* second\n"
+"* line third\n"
+"* line\n"
+"*/",
+format("int a; /* first line second line third line"
+   "\n*/", Style));
+}
+
 #define EXPECT_ALL_STYLES_EQUAL(Styles)\
   for (size_t i = 1; i < Styles.size(); ++i)   \
   EXPECT_EQ(Styles[0], Styles[i]) << "Style #" << i << " of " << Styles.size() \
Index: lib/Format/UnwrappedLineFormatter.cpp
===
--- lib/Format/UnwrappedLineFormatter.cpp
+++ lib/Format/UnwrappedLineFormatter.cpp
@@ -866,6 +866,7 @@
 for (std::deque::iterator I = Path.begin(), E = Path.end();
  I != E; ++I) {
   unsigned Penalty = 0;
+  State.Reflow = (*I)->State.Reflow;
   formatChildren(State, (*I)->NewLine, /*DryRun=*/false, Penalty);
   Penalty += Indenter->addTokenToState(State, (*I)->NewLine, false);
 
Index: lib/Format/ContinuationIndenter.h
===
--- lib/Format/ContinuationIndenter.h
+++ lib/Format/ContinuationIndenter.h
@@ -27,6 +27,7 @@
 namespace format {
 
 class AnnotatedLine;
+class BreakableToken;
 struct FormatToken;
 struct LineState;
 struct ParenState;
@@ -100,6 +101,11 @@
   unsigned breakProtrudingToken(const FormatToken &Current, LineState &State,
 bool DryRun);
 
+  unsigned reflowProtrudingToken(const FormatToken & Current, LineState & State,
+ std::unique_ptr & Token,
+ unsigned ColumnLimit, bool DryRun);
+
+
   /// \brief Appends the next token to \p State and updates information
   /// necessary for indentation.
   ///
@@ -350,6 +356,8 @@
   /// \brief The indent of the first token.
   unsigned FirstIndent;
 
+  bool Reflow = true;
+
   /// \brief The line that is being formatted.
   ///
   /// Does not need to be considered for memoization because it doesn't change.
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -1219,6 +1219,112 @@
   return 0;
 }
 
+unsigned Conti

r307923 - NFC, Cleanup the code for -Wdeprecated-implementations

2017-07-13 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Jul 13 09:35:59 2017
New Revision: 307923

URL: http://llvm.org/viewvc/llvm-project?rev=307923&view=rev
Log:
NFC, Cleanup the code for -Wdeprecated-implementations
and void capitalization of the warning message

rdar://22867595

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/test/SemaObjC/warn-deprecated-implementations.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=307923&r1=307922&r2=307923&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 13 09:35:59 
2017
@@ -4579,8 +4579,8 @@ def warn_deprecated_fwdclass_message : W
 "%0 may be deprecated because the receiver type is unknown">,
 InGroup;
 def warn_deprecated_def : Warning<
-"Implementing deprecated %select{method|class|category}0">,
-InGroup, DefaultIgnore;
+  "implementing deprecated %select{method|class|category}0">,
+  InGroup, DefaultIgnore;
 def err_unavailable : Error<"%0 is unavailable">;
 def err_property_method_unavailable :
 Error<"property access is using %0 method which is unavailable">;

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=307923&r1=307922&r2=307923&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Jul 13 09:35:59 2017
@@ -248,19 +248,31 @@ bool Sema::CheckARCMethodDecl(ObjCMethod
   return false;
 }
 
-static void DiagnoseObjCImplementedDeprecations(Sema &S,
-NamedDecl *ND,
-SourceLocation ImplLoc,
-int select) {
-  if (ND && ND->isDeprecated()) {
-S.Diag(ImplLoc, diag::warn_deprecated_def) << select;
-if (select == 0)
-  S.Diag(ND->getLocation(), diag::note_method_declared_at)
-<< ND->getDeclName();
-else
-  S.Diag(ND->getLocation(), diag::note_previous_decl)
-  << (isa(ND) ? "category" : "class");
+static void DiagnoseObjCImplementedDeprecations(Sema &S, const NamedDecl *ND,
+SourceLocation ImplLoc) {
+  if (!ND)
+return;
+  bool IsCategory = false;
+  if (!ND->isDeprecated()) {
+if (const auto *CD = dyn_cast(ND)) {
+  if (!CD->getClassInterface()->isDeprecated())
+return;
+  ND = CD->getClassInterface();
+  IsCategory = true;
+} else
+  return;
   }
+  S.Diag(ImplLoc, diag::warn_deprecated_def)
+  << (isa(ND)
+  ? /*Method*/ 0
+  : isa(ND) || IsCategory ? /*Category*/ 2
+: /*Class*/ 1);
+  if (isa(ND))
+S.Diag(ND->getLocation(), diag::note_method_declared_at)
+<< ND->getDeclName();
+  else
+S.Diag(ND->getLocation(), diag::note_previous_decl)
+<< (isa(ND) ? "category" : "class");
 }
 
 /// AddAnyMethodToGlobalPool - Add any method, instance or factory to global
@@ -385,9 +397,7 @@ void Sema::ActOnStartOfObjCMethodDef(Sco
   // No need to issue deprecated warning if deprecated mehod in 
class/category
   // is being implemented in its own implementation (no overriding is 
involved).
   if (!ImplDeclOfMethodDecl || ImplDeclOfMethodDecl != ImplDeclOfMethodDef)
-DiagnoseObjCImplementedDeprecations(*this, 
-  dyn_cast(IMD), 
-  MDecl->getLocation(), 0);
+DiagnoseObjCImplementedDeprecations(*this, IMD, MDecl->getLocation());
 }
 
 if (MDecl->getMethodFamily() == OMF_init) {
@@ -1873,10 +1883,8 @@ Decl *Sema::ActOnStartCategoryImplementa
   CatIDecl->setImplementation(CDecl);
   // Warn on implementating category of deprecated class under 
   // -Wdeprecated-implementations flag.
-  DiagnoseObjCImplementedDeprecations(
-  *this,
-  CatIDecl->isDeprecated() ? CatIDecl : dyn_cast(IDecl),
-  CDecl->getLocation(), 2);
+  DiagnoseObjCImplementedDeprecations(*this, CatIDecl,
+  CDecl->getLocation());
 }
   }
 
@@ -1996,9 +2004,7 @@ Decl *Sema::ActOnStartClassImplementatio
 PushOnScopeChains(IMPDecl, TUScope);
 // Warn on implementating deprecated class under 
 // -Wdeprecated-implementations flag.
-DiagnoseObjCImplementedDeprecations(*this, 
-dyn_cast(IDecl), 
-IMPDecl->getLocation(), 1);
+DiagnoseObjCImplementedDeprecations(*this, IDecl, IMPDecl->getLocation()

r307924 - Extend -Wdeprecated-implementations to warn about unavailable methods

2017-07-13 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Jul 13 09:37:11 2017
New Revision: 307924

URL: http://llvm.org/viewvc/llvm-project?rev=307924&view=rev
Log:
Extend -Wdeprecated-implementations to warn about unavailable methods

rdar://22867595

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/test/SemaObjC/warn-deprecated-implementations.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=307924&r1=307923&r2=307924&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 13 09:37:11 
2017
@@ -4581,6 +4581,9 @@ def warn_deprecated_fwdclass_message : W
 def warn_deprecated_def : Warning<
   "implementing deprecated %select{method|class|category}0">,
   InGroup, DefaultIgnore;
+def warn_unavailable_def : Warning<
+  "implementing unavailable method">,
+  InGroup, DefaultIgnore;
 def err_unavailable : Error<"%0 is unavailable">;
 def err_property_method_unavailable :
 Error<"property access is using %0 method which is unavailable">;

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=307924&r1=307923&r2=307924&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Jul 13 09:37:11 2017
@@ -253,7 +253,17 @@ static void DiagnoseObjCImplementedDepre
   if (!ND)
 return;
   bool IsCategory = false;
-  if (!ND->isDeprecated()) {
+  AvailabilityResult Availability = ND->getAvailability();
+  if (Availability != AR_Deprecated) {
+if (const auto *MD = dyn_cast(ND)) {
+  if (Availability != AR_Unavailable)
+return;
+  // Warn about implementing unavailable methods.
+  S.Diag(ImplLoc, diag::warn_unavailable_def);
+  S.Diag(ND->getLocation(), diag::note_method_declared_at)
+  << ND->getDeclName();
+  return;
+}
 if (const auto *CD = dyn_cast(ND)) {
   if (!CD->getClassInterface()->isDeprecated())
 return;

Modified: cfe/trunk/test/SemaObjC/warn-deprecated-implementations.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/warn-deprecated-implementations.m?rev=307924&r1=307923&r2=307924&view=diff
==
--- cfe/trunk/test/SemaObjC/warn-deprecated-implementations.m (original)
+++ cfe/trunk/test/SemaObjC/warn-deprecated-implementations.m Thu Jul 13 
09:37:11 2017
@@ -1,9 +1,11 @@
-// RUN: %clang_cc1 -fsyntax-only -Wdeprecated-implementations -verify 
-Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple=x86_64-apple-macos10.10 -fsyntax-only 
-Wdeprecated-implementations -verify -Wno-objc-root-class %s
 // rdar://8973810
 // rdar://12717705
 
 @protocol P
 - (void) D __attribute__((deprecated)); // expected-note {{method 'D' declared 
here}}
+
+- (void) unavailable __attribute__((__unavailable__)); // expected-note 
{{method 'unavailable' declared here}}
 @end
 
 @interface A 
@@ -18,6 +20,8 @@
 + (void)F { }  // No warning, implementing its own deprecated method
 - (void) D {} //  expected-warning {{implementing deprecated method}}
 - (void) E {} // No warning, implementing deprecated method in its class 
extension.
+
+- (void) unavailable { } // expected-warning {{implementing unavailable metho}}
 @end
 
 @interface A(CAT)
@@ -43,6 +47,8 @@ __attribute__((deprecated)) // expected-
 
 @interface BASE
 - (void) B __attribute__((deprecated)); // expected-note {{method 'B' declared 
here}}
+
++ (void) unavailable __attribute__((availability(macos, unavailable))); // 
expected-note {{method 'unavailable' declared here}}
 @end
 
 @interface SUB : BASE
@@ -50,6 +56,7 @@ __attribute__((deprecated)) // expected-
 
 @implementation SUB
 - (void) B {} // expected-warning {{implementing deprecated method}}
++ (void) unavailable { } // expected-warning {{implementing unavailable 
method}}
 @end
 
 @interface Test


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


[PATCH] D35081: [ThinLTO] Allow multiple summary entries.

2017-07-13 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In https://reviews.llvm.org/D35081#808158, @mehdi_amini wrote:

> Thanks, very clear :)
>
> I would expect that if we reprocess a GUID we invalidate the previous import 
> of the same GUID. Right now my impression is that the issue is that ` 
> ImportList[ExportModulePath][VI.getGUID()]` is indexed on the importing 
> module. So it'd require for every new import to loop over the ImportList map 
> and delete the GUID on each inner map.


Right, that was the processing I was hoping to avoid.

> Alternatively (and likely preferably from a compile-time point of view to 
> limit the list of import), we could keep a map of GUID->Summary and reuse it 
> before trying to select a new callee.

Yep, that was my third option. I only hesitate because it seems like it might 
be better to select the prevailing copy when we can, but perhaps it doesn't 
matter much.


https://reviews.llvm.org/D35081



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


[PATCH] D35081: [ThinLTO] Allow multiple summary entries.

2017-07-13 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

In https://reviews.llvm.org/D35081#808189, @tejohnson wrote:

> > Alternatively (and likely preferably from a compile-time point of view to 
> > limit the list of import), we could keep a map of GUID->Summary and reuse 
> > it before trying to select a new callee.
>
> Yep, that was my third option. I only hesitate because it seems like it might 
> be better to select the prevailing copy when we can, but perhaps it doesn't 
> matter much.


I'm not sure I understand what is your first option? Always selecting the 
prevailing copy? 
Unless doing a topological order for visiting (which I don't think we could 
reasonably do), I don't see how you can ensure that:  on your first visit you 
may see the prevailing not eligible, but it may become eligible on the second 
visit, at which point you need to do something about the first copy you already 
selected.


https://reviews.llvm.org/D35081



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


[PATCH] D35081: [ThinLTO] Allow multiple summary entries.

2017-07-13 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In https://reviews.llvm.org/D35081#808204, @mehdi_amini wrote:

> In https://reviews.llvm.org/D35081#808189, @tejohnson wrote:
>
> > > Alternatively (and likely preferably from a compile-time point of view to 
> > > limit the list of import), we could keep a map of GUID->Summary and reuse 
> > > it before trying to select a new callee.
> >
> > Yep, that was my third option. I only hesitate because it seems like it 
> > might be better to select the prevailing copy when we can, but perhaps it 
> > doesn't matter much.
>
>
> I'm not sure I understand what is your first option? Always selecting the 
> prevailing copy? 
>  Unless doing a topological order for visiting (which I don't think we could 
> reasonably do), I don't see how you can ensure that:  on your first visit you 
> may see the prevailing not eligible, but it may become eligible on the second 
> visit, at which point you need to do something about the first copy you 
> already selected.


My first option was if any copy is under the threshold, simply pick the 
prevailing copy (it may be over threshold, but assume we want that one anyway). 
Another possibility is to only allow importing of the prevailing copy, if it is 
over the inst limit, too bad. The main reason I think that could be better is 
when we have PGO - the prevailing copy would for sure have the matched PGO 
data, but the non-prevailing copies may not.


https://reviews.llvm.org/D35081



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


[PATCH] D35337: [Solaris] gcc runtime dropped support for .ctors, switch to .init_array

2017-07-13 Thread David L. Jones via Phabricator via cfe-commits
dlj accepted this revision.
dlj added a comment.

I think this change is structurally fine, but I'll defer to others on whether 
it's actually doing the right thing. (I'm pretty sure it is, but I'm far from 
an expert on Solaris or Sparc.)




Comment at: lib/Driver/ToolChains/Gnu.cpp:2467
   const Generic_GCC::GCCVersion &V = GCCInstallation.getVersion();
   bool UseInitArrayDefault =
   getTriple().getArch() == llvm::Triple::aarch64 ||

fedor.sergeev wrote:
> davide wrote:
> > this is really a mess.
> Any suggestions on how to improve? :)
From my perspective, this is really no worse than what's already here. I tried 
to avoid changing logic in https://reviews.llvm.org/rL297250, but this function 
is an example of something that still can use a lot of work.

Since this variable depends on all the parts of the triple, it probably won't 
break down very cleanly among the various subclasses. That said, if you do want 
to refactor this, you'll of course want to spend some time to think through 
exactly how this should work, and spend some time gathering feedback from other 
Clang devs... so it's probably out of the scope of this patch. I would be happy 
to help review that change... but, more pragmatically, I'd say land this change 
first before starting any surgery.



Comment at: test/Driver/constructors.c:83
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1\
+// RUN: -target i386-pc-solaris2.11 \
+// RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s

Thank you for adding these. :-D Most of the toolchain classes lack explanatory 
comments about which platform combinations are expected to work for different 
features, so test cases like this will be invaluable to anyone who wants to 
refactor parts of the driver.


https://reviews.llvm.org/D35337



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


[PATCH] D35362: [clang-tidy] Add close-on-exec checks on several functions in Android module.

2017-07-13 Thread Yan Wang via Phabricator via cfe-commits
yawanng created this revision.
yawanng added a project: clang-tools-extra.
Herald added subscribers: xazax.hun, JDevlieghere, mgorny.

accept() is better to be replaced by accept4() with SOCK_CLOEXEC flag to avoid 
file descriptor leakage.

This is one of a bunch of similar APIs as below and they have very similar 
structures:


https://reviews.llvm.org/D35362

Files:
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/CloexecAcceptCheck.cpp
  clang-tidy/android/CloexecAcceptCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-cloexec-accept.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/android-cloexec-accept.cpp

Index: test/clang-tidy/android-cloexec-accept.cpp
===
--- /dev/null
+++ test/clang-tidy/android-cloexec-accept.cpp
@@ -0,0 +1,28 @@
+// RUN: %check_clang_tidy %s android-cloexec-accept %t
+
+struct sockaddr {};
+typedef int socklen_t;
+#define NULL 0
+
+extern "C" int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
+
+void f() {
+  accept(0, NULL, NULL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer accept4() to accept() because accept4() allows SOCK_CLOEXEC [android-cloexec-accept]
+  // CHECK-FIXES: accept4(0, NULL, NULL, SOCK_CLOEXEC)
+}
+
+namespace i {
+int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
+void g() {
+  accept(0, NULL, NULL);
+}
+} // namespace i
+
+class C {
+public:
+  int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
+  void h() {
+accept(0, NULL, NULL);
+  }
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -4,6 +4,7 @@
 =
 
 .. toctree::
+   android-cloexec-accept
android-cloexec-creat
android-cloexec-fopen
android-cloexec-open
Index: docs/clang-tidy/checks/android-cloexec-accept.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/android-cloexec-accept.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - android-cloexec-accept
+
+android-cloexec-accept
+==
+
+The usage of ``accept()`` is not recommended, it's better to use ``accept4()``.
+Without this flag, an opened sensitive file descriptor would remain open across
+a fork+exec to a lower-privileged SELinux domain.
+
+Examples:
+
+.. code-block:: c++
+
+  accept(sockfd, addr, addrlen);
+
+  // becomes
+
+  accept4(sockfd, addr, addrlen, SOCK_CLOEXEC);
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `android-cloexec-accept
+  `_ check
+
+  Detects usage of ``accept()``.
+
 - New `android-cloexec-creat
   `_ check
 
Index: clang-tidy/android/CloexecAcceptCheck.h
===
--- /dev/null
+++ clang-tidy/android/CloexecAcceptCheck.h
@@ -0,0 +1,35 @@
+//===--- CloexecAcceptCheck.h - clang-tidy---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_ACCEPT_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_ACCEPT_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+/// accept() is better to be replaced by accept4().
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-accept.html
+class CloexecAcceptCheck : public ClangTidyCheck {
+public:
+  CloexecAcceptCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_ACCEPT_H
Index: clang-tidy/android/CloexecAcceptCheck.cpp
===
--- /dev/null
+++ clang-tidy/android/CloexecAcceptCheck.cpp
@@ -0,0 +1,64 @@
+//===--- CloexecAcceptCheck.cpp - clang-tidy---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===-

r307931 - Fix -Wdocumentation warning. NFCI

2017-07-13 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Jul 13 10:29:48 2017
New Revision: 307931

URL: http://llvm.org/viewvc/llvm-project?rev=307931&view=rev
Log:
Fix -Wdocumentation warning. NFCI

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=307931&r1=307930&r2=307931&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Thu Jul 13 10:29:48 2017
@@ -159,7 +159,6 @@ public:
   /// \param DefaultInit Default initialization sequence that should be
   /// performed if no reduction specific initialization is found.
   /// \param SharedLVal Addreiss of the original shared variable.
-  /// \return true, if the initialization sequence was emitted, false 
otherwise.
   void
   emitInitialization(CodeGenFunction &CGF, unsigned N, Address PrivateAddr,
  LValue SharedLVal,


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


r307932 - Fix spelling mistakes in comments. NFCI.

2017-07-13 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Jul 13 10:34:44 2017
New Revision: 307932

URL: http://llvm.org/viewvc/llvm-project?rev=307932&view=rev
Log:
Fix spelling mistakes in comments. NFCI.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=307932&r1=307931&r2=307932&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Thu Jul 13 10:34:44 2017
@@ -108,7 +108,7 @@ struct OMPTaskDataTy final {
 /// Class intended to support codegen of all kind of the reduction clauses.
 class ReductionCodeGen {
 private:
-  /// Data requiored for codegen of reduction clauses.
+  /// Data required for codegen of reduction clauses.
   struct ReductionData {
 /// Reference to the original shared item.
 const Expr *Ref = nullptr;
@@ -158,18 +158,18 @@ public:
   /// \param PrivateAddr Address of the corresponding private item.
   /// \param DefaultInit Default initialization sequence that should be
   /// performed if no reduction specific initialization is found.
-  /// \param SharedLVal Addreiss of the original shared variable.
+  /// \param SharedLVal Address of the original shared variable.
   void
   emitInitialization(CodeGenFunction &CGF, unsigned N, Address PrivateAddr,
  LValue SharedLVal,
  llvm::function_ref DefaultInit);
-  /// ReturCns true if the private copy requires cleanups.
+  /// Returns true if the private copy requires cleanups.
   bool needCleanups(unsigned N);
-  /// Emits cleanup code nfor the reduction item.
+  /// Emits cleanup code for the reduction item.
   /// \param N Number of the reduction item.
   /// \param PrivateAddr Address of the corresponding private item.
   void emitCleanups(CodeGenFunction &CGF, unsigned N, Address PrivateAddr);
-  /// Adjusts \p PrivatedAddr for using ninstead of the original variable
+  /// Adjusts \p PrivatedAddr for using instead of the original variable
   /// address in normal operations.
   /// \param N Number of the reduction item.
   /// \param PrivateAddr Address of the corresponding private item.
@@ -200,7 +200,7 @@ protected:
   /// \param OutlinedFnID Outlined function ID value to be defined by this 
call.
   /// \param IsOffloadEntry True if the outlined function is an offload entry.
   /// \param CodeGen Lambda codegen specific to an accelerator device.
-  /// An oulined function may not be an entry if, e.g. the if clause always
+  /// An outlined function may not be an entry if, e.g. the if clause always
   /// evaluates to false.
   virtual void emitTargetOutlinedFunctionHelper(const OMPExecutableDirective 
&D,
 StringRef ParentName,
@@ -778,7 +778,7 @@ public:
   /// \param Loc Clang source location.
   /// \param ScheduleKind Schedule kind, specified by the 'schedule' clause.
   /// \param IVSize Size of the iteration variable in bits.
-  /// \param IVSigned Sign of the interation variable.
+  /// \param IVSigned Sign of the iteration variable.
   /// \param Ordered true if loop is ordered, false otherwise.
   /// \param DispatchValues struct containing llvm values for lower bound, 
upper
   /// bound, and chunk expression.
@@ -802,7 +802,7 @@ public:
   /// \param Loc Clang source location.
   /// \param ScheduleKind Schedule kind, specified by the 'schedule' clause.
   /// \param IVSize Size of the iteration variable in bits.
-  /// \param IVSigned Sign of the interation variable.
+  /// \param IVSigned Sign of the iteration variable.
   /// \param Ordered true if loop is ordered, false otherwise.
   /// \param IL Address of the output variable in which the flag of the
   /// last iteration is returned.
@@ -811,7 +811,7 @@ public:
   /// \param UB Address of the output variable in which the upper iteration
   /// number is returned.
   /// \param ST Address of the output variable in which the stride value is
-  /// returned nesessary to generated the static_chunked scheduled loop.
+  /// returned necessary to generated the static_chunked scheduled loop.
   /// \param Chunk Value of the chunk for the static_chunked scheduled loop.
   /// For the default (nullptr) value, the chunk 1 will be used.
   ///
@@ -826,7 +826,7 @@ public:
   /// \param Loc Clang source location.
   /// \param SchedKind Schedule kind, specified by the 'dist_schedule' clause.
   /// \param IVSize Size of the iteration variable in bits.
-  /// \param IVSigned Sign of the interation variable.
+  /// \param IVSigned Sign of the iteration variable.
   /// \param Ordered true if loop is ordered, false otherwise.
   /// \param IL Address of the output variable in which the flag of the
   /// last iteration is returned.
@@ -835,7 +835,7 @@ public:
   /// \param UB Address of the output variable in which the upper iteration
   /// numb

[PATCH] D32914: Introduce Wzero-as-null-pointer-constant.

2017-07-13 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

PR #33771  filled.
IMHO the problems with this diagnostic should be resolved before 5.0


https://reviews.llvm.org/D32914



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


Re: [PATCH] D32914: Introduce Wzero-as-null-pointer-constant.

2017-07-13 Thread Nico Weber via cfe-commits
On Thu, Jul 13, 2017 at 1:38 PM, Roman Lebedev via Phabricator via
cfe-commits  wrote:

> lebedev.ri added a comment.
>
> PR #33771  filled.
> IMHO the problems with this diagnostic should be resolved before 5.0
>

iirc gcc warns in that case too (?) Also, the warning is off by default.


>
>
> https://reviews.llvm.org/D32914
>
>
>
> ___
> 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


[PATCH] D35008: [AArch64] Produce the right kind of va_arg for windows

2017-07-13 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

Ping - the dependency, https://reviews.llvm.org/D35006, has now been committed.


https://reviews.llvm.org/D35008



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


[PATCH] D35008: [AArch64] Produce the right kind of va_arg for windows

2017-07-13 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm




Comment at: lib/CodeGen/TargetInfo.cpp:8463
   Kind = AArch64ABIInfo::DarwinPCS;
+else if (Triple.getOS() == llvm::Triple::Win32)
+  Kind = AArch64ABIInfo::Win64;

`Triple.isOSWindows()` is probably cleaner.


https://reviews.llvm.org/D35008



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


r307933 - [AArch64] Produce the right kind of va_arg for windows

2017-07-13 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Thu Jul 13 10:59:14 2017
New Revision: 307933

URL: http://llvm.org/viewvc/llvm-project?rev=307933&view=rev
Log:
[AArch64] Produce the right kind of va_arg for windows

On windows on arm64, the va_list is a plain pointer.

Differential Revision: https://reviews.llvm.org/D35008

Added:
cfe/trunk/test/CodeGen/aarch64-varargs-ms.c
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=307933&r1=307932&r2=307933&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Jul 13 10:59:14 2017
@@ -4785,7 +4785,8 @@ class AArch64ABIInfo : public SwiftABIIn
 public:
   enum ABIKind {
 AAPCS = 0,
-DarwinPCS
+DarwinPCS,
+Win64
   };
 
 private:
@@ -4823,10 +4824,14 @@ private:
 
   Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
 QualType Ty) const override {
-return isDarwinPCS() ? EmitDarwinVAArg(VAListAddr, Ty, CGF)
- : EmitAAPCSVAArg(VAListAddr, Ty, CGF);
+return Kind == Win64 ? EmitMSVAArg(CGF, VAListAddr, Ty)
+ : isDarwinPCS() ? EmitDarwinVAArg(VAListAddr, Ty, CGF)
+ : EmitAAPCSVAArg(VAListAddr, Ty, CGF);
   }
 
+  Address EmitMSVAArg(CodeGenFunction &CGF, Address VAListAddr,
+  QualType Ty) const override;
+
   bool shouldPassIndirectlyForSwift(CharUnits totalSize,
 ArrayRef scalars,
 bool asReturnValue) const override {
@@ -5332,6 +5337,14 @@ Address AArch64ABIInfo::EmitDarwinVAArg(
   TyInfo, SlotSize, /*AllowHigherAlign*/ true);
 }
 
+Address AArch64ABIInfo::EmitMSVAArg(CodeGenFunction &CGF, Address VAListAddr,
+QualType Ty) const {
+  return emitVoidPtrVAArg(CGF, VAListAddr, Ty, /*indirect*/ false,
+  CGF.getContext().getTypeInfoInChars(Ty),
+  CharUnits::fromQuantity(8),
+  /*allowHigherAlign*/ false);
+}
+
 
//===--===//
 // ARM ABI Implementation
 
//===--===//
@@ -8494,6 +8507,8 @@ const TargetCodeGenInfo &CodeGenModule::
 AArch64ABIInfo::ABIKind Kind = AArch64ABIInfo::AAPCS;
 if (getTarget().getABI() == "darwinpcs")
   Kind = AArch64ABIInfo::DarwinPCS;
+else if (Triple.isOSWindows())
+  Kind = AArch64ABIInfo::Win64;
 
 return SetCGInfo(new AArch64TargetCodeGenInfo(Types, Kind));
   }

Added: cfe/trunk/test/CodeGen/aarch64-varargs-ms.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-varargs-ms.c?rev=307933&view=auto
==
--- cfe/trunk/test/CodeGen/aarch64-varargs-ms.c (added)
+++ cfe/trunk/test/CodeGen/aarch64-varargs-ms.c Thu Jul 13 10:59:14 2017
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple arm64-windows-msvc -emit-llvm -o - %s | FileCheck 
--check-prefix=CHECK %s
+
+#include 
+
+int simple_int(va_list ap) {
+// CHECK-LABEL: define i32 @simple_int
+  return va_arg(ap, int);
+// CHECK: [[ADDR:%[a-z_0-9]+]] = bitcast i8* %argp.cur to i32*
+// CHECK: [[RESULT:%[a-z_0-9]+]] = load i32, i32* [[ADDR]]
+// CHECK: ret i32 [[RESULT]]
+}


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


[PATCH] D35008: [AArch64] Produce the right kind of va_arg for windows

2017-07-13 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL307933: [AArch64] Produce the right kind of va_arg for 
windows (authored by mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D35008?vs=105392&id=106471#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35008

Files:
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/test/CodeGen/aarch64-varargs-ms.c


Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -4785,7 +4785,8 @@
 public:
   enum ABIKind {
 AAPCS = 0,
-DarwinPCS
+DarwinPCS,
+Win64
   };
 
 private:
@@ -4823,10 +4824,14 @@
 
   Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
 QualType Ty) const override {
-return isDarwinPCS() ? EmitDarwinVAArg(VAListAddr, Ty, CGF)
- : EmitAAPCSVAArg(VAListAddr, Ty, CGF);
+return Kind == Win64 ? EmitMSVAArg(CGF, VAListAddr, Ty)
+ : isDarwinPCS() ? EmitDarwinVAArg(VAListAddr, Ty, CGF)
+ : EmitAAPCSVAArg(VAListAddr, Ty, CGF);
   }
 
+  Address EmitMSVAArg(CodeGenFunction &CGF, Address VAListAddr,
+  QualType Ty) const override;
+
   bool shouldPassIndirectlyForSwift(CharUnits totalSize,
 ArrayRef scalars,
 bool asReturnValue) const override {
@@ -5332,6 +5337,14 @@
   TyInfo, SlotSize, /*AllowHigherAlign*/ true);
 }
 
+Address AArch64ABIInfo::EmitMSVAArg(CodeGenFunction &CGF, Address VAListAddr,
+QualType Ty) const {
+  return emitVoidPtrVAArg(CGF, VAListAddr, Ty, /*indirect*/ false,
+  CGF.getContext().getTypeInfoInChars(Ty),
+  CharUnits::fromQuantity(8),
+  /*allowHigherAlign*/ false);
+}
+
 
//===--===//
 // ARM ABI Implementation
 
//===--===//
@@ -8494,6 +8507,8 @@
 AArch64ABIInfo::ABIKind Kind = AArch64ABIInfo::AAPCS;
 if (getTarget().getABI() == "darwinpcs")
   Kind = AArch64ABIInfo::DarwinPCS;
+else if (Triple.isOSWindows())
+  Kind = AArch64ABIInfo::Win64;
 
 return SetCGInfo(new AArch64TargetCodeGenInfo(Types, Kind));
   }
Index: cfe/trunk/test/CodeGen/aarch64-varargs-ms.c
===
--- cfe/trunk/test/CodeGen/aarch64-varargs-ms.c
+++ cfe/trunk/test/CodeGen/aarch64-varargs-ms.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple arm64-windows-msvc -emit-llvm -o - %s | FileCheck 
--check-prefix=CHECK %s
+
+#include 
+
+int simple_int(va_list ap) {
+// CHECK-LABEL: define i32 @simple_int
+  return va_arg(ap, int);
+// CHECK: [[ADDR:%[a-z_0-9]+]] = bitcast i8* %argp.cur to i32*
+// CHECK: [[RESULT:%[a-z_0-9]+]] = load i32, i32* [[ADDR]]
+// CHECK: ret i32 [[RESULT]]
+}


Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -4785,7 +4785,8 @@
 public:
   enum ABIKind {
 AAPCS = 0,
-DarwinPCS
+DarwinPCS,
+Win64
   };
 
 private:
@@ -4823,10 +4824,14 @@
 
   Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
 QualType Ty) const override {
-return isDarwinPCS() ? EmitDarwinVAArg(VAListAddr, Ty, CGF)
- : EmitAAPCSVAArg(VAListAddr, Ty, CGF);
+return Kind == Win64 ? EmitMSVAArg(CGF, VAListAddr, Ty)
+ : isDarwinPCS() ? EmitDarwinVAArg(VAListAddr, Ty, CGF)
+ : EmitAAPCSVAArg(VAListAddr, Ty, CGF);
   }
 
+  Address EmitMSVAArg(CodeGenFunction &CGF, Address VAListAddr,
+  QualType Ty) const override;
+
   bool shouldPassIndirectlyForSwift(CharUnits totalSize,
 ArrayRef scalars,
 bool asReturnValue) const override {
@@ -5332,6 +5337,14 @@
   TyInfo, SlotSize, /*AllowHigherAlign*/ true);
 }
 
+Address AArch64ABIInfo::EmitMSVAArg(CodeGenFunction &CGF, Address VAListAddr,
+QualType Ty) const {
+  return emitVoidPtrVAArg(CGF, VAListAddr, Ty, /*indirect*/ false,
+  CGF.getContext().getTypeInfoInChars(Ty),
+  CharUnits::fromQuantity(8),
+  /*allowHigherAlign*/ false);
+}
+
 //===--===//
 // ARM ABI Implementation
 //===--===//
@@ -8494,6 +8507,8 @@
 AArch64ABIInfo::ABIKin

[PATCH] D34121: [ubsan] Teach the pointer overflow check that "p - <= p" (PR33430)

2017-07-13 Thread Will Dietz via Phabricator via cfe-commits
dtzWill added a comment.

In https://reviews.llvm.org/D34121#806978, @vsk wrote:

> @dtzWill do you have any further comments on this one?
>
> I'd like to get another 'lgtm' before committing, and it'd be nice to get 
> this in before llvm 5.0 branches (7/19).
>
> FWIW we've been living on this for a few weeks internally without any issues:
>  
> https://github.com/apple/swift-clang/commit/3ebe7d87b9d545aebdd80452d0b79695ff871bce


@vsk sorry for the delay.  Looks solid to me, seems to work well in my testing.

Unrelated to the suitability of the patch itself, but on the subject:
Interestingly there don''t seem to be any changes in observed errors, which on 
one hand is great (yay no breakage and earlier results were mostly correct) but 
on the other isn't what I expected.
Does this match your experiences?


https://reviews.llvm.org/D34121



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


[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

2017-07-13 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 6 inline comments as done.
yaxunl added inline comments.



Comment at: lib/AST/Expr.cpp:3235
+// has non-default address space it is not treated as nullptr.
+bool PointeeHasDefaultAS = false;
+if (Ctx.getLangOpts().OpenCL)

Anastasia wrote:
> Would we still be accepting the following:
>   global int * ptr = (global void*)0;
Yes. There is a test SemaOpenCL/null_literal.cl



Comment at: lib/Sema/SemaDecl.cpp:7964
+PointeeType.getAddressSpace() == LangAS::opencl_private ||
 PointeeType.getAddressSpace() == 0)
   return InvalidAddrSpacePtrKernelParam;

Anastasia wrote:
> Could we use `LangAS::Default` instead?
done



Comment at: lib/Sema/SemaDecl.cpp:11846
   // an address space.
   if (T.getAddressSpace() != 0) {
 // OpenCL allows function arguments declared to be an array of a type

Anastasia wrote:
> Could we use `LangAS::Default` here too?
done



Comment at: lib/Sema/SemaDecl.cpp:11851
+  (T->isArrayType() ||
+   T.getAddressSpace() == LangAS::opencl_private))) {
   Diag(NameLoc, diag::err_arg_with_address_space);

Anastasia wrote:
> Would it be better to lift this into if condition of line 11846?
will do.



Comment at: lib/Sema/SemaType.cpp:6969
 
+  if (state.getSema().getLangOpts().OpenCL &&
+  !hasOpenCLAddressSpace && type.getAddressSpace() == 0 &&

Anastasia wrote:
> Would it be nicer to not append any address space at all neither here nor 
> down at the end of this function and keep it default instead until the 
> Codegen? If it's doable I would very much prefer that. It seems like it would 
> make the implementation potentially a bit cleaner to understand and easier to 
> improve semantical analysis. See one example of improving original type 
> printing in my comment to the test below.
> 
> Also there are at least these 3 related bugs open currently:
> https://bugs.llvm.org//show_bug.cgi?id=33418
> https://bugs.llvm.org//show_bug.cgi?id=33419
> https://bugs.llvm.org//show_bug.cgi?id=33420
> 
> Does your change address any of those?
On the contrary, I think using default address space for automatic variable and 
function parameter will cause ambiguity and inconsistency in AST, making it 
more difficult to understand and process, and making some bug (e.g. 
https://bugs.llvm.org//show_bug.cgi?id=33419) unfixable. For example, `private 
int f(void)` and `int f(void)` will be identical in AST, therefore we cannot 
diagnose `private int f(void)`.

With current representation I am able to fix the 3 bugs. I will update the diff.



Comment at: test/SemaOpenCL/access-qualifier.cl:23
 #else
-void myReadWrite(read_write image1d_t); // expected-error {{access qualifier 
'read_write' can not be used for '__read_write image1d_t' prior to OpenCL 
version 2.0}}
+void myReadWrite(read_write image1d_t); // expected-error {{access qualifier 
'read_write' can not be used for '__private __read_write image1d_t' prior to 
OpenCL version 2.0}}
 #endif

Anastasia wrote:
> Ok, I think that here it would be less confusing not to add any address space 
> since it's missing in the original source.
Although it looks strange at first sight, `__private __read_write image1d_t` is 
the true type of the argument. The function argument is allocated from stack 
and is an l-value. If we take its address, we get a private pointer.


https://reviews.llvm.org/D35082



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


[PATCH] D35081: [ThinLTO] Allow multiple summary entries.

2017-07-13 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

In https://reviews.llvm.org/D35081#808207, @tejohnson wrote:

> My first option was if any copy is under the threshold, simply pick the 
> prevailing copy (it may be over threshold, but assume we want that one 
> anyway). Another possibility is to only allow importing of the prevailing 
> copy, if it is over the inst limit, too bad. The main reason I think that 
> could be better is when we have PGO - the prevailing copy would for sure have 
> the matched PGO data, but the non-prevailing copies may not.


Ah makes sense, both way are fine with me.

I'd rather limit to the prevailing copy though and too bad if it is over the 
limit, to avoid the possibility of too large importing just because there was a 
small non-prevailing somewhere, but likely a rare case.

Limiting to the prevailing copy means that we could prune the index early after 
symbol resolution to keep only the prevailing summary, which could speed-up all 
the process (and possibly get more accurate dead-stripping if we don't use the 
prevailing information there already?).


https://reviews.llvm.org/D35081



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


[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

2017-07-13 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 106486.
yaxunl marked 6 inline comments as done.
yaxunl added a comment.

Revised by Anastasia's comments.


https://reviews.llvm.org/D35082

Files:
  include/clang/Basic/AddressSpaces.h
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/TypePrinter.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGDecl.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenOpenCL/address-spaces-mangling.cl
  test/Index/opencl-types.cl
  test/Parser/opencl-astype.cl
  test/Parser/opencl-atomics-cl20.cl
  test/SemaOpenCL/access-qualifier.cl
  test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  test/SemaOpenCL/address-spaces.cl
  test/SemaOpenCL/arithmetic-conversions.cl
  test/SemaOpenCL/as_type.cl
  test/SemaOpenCL/cl20-device-side-enqueue.cl
  test/SemaOpenCL/event_t.cl
  test/SemaOpenCL/extension-begin.cl
  test/SemaOpenCL/half.cl
  test/SemaOpenCL/images.cl
  test/SemaOpenCL/invalid-block.cl
  test/SemaOpenCL/invalid-image.cl
  test/SemaOpenCL/invalid-kernel-parameters.cl
  test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
  test/SemaOpenCL/invalid-pipes-cl2.0.cl
  test/SemaOpenCL/null_literal.cl
  test/SemaOpenCL/null_queue.cl
  test/SemaOpenCL/queue_t_overload.cl
  test/SemaOpenCL/sampler_t.cl
  test/SemaOpenCL/shifts.cl
  test/SemaOpenCL/to_addr_builtin.cl
  test/SemaOpenCL/vec_step.cl
  test/SemaOpenCL/vector_conv_invalid.cl

Index: test/SemaOpenCL/vector_conv_invalid.cl
===
--- test/SemaOpenCL/vector_conv_invalid.cl
+++ test/SemaOpenCL/vector_conv_invalid.cl
@@ -7,7 +7,7 @@
 
 void vector_conv_invalid() {
   uint4 u = (uint4)(1);
-  int4 i = u; // expected-error{{initializing 'int4' (vector of 4 'int' values) with an expression of incompatible type 'uint4' (vector of 4 'unsigned int' values)}}
+  int4 i = u; // expected-error{{initializing '__private int4' (vector of 4 'int' values) with an expression of incompatible type '__private uint4' (vector of 4 'unsigned int' values)}}
   int4 e = (int4)u; // expected-error{{invalid conversion between ext-vector type 'int4' (vector of 4 'int' values) and 'uint4' (vector of 4 'unsigned int' values)}}
 
   uint3 u4 = (uint3)u; // expected-error{{invalid conversion between ext-vector type 'uint3' (vector of 3 'unsigned int' values) and 'uint4' (vector of 4 'unsigned int' values)}}
Index: test/SemaOpenCL/vec_step.cl
===
--- test/SemaOpenCL/vec_step.cl
+++ test/SemaOpenCL/vec_step.cl
@@ -26,7 +26,7 @@
   int res11[vec_step(int16) == 16 ? 1 : -1];
   int res12[vec_step(void) == 1 ? 1 : -1];
 
-  int res13 = vec_step(*incomplete1); // expected-error {{'vec_step' requires built-in scalar or vector type, 'struct S' invalid}}
-  int res14 = vec_step(int16*); // expected-error {{'vec_step' requires built-in scalar or vector type, 'int16 *' invalid}}
+  int res13 = vec_step(*incomplete1); // expected-error {{'vec_step' requires built-in scalar or vector type, '__private struct S' invalid}}
+  int res14 = vec_step(int16 *); // expected-error {{'vec_step' requires built-in scalar or vector type, '__private int16 *' invalid}}
   int res15 = vec_step(void(void)); // expected-error {{'vec_step' requires built-in scalar or vector type, 'void (void)' invalid}}
 }
Index: test/SemaOpenCL/to_addr_builtin.cl
===
--- test/SemaOpenCL/to_addr_builtin.cl
+++ test/SemaOpenCL/to_addr_builtin.cl
@@ -11,45 +11,45 @@
   glob = to_global(glob, loc);
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
   // expected-error@-2{{implicit declaration of function 'to_global' is invalid in OpenCL}}
-  // expected-warning@-3{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
+  // expected-warning@-3{{incompatible integer to pointer conversion assigning to '__global int *__private' from 'int'}}
 #else
   // expected-error@-5{{invalid number of arguments to function: 'to_global'}}
 #endif
 
   int x;
   glob = to_global(x);
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
-  // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *__private' from 'int'}}
 #else
   // expected-error@-4{{invalid argument x to function: 'to_global', expecting a generic pointer argument}}
 #endif
 
   glob = to_global(con);
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
-  // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *__private' from 'int'}}
 #else
   // expected-error@-4{{invalid argument con to function: 'to_global', expecting a generic pointer argument}}
 #endif
 
   glob = to_global(con_typedef);
 #if __OPENCL_C_VERSION__ 

[PATCH] D34824: clang-format: add an option -verbose to list the files being processed

2017-07-13 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added inline comments.



Comment at: tools/clang-format/ClangFormat.cpp:377
 break;
   case 1:
 Error = clang::format::format(FileNames[0]);

djasper wrote:
> I think we should restructure the code to not have to duplicate what you are 
> adding here. I think fundamentally, we should be able to change this to:
> 
>   if (FileNames.empty()) {
> Error = clang::format::format("-");
> return Error ? 1 : 0;
>   }
>   if (FileNames.size() == 1 && (!Offsets.empty() || !Lengths.empty() || 
> !LineRanges.empty())) {
> errs() << "error: -offset  "
> return 1;
>   }
>   for (const auto& FileName : FileNames) {
> if (Verbose.getNumOccurences() != 0)
>   errs() << "Formatting " << Filename << "\n";
> Error |= clang::format::format(FileName);
>   }
>   return Error ? 1 : 0;
This isn't correct.
You can have

```
bin/clang-format  -lines=1:1 foo-1.cpp foo-2.cpp 
```
we won't enter into the "error: -offset" error



https://reviews.llvm.org/D34824



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


[PATCH] D34475: [AArch64] Add support for __builtin_ms_va_list on aarch64

2017-07-13 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo updated this revision to Diff 106489.
mstorsjo retitled this revision from "[RFC] [AArch64] Add support for 
__builtin_ms_va_list on aarch64" to "[AArch64] Add support for 
__builtin_ms_va_list on aarch64".
mstorsjo edited the summary of this revision.
mstorsjo added a comment.

Added test cases, a minor tweak to semantic error handling, removed the RFC 
tag, removed the reference to the clang prerequisite that now is committed.


https://reviews.llvm.org/D34475

Files:
  include/clang-c/Index.h
  include/clang/Basic/BuiltinsAArch64.def
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Specifiers.h
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/Type.cpp
  lib/AST/TypePrinter.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/ms_abi_aarch64.c
  test/Sema/varargs-aarch64.c
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -619,6 +619,7 @@
   TCALLINGCONV(Swift);
   TCALLINGCONV(PreserveMost);
   TCALLINGCONV(PreserveAll);
+  TCALLINGCONV(AArch64Win64);
 case CC_SpirFunction: return CXCallingConv_Unexposed;
 case CC_OpenCLKernel: return CXCallingConv_Unexposed;
   break;
Index: test/Sema/varargs-aarch64.c
===
--- /dev/null
+++ test/Sema/varargs-aarch64.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple aarch64-linux-gnu
+
+void f1(int a, ...) {
+  __builtin_ms_va_list ap;
+  __builtin_ms_va_start(ap, a); // expected-error {{'__builtin_ms_va_start' used in AAPCS ABI function}}
+}
+
+void __attribute__((ms_abi)) f2(int a, ...) {
+  __builtin_va_list ap;
+  __builtin_va_start(ap, a); // expected-error {{'va_start' used in Win64 ABI function}}
+}
Index: test/CodeGen/ms_abi_aarch64.c
===
--- /dev/null
+++ test/CodeGen/ms_abi_aarch64.c
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm < %s | FileCheck -check-prefix=LINUX %s
+// RUN: %clang_cc1 -triple aarch64-pc-win32 -emit-llvm < %s | FileCheck -check-prefix=WIN64 %s
+
+void __attribute__((ms_abi)) f1(void);
+void f2(void);
+void f3(void) {
+  // LINUX-LABEL: define void @f3()
+  // WIN64-LABEL: define void @f3()
+  f1();
+  // LINUX: call aarch64_win64cc void @f1()
+  // WIN64: call void @f1()
+  f2();
+  // LINUX: call void @f2()
+  // WIN64: call void @f2()
+}
+// LINUX: declare aarch64_win64cc void @f1()
+// LINUX: declare void @f2()
+// WIN64: declare void @f1()
+// WIN64: declare void @f2()
+
+// Win64 ABI varargs
+void __attribute__((ms_abi)) f4(int a, ...) {
+  // LINUX-LABEL: define aarch64_win64cc void @f4
+  // WIN64-LABEL: define void @f4
+  __builtin_ms_va_list ap;
+  __builtin_ms_va_start(ap, a);
+  // LINUX: %[[AP:.*]] = alloca i8*
+  // LINUX: call void @llvm.va_start
+  // WIN64: %[[AP:.*]] = alloca i8*
+  // WIN64: call void @llvm.va_start
+  int b = __builtin_va_arg(ap, int);
+  // LINUX: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]]
+  // LINUX-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR]], i64 8
+  // LINUX-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]]
+  // LINUX-NEXT: bitcast i8* %[[AP_CUR]] to i32*
+  // WIN64: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]]
+  // WIN64-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR]], i64 8
+  // WIN64-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]]
+  // WIN64-NEXT: bitcast i8* %[[AP_CUR]] to i32*
+  __builtin_ms_va_list ap2;
+  __builtin_ms_va_copy(ap2, ap);
+  // LINUX: %[[AP_VAL:.*]] = load i8*, i8** %[[AP]]
+  // LINUX-NEXT: store i8* %[[AP_VAL]], i8** %[[AP2:.*]]
+  // WIN64: %[[AP_VAL:.*]] = load i8*, i8** %[[AP]]
+  // WIN64-NEXT: store i8* %[[AP_VAL]], i8** %[[AP2:.*]]
+  __builtin_ms_va_end(ap);
+  // LINUX: call void @llvm.va_end
+  // WIN64: call void @llvm.va_end
+}
+
+// Let's verify that normal va_lists work right on Win64, too.
+void f5(int a, ...) {
+  // WIN64-LABEL: define void @f5
+  __builtin_va_list ap;
+  __builtin_va_start(ap, a);
+  // WIN64: %[[AP:.*]] = alloca i8*
+  // WIN64: call void @llvm.va_start
+  int b = __builtin_va_arg(ap, int);
+  // WIN64: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]]
+  // WIN64-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR]], i64 8
+  // WIN64-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]]
+  // WIN64-NEXT: bitcast i8* %[[AP_CUR]] to i32*
+  __builtin_va_list ap2;
+  __builtin_va_copy(ap2, ap);
+  // WIN64: call void @llvm.va_copy
+  __builtin_va_end(ap);
+  // WIN64: call void @llvm.va_end
+}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4279,8 +4279,13 @@
   case AttributeList::AT_VectorCall: 

[libcxxabi] r307941 - [demangler] Respect try_to_parse_template_args

2017-07-13 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Thu Jul 13 12:37:37 2017
New Revision: 307941

URL: http://llvm.org/viewvc/llvm-project?rev=307941&view=rev
Log:
[demangler] Respect try_to_parse_template_args

Fixes an exponential parse found by oss-fuzz.

Modified:
libcxxabi/trunk/src/cxa_demangle.cpp
libcxxabi/trunk/test/test_demangle.pass.cpp

Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=307941&r1=307940&r2=307941&view=diff
==
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Thu Jul 13 12:37:37 2017
@@ -2364,17 +2364,20 @@ parse_type(const char* first, const char
 first = t;
 // Parsed a substitution.  If the substitution 
is a
 //   it might be followed by 
.
-t = parse_template_args(first, last, db);
-if (t != first)
+if (db.try_to_parse_template_args)
 {
-if (db.names.size() < 2)
-return first;
-auto template_args = 
db.names.back().move_full();
-db.names.pop_back();
-db.names.back().first += template_args;
-// Need to create substitution for 
 
-db.subs.push_back(Db::sub_type(1, 
db.names.back(), db.names.get_allocator()));
-first = t;
+t = parse_template_args(first, last, db);
+if (t != first)
+{
+if (db.names.size() < 2)
+return first;
+auto template_args = 
db.names.back().move_full();
+db.names.pop_back();
+db.names.back().first += template_args;
+// Need to create substitution for 
 
+db.subs.push_back(Db::sub_type(1, 
db.names.back(), db.names.get_allocator()));
+first = t;
+}
 }
 }
 }

Modified: libcxxabi/trunk/test/test_demangle.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_demangle.pass.cpp?rev=307941&r1=307940&r2=307941&view=diff
==
--- libcxxabi/trunk/test/test_demangle.pass.cpp (original)
+++ libcxxabi/trunk/test/test_demangle.pass.cpp Thu Jul 13 12:37:37 2017
@@ -29669,6 +29669,7 @@ const char* invalid_cases[] =
 "_ZcvCiIJEEDvT__T_vT_v",
 "Z1JIJ1_T_EE3o00EUlT_E0",
 "___Z2i_D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D",
+
"ZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIDv_ZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIDv_ZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIDv_Dv_Dv_Dv_Dv_dZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIDv_ZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIDv_ZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIDv_Dv_Dv_Dv_Dv_d",
 };
 
 const unsigned NI = sizeof(invalid_cases) / sizeof(invalid_cases[0]);


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


[PATCH] D35378: [clang] Add getSignedSizeType method

2017-07-13 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap created this revision.

C11 standard refers to the signed counterpart of the size_t type in
the paragraph 7.21.6.1 where it defines d, i, o, u, x, or x conversion 
specifiers
(in printf format string).
In Clang there is a FIXME (in lib/Analysis/PrintfFormatString.cpp) for this case
(which is not handled correctly at the moment).
This diff adds getSignedSizeType method to TargetInfo and exposes it in 
ASTContext similarly to
how it is done for getSizeType.
lib/Analysis/PrintfFormatString.cpp is supposed to be changed in a follow-up 
commit.


Repository:
  rL LLVM

https://reviews.llvm.org/D35378

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/TargetInfo.h
  lib/AST/ASTContext.cpp


Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -4525,6 +4525,11 @@
   return getFromTargetType(Target->getSizeType());
 }
 
+/// Return the unique signed integer type corresponding to size_t.
+CanQualType ASTContext::getSignedSizeType() const {
+  return getFromTargetType(Target->getSignedSizeType());
+}
+
 /// getIntMaxType - Return the unique type for "intmax_t" (C99 7.18.1.5).
 CanQualType ASTContext::getIntMaxType() const {
   return getFromTargetType(Target->getIntMaxType());
Index: include/clang/Basic/TargetInfo.h
===
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -226,6 +226,20 @@
 
 public:
   IntType getSizeType() const { return SizeType; }
+  IntType getSignedSizeType() const {
+switch (SizeType) {
+case UnsignedShort:
+  return SignedShort;
+case UnsignedInt:
+  return SignedInt;
+case UnsignedLong:
+  return SignedLong;
+case UnsignedLongLong:
+  return SignedLongLong;
+default:
+  llvm_unreachable("Invalid SizeType");
+}
+  }
   IntType getIntMaxType() const { return IntMaxType; }
   IntType getUIntMaxType() const {
 return getCorrespondingUnsignedType(IntMaxType);
Index: include/clang/AST/ASTContext.h
===
--- include/clang/AST/ASTContext.h
+++ include/clang/AST/ASTContext.h
@@ -1441,6 +1441,10 @@
   /// The sizeof operator requires this (C99 6.5.3.4p4).
   CanQualType getSizeType() const;
 
+  /// \brief Return the unique signed counterpart of 
+  /// the integer type corresponding to size_t.
+  CanQualType getSignedSizeType() const;
+
   /// \brief Return the unique type for "intmax_t" (C99 7.18.1.5), defined in
   /// .
   CanQualType getIntMaxType() const;


Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -4525,6 +4525,11 @@
   return getFromTargetType(Target->getSizeType());
 }
 
+/// Return the unique signed integer type corresponding to size_t.
+CanQualType ASTContext::getSignedSizeType() const {
+  return getFromTargetType(Target->getSignedSizeType());
+}
+
 /// getIntMaxType - Return the unique type for "intmax_t" (C99 7.18.1.5).
 CanQualType ASTContext::getIntMaxType() const {
   return getFromTargetType(Target->getIntMaxType());
Index: include/clang/Basic/TargetInfo.h
===
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -226,6 +226,20 @@
 
 public:
   IntType getSizeType() const { return SizeType; }
+  IntType getSignedSizeType() const {
+switch (SizeType) {
+case UnsignedShort:
+  return SignedShort;
+case UnsignedInt:
+  return SignedInt;
+case UnsignedLong:
+  return SignedLong;
+case UnsignedLongLong:
+  return SignedLongLong;
+default:
+  llvm_unreachable("Invalid SizeType");
+}
+  }
   IntType getIntMaxType() const { return IntMaxType; }
   IntType getUIntMaxType() const {
 return getCorrespondingUnsignedType(IntMaxType);
Index: include/clang/AST/ASTContext.h
===
--- include/clang/AST/ASTContext.h
+++ include/clang/AST/ASTContext.h
@@ -1441,6 +1441,10 @@
   /// The sizeof operator requires this (C99 6.5.3.4p4).
   CanQualType getSizeType() const;
 
+  /// \brief Return the unique signed counterpart of 
+  /// the integer type corresponding to size_t.
+  CanQualType getSignedSizeType() const;
+
   /// \brief Return the unique type for "intmax_t" (C99 7.18.1.5), defined in
   /// .
   CanQualType getIntMaxType() const;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35378: [clang] Add getSignedSizeType method

2017-07-13 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap updated this revision to Diff 106496.
alexshap added a comment.

make comments consistent


Repository:
  rL LLVM

https://reviews.llvm.org/D35378

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/TargetInfo.h
  lib/AST/ASTContext.cpp


Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -4525,6 +4525,12 @@
   return getFromTargetType(Target->getSizeType());
 }
 
+/// Return the unique signed counterpart of the integer type 
+/// corresponding to size_t.
+CanQualType ASTContext::getSignedSizeType() const {
+  return getFromTargetType(Target->getSignedSizeType());
+}
+
 /// getIntMaxType - Return the unique type for "intmax_t" (C99 7.18.1.5).
 CanQualType ASTContext::getIntMaxType() const {
   return getFromTargetType(Target->getIntMaxType());
Index: include/clang/Basic/TargetInfo.h
===
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -226,6 +226,20 @@
 
 public:
   IntType getSizeType() const { return SizeType; }
+  IntType getSignedSizeType() const {
+switch (SizeType) {
+case UnsignedShort:
+  return SignedShort;
+case UnsignedInt:
+  return SignedInt;
+case UnsignedLong:
+  return SignedLong;
+case UnsignedLongLong:
+  return SignedLongLong;
+default:
+  llvm_unreachable("Invalid SizeType");
+}
+  }
   IntType getIntMaxType() const { return IntMaxType; }
   IntType getUIntMaxType() const {
 return getCorrespondingUnsignedType(IntMaxType);
Index: include/clang/AST/ASTContext.h
===
--- include/clang/AST/ASTContext.h
+++ include/clang/AST/ASTContext.h
@@ -1441,6 +1441,10 @@
   /// The sizeof operator requires this (C99 6.5.3.4p4).
   CanQualType getSizeType() const;
 
+  /// \brief Return the unique signed counterpart of 
+  /// the integer type corresponding to size_t.
+  CanQualType getSignedSizeType() const;
+
   /// \brief Return the unique type for "intmax_t" (C99 7.18.1.5), defined in
   /// .
   CanQualType getIntMaxType() const;


Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -4525,6 +4525,12 @@
   return getFromTargetType(Target->getSizeType());
 }
 
+/// Return the unique signed counterpart of the integer type 
+/// corresponding to size_t.
+CanQualType ASTContext::getSignedSizeType() const {
+  return getFromTargetType(Target->getSignedSizeType());
+}
+
 /// getIntMaxType - Return the unique type for "intmax_t" (C99 7.18.1.5).
 CanQualType ASTContext::getIntMaxType() const {
   return getFromTargetType(Target->getIntMaxType());
Index: include/clang/Basic/TargetInfo.h
===
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -226,6 +226,20 @@
 
 public:
   IntType getSizeType() const { return SizeType; }
+  IntType getSignedSizeType() const {
+switch (SizeType) {
+case UnsignedShort:
+  return SignedShort;
+case UnsignedInt:
+  return SignedInt;
+case UnsignedLong:
+  return SignedLong;
+case UnsignedLongLong:
+  return SignedLongLong;
+default:
+  llvm_unreachable("Invalid SizeType");
+}
+  }
   IntType getIntMaxType() const { return IntMaxType; }
   IntType getUIntMaxType() const {
 return getCorrespondingUnsignedType(IntMaxType);
Index: include/clang/AST/ASTContext.h
===
--- include/clang/AST/ASTContext.h
+++ include/clang/AST/ASTContext.h
@@ -1441,6 +1441,10 @@
   /// The sizeof operator requires this (C99 6.5.3.4p4).
   CanQualType getSizeType() const;
 
+  /// \brief Return the unique signed counterpart of 
+  /// the integer type corresponding to size_t.
+  CanQualType getSignedSizeType() const;
+
   /// \brief Return the unique type for "intmax_t" (C99 7.18.1.5), defined in
   /// .
   CanQualType getIntMaxType() const;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35379: Add documentation for @available

2017-07-13 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.

Based on 
https://devstreaming-cdn.apple.com/videos/wwdc/2017/411a7o9phe4uekm/411/411_whats_new_in_llvm.pdf

(I couldn't find a way to play the corresponding video on linux, so I didn't 
look at that.)


https://reviews.llvm.org/D35379

Files:
  docs/LanguageExtensions.rst
  include/clang/Basic/AttrDocs.td

Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -910,13 +910,13 @@
 
   void f(void) __attribute__((availability(macos,introduced=10.4,deprecated=10.6,obsoleted=10.7)));
 
-The availability attribute states that ``f`` was introduced in Mac OS X 10.4,
-deprecated in Mac OS X 10.6, and obsoleted in Mac OS X 10.7.  This information
+The availability attribute states that ``f`` was introduced in macOS 10.4,
+deprecated in macOS 10.6, and obsoleted in macOS 10.7.  This information
 is used by Clang to determine when it is safe to use ``f``: for example, if
-Clang is instructed to compile code for Mac OS X 10.5, a call to ``f()``
-succeeds.  If Clang is instructed to compile code for Mac OS X 10.6, the call
+Clang is instructed to compile code for macOS 10.5, a call to ``f()``
+succeeds.  If Clang is instructed to compile code for macOS 10.6, the call
 succeeds but Clang emits a warning specifying that the function is deprecated.
-Finally, if Clang is instructed to compile code for Mac OS X 10.7, the call
+Finally, if Clang is instructed to compile code for macOS 10.7, the call
 fails because ``f()`` is no longer available.
 
 The availability attribute is a comma-separated list starting with the
@@ -961,7 +961,7 @@
   command-line arguments.
 
 ``macos``
-  Apple's Mac OS X operating system.  The minimum deployment target is
+  Apple's macOS operating system.  The minimum deployment target is
   specified by the ``-mmacosx-version-min=*version*`` command-line argument.
   ``macosx`` is supported for backward-compatibility reasons, but it is
   deprecated.
@@ -1016,6 +1016,19 @@
   - (id)method __attribute__((availability(macos,introduced=10.5))); // error: this method was available via the base class in 10.4
   @end
   }];
+
+Starting with the macOS 10.12 SDK, the ``API_AVAILABLE`` macro from
+ can simplify the spelling:
+
+.. code-block:: objc
+
+  @interface A
+  - (id)method API_AVAILABLE(macos(10.11)));
+  - (id)otherMethod API_AVAILABLE(macos(10.11), ios(11.0));
+  @end
+
+Also see the documentation for `@available
+`_
 }
 
 def ExternalSourceSymbolDocs : Documentation {
Index: docs/LanguageExtensions.rst
===
--- docs/LanguageExtensions.rst
+++ docs/LanguageExtensions.rst
@@ -1271,7 +1271,88 @@
 Query for these features with ``__has_attribute(ns_consumed)``,
 ``__has_attribute(ns_returns_retained)``, etc.
 
+Objective-C @available
+--
 
+It is possible use the newest SDK but still build a program that can run on
+older macOS and iOS versions, by passing ``-mmacosx-version-info=`` /
+``--miphoneos-version-min=``.
+
+Before LLVM 5.0, when calling a function that exists only in the newest OS
+version, programmers had to carefully check if the function exists at runtime,
+using null checks for weakly-linked C functions, ``+class`` for Objective-C
+classes, and ``-respondsToSelector:`` or ``+instancesRespondToSelector:`` for
+Objective-C methods.  If such a check was missed, the program would compile
+fine, run fine on the new OS version, but crash on older OS versions.
+
+As of LLVM 5.0, ``-Wunguarded-availability`` uses the `availability attributes
+`_ together
+with the new ``@available()`` keyword to assist with this issue.  If a function
+is called that exists on new OS versions while the minimum deployment version
+is older, then ``-Wunguarded-availability`` will fire:
+
+.. code-block:: objc
+
+  void my_fun(NSSomeClass* var) {
+// If fancyNewMethod was added in e.g. macOS 10.12, but the code is
+// built with -mmacosx-version-min=10.11, then this unconditional call
+// will emit a -Wunguarded-availability warning:
+[var fancyNewMethod];
+  }
+
+To fix the warning (and to make the call not crash on 10.11!), wrap it in
+``if(@available())``:
+
+.. code-block:: objc
+
+  void my_fun(NSSomeClass* var) {
+if (@available(macOS 10.12)) {
+  [var fancyNewMethod];
+} else {
+  // Put fallback behavior for old macOS versions (and for non-mac
+  // platforms) here.
+}
+  }
+
+If the caller of ``my_fun()`` already checks that ``my_fun()`` is only called
+on 10.12, then add an `availability attributes
+`_ to it,
+which will also suppress the warning:
+
+.. code-block:: objc
+
+  API_AVAILABLE(macos(10.12)) void my_fun(NSSome

[PATCH] D34475: [AArch64] Add support for __builtin_ms_va_list on aarch64

2017-07-13 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: include/clang/Basic/BuiltinsAArch64.def:65
+// Win64-compatible va_list functions
+BUILTIN(__builtin_ms_va_start, "vc*&.", "nt")
+BUILTIN(__builtin_ms_va_end, "vc*&", "n")

I strongly suspect that Microsoft will never adopt a varargs calling convention 
that uses a complex, non-`char*` va_list.

I'm starting to think we should move this to the generic builtin list and make 
it available everywhere. The semantics are that you can only use 
__builtin_ms_va_start in ms_abi functions. It always produces a `char*`-style 
va_list.




Comment at: include/clang/Basic/Specifiers.h:239
 CC_X86Pascal,   // __attribute__((pascal))
 CC_X86_64Win64, // __attribute__((ms_abi))
 CC_X86_64SysV,  // __attribute__((sysv_abi))

I think we might prefer to make this non-x86_64 specific. I suspect that this 
pattern will arise again on ARM32 if anyone goes back there in seriousness. 
We'll probably want sysv_abi as well as ms_abi, and all the logic should be 
independent of the ISA: ms_abi is a no-op when the target OS is already 
Windows, and sysv_abi is a no-op when the target OS isn't Windows.



Comment at: lib/CodeGen/CGBuiltin.cpp:5276
const CallExpr *E) {
+  if (BuiltinID == AArch64::BI__builtin_ms_va_start ||
+  BuiltinID == AArch64::BI__builtin_ms_va_end)

If we made __builtin_ms_va_start generic, that would also eliminate this 
duplicate code.



Comment at: lib/CodeGen/CGCall.cpp:223-224
   if (D->hasAttr())
-return IsWindows ? CC_C : CC_X86_64Win64;
+return IsWindows ? CC_C : Arch == llvm::Triple::aarch64 ? CC_AArch64Win64
+: CC_X86_64Win64;
 

Unifying the ms_abi CCs would remove the need for this.



Comment at: lib/Sema/SemaChecking.cpp:3625
 /// target and calling convention.
 static bool checkVAStartABI(Sema &S, unsigned BuiltinID, Expr *Fn) {
   const llvm::Triple &TT = S.Context.getTargetInfo().getTriple();

Oh dear, how can we keep this simple. I think unifying the CC's would improve 
things.



Comment at: lib/Sema/SemaDeclAttr.cpp:4283
+
+CC = Context.getTargetInfo().getTriple().isOSWindows()
+ ? CC_C

Ditto


https://reviews.llvm.org/D34475



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


[PATCH] D34121: [ubsan] Teach the pointer overflow check that "p - <= p" (PR33430)

2017-07-13 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

In https://reviews.llvm.org/D34121#808486, @dtzWill wrote:

> In https://reviews.llvm.org/D34121#806978, @vsk wrote:
>
> > @dtzWill do you have any further comments on this one?
> >
> > I'd like to get another 'lgtm' before committing, and it'd be nice to get 
> > this in before llvm 5.0 branches (7/19).
> >
> > FWIW we've been living on this for a few weeks internally without any 
> > issues:
> >  
> > https://github.com/apple/swift-clang/commit/3ebe7d87b9d545aebdd80452d0b79695ff871bce
>
>
> @vsk sorry for the delay.  Looks solid to me, seems to work well in my 
> testing.
>
> Unrelated to the suitability of the patch itself, but on the subject:
>  Interestingly there don''t seem to be any changes in observed errors, which 
> on one hand is great (yay no breakage and earlier results were mostly 
> correct) but on the other isn't what I expected.
>  Does this match your experiences?


Thanks for testing the patch out! Your results match my experiences with some 
Apple frameworks. The 'p - unsigned > p' case seems to be relatively uncommon.


https://reviews.llvm.org/D34121



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


[PATCH] D34475: [AArch64] Add support for __builtin_ms_va_list on aarch64

2017-07-13 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: include/clang/Basic/BuiltinsAArch64.def:65
+// Win64-compatible va_list functions
+BUILTIN(__builtin_ms_va_start, "vc*&.", "nt")
+BUILTIN(__builtin_ms_va_end, "vc*&", "n")

rnk wrote:
> I strongly suspect that Microsoft will never adopt a varargs calling 
> convention that uses a complex, non-`char*` va_list.
> 
> I'm starting to think we should move this to the generic builtin list and 
> make it available everywhere. The semantics are that you can only use 
> __builtin_ms_va_start in ms_abi functions. It always produces a `char*`-style 
> va_list.
> 
Yes, that seems probable.

I'm a little weary about making this available anywhere though, since it is 
coupled with the x86_64/aarch64 specific calling convention for lowering 
va_start, and there we only support it specifically on those two arches.



Comment at: include/clang/Basic/Specifiers.h:239
 CC_X86Pascal,   // __attribute__((pascal))
 CC_X86_64Win64, // __attribute__((ms_abi))
 CC_X86_64SysV,  // __attribute__((sysv_abi))

rnk wrote:
> I think we might prefer to make this non-x86_64 specific. I suspect that this 
> pattern will arise again on ARM32 if anyone goes back there in seriousness. 
> We'll probably want sysv_abi as well as ms_abi, and all the logic should be 
> independent of the ISA: ms_abi is a no-op when the target OS is already 
> Windows, and sysv_abi is a no-op when the target OS isn't Windows.
FWIW, we already support ARM32 for windows, and there, varargs are identical to 
other platforms.

Extending this to all platforms probably also makes sense (although I'm a 
little weary about how it would work for signaling down to the LLVM IR).


https://reviews.llvm.org/D34475



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


[PATCH] D34475: [AArch64] Add support for __builtin_ms_va_list on aarch64

2017-07-13 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: include/clang/Basic/BuiltinsAArch64.def:65
+// Win64-compatible va_list functions
+BUILTIN(__builtin_ms_va_start, "vc*&.", "nt")
+BUILTIN(__builtin_ms_va_end, "vc*&", "n")

mstorsjo wrote:
> rnk wrote:
> > I strongly suspect that Microsoft will never adopt a varargs calling 
> > convention that uses a complex, non-`char*` va_list.
> > 
> > I'm starting to think we should move this to the generic builtin list and 
> > make it available everywhere. The semantics are that you can only use 
> > __builtin_ms_va_start in ms_abi functions. It always produces a 
> > `char*`-style va_list.
> > 
> Yes, that seems probable.
> 
> I'm a little weary about making this available anywhere though, since it is 
> coupled with the x86_64/aarch64 specific calling convention for lowering 
> va_start, and there we only support it specifically on those two arches.
We should have Sema checking that rejects it when not targeting x64 or aarch64. 
Ultimately the codegen is shared and simple: just call llvm.va.start.


https://reviews.llvm.org/D34475



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


[PATCH] D35103: Expand clang-interpreter with example of throwing in and from the JIT for Windows64.

2017-07-13 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

Just 2 small nits.




Comment at: examples/clang-interpreter/main.cpp:165
+  llvm::errs() << "'main' function not found in module.\n";
+  return 255;
+}

255 -> Res ?



Comment at: examples/clang-interpreter/main.cpp:173
+  llvm::errs() << "unable to make execution engine: " << Error << "\n";
+  return 255;
+}

255 -> Res


https://reviews.llvm.org/D35103



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


[PATCH] D35378: [clang] Add getSignedSizeType method

2017-07-13 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rL LLVM

https://reviews.llvm.org/D35378



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


[PATCH] D35103: Expand clang-interpreter with example of throwing in and from the JIT for Windows64.

2017-07-13 Thread Martell Malone via Phabricator via cfe-commits
martell added inline comments.



Comment at: examples/clang-interpreter/Manager.cpp:18
+#define NOMINMAX
+#include 
+#endif

windows.h with lower case `w` to not break mingw


https://reviews.llvm.org/D35103



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


[PATCH] D35383: [coroutines] Add serialization/deserialization of coroutines

2017-07-13 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov created this revision.
Herald added a subscriber: EricWF.

https://reviews.llvm.org/D35383

Files:
  include/clang/AST/StmtCXX.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/StmtCXX.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/PCH/coroutines.cpp

Index: test/PCH/coroutines.cpp
===
--- /dev/null
+++ test/PCH/coroutines.cpp
@@ -0,0 +1,77 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %s -verify -std=c++1z -fcoroutines-ts %s
+
+// Test with pch.
+// RUN: %clang_cc1 -std=c++1z -fcoroutines-ts  -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -verify -std=c++1z -fcoroutines-ts %s
+
+#ifndef HEADER
+#define HEADER
+
+namespace std::experimental {
+template  struct coroutine_traits;
+
+template  struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept;
+};
+template <> struct coroutine_handle {
+  static coroutine_handle from_address(void *) noexcept;
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept;
+};
+}
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template  struct std::experimental::coroutine_traits {
+  struct promise_type {
+void get_return_object() noexcept;
+suspend_always initial_suspend() noexcept;
+suspend_always final_suspend() noexcept;
+void return_void() noexcept;
+suspend_always yield_value(int) noexcept;
+promise_type();
+~promise_type() noexcept;
+void unhandled_exception() noexcept;
+  };
+};
+
+template  struct std::experimental::coroutine_traits {
+  struct promise_type {
+int get_return_object() noexcept;
+suspend_always initial_suspend() noexcept;
+suspend_always final_suspend() noexcept;
+void return_value(int) noexcept;
+promise_type();
+~promise_type() noexcept;
+void unhandled_exception() noexcept;
+  };
+};
+
+template 
+void f(T x) {  // checks coawait_expr and coroutine_body_stmt
+  co_yield 42; // checks coyield_expr
+  co_await x;  // checks dependent_coawait
+  co_return;   // checks coreturn_stmt
+}
+
+template 
+int f2(T x) {  // checks coawait_expr and coroutine_body_stmt
+  co_return x;   // checks coreturn_stmt with expr
+}
+
+#else
+
+// expected-no-diagnostics
+void g() {
+  f(suspend_always{});
+  f2(42);
+}
+
+#endif
Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -286,7 +286,7 @@
   }
 
   // Outputs
-  for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {  
+  for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
 Record.AddStmt(S->getOutputExpr(I));
 Record.AddString(S->getOutputConstraint(I));
   }
@@ -300,29 +300,49 @@
   Code = serialization::STMT_MSASM;
 }
 
-void ASTStmtWriter::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+void ASTStmtWriter::VisitCoroutineBodyStmt(CoroutineBodyStmt *CoroStmt) {
+  VisitStmt(CoroStmt);
+  Record.push_back(CoroStmt->getParamMoves().size());
+  for (Stmt *S : CoroStmt->children())
+Record.AddStmt(S);
+  Code = serialization::STMT_COROUTINE_BODY;
 }
 
 void ASTStmtWriter::VisitCoreturnStmt(CoreturnStmt *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+  VisitStmt(S);
+  Record.AddSourceLocation(S->getKeywordLoc());
+  Record.AddStmt(S->getOperand());
+  Record.AddStmt(S->getPromiseCall());
+  Record.push_back(S->isImplicit());
+  Code = serialization::STMT_CORETURN;
+}
+
+static void serializeSuspendExpr(ASTStmtWriter &Writer, ASTRecordWriter &Record,
+ CoroutineSuspendExpr *E) {
+  Writer.VisitExpr(E);
+  Record.AddSourceLocation(E->getKeywordLoc());
+  for (Stmt *S : E->children())
+Record.AddStmt(S);
+  Record.AddStmt(E->getOpaqueValue());
 }
 
-void ASTStmtWriter::VisitCoawaitExpr(CoawaitExpr *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+void ASTStmtWriter::VisitCoawaitExpr(CoawaitExpr *E) {
+  serializeSuspendExpr(*this, Record, E);
+  Record.push_back(E->isImplicit());
+  Code = serialization::EXPR_COAWAIT;
 }
 
-void ASTStmtWriter::VisitDependentCoawaitExpr(DependentCoawaitExpr *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+void ASTStmtWriter::VisitCoyieldExpr(CoyieldExpr *E) {
+  serializeSuspendExpr(*this, Record, E);
+  Code = serialization::EXPR_COYIELD;
 }
 
-void ASTStmtWriter::VisitCoyieldExpr(CoyieldExpr *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+void ASTStmtWriter::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
+

[PATCH] D35379: Add documentation for @available

2017-07-13 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a reviewer: arphaman.
erik.pilkington added a subscriber: arphaman.
erik.pilkington added a comment.

This looks great, thanks for working on this! LGTM, but @arphaman might have 
some thoughts.




Comment at: docs/LanguageExtensions.rst:1290
 
-.. _langext-overloading:
-

did you mean to remove this?



Comment at: docs/LanguageExtensions.rst:1309
+  void my_fun(NSSomeClass* var) {
+if (@available(macOS 10.12)) {
+  [var fancyNewMethod];

Don't forget the '*', ie @available(macos 10.12, *)!


https://reviews.llvm.org/D35379



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


[PATCH] D35379: Add documentation for @available

2017-07-13 Thread Nico Weber via Phabricator via cfe-commits
thakis updated this revision to Diff 106513.
thakis marked an inline comment as done.
thakis added a comment.

comments


https://reviews.llvm.org/D35379

Files:
  docs/LanguageExtensions.rst
  include/clang/Basic/AttrDocs.td

Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -910,13 +910,13 @@
 
   void f(void) __attribute__((availability(macos,introduced=10.4,deprecated=10.6,obsoleted=10.7)));
 
-The availability attribute states that ``f`` was introduced in Mac OS X 10.4,
-deprecated in Mac OS X 10.6, and obsoleted in Mac OS X 10.7.  This information
+The availability attribute states that ``f`` was introduced in macOS 10.4,
+deprecated in macOS 10.6, and obsoleted in macOS 10.7.  This information
 is used by Clang to determine when it is safe to use ``f``: for example, if
-Clang is instructed to compile code for Mac OS X 10.5, a call to ``f()``
-succeeds.  If Clang is instructed to compile code for Mac OS X 10.6, the call
+Clang is instructed to compile code for macOS 10.5, a call to ``f()``
+succeeds.  If Clang is instructed to compile code for macOS 10.6, the call
 succeeds but Clang emits a warning specifying that the function is deprecated.
-Finally, if Clang is instructed to compile code for Mac OS X 10.7, the call
+Finally, if Clang is instructed to compile code for macOS 10.7, the call
 fails because ``f()`` is no longer available.
 
 The availability attribute is a comma-separated list starting with the
@@ -961,7 +961,7 @@
   command-line arguments.
 
 ``macos``
-  Apple's Mac OS X operating system.  The minimum deployment target is
+  Apple's macOS operating system.  The minimum deployment target is
   specified by the ``-mmacosx-version-min=*version*`` command-line argument.
   ``macosx`` is supported for backward-compatibility reasons, but it is
   deprecated.
@@ -1016,6 +1016,19 @@
   - (id)method __attribute__((availability(macos,introduced=10.5))); // error: this method was available via the base class in 10.4
   @end
   }];
+
+Starting with the macOS 10.12 SDK, the ``API_AVAILABLE`` macro from
+ can simplify the spelling:
+
+.. code-block:: objc
+
+  @interface A
+  - (id)method API_AVAILABLE(macos(10.11)));
+  - (id)otherMethod API_AVAILABLE(macos(10.11), ios(11.0));
+  @end
+
+Also see the documentation for `@available
+`_
 }
 
 def ExternalSourceSymbolDocs : Documentation {
Index: docs/LanguageExtensions.rst
===
--- docs/LanguageExtensions.rst
+++ docs/LanguageExtensions.rst
@@ -1271,7 +1271,90 @@
 Query for these features with ``__has_attribute(ns_consumed)``,
 ``__has_attribute(ns_returns_retained)``, etc.
 
+Objective-C @available
+--
 
+It is possible use the newest SDK but still build a program that can run on
+older macOS and iOS versions, by passing ``-mmacosx-version-info=`` /
+``--miphoneos-version-min=``.
+
+Before LLVM 5.0, when calling a function that exists only in the newest OS
+version, programmers had to carefully check if the function exists at runtime,
+using null checks for weakly-linked C functions, ``+class`` for Objective-C
+classes, and ``-respondsToSelector:`` or ``+instancesRespondToSelector:`` for
+Objective-C methods.  If such a check was missed, the program would compile
+fine, run fine on the new OS version, but crash on older OS versions.
+
+As of LLVM 5.0, ``-Wunguarded-availability`` uses the `availability attributes
+`_ together
+with the new ``@available()`` keyword to assist with this issue.  If a function
+is called that exists on new OS versions while the minimum deployment version
+is older, then ``-Wunguarded-availability`` will fire:
+
+.. code-block:: objc
+
+  void my_fun(NSSomeClass* var) {
+// If fancyNewMethod was added in e.g. macOS 10.12, but the code is
+// built with -mmacosx-version-min=10.11, then this unconditional call
+// will emit a -Wunguarded-availability warning:
+[var fancyNewMethod];
+  }
+
+To fix the warning (and to make the call not crash on 10.11!), wrap it in
+``if(@available())``:
+
+.. code-block:: objc
+
+  void my_fun(NSSomeClass* var) {
+if (@available(macOS 10.12, *)) {
+  [var fancyNewMethod];
+} else {
+  // Put fallback behavior for old macOS versions (and for non-mac
+  // platforms) here.
+}
+  }
+
+If the caller of ``my_fun()`` already checks that ``my_fun()`` is only called
+on 10.12, then add an `availability attributes
+`_ to it,
+which will also suppress the warning:
+
+.. code-block:: objc
+
+  API_AVAILABLE(macos(10.12)) void my_fun(NSSomeClass* var) {
+[var fancyNewMethod];  // Now ok.
+  }
+
+``@available()`` is only available in Objective-C

[PATCH] D35379: Add documentation for @available

2017-07-13 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: docs/LanguageExtensions.rst:1290
 
-.. _langext-overloading:
-

erik.pilkington wrote:
> did you mean to remove this?
I meant to move it above the "protocol-qualifier mangling of parameters" 
section; I think that's where it belongs. Did that.



Comment at: docs/LanguageExtensions.rst:1309
+  void my_fun(NSSomeClass* var) {
+if (@available(macOS 10.12)) {
+  [var fancyNewMethod];

erik.pilkington wrote:
> Don't forget the '*', ie @available(macos 10.12, *)!
Done, thanks. What does the `*` do, by the way? :-)


https://reviews.llvm.org/D35379



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


[PATCH] D35372: [clang-tidy] Add a close-on-exec check on memfd_create() in Android module.

2017-07-13 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/ReleaseNotes.rst:60
 
+- New `android-cloexec-memfd_create
+  
`_
 check

Please sort checks in alphabetical order.


Repository:
  rL LLVM

https://reviews.llvm.org/D35372



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


[PATCH] D35370: [clang-tidy] Add a close-on-exec check on inotify_init() in Android module.

2017-07-13 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/ReleaseNotes.rst:60
 
+- New `android-cloexec-inotify-init
+  
`_
 check

Please sort checks in alphabetical order.


Repository:
  rL LLVM

https://reviews.llvm.org/D35370



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


[PATCH] D35368: [clang-tidy] Add a close-on-exec check on inotify_init1() in Android module.

2017-07-13 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/ReleaseNotes.rst:60
 
+- New `android-cloexec-inotify-init1
+  
`_
 check

Please sort checks in alphabetical order.


Repository:
  rL LLVM

https://reviews.llvm.org/D35368



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


[PATCH] D35367: [clang-tidy] Add a close-on-exec check on epoll_create() in Android module.

2017-07-13 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/ReleaseNotes.rst:60
 
+- New `android-cloexec-epoll-create
+  
`_
 check

Please sort checks in alphabetical order.


Repository:
  rL LLVM

https://reviews.llvm.org/D35367



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


[PATCH] D35372: [clang-tidy] Add a close-on-exec check on memfd_create() in Android module.

2017-07-13 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 106515.
yawanng marked an inline comment as done.

https://reviews.llvm.org/D35372

Files:
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/CloexecMemfdCreateCheck.cpp
  clang-tidy/android/CloexecMemfdCreateCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-cloexec-memfd-create.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/android-cloexec-memfd-create.cpp

Index: test/clang-tidy/android-cloexec-memfd-create.cpp
===
--- /dev/null
+++ test/clang-tidy/android-cloexec-memfd-create.cpp
@@ -0,0 +1,63 @@
+// RUN: %check_clang_tidy %s android-cloexec-memfd-create %t
+
+#define MFD_ALLOW_SEALING 1
+#define __O_CLOEXEC 3
+#define MFD_CLOEXEC __O_CLOEXEC
+#define TEMP_FAILURE_RETRY(exp) \
+  ({\
+int _rc;\
+do {\
+  _rc = (exp);  \
+} while (_rc == -1);\
+  })
+#define NULL 0
+
+extern "C" int memfd_create(const char *name, unsigned int flags);
+
+void a() {
+  memfd_create(NULL, MFD_ALLOW_SEALING);
+  // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: 'memfd_create' should use MFD_CLOEXEC where possible [android-cloexec-memfd-create]
+  // CHECK-FIXES: memfd_create(NULL, MFD_ALLOW_SEALING | MFD_CLOEXEC)
+  TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING));
+  // CHECK-MESSAGES: :[[@LINE-1]]:58: warning: 'memfd_create'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING | MFD_CLOEXEC))
+}
+
+void f() {
+  memfd_create(NULL, 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'memfd_create'
+  // CHECK-FIXES: memfd_create(NULL, 3 | MFD_CLOEXEC)
+  TEMP_FAILURE_RETRY(memfd_create(NULL, 3));
+  // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: 'memfd_create'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(memfd_create(NULL, 3 | MFD_CLOEXEC))
+
+  int flag = 3;
+  memfd_create(NULL, flag);
+  TEMP_FAILURE_RETRY(memfd_create(NULL, flag));
+}
+
+namespace i {
+int memfd_create(const char *name, unsigned int flags);
+
+void d() {
+  memfd_create(NULL, MFD_ALLOW_SEALING);
+  TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING));
+}
+
+} // namespace i
+
+void e() {
+  memfd_create(NULL, MFD_CLOEXEC);
+  TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_CLOEXEC));
+  memfd_create(NULL, MFD_ALLOW_SEALING | MFD_CLOEXEC);
+  TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING | MFD_CLOEXEC));
+}
+
+class G {
+public:
+  int memfd_create(const char *name, unsigned int flags);
+  void d() {
+memfd_create(NULL, MFD_ALLOW_SEALING);
+TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING));
+  }
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -6,6 +6,7 @@
 .. toctree::
android-cloexec-creat
android-cloexec-fopen
+   android-cloexec-memfd-create
android-cloexec-open
android-cloexec-socket
boost-use-to-string
Index: docs/clang-tidy/checks/android-cloexec-memfd-create.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/android-cloexec-memfd-create.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - android-cloexec-memfd-create
+
+android-cloexec-memfd-create
+
+
+``memfd_create()`` should include ``MFD_CLOEXEC`` in its type argument to avoid
+the file descriptor leakage. Without this flag, an opened sensitive file would
+remain open across a fork+exec to a lower-privileged SELinux domain.
+
+Examples:
+
+.. code-block:: c++
+
+  memfd_create(name, MFD_ALLOW_SEALING);
+
+  // becomes
+
+  memfd_create(name, MFD_ALLOW_SEALING | MFD_CLOEXEC);
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -73,6 +73,12 @@
 
   Checks if the required mode ``e`` exists in the mode argument of ``fopen()``.
 
+- New `android-cloexec-memfd_create
+  `_ check
+
+  Checks if the required file flag ``MFD_CLOEXEC`` is present in the argument of
+  ``memfd_create()``.
+
 - New `android-cloexec-socket
   `_ check
 
Index: clang-tidy/android/CloexecMemfdCreateCheck.h
===
--- /dev/null
+++ clang-tidy/android/CloexecMemfdCreateCheck.h
@@ -0,0 +1,35 @@
+//===--- CloexecMemfdCreateCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOO

[PATCH] D35365: [clang-tidy] Add a close-on-exec check on epoll_create1() in Android module.

2017-07-13 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tidy/android/CloexecEpollCreate1Check.cpp:21
+
+static constexpr const char *EPOLL_CLOEXEC = "EPOLL_CLOEXEC";
+

Please make this declaration consent across all checks. In some checks it 
declared inside namespaces, in some - outside.



Comment at: docs/ReleaseNotes.rst:60
 
+- New `android-cloexec-epoll-create1
+  
`_
 check

Please sort checks in alphabetical order.


Repository:
  rL LLVM

https://reviews.llvm.org/D35365



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


[PATCH] D35370: [clang-tidy] Add a close-on-exec check on inotify_init() in Android module.

2017-07-13 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 106517.
yawanng marked an inline comment as done.

https://reviews.llvm.org/D35370

Files:
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/CloexecInotifyInitCheck.cpp
  clang-tidy/android/CloexecInotifyInitCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-cloexec-inotify-init.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/android-cloexec-inotify-init.cpp

Index: test/clang-tidy/android-cloexec-inotify-init.cpp
===
--- /dev/null
+++ test/clang-tidy/android-cloexec-inotify-init.cpp
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy %s android-cloexec-inotify-init %t
+
+extern "C" int inotify_init();
+
+void f() {
+  inotify_init();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer inotify_init() to inotify_init1() because inotify_init1() allows IN_CLOEXEC [android-cloexec-inotify-init]
+  // CHECK-FIXES: inotify_init1(IN_CLOEXEC)
+}
+
+namespace i {
+int inotify_init();
+void g() {
+  inotify_init();
+}
+} // namespace i
+
+class C {
+public:
+  int inotify_init();
+  void h() {
+inotify_init();
+  }
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -6,6 +6,7 @@
 .. toctree::
android-cloexec-creat
android-cloexec-fopen
+   android-cloexec-inotify-init
android-cloexec-open
android-cloexec-socket
boost-use-to-string
Index: docs/clang-tidy/checks/android-cloexec-inotify-init.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/android-cloexec-inotify-init.rst
@@ -0,0 +1,17 @@
+.. title:: clang-tidy - android-cloexec-inotify-init
+
+android-cloexec-inotify-init
+
+
+The usage of ``inotify_init()`` is not recommended, it's better to use
+``inotify_init1()``.
+
+Examples:
+
+.. code-block:: c++
+
+  inotify_init();
+
+  // becomes
+
+  inotify_init1(IN_CLOEXEC);
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -73,6 +73,11 @@
 
   Checks if the required mode ``e`` exists in the mode argument of ``fopen()``.
 
+- New `android-cloexec-inotify-init
+  `_ check
+
+  Detects usage of ``inotify_init()``.
+
 - New `android-cloexec-socket
   `_ check
 
Index: clang-tidy/android/CloexecInotifyInitCheck.h
===
--- /dev/null
+++ clang-tidy/android/CloexecInotifyInitCheck.h
@@ -0,0 +1,35 @@
+//===--- CloexecInotifyInitCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_INOTIFY_INIT_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_INOTIFY_INIT_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+/// inotify_init() is better to be replaced by inotify_init1().
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-inotify-init.html
+class CloexecInotifyInitCheck : public ClangTidyCheck {
+public:
+  CloexecInotifyInitCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_INOTIFY_INIT_H
Index: clang-tidy/android/CloexecInotifyInitCheck.cpp
===
--- /dev/null
+++ clang-tidy/android/CloexecInotifyInitCheck.cpp
@@ -0,0 +1,40 @@
+//===--- CloexecInotifyInitCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "CloexecInotifyInitCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+void CloexecInotifyInitCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  ca

  1   2   >