[PATCH] D25008: [cmake] Split linked libraries into private & public, for linker script

2016-10-24 Thread Jonas Hahnfeld via cfe-commits
Hahnfeld added a comment.

Hi Michal,

this currently breaks for me: `-lunwind` will find the system default 
`libunwind.so.8` instead of LLVMs `libunwind.so.1` which breaks some tests.
This has worked magically before because libc++ and libc++abi where explicitely 
linked against LLVMs `libunwind.so.1`. Could we force that in the linker script 
as well?

Thanks,
Jonas


Repository:
  rL LLVM

https://reviews.llvm.org/D25008



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


[PATCH] D25402: [Driver] Pass -lunwind when using libc++ + compiler-rt on Linux

2016-10-24 Thread Jonas Hahnfeld via cfe-commits
Hahnfeld added inline comments.



Comment at: lib/Driver/ToolChains.cpp:4704
+  GetRuntimeLibType(Args) == ToolChain::RLT_CompilerRT)
+CmdArgs.push_back("-lunwind");
+}

As just written in D25008: This will probably result in problems if a system 
default `libunwind.so.8` is installed...


https://reviews.llvm.org/D25402



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


[PATCH] D24361: hasDeclaration(qualType(...)) matcher should unwrap ElaboratedType and TemplateSpecializationType

2016-10-24 Thread Manuel Klimek via cfe-commits
klimek added inline comments.



Comment at: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:2119
+  "template \n"
+  "void Function(Namespace::Template param) {\n"
+  "  param.Method();\n"

lukasza wrote:
> klimek wrote:
> > Given your use case: why do we need hasDeclaration here at all?
> > I'd have expected this working with just matching on the nested name 
> > specifier of the type instead of saying hasDeclaration on the template type.
> > Btw, if you add a type alias for a class not in the namespace into the 
> > namespace (typedef / using), do you wan that to rename or not? :)
> > 
> > I'd personally probably have expected (2), but I'm never sure in these 
> > cases without playing around with more test cases...
> > Given your use case: why do we need hasDeclaration here at all?
> > I'd have expected this working with just matching on the nested name 
> > specifier of the type instead of saying hasDeclaration on the template type.
> 
> Because I want "namespace-of-user-provided-declaration" matching to work both 
> for ElaboratedType nodes (with explicit nested name specifier) and for other 
> kinds of nodes (where there might be no nested name specifier).  I was hoping 
> that I could do this with a single hasDeclaration matcher, rather than 
> listing all possible type nodes myself (when building my own matcher) like I 
> sort of do in a workaround.  In particular, after this CL a single, simple 
> hasDeclaration-based matcher can be used in
> //auto blink_qual_type_base_matcher =
> //qualType(hasDeclaration(in_blink_namespace));
> inside https://codereview.chromium.org/2256913002/patch/180001/190001.
> 
> > Btw, if you add a type alias for a class not in the namespace into the 
> > namespace (typedef / using), do you wan that to rename or not? :)
> 
> Good question.  I want a rename to happen if I have 
> ::SomeOtherNamespace::Typedef resolving to 
> ::NamespaceWithRenamedMethods::Class, but I do not want rename to happen if I 
> have ::NamespaceWithRenamtedMethods::Typedef resolving to 
> ::SomeOtherNamespace::Class.  I guess my current hasDeclaration-based matcher 
> will match both cases :-(  One way to fix this would be to exclude typedefs 
> in |decl_under_blink_namespace| at 
> https://chromium.googlesource.com/chromium/src/+/14d095b4df6754fa4e6959220b2b332db0b4f504/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp#646
> 
> But... this question+answer should have no impact on the CL under review, 
> right?
> 
> > I'd personally probably have expected (2), but I'm never sure in these 
> > cases without playing around with more test cases...
> 
> Ok.  This (#2) is what the current patch results in.
You're right that regardless of what the right solution for your tool is, we 
should close this hole :)

Richard, can you elaborate on why you would have expected (3) to happen? I'm 
reluctant to put something into the matchers that you think is unexpected...


https://reviews.llvm.org/D24361



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


r284958 - Fix myriad test with CLANG_DEFAULT_CXX_STDLIB

2016-10-24 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Mon Oct 24 03:04:17 2016
New Revision: 284958

URL: http://llvm.org/viewvc/llvm-project?rev=284958&view=rev
Log:
Fix myriad test with CLANG_DEFAULT_CXX_STDLIB

Modified:
cfe/trunk/test/Driver/myriad-toolchain.c

Modified: cfe/trunk/test/Driver/myriad-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/myriad-toolchain.c?rev=284958&r1=284957&r2=284958&view=diff
==
--- cfe/trunk/test/Driver/myriad-toolchain.c (original)
+++ cfe/trunk/test/Driver/myriad-toolchain.c Mon Oct 24 03:04:17 2016
@@ -9,7 +9,7 @@
 // LINK_WITH_RTEMS: Inputs{{.*}}crtn.o
 
 // RUN: %clang -c -no-canonical-prefixes -### -target sparc-myriad-rtems-elf 
-x c++ %s \
-// RUN: --gcc-toolchain=%S/Inputs/basic_myriad_tree 2>&1 | FileCheck %s 
-check-prefix=COMPILE_CXX
+// RUN: -stdlib=libstdc++ --gcc-toolchain=%S/Inputs/basic_myriad_tree 2>&1 | 
FileCheck %s -check-prefix=COMPILE_CXX
 // COMPILE_CXX: "-internal-isystem" 
"{{.*}}/Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/../../../../sparc-myriad-elf/include/c++/4.8.2"
 // COMPILE_CXX: "-internal-isystem" 
"{{.*}}/Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/../../../../sparc-myriad-elf/include/c++/4.8.2/sparc-myriad-elf"
 // COMPILE_CXX: "-internal-isystem" 
"{{.*}}/Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/../../../../sparc-myriad-elf/include/c++/4.8.2/backward"
@@ -69,7 +69,7 @@
 // RUN:   | FileCheck %s -check-prefix=PREPROCESS
 // PREPROCESS: "-E" "-DMYRIAD2" "-I" "foo"
 
-// RUN: %clang -target sparc-myriad -### --driver-mode=g++ %s 2>&1 | FileCheck 
%s --check-prefix=LIBSTDCXX
+// RUN: %clang -stdlib=platform -target sparc-myriad -### --driver-mode=g++ %s 
2>&1 | FileCheck %s --check-prefix=LIBSTDCXX
 // LIBSTDCXX: "-lstdc++" "-lc" "-lgcc"
 
 // RUN: %clang -stdlib=libc++ -### -target sparcel-myriad -S -x c++ %s 2>&1 | 
FileCheck %s -check-prefix=LIBCXX


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


r284959 - [Sema][TreeTransform] Re-create DesignatedInitExpr when a field designator

2016-10-24 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Oct 24 04:33:32 2016
New Revision: 284959

URL: http://llvm.org/viewvc/llvm-project?rev=284959&view=rev
Log:
[Sema][TreeTransform] Re-create DesignatedInitExpr when a field designator
has no field declaration.

This commit fixes an invalid Winitializer-overrides warning that's shown
when analyzing a second (or any after the first) instantiation of a designated
initializer. This invalid warning is fixed by making sure that a
DesignatedInitExpr is rebuilt by the tree transformer when it has a field
designator whose FieldDecl* hasn't been yet initialized. This ensures that a
different DesignatedInitExpr is processed by Sema for every instantiation, and
thus the invalid warning is avoided.

rdar://28768441

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

Added:
cfe/trunk/test/SemaCXX/designated-initializers.cpp
Modified:
cfe/trunk/lib/Sema/TreeTransform.h

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=284959&r1=284958&r2=284959&view=diff
==
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Mon Oct 24 04:33:32 2016
@@ -8923,6 +8923,19 @@ TreeTransform::TransformDesigna
   Desig.AddDesignator(Designator::getField(D.getFieldName(),
D.getDotLoc(),
D.getFieldLoc()));
+  if (D.getField()) {
+FieldDecl *Field = cast_or_null(
+getDerived().TransformDecl(D.getFieldLoc(), D.getField()));
+if (Field != D.getField())
+  // Rebuild the expression when the transformed FieldDecl is
+  // different to the already assigned FieldDecl.
+  ExprChanged = true;
+  } else {
+// Ensure that the designator expression is rebuilt when there isn't
+// a resolved FieldDecl in the designator as we don't want to assign
+// a FieldDecl to a pattern designator that will be instantiated again.
+ExprChanged = true;
+  }
   continue;
 }
 

Added: cfe/trunk/test/SemaCXX/designated-initializers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/designated-initializers.cpp?rev=284959&view=auto
==
--- cfe/trunk/test/SemaCXX/designated-initializers.cpp (added)
+++ cfe/trunk/test/SemaCXX/designated-initializers.cpp Mon Oct 24 04:33:32 2016
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Winitializer-overrides %s
+
+template  struct Foo {
+  struct SubFoo {
+int bar1;
+int bar2;
+  };
+
+  static void Test() { SubFoo sf = {.bar1 = 10, .bar2 = 20}; } // Expected no 
warning
+};
+
+void foo() {
+  Foo::Test();
+  Foo::Test();
+  Foo::Test();
+}
+
+template  struct Bar {
+  struct SubFoo {
+int bar1;
+int bar2;
+  };
+
+  static void Test() { SubFoo sf = {.bar1 = 10,// expected-note 2 
{{previous initialization is here}}
+.bar1 = 20}; } // expected-warning 2 
{{initializer overrides prior initialization of this subobject}}
+};
+
+void bar() {
+  Bar::Test();  // expected-note {{in instantiation of member function 
'Bar::Test' requested here}}
+  Bar::Test(); // expected-note {{in instantiation of member function 
'Bar::Test' requested here}}
+}


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


[PATCH] D25777: [Sema][TreeTransform] Re-create DesignatedInitExpr when it has a field designator with a valid FieldDecl

2016-10-24 Thread Alex Lorenz via cfe-commits
This revision was automatically updated to reflect the committed changes.
arphaman marked an inline comment as done.
Closed by commit rL284959: [Sema][TreeTransform] Re-create DesignatedInitExpr 
when a field designator (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D25777?vs=75414&id=75559#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25777

Files:
  cfe/trunk/lib/Sema/TreeTransform.h
  cfe/trunk/test/SemaCXX/designated-initializers.cpp


Index: cfe/trunk/test/SemaCXX/designated-initializers.cpp
===
--- cfe/trunk/test/SemaCXX/designated-initializers.cpp
+++ cfe/trunk/test/SemaCXX/designated-initializers.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Winitializer-overrides %s
+
+template  struct Foo {
+  struct SubFoo {
+int bar1;
+int bar2;
+  };
+
+  static void Test() { SubFoo sf = {.bar1 = 10, .bar2 = 20}; } // Expected no 
warning
+};
+
+void foo() {
+  Foo::Test();
+  Foo::Test();
+  Foo::Test();
+}
+
+template  struct Bar {
+  struct SubFoo {
+int bar1;
+int bar2;
+  };
+
+  static void Test() { SubFoo sf = {.bar1 = 10,// expected-note 2 
{{previous initialization is here}}
+.bar1 = 20}; } // expected-warning 2 
{{initializer overrides prior initialization of this subobject}}
+};
+
+void bar() {
+  Bar::Test();  // expected-note {{in instantiation of member function 
'Bar::Test' requested here}}
+  Bar::Test(); // expected-note {{in instantiation of member function 
'Bar::Test' requested here}}
+}
Index: cfe/trunk/lib/Sema/TreeTransform.h
===
--- cfe/trunk/lib/Sema/TreeTransform.h
+++ cfe/trunk/lib/Sema/TreeTransform.h
@@ -8923,6 +8923,19 @@
   Desig.AddDesignator(Designator::getField(D.getFieldName(),
D.getDotLoc(),
D.getFieldLoc()));
+  if (D.getField()) {
+FieldDecl *Field = cast_or_null(
+getDerived().TransformDecl(D.getFieldLoc(), D.getField()));
+if (Field != D.getField())
+  // Rebuild the expression when the transformed FieldDecl is
+  // different to the already assigned FieldDecl.
+  ExprChanged = true;
+  } else {
+// Ensure that the designator expression is rebuilt when there isn't
+// a resolved FieldDecl in the designator as we don't want to assign
+// a FieldDecl to a pattern designator that will be instantiated again.
+ExprChanged = true;
+  }
   continue;
 }
 


Index: cfe/trunk/test/SemaCXX/designated-initializers.cpp
===
--- cfe/trunk/test/SemaCXX/designated-initializers.cpp
+++ cfe/trunk/test/SemaCXX/designated-initializers.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Winitializer-overrides %s
+
+template  struct Foo {
+  struct SubFoo {
+int bar1;
+int bar2;
+  };
+
+  static void Test() { SubFoo sf = {.bar1 = 10, .bar2 = 20}; } // Expected no warning
+};
+
+void foo() {
+  Foo::Test();
+  Foo::Test();
+  Foo::Test();
+}
+
+template  struct Bar {
+  struct SubFoo {
+int bar1;
+int bar2;
+  };
+
+  static void Test() { SubFoo sf = {.bar1 = 10,// expected-note 2 {{previous initialization is here}}
+.bar1 = 20}; } // expected-warning 2 {{initializer overrides prior initialization of this subobject}}
+};
+
+void bar() {
+  Bar::Test();  // expected-note {{in instantiation of member function 'Bar::Test' requested here}}
+  Bar::Test(); // expected-note {{in instantiation of member function 'Bar::Test' requested here}}
+}
Index: cfe/trunk/lib/Sema/TreeTransform.h
===
--- cfe/trunk/lib/Sema/TreeTransform.h
+++ cfe/trunk/lib/Sema/TreeTransform.h
@@ -8923,6 +8923,19 @@
   Desig.AddDesignator(Designator::getField(D.getFieldName(),
D.getDotLoc(),
D.getFieldLoc()));
+  if (D.getField()) {
+FieldDecl *Field = cast_or_null(
+getDerived().TransformDecl(D.getFieldLoc(), D.getField()));
+if (Field != D.getField())
+  // Rebuild the expression when the transformed FieldDecl is
+  // different to the already assigned FieldDecl.
+  ExprChanged = true;
+  } else {
+// Ensure that the designator expression is rebuilt when there isn't
+// a resolved FieldDecl in the designator as we don't want to assign
+// a FieldDecl to a pattern designator that will be instantiated again.
+ExprChanged = true;
+  }
   continue;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/

r284960 - [analyzer] Add StdLibraryFunctions checker.

2016-10-24 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Oct 24 04:41:38 2016
New Revision: 284960

URL: http://llvm.org/viewvc/llvm-project?rev=284960&view=rev
Log:
[analyzer] Add StdLibraryFunctions checker.

This checker does not emit reports, however it influences the analysis
by providing complete summaries for, or otherwise improving modeling of,
various standard library functions.

This should reduce the number of infeasible paths explored during analysis.
The custom function summary format used in this checker is superior to
body farms by causing less unnecessary state splits,
which would result in better analysis performance.

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

Added:
cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
cfe/trunk/test/Analysis/std-c-library-functions.c
cfe/trunk/test/Analysis/std-c-library-functions.cpp
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=284960&r1=284959&r2=284960&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Mon Oct 24 
04:41:38 2016
@@ -416,6 +416,10 @@ def VforkChecker : Checker<"Vfork">,
   HelpText<"Check for proper usage of vfork">,
   DescFile<"VforkChecker.cpp">;
 
+def StdCLibraryFunctionsChecker : Checker<"StdCLibraryFunctions">,
+  HelpText<"Improve modeling of the C standard library functions">,
+  DescFile<"StdLibraryFunctionsChecker.cpp">;
+
 } // end "unix"
 
 let ParentPackage = UnixAlpha in {

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=284960&r1=284959&r2=284960&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Mon Oct 24 04:41:38 
2016
@@ -71,6 +71,7 @@ add_clang_library(clangStaticAnalyzerChe
   ReturnUndefChecker.cpp
   SimpleStreamChecker.cpp
   StackAddrEscapeChecker.cpp
+  StdLibraryFunctionsChecker.cpp
   StreamChecker.cpp
   TaintTesterChecker.cpp
   TestAfterDivZeroChecker.cpp

Added: cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp?rev=284960&view=auto
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp (added)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp Mon 
Oct 24 04:41:38 2016
@@ -0,0 +1,943 @@
+//=== StdLibraryFunctionsChecker.cpp - Model standard functions -*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This checker improves modeling of a few simple library functions.
+// It does not generate warnings.
+//
+// This checker provides a specification format - `FunctionSummaryTy' - and
+// contains descriptions of some library functions in this format. Each
+// specification contains a list of branches for splitting the program state
+// upon call, and range constraints on argument and return-value symbols that
+// are satisfied on each branch. This spec can be expanded to include more
+// items, like external effects of the function.
+//
+// The main difference between this approach and the body farms technique is
+// in more explicit control over how many branches are produced. For example,
+// consider standard C function `ispunct(int x)', which returns a non-zero 
value
+// iff `x' is a punctuation character, that is, when `x' is in range
+//   ['!', '/']   [':', '@']  U  ['[', '\`']  U  ['{', '~'].
+// `FunctionSummaryTy' provides only two branches for this function. However,
+// any attempt to describe this range with if-statements in the body farm
+// would result in many more branches. Because each branch needs to be analyzed
+// independently, this significantly reduces performance. Additionally,
+// once we consider a branch on which `x' is in range, say, ['!', '/'],
+// we assume that such branch is an important separate path through the 
program,
+// which may lead to false positives because considering this particular path
+// was not consciously intended, and therefore it might have been unreachable.
+//
+// This checker uses eval::Call for modeling "pure" functions, for which
+// their `FunctionSumma

[PATCH] D20811: [analyzer] Model some library functions

2016-10-24 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284960: [analyzer] Add StdLibraryFunctions checker. 
(authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D20811?vs=75446&id=75560#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D20811

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
  cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  cfe/trunk/test/Analysis/std-c-library-functions.c
  cfe/trunk/test/Analysis/std-c-library-functions.cpp

Index: cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -0,0 +1,943 @@
+//=== StdLibraryFunctionsChecker.cpp - Model standard functions -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This checker improves modeling of a few simple library functions.
+// It does not generate warnings.
+//
+// This checker provides a specification format - `FunctionSummaryTy' - and
+// contains descriptions of some library functions in this format. Each
+// specification contains a list of branches for splitting the program state
+// upon call, and range constraints on argument and return-value symbols that
+// are satisfied on each branch. This spec can be expanded to include more
+// items, like external effects of the function.
+//
+// The main difference between this approach and the body farms technique is
+// in more explicit control over how many branches are produced. For example,
+// consider standard C function `ispunct(int x)', which returns a non-zero value
+// iff `x' is a punctuation character, that is, when `x' is in range
+//   ['!', '/']   [':', '@']  U  ['[', '\`']  U  ['{', '~'].
+// `FunctionSummaryTy' provides only two branches for this function. However,
+// any attempt to describe this range with if-statements in the body farm
+// would result in many more branches. Because each branch needs to be analyzed
+// independently, this significantly reduces performance. Additionally,
+// once we consider a branch on which `x' is in range, say, ['!', '/'],
+// we assume that such branch is an important separate path through the program,
+// which may lead to false positives because considering this particular path
+// was not consciously intended, and therefore it might have been unreachable.
+//
+// This checker uses eval::Call for modeling "pure" functions, for which
+// their `FunctionSummaryTy' is a precise model. This avoids unnecessary
+// invalidation passes. Conflicts with other checkers are unlikely because
+// if the function has no other effects, other checkers would probably never
+// want to improve upon the modeling done by this checker.
+//
+// Non-"pure" functions, for which only partial improvement over the default
+// behavior is expected, are modeled via check::PostCall, non-intrusively.
+//
+// The following standard C functions are currently supported:
+//
+//   fgetc  getline   isdigit   isupper
+//   fread  isalnum   isgraph   isxdigit
+//   fwrite isalpha   islower   read
+//   getc   isascii   isprint   write
+//   getcharisblank   ispunct
+//   getdelim   iscntrl   isspace
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+
+using namespace clang;
+using namespace clang::ento;
+
+namespace {
+class StdLibraryFunctionsChecker : public Checker {
+  /// Below is a series of typedefs necessary to define function specs.
+  /// We avoid nesting types here because each additional qualifier
+  /// would need to be repeated in every function spec.
+  struct FunctionSummaryTy;
+
+  /// Specify how much the analyzer engine should entrust modeling this function
+  /// to us. If he doesn't, he performs additional invalidations.
+  enum InvalidationKindTy { NoEvalCall, EvalCallAsPure };
+
+  /// A pair of ValueRangeKindTy and IntRangeVectorTy would describe a range
+  /// imposed on a particular argument or return value symbol.
+  ///
+  /// Given a range, should the argument stay inside or outside this range?
+  /// The special `ComparesToArgument' value indicates that we should
+  /// impose a constraint that involves other argument or return value symbols.
+  enum ValueRangeKindTy { OutOfRange, WithinRang

r284961 - [Sema] Formatting warnings should see through Objective-C message sends

2016-10-24 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Oct 24 04:42:34 2016
New Revision: 284961

URL: http://llvm.org/viewvc/llvm-project?rev=284961&view=rev
Log:
[Sema] Formatting warnings should see through Objective-C message sends

This commit improves the '-Wformat' warnings by ensuring that the formatting
checker can see through Objective-C message sends when we are calling an
Objective-C method with an appropriate format_arg attribute.

rdar://23622446

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

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaObjC/format-strings-objc.m

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=284961&r1=284960&r2=284961&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Oct 24 04:42:34 2016
@@ -4479,6 +4479,20 @@ checkFormatStringExpr(Sema &S, const Exp
 
 return SLCT_NotALiteral;
   }
+  case Stmt::ObjCMessageExprClass: {
+const auto *ME = cast(E);
+if (const auto *ND = ME->getMethodDecl()) {
+  if (const auto *FA = ND->getAttr()) {
+unsigned ArgIndex = FA->getFormatIdx();
+const Expr *Arg = ME->getArg(ArgIndex - 1);
+return checkFormatStringExpr(
+S, Arg, Args, HasVAListArg, format_idx, firstDataArg, Type,
+CallType, InFunctionCall, CheckedVarArgs, UncoveredArg, Offset);
+  }
+}
+
+return SLCT_NotALiteral;
+  }
   case Stmt::ObjCStringLiteralClass:
   case Stmt::StringLiteralClass: {
 const StringLiteral *StrE = nullptr;

Modified: cfe/trunk/test/SemaObjC/format-strings-objc.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/format-strings-objc.m?rev=284961&r1=284960&r2=284961&view=diff
==
--- cfe/trunk/test/SemaObjC/format-strings-objc.m (original)
+++ cfe/trunk/test/SemaObjC/format-strings-objc.m Mon Oct 24 04:42:34 2016
@@ -264,3 +264,41 @@ void testObjCModifierFlags() {
   NSLog(@"%2$[tt]@ %1$[tt]@", @"Foo", @"Bar"); // no-warning
   NSLog(@"%2$[tt]@ %1$[tt]s", @"Foo", @"Bar"); // expected-warning {{object 
format flags cannot be used with 's' conversion specifier}}
 }
+
+// rdar://23622446
+@interface RD23622446_Tester: NSObject
+
++ (void)stringWithFormat:(const char *)format, ... 
__attribute__((format(__printf__, 1, 2)));
+
+@end
+
+@implementation RD23622446_Tester
+
+__attribute__ ((format_arg(1)))
+const char *rd23622446(const char *format) {
+  return format;
+}
+
++ (void)stringWithFormat:(const char *)format, ... {
+  return;
+}
+
+- (const char *)test:(const char *)format __attribute__ ((format_arg(1))) {
+  return format;
+}
+
+- (NSString *)str:(NSString *)format __attribute__ ((format_arg(1))) {
+  return format;
+}
+
+- (void)foo {
+  [RD23622446_Tester stringWithFormat:rd23622446("%u"), 1, 2]; // 
expected-warning {{data argument not used by format string}}
+  [RD23622446_Tester stringWithFormat:[self test: "%u"], 1, 2]; // 
expected-warning {{data argument not used by format string}}
+  [RD23622446_Tester stringWithFormat:[self test: "%s %s"], "name"]; // 
expected-warning {{more '%' conversions than data arguments}}
+  NSLog([self str: @"%@ %@"], @"name"); // expected-warning {{more '%' 
conversions than data arguments}}
+  [RD23622446_Tester stringWithFormat:rd23622446("%d"), 1]; // ok
+  [RD23622446_Tester stringWithFormat:[self test: "%d %d"], 1, 2]; // ok
+  NSLog([self str: @"%@"], @"string"); // ok
+}
+
+@end


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


[PATCH] D25820: [Sema][Objective-C] Formatting warnings should see through Objective-C message sends

2016-10-24 Thread Alex Lorenz via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284961: [Sema] Formatting warnings should see through 
Objective-C message sends (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D25820?vs=75408&id=75561#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25820

Files:
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/SemaObjC/format-strings-objc.m


Index: cfe/trunk/test/SemaObjC/format-strings-objc.m
===
--- cfe/trunk/test/SemaObjC/format-strings-objc.m
+++ cfe/trunk/test/SemaObjC/format-strings-objc.m
@@ -264,3 +264,41 @@
   NSLog(@"%2$[tt]@ %1$[tt]@", @"Foo", @"Bar"); // no-warning
   NSLog(@"%2$[tt]@ %1$[tt]s", @"Foo", @"Bar"); // expected-warning {{object 
format flags cannot be used with 's' conversion specifier}}
 }
+
+// rdar://23622446
+@interface RD23622446_Tester: NSObject
+
++ (void)stringWithFormat:(const char *)format, ... 
__attribute__((format(__printf__, 1, 2)));
+
+@end
+
+@implementation RD23622446_Tester
+
+__attribute__ ((format_arg(1)))
+const char *rd23622446(const char *format) {
+  return format;
+}
+
++ (void)stringWithFormat:(const char *)format, ... {
+  return;
+}
+
+- (const char *)test:(const char *)format __attribute__ ((format_arg(1))) {
+  return format;
+}
+
+- (NSString *)str:(NSString *)format __attribute__ ((format_arg(1))) {
+  return format;
+}
+
+- (void)foo {
+  [RD23622446_Tester stringWithFormat:rd23622446("%u"), 1, 2]; // 
expected-warning {{data argument not used by format string}}
+  [RD23622446_Tester stringWithFormat:[self test: "%u"], 1, 2]; // 
expected-warning {{data argument not used by format string}}
+  [RD23622446_Tester stringWithFormat:[self test: "%s %s"], "name"]; // 
expected-warning {{more '%' conversions than data arguments}}
+  NSLog([self str: @"%@ %@"], @"name"); // expected-warning {{more '%' 
conversions than data arguments}}
+  [RD23622446_Tester stringWithFormat:rd23622446("%d"), 1]; // ok
+  [RD23622446_Tester stringWithFormat:[self test: "%d %d"], 1, 2]; // ok
+  NSLog([self str: @"%@"], @"string"); // ok
+}
+
+@end
Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -4479,6 +4479,20 @@
 
 return SLCT_NotALiteral;
   }
+  case Stmt::ObjCMessageExprClass: {
+const auto *ME = cast(E);
+if (const auto *ND = ME->getMethodDecl()) {
+  if (const auto *FA = ND->getAttr()) {
+unsigned ArgIndex = FA->getFormatIdx();
+const Expr *Arg = ME->getArg(ArgIndex - 1);
+return checkFormatStringExpr(
+S, Arg, Args, HasVAListArg, format_idx, firstDataArg, Type,
+CallType, InFunctionCall, CheckedVarArgs, UncoveredArg, Offset);
+  }
+}
+
+return SLCT_NotALiteral;
+  }
   case Stmt::ObjCStringLiteralClass:
   case Stmt::StringLiteralClass: {
 const StringLiteral *StrE = nullptr;


Index: cfe/trunk/test/SemaObjC/format-strings-objc.m
===
--- cfe/trunk/test/SemaObjC/format-strings-objc.m
+++ cfe/trunk/test/SemaObjC/format-strings-objc.m
@@ -264,3 +264,41 @@
   NSLog(@"%2$[tt]@ %1$[tt]@", @"Foo", @"Bar"); // no-warning
   NSLog(@"%2$[tt]@ %1$[tt]s", @"Foo", @"Bar"); // expected-warning {{object format flags cannot be used with 's' conversion specifier}}
 }
+
+// rdar://23622446
+@interface RD23622446_Tester: NSObject
+
++ (void)stringWithFormat:(const char *)format, ... __attribute__((format(__printf__, 1, 2)));
+
+@end
+
+@implementation RD23622446_Tester
+
+__attribute__ ((format_arg(1)))
+const char *rd23622446(const char *format) {
+  return format;
+}
+
++ (void)stringWithFormat:(const char *)format, ... {
+  return;
+}
+
+- (const char *)test:(const char *)format __attribute__ ((format_arg(1))) {
+  return format;
+}
+
+- (NSString *)str:(NSString *)format __attribute__ ((format_arg(1))) {
+  return format;
+}
+
+- (void)foo {
+  [RD23622446_Tester stringWithFormat:rd23622446("%u"), 1, 2]; // expected-warning {{data argument not used by format string}}
+  [RD23622446_Tester stringWithFormat:[self test: "%u"], 1, 2]; // expected-warning {{data argument not used by format string}}
+  [RD23622446_Tester stringWithFormat:[self test: "%s %s"], "name"]; // expected-warning {{more '%' conversions than data arguments}}
+  NSLog([self str: @"%@ %@"], @"name"); // expected-warning {{more '%' conversions than data arguments}}
+  [RD23622446_Tester stringWithFormat:rd23622446("%d"), 1]; // ok
+  [RD23622446_Tester stringWithFormat:[self test: "%d %d"], 1, 2]; // ok
+  NSLog([self str: @"%@"], @"string"); // ok
+}
+
+@end
Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -4479,6 +4479,20 @@
 
 return 

[PATCH] D25305: [OpenCL] Setting constant address space for array initializers

2016-10-24 Thread Alexey Bader via cfe-commits
bader added inline comments.



Comment at: lib/CodeGen/CGDecl.cpp:1272
+if (getLangOpts().OpenCL) {
+  UA = llvm::GlobalValue::UnnamedAddr::None;
+  AS = CGM.getContext().getTargetAddressSpace(LangAS::opencl_constant);

AlexeySotkin wrote:
> Anastasia wrote:
> > Why this change?
> Without this change, global variables with unnamed address space are 
> translated to SPIR-V as variables with "Function" storage class, which is 
> wrong.
> This should fix this issue: 
> https://github.com/KhronosGroup/SPIRV-LLVM/issues/50
There is inconsistency with how Clang maps initializers to OpenCL memory model.
Consider example from the test case:
```
__private int arr[] = {1, 2, 3};
```
This code allocates a global constant for initializer {1, 2, 3} and later 
copies values from this global constant to the private array using memcpy 
intrinsic. The global constant must be allocated in constant address space, but 
old code do assign any address space, which is considered to be a private 
memory region.
This patch puts global constant objects to constant address space.


https://reviews.llvm.org/D25305



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


[PATCH] D23712: [OpenCL] Override supported OpenCL extensions with -cl-ext option

2016-10-24 Thread Joey Gouly via cfe-commits
joey added a comment.

Two minor comments, but otherwise LGTM!




Comment at: include/clang/Basic/OpenCLOptions.h:33
 
   // Enable all options.
+  void setAll(bool Enable = true) {

This comment needs to be changed, to reflect that they are now all enabled or 
disabled.



Comment at: include/clang/Basic/TargetInfo.h:992
+  virtual void setOpenCLExtensionOpts() {
+for (const auto &Ext:getTargetOpts().OpenCLExtensionsAsWritten) {
+  getTargetOpts().SupportedOpenCLOptions.set(Ext);

Can you put a space around the ':'.


https://reviews.llvm.org/D23712



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


r284963 - [X86][AVX512][Clang][Intrinsics][reduce] Adding missing reduce (Operators: +, *, &&, ||) intrinsics to Clang

2016-10-24 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Mon Oct 24 05:53:20 2016
New Revision: 284963

URL: http://llvm.org/viewvc/llvm-project?rev=284963&view=rev
Log:
[X86][AVX512][Clang][Intrinsics][reduce] Adding missing reduce (Operators: 
+,*,&&,||) intrinsics to Clang

Committed after LGTM and check-all

Vector-reduction arithmetic accepts vectors as inputs and produces scalars as 
outputs.
This class of vector operation forms the basis of many scientific computations.
In vector-reduction arithmetic, the evaluation off is independent of the order 
of the input elements of V.

Used bisection method. At each step, we partition the vector with previous
step in half, and the operation is performed on its two halves.
This takes log2(n) steps where n is the number of elements in the vector.

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


Added:
cfe/trunk/test/CodeGen/avx512-reduceIntrin.c
Modified:
cfe/trunk/lib/Headers/avx512fintrin.h

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=284963&r1=284962&r2=284963&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Mon Oct 24 05:53:20 2016
@@ -9658,6 +9658,243 @@ _mm512_mask_abs_pd(__m512d __W, __mmask8
   return (__m512d)_mm512_mask_and_epi64((__v8di)__W, __K, 
_mm512_set1_epi64(0x7FFF),(__v8di)__A);
 }
 
+// Vector-reduction arithmetic accepts vectors as inputs and produces scalars 
as
+// outputs. This class of vector operation forms the basis of many scientific
+// computations. In vector-reduction arithmetic, the evaluation off is
+// independent of the order of the input elements of V.
+
+// Used bisection method. At each step, we partition the vector with previous
+// step in half, and the operation is performed on its two halves.
+// This takes log2(n) steps where n is the number of elements in the vector.
+
+// Vec512 - Vector with size 512.
+// Operator - Can be one of following: +,*,&&,||
+// T2  - Can get 'i' for int and 'f' for float.
+// T1 - Can get 'i' for int and 'd' for double.
+
+#define _mm512_reduce_operator_64bit(Vec512, Operator, T2, T1) \
+  __extension__({  \
+__m256##T1 Vec256 = __builtin_shufflevector(   \
+(__v8d##T2)Vec512, \
+(__v8d##T2)Vec512, \
+0, 1, 2, 3)\
+Operator   \
+__builtin_shufflevector(   \
+(__v8d##T2)Vec512, \
+(__v8d##T2)Vec512, \
+4, 5, 6, 7);   \
+__m128##T1 Vec128 = __builtin_shufflevector(   \
+(__v4d##T2)Vec256, \
+(__v4d##T2)Vec256, \
+0, 1)  \
+Operator   \
+__builtin_shufflevector(   \
+(__v4d##T2)Vec256, \
+(__v4d##T2)Vec256, \
+2, 3); \
+Vec128 = __builtin_shufflevector((__v2d##T2)Vec128,\
+ (__v2d##T2)Vec128, 0, -1) \
+ Operator  \
+ __builtin_shufflevector((__v2d##T2)Vec128,\
+ (__v2d##T2)Vec128, 1, -1);\
+return Vec128[0];  \
+  })
+
+static __inline__ long long __DEFAULT_FN_ATTRS _mm512_reduce_add_epi64(__m512i 
__W) {
+  _mm512_reduce_operator_64bit(__W, +, i, i);
+}
+
+static __inline__ long long __DEFAULT_FN_ATTRS _mm512_reduce_mul_epi64(__m512i 
__W) {
+  _mm512_reduce_operator_64bit(__W, *, i, i);
+}
+
+static __inline__ long long __DEFAULT_FN_ATTRS _mm512_reduce_and_epi64(__m512i 
__W) {
+  _mm512_reduce_operator_64bit(__W, &, i, i);
+}
+
+static __inline__ long long __DEFAULT_FN_ATTRS _mm512_reduce_or_epi64(__m512i 
__W) {
+  _mm512_reduce_operator_64bit(__W, |, i, i);
+}
+
+static __inline__ double __DEFAULT_FN_ATTRS _mm512_reduce_add_pd(__m512d __W) {
+  _mm512_reduce_operator_64bit(__W, +, f, d);
+}
+
+static __inline__ double __DEFAULT_FN_ATTRS _mm512_reduce_mul_pd(__m512d __W) {
+  _mm512_reduce_operator_64bit(__W, *, f, d);
+}
+
+// Vec512 - Vector with size 512.
+// Operator - 

r284964 - Adjust for TimePoint interface change in llvm: D25730. NFC

2016-10-24 Thread Pavel Labath via cfe-commits
Author: labath
Date: Mon Oct 24 05:59:13 2016
New Revision: 284964

URL: http://llvm.org/viewvc/llvm-project?rev=284964&view=rev
Log:
Adjust for TimePoint interface change in llvm: D25730. NFC

Modified:
cfe/trunk/include/clang/Basic/VirtualFileSystem.h
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=284964&r1=284963&r2=284964&view=diff
==
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Mon Oct 24 05:59:13 2016
@@ -19,6 +19,7 @@
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/SourceMgr.h"
+#include "llvm/Support/TimeValue.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=284964&r1=284963&r2=284964&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Oct 24 05:59:13 2016
@@ -5576,9 +5576,11 @@ void Clang::ConstructJob(Compilation &C,
 llvm::sys::fs::file_status Status;
 if (llvm::sys::fs::status(A->getValue(), Status))
   D.Diag(diag::err_drv_no_such_file) << A->getValue();
-CmdArgs.push_back(Args.MakeArgString(
-"-fbuild-session-timestamp=" +
-Twine((uint64_t)Status.getLastModificationTime().toEpochTime(;
+CmdArgs.push_back(
+Args.MakeArgString("-fbuild-session-timestamp=" +
+   Twine((uint64_t)Status.getLastModificationTime()
+ .time_since_epoch()
+ .count(;
   }
 
   if (Args.getLastArg(options::OPT_fmodules_validate_once_per_build_session)) {


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


[PATCH] D23712: [OpenCL] Override supported OpenCL extensions with -cl-ext option

2016-10-24 Thread Andrew Savonichev via cfe-commits
asavonic updated this revision to Diff 75568.
asavonic added a comment.

- Fix comments and code formatting


https://reviews.llvm.org/D23712

Files:
  include/clang/Basic/OpenCLOptions.h
  include/clang/Basic/TargetInfo.h
  include/clang/Basic/TargetOptions.h
  include/clang/Driver/CC1Options.td
  lib/Basic/Targets.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/SemaOpenCL/extensions.cl

Index: test/SemaOpenCL/extensions.cl
===
--- test/SemaOpenCL/extensions.cl
+++ test/SemaOpenCL/extensions.cl
@@ -2,7 +2,26 @@
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.1
 
 // Test with a target not supporting fp64.
-// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64
+// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
+
+// Test with some extensions enabled or disabled by cmd-line args
+//
+// Target does not support fp64 and fp16 - override it
+// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+cl_khr_fp64,+cl_khr_fp16
+//
+// Disable or enable all extensions
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -DNOFP64 -DNOFP16
+// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all
+// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all,-cl_khr_fp64 -DNOFP64
+// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=-all,+cl_khr_fp64 -DNOFP16
+//
+// Concatenating
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-cl_khr_fp64 -cl-ext=+cl_khr_fp64  -DNOFP16
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-cl_khr_fp64,+cl_khr_fp64  -DNOFP16
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64 -cl-ext=+cl_khr_fp16 -cl-ext=-cl_khr_fp64 -DNOFP64
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64,-cl_khr_fp64,+cl_khr_fp16 -DNOFP64
+
+
 
 void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}}
   double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
@@ -14,6 +33,11 @@
 // expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp64' - ignoring}}
 #endif
 
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+#ifdef NOFP16
+// expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp16' - ignoring}}
+#endif
+
 void f2(void) {
   double d;
 #ifdef NOFP64
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2349,6 +2349,7 @@
   // Use the default target triple if unspecified.
   if (Opts.Triple.empty())
 Opts.Triple = llvm::sys::getDefaultTargetTriple();
+  Opts.OpenCLExtensionsAsWritten = Args.getAllArgValues(OPT_cl_ext_EQ);
 }
 
 bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -8676,6 +8676,7 @@
 return nullptr;
 
   Target->setSupportedOpenCLOpts();
+  Target->setOpenCLExtensionOpts();
 
   if (!Target->validateTarget(Diags))
 return nullptr;
Index: include/clang/Driver/CC1Options.td
===
--- include/clang/Driver/CC1Options.td
+++ include/clang/Driver/CC1Options.td
@@ -685,6 +685,13 @@
   HelpText<"include a detailed record of preprocessing actions">;
 
 //===--===//
+// OpenCL Options
+//===--===//
+
+def cl_ext_EQ : CommaJoined<["-"], "cl-ext=">,
+  HelpText<"OpenCL only. Enable or disable OpenCL extensions. The argument is a comma-separated sequence of one or more extension names, each prefixed by '+' or '-'.">;
+
+//===--===//
 // CUDA Options
 //===--===//
 
Index: include/clang/Basic/TargetOptions.h
===
--- include/clang/Basic/TargetOptions.h
+++ include/clang/Basic/TargetOptions.h
@@ -58,6 +58,10 @@
 
   /// Supported OpenCL extensions and optional core features.
   OpenCLOptions SupportedOpenCLOptions;
+
+  /// \brief The list of OpenCL extensions to enable or disable, as written on
+  /// the command line.
+  std::vector OpenCLExtensionsAsW

r284967 - revert r284963

2016-10-24 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Mon Oct 24 06:30:23 2016
New Revision: 284967

URL: http://llvm.org/viewvc/llvm-project?rev=284967&view=rev
Log:
revert r284963 

because new test file is failing in some OS.
test/CodeGen/avx512-reduceIntrin.c


Removed:
cfe/trunk/test/CodeGen/avx512-reduceIntrin.c
Modified:
cfe/trunk/lib/Headers/avx512fintrin.h

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=284967&r1=284966&r2=284967&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Mon Oct 24 06:30:23 2016
@@ -9658,243 +9658,6 @@ _mm512_mask_abs_pd(__m512d __W, __mmask8
   return (__m512d)_mm512_mask_and_epi64((__v8di)__W, __K, 
_mm512_set1_epi64(0x7FFF),(__v8di)__A);
 }
 
-// Vector-reduction arithmetic accepts vectors as inputs and produces scalars 
as
-// outputs. This class of vector operation forms the basis of many scientific
-// computations. In vector-reduction arithmetic, the evaluation off is
-// independent of the order of the input elements of V.
-
-// Used bisection method. At each step, we partition the vector with previous
-// step in half, and the operation is performed on its two halves.
-// This takes log2(n) steps where n is the number of elements in the vector.
-
-// Vec512 - Vector with size 512.
-// Operator - Can be one of following: +,*,&&,||
-// T2  - Can get 'i' for int and 'f' for float.
-// T1 - Can get 'i' for int and 'd' for double.
-
-#define _mm512_reduce_operator_64bit(Vec512, Operator, T2, T1) \
-  __extension__({  \
-__m256##T1 Vec256 = __builtin_shufflevector(   \
-(__v8d##T2)Vec512, \
-(__v8d##T2)Vec512, \
-0, 1, 2, 3)\
-Operator   \
-__builtin_shufflevector(   \
-(__v8d##T2)Vec512, \
-(__v8d##T2)Vec512, \
-4, 5, 6, 7);   \
-__m128##T1 Vec128 = __builtin_shufflevector(   \
-(__v4d##T2)Vec256, \
-(__v4d##T2)Vec256, \
-0, 1)  \
-Operator   \
-__builtin_shufflevector(   \
-(__v4d##T2)Vec256, \
-(__v4d##T2)Vec256, \
-2, 3); \
-Vec128 = __builtin_shufflevector((__v2d##T2)Vec128,\
- (__v2d##T2)Vec128, 0, -1) \
- Operator  \
- __builtin_shufflevector((__v2d##T2)Vec128,\
- (__v2d##T2)Vec128, 1, -1);\
-return Vec128[0];  \
-  })
-
-static __inline__ long long __DEFAULT_FN_ATTRS _mm512_reduce_add_epi64(__m512i 
__W) {
-  _mm512_reduce_operator_64bit(__W, +, i, i);
-}
-
-static __inline__ long long __DEFAULT_FN_ATTRS _mm512_reduce_mul_epi64(__m512i 
__W) {
-  _mm512_reduce_operator_64bit(__W, *, i, i);
-}
-
-static __inline__ long long __DEFAULT_FN_ATTRS _mm512_reduce_and_epi64(__m512i 
__W) {
-  _mm512_reduce_operator_64bit(__W, &, i, i);
-}
-
-static __inline__ long long __DEFAULT_FN_ATTRS _mm512_reduce_or_epi64(__m512i 
__W) {
-  _mm512_reduce_operator_64bit(__W, |, i, i);
-}
-
-static __inline__ double __DEFAULT_FN_ATTRS _mm512_reduce_add_pd(__m512d __W) {
-  _mm512_reduce_operator_64bit(__W, +, f, d);
-}
-
-static __inline__ double __DEFAULT_FN_ATTRS _mm512_reduce_mul_pd(__m512d __W) {
-  _mm512_reduce_operator_64bit(__W, *, f, d);
-}
-
-// Vec512 - Vector with size 512.
-// Operator - Can be one of following: +,*,&&,||
-// Mask - Intrinsic Mask
-// Neutral - Identity element: {+,0},{*,1},{&&,0x},{||,0}
-// T2  - Can get 'i' for int and 'f' for float.
-// T1 - Can get 'i' for int and 'd' for packed double-precision.
-// T3 - Can be Pd for packed double or q for q-word.
-
-#define _mm512_mask_reduce_operator_64bit(Vec512, Operator, Mask, Neutral, 
\
-  T2, T1, T3)  
\
-  __extension__({  
\
-Vec512 = __builtin_ia32_select

Re: r284960 - [analyzer] Add StdLibraryFunctions checker.

2016-10-24 Thread Renato Golin via cfe-commits
On 24 October 2016 at 10:41, Artem Dergachev via cfe-commits
 wrote:
> Author: dergachev
> Date: Mon Oct 24 04:41:38 2016
> New Revision: 284960
>
> URL: http://llvm.org/viewvc/llvm-project?rev=284960&view=rev
> Log:
> [analyzer] Add StdLibraryFunctions checker.

Hi Artem,

I'm not sure what you're checking, but this failed on the ARM bots:

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/14
http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/14

error: 'warning' diagnostics expected but not seen:
  File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 35: TRUE
  File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 38: TRUE
  File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 44: TRUE
  File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 52: TRUE
  File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 54: TRUE
  File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 66: FALSE
error: 'warning' diagnostics seen but not expected:
  File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 35: UNKNOWN
  File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 38: UNKNOWN
  File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 44: UNKNOWN
  File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 52: UNKNOWN
  File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 54: UNKNOWN
  File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 66: UNKNOWN
12 errors generated.

If it's not trivial to fix, let's revert and try to find it offline.

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


[PATCH] D25305: [OpenCL] Setting constant address space for array initializers

2016-10-24 Thread Alexey Sotkin via cfe-commits
AlexeySotkin added inline comments.



Comment at: lib/CodeGen/CGDecl.cpp:1272
+if (getLangOpts().OpenCL) {
+  UA = llvm::GlobalValue::UnnamedAddr::None;
+  AS = CGM.getContext().getTargetAddressSpace(LangAS::opencl_constant);

Anastasia wrote:
> Why this change?
Without this change, global variables with unnamed address space are translated 
to SPIR-V as variables with "Function" storage class, which is wrong.
This should fix this issue: https://github.com/KhronosGroup/SPIRV-LLVM/issues/50


https://reviews.llvm.org/D25305



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


[PATCH] D25888: Add support for __builtin_os_log_format[_buffer_size]

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

This looks good from a Clang perspective. You also might want to get review 
from someone who knows how the os_log API is supposed to work, as I can't 
comment on that.




Comment at: clang/test/CodeGenObjC/os_log.m:13
+// Behavior of __builtin_os_log differs between platforms, so only test on X86
+#ifdef __x86_64__
+// CHECK-LABEL: define i8* @test_builtin_os_log

This is only ever compile for x86 (you have a triple in the command line). Just 
drop the #ifdef.


https://reviews.llvm.org/D25888



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


[PATCH] D25402: [Driver] Pass -lunwind when using libc++ + compiler-rt on Linux

2016-10-24 Thread Michał Górny via cfe-commits
mgorny added inline comments.



Comment at: lib/Driver/ToolChains.cpp:4704
+  GetRuntimeLibType(Args) == ToolChain::RLT_CompilerRT)
+CmdArgs.push_back("-lunwind");
+}

Hahnfeld wrote:
> As just written in D25008: This will probably result in problems if a system 
> default `libunwind.so.8` is installed...
I think this is the correct behavior in this case. Clang should work with 
whichever unwinder implementation is available, and if you want to change that, 
change the `libunwind.so` symlink.

However, I don't really think it's a good idea to have both unwinder libraries 
installed alongside, especially that they are sharing the same name.


https://reviews.llvm.org/D25402



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


r284969 - [analyzer] Fix an ARM buildbot after r284960.

2016-10-24 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Oct 24 07:54:27 2016
New Revision: 284969

URL: http://llvm.org/viewvc/llvm-project?rev=284969&view=rev
Log:
[analyzer] Fix an ARM buildbot after r284960.

I guess we should always specify triples in all analyzer tests, regardless.

Modified:
cfe/trunk/test/Analysis/std-c-library-functions.c
cfe/trunk/test/Analysis/std-c-library-functions.cpp

Modified: cfe/trunk/test/Analysis/std-c-library-functions.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/std-c-library-functions.c?rev=284969&r1=284968&r2=284969&view=diff
==
--- cfe/trunk/test/Analysis/std-c-library-functions.c (original)
+++ cfe/trunk/test/Analysis/std-c-library-functions.c Mon Oct 24 07:54:27 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze 
-analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -analyze 
-analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s
 
 void clang_analyzer_eval(int);
 

Modified: cfe/trunk/test/Analysis/std-c-library-functions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/std-c-library-functions.cpp?rev=284969&r1=284968&r2=284969&view=diff
==
--- cfe/trunk/test/Analysis/std-c-library-functions.cpp (original)
+++ cfe/trunk/test/Analysis/std-c-library-functions.cpp Mon Oct 24 07:54:27 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze 
-analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -analyze 
-analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s
 
 // Test that we don't model functions with broken prototypes.
 // Because they probably work differently as well.


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


[PATCH] D25402: [Driver] Pass -lunwind when using libc++ + compiler-rt on Linux

2016-10-24 Thread Jonas Hahnfeld via cfe-commits
Hahnfeld added inline comments.



Comment at: lib/Driver/ToolChains.cpp:4704
+  GetRuntimeLibType(Args) == ToolChain::RLT_CompilerRT)
+CmdArgs.push_back("-lunwind");
+}

mgorny wrote:
> Hahnfeld wrote:
> > As just written in D25008: This will probably result in problems if a 
> > system default `libunwind.so.8` is installed...
> I think this is the correct behavior in this case. Clang should work with 
> whichever unwinder implementation is available, and if you want to change 
> that, change the `libunwind.so` symlink.
> 
> However, I don't really think it's a good idea to have both unwinder 
> libraries installed alongside, especially that they are sharing the same name.
No, we can't: The nongnu libunwind is used by other system libraries that need 
and are tested against this version.

It's certainly not a good idea, but it's reality in many distros. Most of them 
don't ship LLVM's libunwind.


https://reviews.llvm.org/D25402



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


Re: r284960 - [analyzer] Add StdLibraryFunctions checker.

2016-10-24 Thread Artem Dergachev via cfe-commits
Strange, i'm not receiving any buildbot emails again. Will look through 
bots manually next time, that doesn't sound too hard. Pushed a hotfix in 
r284969.


On 10/24/16 3:08 PM, Renato Golin wrote:

On 24 October 2016 at 10:41, Artem Dergachev via cfe-commits
 wrote:

Author: dergachev
Date: Mon Oct 24 04:41:38 2016
New Revision: 284960

URL: http://llvm.org/viewvc/llvm-project?rev=284960&view=rev
Log:
[analyzer] Add StdLibraryFunctions checker.

Hi Artem,

I'm not sure what you're checking, but this failed on the ARM bots:

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/14
http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/14

error: 'warning' diagnostics expected but not seen:
   File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 35: TRUE
   File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 38: TRUE
   File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 44: TRUE
   File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 52: TRUE
   File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 54: TRUE
   File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 66: FALSE
error: 'warning' diagnostics seen but not expected:
   File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 35: UNKNOWN
   File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 38: UNKNOWN
   File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 44: UNKNOWN
   File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 52: UNKNOWN
   File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 54: UNKNOWN
   File 
/home/linaro/buildbot/clang-cmake-armv7-a15/llvm/tools/clang/test/Analysis/std-c-library-functions.c
Line 66: UNKNOWN
12 errors generated.

If it's not trivial to fix, let's revert and try to find it offline.

cheers,
--renato


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


[PATCH] D25008: [cmake] Split linked libraries into private & public, for linker script

2016-10-24 Thread Michał Górny via cfe-commits
mgorny added a comment.

I think it'd be technically possible to force a specific SONAME in the linker 
script but I don't think that's a good idea. Clang should be able to use any 
libunwind implementation, and libc++ shouldn't really be encoding internal 
implementation details to the point of specific SONAME.

On the other hand, if we are doing a complete in-tree build of LLVM with 
libunwind, I guess it'd be reasonable to avoid combining the system library 
with the just-built library. Assuming we want to force 'our' library, and 
considering the fact that the tests are specifying all dependencies explicitly 
anyway, I think the most correct solution for that would be to skip the linker 
script for tests.

I see two possible solutions for that: either we pass full SONAME of the 
library when linking tests, or we provide an additional symlink to skip linker 
script. Gentoo already does the latter, and I wanted to add support for that 
into libcxx anyway, so that may be the solution. The idea is that besides 
`libc++.so` (the linker script), additional `libc++_shared.so` symlink is 
installed that references the library directly.


Repository:
  rL LLVM

https://reviews.llvm.org/D25008



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


[PATCH] D25402: [Driver] Pass -lunwind when using libc++ + compiler-rt on Linux

2016-10-24 Thread Michał Górny via cfe-commits
mgorny added inline comments.



Comment at: lib/Driver/ToolChains.cpp:4704
+  GetRuntimeLibType(Args) == ToolChain::RLT_CompilerRT)
+CmdArgs.push_back("-lunwind");
+}

Hahnfeld wrote:
> mgorny wrote:
> > Hahnfeld wrote:
> > > As just written in D25008: This will probably result in problems if a 
> > > system default `libunwind.so.8` is installed...
> > I think this is the correct behavior in this case. Clang should work with 
> > whichever unwinder implementation is available, and if you want to change 
> > that, change the `libunwind.so` symlink.
> > 
> > However, I don't really think it's a good idea to have both unwinder 
> > libraries installed alongside, especially that they are sharing the same 
> > name.
> No, we can't: The nongnu libunwind is used by other system libraries that 
> need and are tested against this version.
> 
> It's certainly not a good idea, but it's reality in many distros. Most of 
> them don't ship LLVM's libunwind.
Well, IMO only sane solution to the problem is to have LLVM's libunwind 
renamed. Otherwise, using the two libraries is going always to be an 
unreliable, awful hackery with high risk that someone will accidentally end up 
with wrong one or -- even worse -- both of them in the same executable.


https://reviews.llvm.org/D25402



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


[PATCH] D25008: [cmake] Split linked libraries into private & public, for linker script

2016-10-24 Thread Jonas Hahnfeld via cfe-commits
Hahnfeld added a comment.

`LIBCXXABI_USE_LLVM_UNWINDER` implies to me: "Use LLVM's `libunwind` whenever 
you use `libc++abi`". This has worked until now and I would vote for this to be 
the right thing to do.


Repository:
  rL LLVM

https://reviews.llvm.org/D25008



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


Re: r284960 - [analyzer] Add StdLibraryFunctions checker.

2016-10-24 Thread Renato Golin via cfe-commits
On 24 October 2016 at 14:09, Artem Dergachev  wrote:
> Strange, i'm not receiving any buildbot emails again. Will look through bots
> manually next time, that doesn't sound too hard. Pushed a hotfix in r284969.

The buildmaster was restarted this weekend and got all old builds data wiped.

I only know because I have a monitoring page.

Galina,

Any info on the server migration and the email configuration?

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


[PATCH] D25475: [analyzer] Add a new SVal to support pointer-to-member operations.

2016-10-24 Thread Kirill Romanenkov via cfe-commits
kromanenkov added inline comments.



Comment at: lib/StaticAnalyzer/Core/ExprEngineC.cpp:462
+  case CK_ReinterpretMemberPointer: {
+const Expr *UOExpr = CastE->getSubExpr()->IgnoreParenCasts();
+assert(isa(UOExpr) &&

dcoughlin wrote:
> dcoughlin wrote:
> > dcoughlin wrote:
> > > I don't think pattern matching on the sub expression to find the 
> > > referred-to declaration is the right thing to do here. It isn't always 
> > > the case that the casted expression will be a unary pointer to member 
> > > operation. For example, this is perfectly fine and triggers an assertion 
> > > failure on your patch:
> > > 
> > > ```
> > > struct B {
> > >   int f;
> > > };
> > > 
> > > struct D : public B {
> > >   int g;
> > > };
> > > 
> > > void foo() {
> > >   D d;
> > >   d.f = 7;
> > > 
> > >   int B::* pfb = &B::f;
> > >   int D::* pfd = pfb;
> > >   int v = d.*pfd;
> > > }
> > > ```
> > > Note that you can't just propagate the value already computed for the 
> > > subexpression. Here is a particularly annoying example from the C++ spec:
> > > 
> > > ```
> > > struct B {
> > >   int f;
> > > };
> > > struct L : public B { };
> > > struct R : public B { };
> > > struct D : public L, R { };
> > > 
> > > void foo() {
> > >   D d;
> > > 
> > >   int B::* pb = &B::f;
> > >   int L::* pl = pb;
> > >   int R::* pr = pb;
> > > 
> > >   int D::* pdl = pl;
> > >   int D::* pdr = pr;
> > > 
> > >   clang_analyzer_eval(pdl == pdr); // FALSE
> > >   clang_analyzer_eval(pb == pl); // TRUE
> > > }
> > > ```
> > > My guess is this will require accumulating CXXBasePath s or something 
> > > similar for each cast. I don't know how to do this efficiently. 
> > > I don't know how to do this efficiently.
> > 
> > Jordan suggested storing this in a bump-pointer allocated object with a 
> > lifetime of the AnalysisDeclContext. The common case is no multiple 
> > inheritance, so that should be the fast case.
> > 
> > Maybe the Data could be a pointer union between a DeclaratorDecl and an 
> > immutable linked list (with sharing) of CXXBaseSpecifiers from the 
> > CastExprs in the AST. The storage for this could be managed with a new 
> > manager in SValBuilder.
> (The bump pointer-allocated thing would have to have the Decl as well.)
> 
> This could also probably live in BasicValueFactory. The extra data would be 
> similar to LazyCompoundValData.
My understanding is that PointerToMember SVal should be represented similar to 
LazyCompoundVal SVal. If I got you right, PointerToMember SVal should be 
constructed  in VisitUnaryOperator and  VisitCast 
(CK_BaseToDerivedMemberPointer and so on) just add CXXBaseSpecifiers to this 
SVal?
What do you mean by sharing of immutable linked list?


https://reviews.llvm.org/D25475



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


[PATCH] D25402: [Driver] Pass -lunwind when using libc++ + compiler-rt on Linux

2016-10-24 Thread Jonas Hahnfeld via cfe-commits
Hahnfeld added inline comments.



Comment at: lib/Driver/ToolChains.cpp:4704
+  GetRuntimeLibType(Args) == ToolChain::RLT_CompilerRT)
+CmdArgs.push_back("-lunwind");
+}

mgorny wrote:
> Hahnfeld wrote:
> > mgorny wrote:
> > > Hahnfeld wrote:
> > > > As just written in D25008: This will probably result in problems if a 
> > > > system default `libunwind.so.8` is installed...
> > > I think this is the correct behavior in this case. Clang should work with 
> > > whichever unwinder implementation is available, and if you want to change 
> > > that, change the `libunwind.so` symlink.
> > > 
> > > However, I don't really think it's a good idea to have both unwinder 
> > > libraries installed alongside, especially that they are sharing the same 
> > > name.
> > No, we can't: The nongnu libunwind is used by other system libraries that 
> > need and are tested against this version.
> > 
> > It's certainly not a good idea, but it's reality in many distros. Most of 
> > them don't ship LLVM's libunwind.
> Well, IMO only sane solution to the problem is to have LLVM's libunwind 
> renamed. Otherwise, using the two libraries is going always to be an 
> unreliable, awful hackery with high risk that someone will accidentally end 
> up with wrong one or -- even worse -- both of them in the same executable.
Well, then the worse thing will happen with this patch if both libraries are 
installed...


https://reviews.llvm.org/D25402



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


[PATCH] D25008: [cmake] Split linked libraries into private & public, for linker script

2016-10-24 Thread Joerg Sonnenberger via cfe-commits
joerg added a comment.

So the historical reason for the libgcc_s dance for glibc was the use of 
unwinding for thread cancellation. With all the glibc versions I can find, 
going back to SLES11 SP1, this is no longer the case. To check for yourself, 
look for _Unwind* symbols in libc.so and libc.a. Only findfde seems to be 
exposed now.

As such, I think we can avoid all this complexity.


Repository:
  rL LLVM

https://reviews.llvm.org/D25008



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


Re: [clang-tools-extra] r284888 - Remove 'misc-pointer-and-integral-operation' clang-tidy check. The only cases

2016-10-24 Thread Alexander Kornienko via cfe-commits
Wait, I thought the check was mostly useful for C code, where it detects
real issues? Etienne, can you comment?

On Fri, Oct 21, 2016 at 11:50 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Fri Oct 21 16:50:28 2016
> New Revision: 284888
>
> URL: http://llvm.org/viewvc/llvm-project?rev=284888&view=rev
> Log:
> Remove 'misc-pointer-and-integral-operation' clang-tidy check. The only
> cases
> it detects are ill-formed (some per C++ core issue 1512, others always have
> been).
>
> Removed:
> clang-tools-extra/trunk/clang-tidy/misc/PointerAndIntegralOperationChe
> ck.cpp
> clang-tools-extra/trunk/clang-tidy/misc/PointerAndIntegralOperationChe
> ck.h
> clang-tools-extra/trunk/docs/clang-tidy/checks/misc-
> pointer-and-integral-operation.rst
> clang-tools-extra/trunk/test/clang-tidy/misc-pointer-and-
> integral-operation-cxx98.cpp
> clang-tools-extra/trunk/test/clang-tidy/misc-pointer-and-
> integral-operation.cpp
> Modified:
> clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/Resources/
> ClangTidyChecks.yaml
> clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
> clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>
> Modified: clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/Resources/
> ClangTidyChecks.yaml
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy-vs/ClangTidy/Resources/ClangTidyChecks.
> yaml?rev=284888&r1=284887&r2=284888&view=diff
> 
> ==
> --- 
> clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/Resources/ClangTidyChecks.yaml
> (original)
> +++ 
> clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/Resources/ClangTidyChecks.yaml
> Fri Oct 21 16:50:28 2016
> @@ -239,10 +239,6 @@ Checks:
>  Description:
>  Name:misc-non-copyable-objects
>- Category:Miscellaneous
> -Label:   Suspicious pointer / integer operations
> -Description:
> -Name:misc-pointer-and-integral-operation
> -  - Category:Miscellaneous
>  Label:   Find redundant expressions
>  Description:
>  Name:misc-redundant-expression
>
> Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/misc/CMakeLists.txt?rev=284888&r1=
> 284887&r2=284888&view=diff
> 
> ==
> --- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
> +++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Fri Oct 21
> 16:50:28 2016
> @@ -24,7 +24,6 @@ add_clang_library(clangTidyMiscModule
>NewDeleteOverloadsCheck.cpp
>NoexceptMoveConstructorCheck.cpp
>NonCopyableObjects.cpp
> -  PointerAndIntegralOperationCheck.cpp
>RedundantExpressionCheck.cpp
>SizeofContainerCheck.cpp
>SizeofExpressionCheck.cpp
>
> Modified: clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/misc/MiscTidyModule.cpp?rev=284888&
> r1=284887&r2=284888&view=diff
> 
> ==
> --- clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp (original)
> +++ clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp Fri Oct 21
> 16:50:28 2016
> @@ -32,7 +32,6 @@
>  #include "NewDeleteOverloadsCheck.h"
>  #include "NoexceptMoveConstructorCheck.h"
>  #include "NonCopyableObjects.h"
> -#include "PointerAndIntegralOperationCheck.h"
>  #include "RedundantExpressionCheck.h"
>  #include "SizeofContainerCheck.h"
>  #include "SizeofExpressionCheck.h"
> @@ -104,8 +103,6 @@ public:
>  "misc-noexcept-move-constructor");
>  CheckFactories.registerCheck(
>  "misc-non-copyable-objects");
> -CheckFactories.registerCheck(
> -"misc-pointer-and-integral-operation");
>  CheckFactories.registerCheck(
>  "misc-redundant-expression");
>  CheckFactories.registerCheck("misc-
> sizeof-container");
>
> Removed: clang-tools-extra/trunk/clang-tidy/misc/
> PointerAndIntegralOperationCheck.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/misc/PointerAndIntegralOperationChe
> ck.cpp?rev=284887&view=auto
> 
> ==
> --- 
> clang-tools-extra/trunk/clang-tidy/misc/PointerAndIntegralOperationCheck.cpp
> (original)
> +++ 
> clang-tools-extra/trunk/clang-tidy/misc/PointerAndIntegralOperationCheck.cpp
> (removed)
> @@ -1,104 +0,0 @@
> -//===--- PointerAndIntegralOperationCheck.cpp -
> clang-tidy-===//
> -//
> -// The LLVM Compiler Infrastructure
> -//
> -// This file is distributed under the University of Illinois Open Source
> -// License. See LICENSE.TXT for details.
> -//

[PATCH] D25731: [analyzer] NumberObjectConversion: Support OSNumber and CFNumberRef.

2016-10-24 Thread Artem Dergachev via cfe-commits
NoQ updated this revision to Diff 75586.
NoQ marked an inline comment as done.
NoQ added a comment.

- Update warning messages. I think it's better to pattern-match for integer 
sizes after all when we're suggesting API, this especially looks ugly for 
OSNumber (which is rare).
- Add tests for converting `CFNumberRef` into `intptr_t`.
- An unrelated change: Move casts to bools to non-pedantic mode (i mistakenly 
thought this check is loud).


https://reviews.llvm.org/D25731

Files:
  lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
  test/Analysis/number-object-conversion.c
  test/Analysis/number-object-conversion.cpp
  test/Analysis/number-object-conversion.m

Index: test/Analysis/number-object-conversion.m
===
--- test/Analysis/number-object-conversion.m
+++ test/Analysis/number-object-conversion.m
@@ -10,30 +10,35 @@
 
 void bad(NSNumber *p) {
 #ifdef PEDANTIC
-  if (p) {} // expected-warning{{Converting 'NSNumber *' to a plain boolean value for branching; please compare the pointer to nil instead to suppress this warning}}
-  if (!p) {} // expected-warning{{Converting 'NSNumber *' to a plain boolean value for branching; please compare the pointer to nil instead to suppress this warning}}
-  (!p) ? 1 : 2; // expected-warning{{Converting 'NSNumber *' to a plain boolean value for branching; please compare the pointer to nil instead to suppress this warning}}
-  (BOOL)p; // expected-warning{{Converting 'NSNumber *' to a plain BOOL value; please compare the pointer to nil instead to suppress this warning}}
-  if (p == 0) {} // expected-warning{{Converting 'NSNumber *' to a plain integer value; please compare the pointer to nil instead to suppress this warning}}
-  if (p > 0) {} // expected-warning{{Converting 'NSNumber *' to a plain integer value; pointer value is being used instead}}
+  if (p) {} // expected-warning{{Converting a pointer value of type 'NSNumber *' to a primitive boolean value; instead, either compare the pointer to nil or call -boolValue}}
+  if (!p) {} // expected-warning{{Converting a pointer value of type 'NSNumber *' to a primitive boolean value; instead, either compare the pointer to nil or call -boolValue}}
+  (!p) ? 1 : 2; // expected-warning{{Converting a pointer value of type 'NSNumber *' to a primitive boolean value; instead, either compare the pointer to nil or call -boolValue}}
+  if (p == 0) {} // expected-warning{{Comparing a pointer value of type 'NSNumber *' to a primitive integer value; instead, either compare the pointer to nil or compare the result of calling object API such as -intValue}}
+#else
+  if (p) {} // no-warning
+  if (!p) {} // no-warning
+  (!p) ? 1 : 2; // no-warning
+  if (p == 0) {} // no-warning
 #endif
-  if (p == YES) {} // expected-warning{{Converting 'NSNumber *' to a plain BOOL value; pointer value is being used instead}}
-  if (p == NO) {} // expected-warning{{Converting 'NSNumber *' to a plain BOOL value; pointer value is being used instead}}
-  BOOL x = p; // expected-warning{{Converting 'NSNumber *' to a plain BOOL value; pointer value is being used instead}}
-  x = p; // expected-warning{{Converting 'NSNumber *' to a plain BOOL value; pointer value is being used instead}}
-  x = (p == YES); // expected-warning{{Converting 'NSNumber *' to a plain BOOL value; pointer value is being used instead}}
-  if (p == 1) {} // expected-warning{{Converting 'NSNumber *' to a plain integer value; pointer value is being used instead}}
-  int y = p; // expected-warning{{Converting 'NSNumber *' to a plain integer value; pointer value is being used instead}}
-  y = p; // expected-warning{{Converting 'NSNumber *' to a plain integer value; pointer value is being used instead}}
-  takes_boolean(p); // expected-warning{{Converting 'NSNumber *' to a plain BOOL value; pointer value is being used instead}}
-  takes_integer(p); // expected-warning{{Converting 'NSNumber *' to a plain integer value; pointer value is being used instead}}
+  (BOOL)p; // expected-warning{{Converting a pointer value of type 'NSNumber *' to a primitive BOOL value; did you mean to call -boolValue?}}
+  if (p > 0) {} // expected-warning{{Comparing a pointer value of type 'NSNumber *' to a primitive integer value; did you mean to compare the result of calling object API such as -intValue?}}
+  if (p == YES) {} // expected-warning{{Comparing a pointer value of type 'NSNumber *' to a primitive BOOL value; did you mean to compare the result of calling -boolValue?}}
+  if (p == NO) {} // expected-warning{{Comparing a pointer value of type 'NSNumber *' to a primitive BOOL value; did you mean to compare the result of calling -boolValue?}}
+  BOOL x = p; // expected-warning{{Converting a pointer value of type 'NSNumber *' to a primitive BOOL value; did you mean to call -boolValue?}}
+  x = p; // expected-warning{{Converting a pointer value of type 'NSNumber *' to a primitive BOOL value; did you mean to call -boolValue?}}
+  x = 

[PATCH] D25893: [clang] Remove redundant --check-prefix=CHECK from tests

2016-10-24 Thread Hans Wennborg via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Looks good to me.


https://reviews.llvm.org/D25893



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


[PATCH] D25909: [analyzer] MacOSXApiChecker: Disallow dispatch_once predicates on heap and in ivars.

2016-10-24 Thread Artem Dergachev via cfe-commits
NoQ created this revision.
NoQ added reviewers: zaks.anna, dcoughlin.
NoQ added a subscriber: cfe-commits.

As documentation in 
https://developer.apple.com/reference/dispatch/dispatch_once_t says, only 
global or static variables should have type `dispatch_once_t`, otherwise the 
magic with fast memory barriers doesn't work, and using dispatch_once() would 
cause hard-to-catch errors.

There's already a check in `MacOSXApiChecker` that disallows stack variables 
here. The check is extended to warn upon heap and ivar predicates of type 
`dispatch_once_t`.

While ivars could have been handled on the AST level, heap variables could not.

Currently the analyzer core does not realize that all Objective-C objects 
always reside on the heap. I thought of stating that, say, any 
`SymbolRegionValue` of `ObjCObjectPointerType` type should produce a heap-based 
symbolic region. However, if i do this, it would no longer be true that 
different heap-based symbolic regions never alias. So a more complicated 
solution is necessary here. So for this checker i'm settling on the solution of 
"treat all ivars as heap regions in this checker".


https://reviews.llvm.org/D25909

Files:
  lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
  test/Analysis/dispatch-once.m


Index: test/Analysis/dispatch-once.m
===
--- /dev/null
+++ test/Analysis/dispatch-once.m
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -w -fblocks -analyze 
-analyzer-checker=core,osx.API,unix.Malloc -verify %s
+// RUN: %clang_cc1 -w -fblocks -fobjc-arc -analyze 
-analyzer-checker=core,osx.API,unix.Malloc -verify %s
+
+#include "Inputs/system-header-simulator-objc.h"
+
+typedef unsigned long size_t;
+void *calloc(size_t nmemb, size_t size);
+
+typedef void (^dispatch_block_t)(void);
+typedef long dispatch_once_t;
+void dispatch_once(dispatch_once_t *predicate, dispatch_block_t block);
+
+void test_stack() {
+  dispatch_once_t once;
+  dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' uses 
the local variable 'once' for the predicate value.}}
+}
+
+void test_static_local() {
+  static dispatch_once_t once;
+  dispatch_once(&once, ^{}); // no-warning
+}
+
+void test_heap_var() {
+  dispatch_once_t *once = calloc(1, sizeof(dispatch_once_t));
+  dispatch_once(once, ^{}); // expected-warning{{Call to 'dispatch_once' uses 
heap allocated memory for the predicate value.}}
+}
+
+void test_external_pointer(dispatch_once_t *once) {
+  // External pointer does not necessarily point to the heap.
+  dispatch_once(once, ^{}); // no-warning
+}
+
+typedef struct {
+  dispatch_once_t once;
+} Struct;
+
+void test_heap_struct() {
+  Struct *s = calloc(1, sizeof(Struct));
+  dispatch_once(&s->once, ^{}); // expected-warning{{Call to 'dispatch_once' 
uses heap allocated memory for the predicate value.}}
+}
+
+@interface Object : NSObject {
+@public
+  dispatch_once_t once;
+}
+- (void)test_ivar_from_inside;
+@end
+
+@implementation Object
+- (void)test_ivar_from_inside {
+  dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' uses 
the instance variable 'once' for the predicate value.}}
+}
+@end
+
+void test_ivar_from_alloc_init() {
+  Object *o = [[Object alloc] init];
+  dispatch_once(&o->once, ^{}); // expected-warning{{Call to 'dispatch_once' 
uses the instance variable 'once' for the predicate value.}}
+}
+
+void test_ivar_from_external_obj(Object *o) {
+  // ObjC object pointer always points to the heap.
+  dispatch_once(&o->once, ^{}); // expected-warning{{Call to 'dispatch_once' 
uses the instance variable 'once' for the predicate value.}}
+}
Index: lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
@@ -59,7 +59,8 @@
   ProgramStateRef state = C.getState();
   const MemRegion *R =
 state->getSVal(CE->getArg(0), C.getLocationContext()).getAsRegion();
-  if (!R || !isa(R->getMemorySpace()))
+  const MemSpaceRegion *RS = R->getMemorySpace();
+  if (!R || isa(RS))
 return;
 
   ExplodedNode *N = C.generateErrorNode(state);
@@ -85,7 +86,16 @@
   os << "Call to '" << FName << "' uses";
   if (const VarRegion *VR = dyn_cast(R))
 os << " the local variable '" << VR->getDecl()->getName() << '\'';
-  else
+  else if (const ObjCIvarRegion *IVR = dyn_cast(R))
+os << " the instance variable '" << IVR->getDecl()->getName() << '\'';
+  else if (isa(R->getMemorySpace()))
+os << " heap allocated memory";
+  else if (isa(R->getMemorySpace())) {
+// FIXME: Presence of an IVar region has priority over this branch, because
+// ObjC objects are on the heap even if the core doesn't realize this.
+// Make core realize that all ObjC objects are on the heap.
+return;
+  } else
 os << " stack allocated memory";
   os << " for the predicate value.  Using such transient memory for "
 "the pr

[PATCH] D25909: [analyzer] MacOSXApiChecker: Disallow dispatch_once predicates on heap and in ivars.

2016-10-24 Thread Artem Dergachev via cfe-commits
NoQ updated this revision to Diff 75589.
NoQ added a comment.

Hotfix code duplication i just noticed.


https://reviews.llvm.org/D25909

Files:
  lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
  test/Analysis/dispatch-once.m


Index: test/Analysis/dispatch-once.m
===
--- /dev/null
+++ test/Analysis/dispatch-once.m
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -w -fblocks -analyze 
-analyzer-checker=core,osx.API,unix.Malloc -verify %s
+// RUN: %clang_cc1 -w -fblocks -fobjc-arc -analyze 
-analyzer-checker=core,osx.API,unix.Malloc -verify %s
+
+#include "Inputs/system-header-simulator-objc.h"
+
+typedef unsigned long size_t;
+void *calloc(size_t nmemb, size_t size);
+
+typedef void (^dispatch_block_t)(void);
+typedef long dispatch_once_t;
+void dispatch_once(dispatch_once_t *predicate, dispatch_block_t block);
+
+void test_stack() {
+  dispatch_once_t once;
+  dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' uses 
the local variable 'once' for the predicate value.}}
+}
+
+void test_static_local() {
+  static dispatch_once_t once;
+  dispatch_once(&once, ^{}); // no-warning
+}
+
+void test_heap_var() {
+  dispatch_once_t *once = calloc(1, sizeof(dispatch_once_t));
+  dispatch_once(once, ^{}); // expected-warning{{Call to 'dispatch_once' uses 
heap allocated memory for the predicate value.}}
+}
+
+void test_external_pointer(dispatch_once_t *once) {
+  // External pointer does not necessarily point to the heap.
+  dispatch_once(once, ^{}); // no-warning
+}
+
+typedef struct {
+  dispatch_once_t once;
+} Struct;
+
+void test_heap_struct() {
+  Struct *s = calloc(1, sizeof(Struct));
+  dispatch_once(&s->once, ^{}); // expected-warning{{Call to 'dispatch_once' 
uses heap allocated memory for the predicate value.}}
+}
+
+@interface Object : NSObject {
+@public
+  dispatch_once_t once;
+}
+- (void)test_ivar_from_inside;
+@end
+
+@implementation Object
+- (void)test_ivar_from_inside {
+  dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' uses 
the instance variable 'once' for the predicate value.}}
+}
+@end
+
+void test_ivar_from_alloc_init() {
+  Object *o = [[Object alloc] init];
+  dispatch_once(&o->once, ^{}); // expected-warning{{Call to 'dispatch_once' 
uses the instance variable 'once' for the predicate value.}}
+}
+
+void test_ivar_from_external_obj(Object *o) {
+  // ObjC object pointer always points to the heap.
+  dispatch_once(&o->once, ^{}); // expected-warning{{Call to 'dispatch_once' 
uses the instance variable 'once' for the predicate value.}}
+}
Index: lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
@@ -59,7 +59,8 @@
   ProgramStateRef state = C.getState();
   const MemRegion *R =
 state->getSVal(CE->getArg(0), C.getLocationContext()).getAsRegion();
-  if (!R || !isa(R->getMemorySpace()))
+  const MemSpaceRegion *RS = R->getMemorySpace();
+  if (!R || isa(RS))
 return;
 
   ExplodedNode *N = C.generateErrorNode(state);
@@ -85,7 +86,16 @@
   os << "Call to '" << FName << "' uses";
   if (const VarRegion *VR = dyn_cast(R))
 os << " the local variable '" << VR->getDecl()->getName() << '\'';
-  else
+  else if (const ObjCIvarRegion *IVR = dyn_cast(R))
+os << " the instance variable '" << IVR->getDecl()->getName() << '\'';
+  else if (isa(RS))
+os << " heap allocated memory";
+  else if (isa(RS)) {
+// FIXME: Presence of an IVar region has priority over this branch, because
+// ObjC objects are on the heap even if the core doesn't realize this.
+// Make core realize that all ObjC objects are on the heap.
+return;
+  } else
 os << " stack allocated memory";
   os << " for the predicate value.  Using such transient memory for "
 "the predicate is potentially dangerous.";


Index: test/Analysis/dispatch-once.m
===
--- /dev/null
+++ test/Analysis/dispatch-once.m
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -w -fblocks -analyze -analyzer-checker=core,osx.API,unix.Malloc -verify %s
+// RUN: %clang_cc1 -w -fblocks -fobjc-arc -analyze -analyzer-checker=core,osx.API,unix.Malloc -verify %s
+
+#include "Inputs/system-header-simulator-objc.h"
+
+typedef unsigned long size_t;
+void *calloc(size_t nmemb, size_t size);
+
+typedef void (^dispatch_block_t)(void);
+typedef long dispatch_once_t;
+void dispatch_once(dispatch_once_t *predicate, dispatch_block_t block);
+
+void test_stack() {
+  dispatch_once_t once;
+  dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the local variable 'once' for the predicate value.}}
+}
+
+void test_static_local() {
+  static dispatch_once_t once;
+  dispatch_once(&once, ^{}); // no-warning
+}
+
+void test_heap_var() {
+  dispatch_once_t *once = calloc(1, sizeof(dispatch_once_t));
+  dispat

[PATCH] D25888: Add support for __builtin_os_log_format[_buffer_size]

2016-10-24 Thread Mehdi AMINI via cfe-commits
mehdi_amini added a comment.

Thanks!
For the API part, this is already in production ( 
https://github.com/apple/swift-clang/blob/stable/lib/CodeGen/CGBuiltin.cpp#L2071
 ), so it should be OK!


https://reviews.llvm.org/D25888



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


[PATCH] D25911: [clang-move] Support moving template class forward declarations.

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

[clang-tidy] Don't warn implicit variables in 
peformance-unnecessary-copy-initialization.

This will prevent the check warning the variables which have been
implicitly added by compiler, like the following case (in for-range loop):

  the variable '__end' is copy-constructed from a const reference...


https://reviews.llvm.org/D25911

Files:
  clang-move/ClangMove.cpp
  clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  test/clang-tidy/performance-unnecessary-copy-initialization.cpp
  unittests/clang-move/ClangMoveTests.cpp


Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -30,6 +30,7 @@
 
 const char TestHeader[] = "namespace a {\n"
   "class C1; // test\n"
+  "template  class C2;\n"
   "namespace b {\n"
   "// This is a Foo class\n"
   "// which is used in\n"
@@ -87,6 +88,7 @@
 
 const char ExpectedTestHeader[] = "namespace a {\n"
   "class C1; // test\n"
+  "template  class C2;\n"
   "namespace b {\n"
   "\n"
   "class Foo2 {\n"
@@ -127,6 +129,7 @@
  "#define NEW_FOO_H\n"
  "namespace a {\n"
  "class C1; // test\n"
+ "template  class C2;\n"
  "namespace b {\n"
  "// This is a Foo class\n"
  "// which is used in\n"
Index: test/clang-tidy/performance-unnecessary-copy-initialization.cpp
===
--- test/clang-tidy/performance-unnecessary-copy-initialization.cpp
+++ test/clang-tidy/performance-unnecessary-copy-initialization.cpp
@@ -368,3 +368,22 @@
   // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy' of the 
variable 'orig' is never modified; consider avoiding the copy 
[performance-unnecessary-copy-initialization]
   // CHECK-FIXES: ExpensiveToCopyType copy = orig, copy2;
 }
+
+class Element {};
+class Container {
+public:
+  class Iterator {
+  public:
+void operator++();
+Element operator*();
+bool operator!=(const Iterator &);
+WeirdCopyCtorType c;
+  };
+  const Iterator &begin() const;
+  const Iterator &end() const;
+};
+
+void implicitVarFalsePositive() {
+  for (const Element &E : Container()) {
+  }
+}
Index: clang-tidy/performance/UnnecessaryCopyInitialization.cpp
===
--- clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -57,6 +57,7 @@
declStmt(
has(varDecl(hasLocalStorage(),
hasType(matchers::isExpensiveToCopy()),
+   unless(isImplicit()),
hasInitializer(
cxxConstructExpr(
hasDeclaration(cxxConstructorDecl(
Index: clang-move/ClangMove.cpp
===
--- clang-move/ClangMove.cpp
+++ clang-move/ClangMove.cpp
@@ -406,8 +406,13 @@
   } else if (const auto *FWD =
  Result.Nodes.getNodeAs("fwd_decl")) {
 // Skip all forwad declarations which appear after moved class declaration.
-if (RemovedDecls.empty())
-  MovedDecls.emplace_back(FWD, &Result.Context->getSourceManager());
+if (RemovedDecls.empty()) {
+  if (const auto *DCT = FWD->getDescribedClassTemplate()) {
+MovedDecls.emplace_back(DCT, &Result.Context->getSourceManager());
+  } else {
+MovedDecls.emplace_back(FWD, &Result.Context->getSourceManager());
+  }
+}
   } else if (const auto *ANS = Result.Nodes.getNodeAs(
  "anonymous_ns")) {
 MovedDecls.emplace_back(ANS, &Result.Context->getSourceManager());


Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -30,6 +30,7 @@
 
 const char TestHeader[] = "namespace a {\n"
   "class C1; // test\n"
+  "template  class C2;\n"
   "namespace b {\n"
   "// This is a Foo class\n"
   "// which is used in\n"
@@ -87,6 +88,7 @@
 
 const char ExpectedTestHeader[] = "namespace a {\n"
 

[PATCH] D25911: [clang-move] Support moving template class forward declarations.

2016-10-24 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 75595.
hokein added a comment.

Don't mess up with other patches.


https://reviews.llvm.org/D25911

Files:
  clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  test/clang-tidy/performance-unnecessary-copy-initialization.cpp


Index: test/clang-tidy/performance-unnecessary-copy-initialization.cpp
===
--- test/clang-tidy/performance-unnecessary-copy-initialization.cpp
+++ test/clang-tidy/performance-unnecessary-copy-initialization.cpp
@@ -368,3 +368,22 @@
   // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy' of the 
variable 'orig' is never modified; consider avoiding the copy 
[performance-unnecessary-copy-initialization]
   // CHECK-FIXES: ExpensiveToCopyType copy = orig, copy2;
 }
+
+class Element {};
+class Container {
+public:
+  class Iterator {
+  public:
+void operator++();
+Element operator*();
+bool operator!=(const Iterator &);
+WeirdCopyCtorType c;
+  };
+  const Iterator &begin() const;
+  const Iterator &end() const;
+};
+
+void implicitVarFalsePositive() {
+  for (const Element &E : Container()) {
+  }
+}
Index: clang-tidy/performance/UnnecessaryCopyInitialization.cpp
===
--- clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -57,6 +57,7 @@
declStmt(
has(varDecl(hasLocalStorage(),
hasType(matchers::isExpensiveToCopy()),
+   unless(isImplicit()),
hasInitializer(
cxxConstructExpr(
hasDeclaration(cxxConstructorDecl(


Index: test/clang-tidy/performance-unnecessary-copy-initialization.cpp
===
--- test/clang-tidy/performance-unnecessary-copy-initialization.cpp
+++ test/clang-tidy/performance-unnecessary-copy-initialization.cpp
@@ -368,3 +368,22 @@
   // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy' of the variable 'orig' is never modified; consider avoiding the copy [performance-unnecessary-copy-initialization]
   // CHECK-FIXES: ExpensiveToCopyType copy = orig, copy2;
 }
+
+class Element {};
+class Container {
+public:
+  class Iterator {
+  public:
+void operator++();
+Element operator*();
+bool operator!=(const Iterator &);
+WeirdCopyCtorType c;
+  };
+  const Iterator &begin() const;
+  const Iterator &end() const;
+};
+
+void implicitVarFalsePositive() {
+  for (const Element &E : Container()) {
+  }
+}
Index: clang-tidy/performance/UnnecessaryCopyInitialization.cpp
===
--- clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -57,6 +57,7 @@
declStmt(
has(varDecl(hasLocalStorage(),
hasType(matchers::isExpensiveToCopy()),
+   unless(isImplicit()),
hasInitializer(
cxxConstructExpr(
hasDeclaration(cxxConstructorDecl(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25475: [analyzer] Add a new SVal to support pointer-to-member operations.

2016-10-24 Thread Devin Coughlin via cfe-commits
dcoughlin added inline comments.



Comment at: lib/StaticAnalyzer/Core/ExprEngineC.cpp:462
+  case CK_ReinterpretMemberPointer: {
+const Expr *UOExpr = CastE->getSubExpr()->IgnoreParenCasts();
+assert(isa(UOExpr) &&

kromanenkov wrote:
> dcoughlin wrote:
> > dcoughlin wrote:
> > > dcoughlin wrote:
> > > > I don't think pattern matching on the sub expression to find the 
> > > > referred-to declaration is the right thing to do here. It isn't always 
> > > > the case that the casted expression will be a unary pointer to member 
> > > > operation. For example, this is perfectly fine and triggers an 
> > > > assertion failure on your patch:
> > > > 
> > > > ```
> > > > struct B {
> > > >   int f;
> > > > };
> > > > 
> > > > struct D : public B {
> > > >   int g;
> > > > };
> > > > 
> > > > void foo() {
> > > >   D d;
> > > >   d.f = 7;
> > > > 
> > > >   int B::* pfb = &B::f;
> > > >   int D::* pfd = pfb;
> > > >   int v = d.*pfd;
> > > > }
> > > > ```
> > > > Note that you can't just propagate the value already computed for the 
> > > > subexpression. Here is a particularly annoying example from the C++ 
> > > > spec:
> > > > 
> > > > ```
> > > > struct B {
> > > >   int f;
> > > > };
> > > > struct L : public B { };
> > > > struct R : public B { };
> > > > struct D : public L, R { };
> > > > 
> > > > void foo() {
> > > >   D d;
> > > > 
> > > >   int B::* pb = &B::f;
> > > >   int L::* pl = pb;
> > > >   int R::* pr = pb;
> > > > 
> > > >   int D::* pdl = pl;
> > > >   int D::* pdr = pr;
> > > > 
> > > >   clang_analyzer_eval(pdl == pdr); // FALSE
> > > >   clang_analyzer_eval(pb == pl); // TRUE
> > > > }
> > > > ```
> > > > My guess is this will require accumulating CXXBasePath s or something 
> > > > similar for each cast. I don't know how to do this efficiently. 
> > > > I don't know how to do this efficiently.
> > > 
> > > Jordan suggested storing this in a bump-pointer allocated object with a 
> > > lifetime of the AnalysisDeclContext. The common case is no multiple 
> > > inheritance, so that should be the fast case.
> > > 
> > > Maybe the Data could be a pointer union between a DeclaratorDecl and an 
> > > immutable linked list (with sharing) of CXXBaseSpecifiers from the 
> > > CastExprs in the AST. The storage for this could be managed with a new 
> > > manager in SValBuilder.
> > (The bump pointer-allocated thing would have to have the Decl as well.)
> > 
> > This could also probably live in BasicValueFactory. The extra data would be 
> > similar to LazyCompoundValData.
> My understanding is that PointerToMember SVal should be represented similar 
> to LazyCompoundVal SVal. If I got you right, PointerToMember SVal should be 
> constructed  in VisitUnaryOperator and  VisitCast 
> (CK_BaseToDerivedMemberPointer and so on) just add CXXBaseSpecifiers to this 
> SVal?
> What do you mean by sharing of immutable linked list?
SVal has very strict size limitations -- you can only store a single pointer 
for its Data. Since you'll need to have multiple CXXBaseSpecifiers in a single 
SVal (for example, consider a multiple inheritance hierarchy with a double 
diamond), the storage for this container will have to live elsewhere.

One way to do this is to bump-pointer allocate linked list nodes for the "path" 
of casts that the value has taken. If you do this then you can share the memory 
for the nodes for a shared path prefix for two paths with a common prefix.


https://reviews.llvm.org/D25475



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


r284988 - Fix clang-format vim integration issue with non-ascii characters

2016-10-24 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon Oct 24 11:31:26 2016
New Revision: 284988

URL: http://llvm.org/viewvc/llvm-project?rev=284988&view=rev
Log:
Fix clang-format vim integration issue with non-ascii characters

clang-format.py currently seems to treat vim.current.buf as ascii-encoded data,
which leads to an UnicodeDecodeError when trying to format any text containing
non-ascii characters:

Traceback (most recent call last):
  File "", line 1, in 
  File ".../tools/clang/tools/clang-format/clang-format.py", line 110, in 

main()
  File ".../tools/clang/tools/clang-format/clang-format.py", line 87, in main
stdout, stderr = p.communicate(input=text.encode(encoding))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 3996: 
ordinal not in range(128)

Modified:
cfe/trunk/tools/clang-format/clang-format.py

Modified: cfe/trunk/tools/clang-format/clang-format.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format.py?rev=284988&r1=284987&r2=284988&view=diff
==
--- cfe/trunk/tools/clang-format/clang-format.py (original)
+++ cfe/trunk/tools/clang-format/clang-format.py Mon Oct 24 11:31:26 2016
@@ -52,7 +52,7 @@ def main():
   # Get the current text.
   encoding = vim.eval("&encoding")
   buf = vim.current.buffer
-  text = '\n'.join(buf)
+  text = unicode('\n'.join(buf), encoding)
 
   # Determine range to format.
   if vim.eval('exists("l:lines")') == '1':


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


RE: [PATCH] D25343: [OpenCL] Mark group functions as convergent in opencl-c.h

2016-10-24 Thread Anastasia Stulova via cfe-commits
Hi Ettore,

As far as I understand the whole problem is that the optimized functions are 
marked by __attribute__((pure)). If the attribute is removed from your example, 
we get LLVM dump preserving correctness:

define i32 @bar(i32 %x) local_unnamed_addr #0 {
entry:
  %call = tail call i32 @foo() #2
  %tobool = icmp eq i32 %x, 0
  %.call = select i1 %tobool, i32 0, i32 %call
  ret i32 %.call
}

Because by default a function without a definition is considered to have side 
effects. If a function has definition at some point and either it's mapped to 
llvm intrintic with convergent attribute or it calls an intrinsic with a 
convergent attribute in LLVM then LLVM should make sure not to perform any 
illegal optimisation. I am not an expert in LLVM however. @Tom or anyone else 
experienced, would you be able to comment whether this is the case?

However, if I understand it well that the motivation for adding the convergent 
attribute to Clang could be to allow some functions (which now have to be 
considered side effect functions) to be better optimised by marking them as 
convergent instead of leaving as side effect? Convergent functions can be 
optimised within its BB as soon as CFG equivalence is preserved for the whole 
caller function.

Appending convergent attribute to every function in Clang CodeGen seems overly 
conservative and can prevent many optimisation. I am not sure how good is that 
LLVM pass removing the attribute. Surely removing the attribute will be 
difficult for the functions with definitions in separate compilation units. Do 
we have a good case for adding the convergent attribute to the frontend now?

I am not sure we have a use case for the noduplicate as well. To me it seems 
that CFG equivalence sematic of convergent attribute would cover noduplicate 
use cases too.

Cheers,
Anastasia

-Original Message-
From: Liu, Yaxun (Sam) [mailto:yaxun@amd.com] 
Sent: 20 October 2016 17:59
To: Ettore Speziale; reviews+d25343+public+a10e9553b0fc8...@reviews.llvm.org
Cc: alexey.ba...@intel.com; Anastasia Stulova; aaron.ball...@gmail.com; Clang 
Commits; Sumner, Brian; Stellard, Thomas; Arsenault, Matthew
Subject: RE: [PATCH] D25343: [OpenCL] Mark group functions as convergent in 
opencl-c.h

+ Tom Matt

Thanks Ettore.
 
I think OpenCL is subject to the same issue, and noduplicate does not help 
either.

Basically if a function A directly or indirectly calls a convergent function 
e.g. barrier, function A itself must also be marked as convergent, otherwise 
optimization passes may transform a convergent call of A into multiple 
divergent calls of A.

That means if we only know the declaration of a function, we have to assume it 
is convergent since in its body it may call a convergent function.

I think probably OpenCL should take the same approach, i.e., mark all functions 
as convergent, then let Transforms/IPO/FunctionAttrs.cpp to remove unnecessary 
convergent attribute.

Sam

-Original Message-
From: Ettore Speziale [mailto:speziale.ett...@gmail.com] 
Sent: Thursday, October 20, 2016 11:42 AM
To: reviews+d25343+public+a10e9553b0fc8...@reviews.llvm.org; Liu, Yaxun (Sam) 

Cc: Ettore Speziale ; alexey.ba...@intel.com; 
anastasia.stul...@arm.com; aaron.ball...@gmail.com; Clang Commits 
; Sumner, Brian 
Subject: Re: [PATCH] D25343: [OpenCL] Mark group functions as convergent in 
opencl-c.h

Hello guys,

>> Should we deprecate noduplicate then as convergent should cover both use 
>> cases for OpenCL I believe? As far as I understand noduplicate was added 
>> specifically for SPMD use cases...
> 
> noduplicate has different semantics than convergent. Although it is proposed 
> for SPMD originally, it could be used by non-SPMD programs to forbid 
> duplicate of functions. There may be applications using this attribute.
> 
> I would suggest to leave this question for future. Probably ask llvm-dev 
> first since the attribute is also in LLVM.

I just want to clarify why I withdraw the convergent patch I initially 
submitted some time ago. It has a problem when dealing with multiple modules. 
Consider the following example:

int foo(void) __attribute__((pure));

int bar(int x) {
  int y = foo();
  if (x)
return y;
  return 0;
}   

I’ve just marked foo with the pure attribute to mark the function readonly in 
LLVM IR. Given that IR, the IR sinking pass pushes the foo call site into the 
then branch:

; Function Attrs: nounwind readonly ssp uwtable define i32 @bar(i32) #0 {
  %2 = icmp eq i32 %0, 0
  br i1 %2, label %5, label %3

; :3   ; preds = %1
  %4 = tail call i32 @foo() #2
  br label %5

; :5   ; preds = %1, %3
  %6 = phi i32 [ %4, %3 ], [ 0, %1 ]
  ret i32 %6
}

; Function Attrs: nounwind readonly
declare i32 @foo() #1

This is kind of dangerous, as we do not know what is inside foo — i.e. it might 
contains a convergent call.

If I understand correctly, the CUDA guys solved the problem in two steps. 

[PATCH] D25909: [analyzer] MacOSXApiChecker: Disallow dispatch_once predicates on heap and in ivars.

2016-10-24 Thread Devin Coughlin via cfe-commits
dcoughlin added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp:92
+  else if (isa(RS))
+os << " heap allocated memory";
+  else if (isa(RS)) {

"heap allocated" --> "heap-allocated"



Comment at: lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp:94
+  else if (isa(RS)) {
+// FIXME: Presence of an IVar region has priority over this branch, because
+// ObjC objects are on the heap even if the core doesn't realize this.

It is not clear to me that this FIXME is a good idea. I would remove it so 
someone doesn't spend a lot of time trying to address it.

Objective-C objects don't have the strong dis-aliasing guarantee that the 
analyzer assumes for heap base regions. In other words, two calls to [[Foo 
alloc] init] may yield exactly the same instance.  This is because, unlike 
malloc() and C++ global new, ObjC initializers can (and frequently do) return 
instances other than the passed-in, freshly-allocated self.



Comment at: test/Analysis/dispatch-once.m:13
+
+void test_stack() {
+  dispatch_once_t once;

Should the tests for dispatch_once in unix-fns.c be moved here?



Comment at: test/Analysis/dispatch-once.m:15
+  dispatch_once_t once;
+  dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' uses 
the local variable 'once' for the predicate value.}}
+}

I think it would be good to include the full diagnostic text for the stack 
local variable case because there is control flow in its construction.


https://reviews.llvm.org/D25909



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


[PATCH] D25888: Add support for __builtin_os_log_format[_buffer_size]

2016-10-24 Thread Mehdi AMINI via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284990: Add support for 
__builtin_os_log_format[_buffer_size] (authored by mehdi_amini).

Changed prior to commit:
  https://reviews.llvm.org/D25888?vs=75552&id=75608#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25888

Files:
  cfe/trunk/include/clang/Analysis/Analyses/FormatString.h
  cfe/trunk/include/clang/Analysis/Analyses/OSLog.h
  cfe/trunk/include/clang/Basic/Builtins.def
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Analysis/CMakeLists.txt
  cfe/trunk/lib/Analysis/FormatString.cpp
  cfe/trunk/lib/Analysis/OSLog.cpp
  cfe/trunk/lib/Analysis/PrintfFormatString.cpp
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/CodeGen/builtins.c
  cfe/trunk/test/CodeGenObjC/os_log.m
  cfe/trunk/test/SemaObjC/format-strings-oslog.m

Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -2804,20 +2804,21 @@
 /// types.
 static FormatAttrKind getFormatAttrKind(StringRef Format) {
   return llvm::StringSwitch(Format)
-// Check for formats that get handled specially.
-.Case("NSString", NSStringFormat)
-.Case("CFString", CFStringFormat)
-.Case("strftime", StrftimeFormat)
-
-// Otherwise, check for supported formats.
-.Cases("scanf", "printf", "printf0", "strfmon", SupportedFormat)
-.Cases("cmn_err", "vcmn_err", "zcmn_err", SupportedFormat)
-.Case("kprintf", SupportedFormat) // OpenBSD.
-.Case("freebsd_kprintf", SupportedFormat) // FreeBSD.
-.Case("os_trace", SupportedFormat)
+  // Check for formats that get handled specially.
+  .Case("NSString", NSStringFormat)
+  .Case("CFString", CFStringFormat)
+  .Case("strftime", StrftimeFormat)
+
+  // Otherwise, check for supported formats.
+  .Cases("scanf", "printf", "printf0", "strfmon", SupportedFormat)
+  .Cases("cmn_err", "vcmn_err", "zcmn_err", SupportedFormat)
+  .Case("kprintf", SupportedFormat) // OpenBSD.
+  .Case("freebsd_kprintf", SupportedFormat) // FreeBSD.
+  .Case("os_trace", SupportedFormat)
+  .Case("os_log", SupportedFormat)
 
-.Cases("gcc_diag", "gcc_cdiag", "gcc_cxxdiag", "gcc_tdiag", IgnoredFormat)
-.Default(InvalidFormat);
+  .Cases("gcc_diag", "gcc_cdiag", "gcc_cxxdiag", "gcc_tdiag", IgnoredFormat)
+  .Default(InvalidFormat);
 }
 
 /// Handle __attribute__((init_priority(priority))) attributes based on
Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -1065,6 +1065,12 @@
   case Builtin::BIget_kernel_preferred_work_group_size_multiple:
 if (SemaOpenCLBuiltinKernelWorkGroupSize(*this, TheCall))
   return ExprError();
+  case Builtin::BI__builtin_os_log_format:
+  case Builtin::BI__builtin_os_log_format_buffer_size:
+if (SemaBuiltinOSLogFormat(TheCall)) {
+  return ExprError();
+}
+break;
   }
 
   // Since the target specific builtins for each arch overlap, only check those
@@ -3478,6 +3484,31 @@
   return false;
 }
 
+/// CheckObjCString - Checks that the format string argument to the os_log()
+/// and os_trace() functions is correct, and converts it to const char *.
+ExprResult Sema::CheckOSLogFormatStringArg(Expr *Arg) {
+  Arg = Arg->IgnoreParenCasts();
+  auto *Literal = dyn_cast(Arg);
+  if (!Literal) {
+if (auto *ObjcLiteral = dyn_cast(Arg)) {
+  Literal = ObjcLiteral->getString();
+}
+  }
+
+  if (!Literal || (!Literal->isAscii() && !Literal->isUTF8())) {
+return ExprError(
+Diag(Arg->getLocStart(), diag::err_os_log_format_not_string_constant)
+<< Arg->getSourceRange());
+  }
+
+  ExprResult Result(Literal);
+  QualType ResultTy = Context.getPointerType(Context.CharTy.withConst());
+  InitializedEntity Entity =
+  InitializedEntity::InitializeParameter(Context, ResultTy, false);
+  Result = PerformCopyInitialization(Entity, SourceLocation(), Result);
+  return Result;
+}
+
 /// Check the arguments to '__builtin_va_start' or '__builtin_ms_va_start'
 /// for validity.  Emit an error and return true on failure; return false
 /// on success.
@@ -3939,6 +3970,86 @@
   return false;
 }
 
+bool Sema::SemaBuiltinOSLogFormat(CallExpr *TheCall) {
+  unsigned BuiltinID =
+  cast(TheCall->getCalleeDecl())->getBuiltinID();
+  bool IsSizeCall = BuiltinID == Builtin::BI__builtin_os_log_format_buffer_size;
+
+  unsigned NumArgs = TheCall->getNumArgs();
+  unsigned NumRequiredArgs = IsSizeCall ? 1 : 2;
+  if (NumArgs < NumRequiredArgs) {
+return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args)
+   << 0 /* function call */ << NumRequiredArgs << Nu

r284990 - Add support for __builtin_os_log_format[_buffer_size]

2016-10-24 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Mon Oct 24 11:56:23 2016
New Revision: 284990

URL: http://llvm.org/viewvc/llvm-project?rev=284990&view=rev
Log:
Add support for __builtin_os_log_format[_buffer_size]

These new builtins support a mechanism for logging OS events, using a
printf-like format string to specify the layout of data in a buffer.
The _buffer_size version of the builtin can be used to determine the size
of the buffer to allocate to hold the data, and then __builtin_os_log_format
can write data into that buffer. This implements format checking to report
mismatches between the format string and the data arguments. Most of this
code was written by Chris Willmore.

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

Added:
cfe/trunk/include/clang/Analysis/Analyses/OSLog.h
cfe/trunk/lib/Analysis/OSLog.cpp
cfe/trunk/test/CodeGenObjC/os_log.m
cfe/trunk/test/SemaObjC/format-strings-oslog.m
Modified:
cfe/trunk/include/clang/Analysis/Analyses/FormatString.h
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Analysis/CMakeLists.txt
cfe/trunk/lib/Analysis/FormatString.cpp
cfe/trunk/lib/Analysis/PrintfFormatString.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/CodeGen/builtins.c

Modified: cfe/trunk/include/clang/Analysis/Analyses/FormatString.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/FormatString.h?rev=284990&r1=284989&r2=284990&view=diff
==
--- cfe/trunk/include/clang/Analysis/Analyses/FormatString.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/FormatString.h Mon Oct 24 
11:56:23 2016
@@ -35,7 +35,7 @@ class OptionalFlag {
 public:
   OptionalFlag(const char *Representation)
   : representation(Representation), flag(false) {}
-  bool isSet() { return flag; }
+  bool isSet() const { return flag; }
   void set() { flag = true; }
   void clear() { flag = false; }
   void setPosition(const char *position) {
@@ -122,12 +122,13 @@ class ConversionSpecifier {
 public:
   enum Kind {
 InvalidSpecifier = 0,
-  // C99 conversion specifiers.
+// C99 conversion specifiers.
 cArg,
 dArg,
 DArg, // Apple extension
 iArg,
-IntArgBeg = dArg, IntArgEnd = iArg,
+IntArgBeg = dArg,
+IntArgEnd = iArg,
 
 oArg,
 OArg, // Apple extension
@@ -135,7 +136,8 @@ public:
 UArg, // Apple extension
 xArg,
 XArg,
-UIntArgBeg = oArg, UIntArgEnd = XArg,
+UIntArgBeg = oArg,
+UIntArgEnd = XArg,
 
 fArg,
 FArg,
@@ -145,7 +147,8 @@ public:
 GArg,
 aArg,
 AArg,
-DoubleArgBeg = fArg, DoubleArgEnd = AArg,
+DoubleArgBeg = fArg,
+DoubleArgEnd = AArg,
 
 sArg,
 pArg,
@@ -154,13 +157,19 @@ public:
 CArg,
 SArg,
 
+// Apple extension: P specifies to os_log that the data being pointed to is
+// to be copied by os_log. The precision indicates the number of bytes to
+// copy.
+PArg,
+
 // ** Printf-specific **
 
 ZArg, // MS extension
 
 // Objective-C specific specifiers.
-ObjCObjArg,  // '@'
-ObjCBeg = ObjCObjArg, ObjCEnd = ObjCObjArg,
+ObjCObjArg, // '@'
+ObjCBeg = ObjCObjArg,
+ObjCEnd = ObjCObjArg,
 
 // FreeBSD kernel specific specifiers.
 FreeBSDbArg,
@@ -169,13 +178,15 @@ public:
 FreeBSDyArg,
 
 // GlibC specific specifiers.
-PrintErrno,   // 'm'
+PrintErrno, // 'm'
 
-PrintfConvBeg = ObjCObjArg, PrintfConvEnd = PrintErrno,
+PrintfConvBeg = ObjCObjArg,
+PrintfConvEnd = PrintErrno,
 
 // ** Scanf-specific **
 ScanListArg, // '['
-ScanfConvBeg = ScanListArg, ScanfConvEnd = ScanListArg
+ScanfConvBeg = ScanListArg,
+ScanfConvEnd = ScanListArg
   };
 
   ConversionSpecifier(bool isPrintf = true)
@@ -437,13 +448,15 @@ class PrintfSpecifier : public analyze_f
   OptionalFlag HasAlternativeForm; // '#'
   OptionalFlag HasLeadingZeroes; // '0'
   OptionalFlag HasObjCTechnicalTerm; // '[tt]'
+  OptionalFlag IsPrivate;// '{private}'
+  OptionalFlag IsPublic; // '{public}'
   OptionalAmount Precision;
 public:
-  PrintfSpecifier() :
-FormatSpecifier(/* isPrintf = */ true),
-HasThousandsGrouping("'"), IsLeftJustified("-"), HasPlusPrefix("+"),
-HasSpacePrefix(" "), HasAlternativeForm("#"), HasLeadingZeroes("0"),
-HasObjCTechnicalTerm("tt") {}
+  PrintfSpecifier()
+  : FormatSpecifier(/* isPrintf = */ true), HasThousandsGrouping("'"),
+IsLeftJustified("-"), HasPlusPrefix("+"), HasSpacePrefix(" "),
+HasAlternativeForm("#"), HasLeadingZeroes("0"),
+HasObjCTechnicalTerm("tt"), IsPrivate("private"), IsPublic("public") {}
 
   static PrintfSpecifier Parse(const char *beg, const char *end);
 
@@ -472,6 +485,8 @@ public:
   

Re: [clang-tools-extra] r284888 - Remove 'misc-pointer-and-integral-operation' clang-tidy check. The only cases

2016-10-24 Thread Richard Smith via cfe-commits
On Mon, Oct 24, 2016 at 8:31 AM, Alexander Kornienko 
wrote:

> Wait, I thought the check was mostly useful for C code, where it detects
> real issues? Etienne, can you comment?
>

See below. This is only checking for cases that are already ill-formed,
some of which we accept as an extension, and all of which have frontend
warnings.

We should consider enabling those of the below warnings that are disabled
by default, and should definitely give them warning flags, but I don't
think we need clang-tidy checks for ill-formed code that the frontend
already diagnoses. (Note that prior to DR1512, some of the cases detected
by this check were valid in C++).


> On Fri, Oct 21, 2016 at 11:50 PM, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Fri Oct 21 16:50:28 2016
>> New Revision: 284888
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=284888&view=rev
>> Log:
>> Remove 'misc-pointer-and-integral-operation' clang-tidy check. The only
>> cases
>> it detects are ill-formed (some per C++ core issue 1512, others always
>> have
>> been).
>>
>> Removed:
>> clang-tools-extra/trunk/clang-tidy/misc/PointerAndIntegralOp
>> erationCheck.cpp
>> clang-tools-extra/trunk/clang-tidy/misc/PointerAndIntegralOp
>> erationCheck.h
>> clang-tools-extra/trunk/docs/clang-tidy/checks/misc-pointer-
>> and-integral-operation.rst
>> clang-tools-extra/trunk/test/clang-tidy/misc-pointer-and-int
>> egral-operation-cxx98.cpp
>> clang-tools-extra/trunk/test/clang-tidy/misc-pointer-and-int
>> egral-operation.cpp
>> Modified:
>> clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/Resources/Cl
>> angTidyChecks.yaml
>> clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
>> clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
>> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>>
>> Modified: clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/Resources/Cl
>> angTidyChecks.yaml
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clang-tidy-vs/ClangTidy/Resources/ClangTidyChecks.yaml?rev=
>> 284888&r1=284887&r2=284888&view=diff
>> 
>> ==
>> --- 
>> clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/Resources/ClangTidyChecks.yaml
>> (original)
>> +++ 
>> clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/Resources/ClangTidyChecks.yaml
>> Fri Oct 21 16:50:28 2016
>> @@ -239,10 +239,6 @@ Checks:
>>  Description:
>>  Name:misc-non-copyable-objects
>>- Category:Miscellaneous
>> -Label:   Suspicious pointer / integer operations
>> -Description:
>> -Name:misc-pointer-and-integral-operation
>> -  - Category:Miscellaneous
>>  Label:   Find redundant expressions
>>  Description:
>>  Name:misc-redundant-expression
>>
>> Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clang-tidy/misc/CMakeLists.txt?rev=284888&r1=284887&r2=284888&view=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
>> +++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Fri Oct 21
>> 16:50:28 2016
>> @@ -24,7 +24,6 @@ add_clang_library(clangTidyMiscModule
>>NewDeleteOverloadsCheck.cpp
>>NoexceptMoveConstructorCheck.cpp
>>NonCopyableObjects.cpp
>> -  PointerAndIntegralOperationCheck.cpp
>>RedundantExpressionCheck.cpp
>>SizeofContainerCheck.cpp
>>SizeofExpressionCheck.cpp
>>
>> Modified: clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clang-tidy/misc/MiscTidyModule.cpp?rev=284888&r1=284887&r2=
>> 284888&view=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp (original)
>> +++ clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp Fri Oct
>> 21 16:50:28 2016
>> @@ -32,7 +32,6 @@
>>  #include "NewDeleteOverloadsCheck.h"
>>  #include "NoexceptMoveConstructorCheck.h"
>>  #include "NonCopyableObjects.h"
>> -#include "PointerAndIntegralOperationCheck.h"
>>  #include "RedundantExpressionCheck.h"
>>  #include "SizeofContainerCheck.h"
>>  #include "SizeofExpressionCheck.h"
>> @@ -104,8 +103,6 @@ public:
>>  "misc-noexcept-move-constructor");
>>  CheckFactories.registerCheck(
>>  "misc-non-copyable-objects");
>> -CheckFactories.registerCheck(
>> -"misc-pointer-and-integral-operation");
>>  CheckFactories.registerCheck(
>>  "misc-redundant-expression");
>>  CheckFactories.registerCheck("misc-si
>> zeof-container");
>>
>> Removed: clang-tools-extra/trunk/clang-tidy/misc/PointerAndIntegralOp
>> erationCheck.cpp
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clang

[PATCH] D25343: [OpenCL] Mark group functions as convergent in opencl-c.h

2016-10-24 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D25343#567374, @tstellarAMD wrote:

> In https://reviews.llvm.org/D25343#565288, @Anastasia wrote:
>
> > Do you have any code example where Clang/LLVM performs wrong optimizations 
> > with respect to the control flow of SPMD execution?
> >
> > My understanding from the earlier discussion we have had: 
> > https://www.mail-archive.com/cfe-commits@lists.llvm.org/msg22643.html that 
> > noduplicate is essentially enough for the frontend to prevent erroneous 
> > optimizations. Because in general compiler can't do much with unknown 
> > function calls.
>
>
> noduplicate is enough for correctness, but it prevents legal optimizations, 
> like unrolling loops with barriers.  The convergent attribute was added 
> specifically for these kinds of builtins, so we should be using it here 
> instead of noduplicate.
>
> > For LLVM intrinsics it is slightly different as I can deduce from this 
> > discussion:http://lists.llvm.org/pipermail/llvm-dev/2015-May/085558.html . 
> > It seems like by default it's assumed to be side effect free and can be 
> > optimized in various ways.




In https://reviews.llvm.org/D25343#567374, @tstellarAMD wrote:

> In https://reviews.llvm.org/D25343#565288, @Anastasia wrote:
>
> > Do you have any code example where Clang/LLVM performs wrong optimizations 
> > with respect to the control flow of SPMD execution?
> >
> > My understanding from the earlier discussion we have had: 
> > https://www.mail-archive.com/cfe-commits@lists.llvm.org/msg22643.html that 
> > noduplicate is essentially enough for the frontend to prevent erroneous 
> > optimizations. Because in general compiler can't do much with unknown 
> > function calls.
>
>
> noduplicate is enough for correctness, but it prevents legal optimizations, 
> like unrolling loops with barriers.  The convergent attribute was added 
> specifically for these kinds of builtins, so we should be using it here 
> instead of noduplicate.
>
> > For LLVM intrinsics it is slightly different as I can deduce from this 
> > discussion:http://lists.llvm.org/pipermail/llvm-dev/2015-May/085558.html . 
> > It seems like by default it's assumed to be side effect free and can be 
> > optimized in various ways.


Tom, as far as I understand a valid generalized use case with a barrier is as 
follows:

  a = compute() 
  barrier()
  use(a)

Regarding unrolling I don't see how the barrier can be unrolled without 
breaking the correctness of OpenCL programs because all compute() calls of one 
WG have to complete before use(a) is invoked for the first time. I am not an 
expert in LLVM transformations but if I read the description of both 
noduplicate and convergent (http://llvm.org/docs/LangRef.html) none of those 
seem to make sense to me for the barrier because both allow reordering within 
the same function or BB respectively and the only valid way seems to mark it as 
a side-effect intrinsic to prevent any reordering of the barrier itself. I 
understand within compute() or use() independently there are not limitations on 
ordering of instructions.

If you have any specific example in mind where the unrolling would work could 
you please elaborate on it. I think it's essential for the community to 
undertsnad the use cases for noduplicate/convergent/sideeffect to make better 
use of them also across similar models i.e. OpenCL, CUDA, etc.


https://reviews.llvm.org/D25343



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


[PATCH] D25305: [OpenCL] Setting constant address space for array initializers

2016-10-24 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.



Comment at: lib/CodeGen/CGDecl.cpp:1272
+if (getLangOpts().OpenCL) {
+  UA = llvm::GlobalValue::UnnamedAddr::None;
+  AS = CGM.getContext().getTargetAddressSpace(LangAS::opencl_constant);

bader wrote:
> AlexeySotkin wrote:
> > Anastasia wrote:
> > > Why this change?
> > Without this change, global variables with unnamed address space are 
> > translated to SPIR-V as variables with "Function" storage class, which is 
> > wrong.
> > This should fix this issue: 
> > https://github.com/KhronosGroup/SPIRV-LLVM/issues/50
> There is inconsistency with how Clang maps initializers to OpenCL memory 
> model.
> Consider example from the test case:
> ```
> __private int arr[] = {1, 2, 3};
> ```
> This code allocates a global constant for initializer {1, 2, 3} and later 
> copies values from this global constant to the private array using memcpy 
> intrinsic. The global constant must be allocated in constant address space, 
> but old code do assign any address space, which is considered to be a private 
> memory region.
> This patch puts global constant objects to constant address space.
Yes, this is perfectly fine. I was specifically asking about setting 
llvm::GlobalValue::UnnamedAddr::None attribute. I can't see why this has to be 
done or is it because we now assign concrete address space and private was 
treated as no address space at all?


https://reviews.llvm.org/D25305



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


[PATCH] D25909: [analyzer] MacOSXApiChecker: Disallow dispatch_once predicates on heap and in ivars.

2016-10-24 Thread Artem Dergachev via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp:94
+  else if (isa(RS)) {
+// FIXME: Presence of an IVar region has priority over this branch, because
+// ObjC objects are on the heap even if the core doesn't realize this.

dcoughlin wrote:
> It is not clear to me that this FIXME is a good idea. I would remove it so 
> someone doesn't spend a lot of time trying to address it.
> 
> Objective-C objects don't have the strong dis-aliasing guarantee that the 
> analyzer assumes for heap base regions. In other words, two calls to [[Foo 
> alloc] init] may yield exactly the same instance.  This is because, unlike 
> malloc() and C++ global new, ObjC initializers can (and frequently do) return 
> instances other than the passed-in, freshly-allocated self.
Hmm, that seems to be exactly the thing i'm looking for: heap-based regions 
that may alias.

The property of a region's staying on the heap has little to do with the 
property of being able to alias.

I've a feeling that we should have avoided using C++ inheritance in the 
memregion hierarchy, and instead went for a bunch of constraints. Eg., memory 
space is essentially a constraint (it may be unknown or get known later through 
exploring aliasing), region's value type is essentially a constraint (as seen 
during dynamic type propagation, it may be unknown, it may be partially known, 
we may get to know it better during the analysis by observing successful 
dynamic casts), extent is essentially a constraint (that we currently impose on 
SymbolExtent), offset of a symbolic region inside its true parent region is a 
constraint, and so on.

But that's too vague. I've no well-defined idea how to make this better at the 
moment.


https://reviews.llvm.org/D25909



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


[clang-tools-extra] r284992 - [clang-tidy] Fix identifier naming in macro args.

2016-10-24 Thread Jason Henline via cfe-commits
Author: jhen
Date: Mon Oct 24 12:20:32 2016
New Revision: 284992

URL: http://llvm.org/viewvc/llvm-project?rev=284992&view=rev
Log:
[clang-tidy] Fix identifier naming in macro args.

Summary:
clang-tidy should fix identifier naming even when the identifier is
referenced inside a macro expansion, provided that the identifier enters
the macro expansion completely within a macro argument.

For example, this will allow fixes to the naming of the identifier
'global' when it is declared and used as follows:

  int global;
  #define USE_IN_MACRO(m) auto use_##m = m
  USE_IN_MACRO(global);

Reviewers: alexfh

Subscribers: jlebar, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp?rev=284992&r1=284991&r2=284992&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp 
Mon Oct 24 12:20:32 2016
@@ -612,27 +612,57 @@ static StyleKind findStyleKind(
 
 static void addUsage(IdentifierNamingCheck::NamingCheckFailureMap &Failures,
  const IdentifierNamingCheck::NamingCheckId &Decl,
- SourceRange Range) {
+ SourceRange Range, SourceManager *SourceMgr = nullptr) {
   // Do nothing if the provided range is invalid.
   if (Range.getBegin().isInvalid() || Range.getEnd().isInvalid())
 return;
 
+  // If we have a source manager, use it to convert to the spelling location 
for
+  // performing the fix. This is necessary because macros can map the same
+  // spelling location to different source locations, and we only want to fix
+  // the token once, before it is expanded by the macro.
+  SourceLocation FixLocation = Range.getBegin();
+  if (SourceMgr)
+FixLocation = SourceMgr->getSpellingLoc(FixLocation);
+  if (FixLocation.isInvalid())
+return;
+
   // Try to insert the identifier location in the Usages map, and bail out if 
it
   // is already in there
   auto &Failure = Failures[Decl];
-  if (!Failure.RawUsageLocs.insert(Range.getBegin().getRawEncoding()).second)
+  if (!Failure.RawUsageLocs.insert(FixLocation.getRawEncoding()).second)
+return;
+
+  if (!Failure.ShouldFix)
 return;
 
-  Failure.ShouldFix = Failure.ShouldFix && !Range.getBegin().isMacroID() &&
-  !Range.getEnd().isMacroID();
+  // Check if the range is entirely contained within a macro argument.
+  SourceLocation MacroArgExpansionStartForRangeBegin;
+  SourceLocation MacroArgExpansionStartForRangeEnd;
+  bool RangeIsEntirelyWithinMacroArgument =
+  SourceMgr &&
+  SourceMgr->isMacroArgExpansion(Range.getBegin(),
+ &MacroArgExpansionStartForRangeBegin) &&
+  SourceMgr->isMacroArgExpansion(Range.getEnd(),
+ &MacroArgExpansionStartForRangeEnd) &&
+  MacroArgExpansionStartForRangeBegin == MacroArgExpansionStartForRangeEnd;
+
+  // Check if the range contains any locations from a macro expansion.
+  bool RangeContainsMacroExpansion = RangeIsEntirelyWithinMacroArgument ||
+ Range.getBegin().isMacroID() ||
+ Range.getEnd().isMacroID();
+
+  bool RangeCanBeFixed =
+  RangeIsEntirelyWithinMacroArgument || !RangeContainsMacroExpansion;
+  Failure.ShouldFix = RangeCanBeFixed;
 }
 
 /// Convenience method when the usage to be added is a NamedDecl
 static void addUsage(IdentifierNamingCheck::NamingCheckFailureMap &Failures,
- const NamedDecl *Decl, SourceRange Range) {
+ const NamedDecl *Decl, SourceRange Range, SourceManager 
*SourceMgr = nullptr) {
   return addUsage(Failures, IdentifierNamingCheck::NamingCheckId(
 Decl->getLocation(), Decl->getNameAsString()),
-  Range);
+  Range, SourceMgr);
 }
 
 void IdentifierNamingCheck::check(const MatchFinder::MatchResult &Result) {
@@ -719,7 +749,7 @@ void IdentifierNamingCheck::check(const
 
   if (const auto *DeclRef = Result.Nodes.getNodeAs("declRef")) {
 SourceRange Range = DeclRef->getNameInfo().getSourceRange();
-addUsage(NamingCheckFailures, DeclRef->getDecl(), Range);
+addUsage(NamingCheckFailures, DeclRef->getDecl(), Range, 
Result.SourceManager);
 return;
   }
 

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp?rev=284992&

[PATCH] D25450: [clang-tidy] Fix identifier naming in macro args.

2016-10-24 Thread Jason Henline via cfe-commits
jhen added a comment.

Thanks for the review!


Repository:
  rL LLVM

https://reviews.llvm.org/D25450



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


[PATCH] D25450: [clang-tidy] Fix identifier naming in macro args.

2016-10-24 Thread Jason Henline via cfe-commits
This revision was automatically updated to reflect the committed changes.
jhen marked an inline comment as done.
Closed by commit rL284992: [clang-tidy] Fix identifier naming in macro args. 
(authored by jhen).

Changed prior to commit:
  https://reviews.llvm.org/D25450?vs=75430&id=75610#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25450

Files:
  clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp
@@ -95,14 +95,41 @@
 USER_MACRO(var2);
 // NO warnings or fixes expected as var2 is declared in a macro expansion
 
+#define BLA int FOO_bar
+BLA;
+// NO warnings or fixes expected as FOO_bar is from macro expansion
+
+int global0;
+#define USE_NUMBERED_GLOBAL(number) auto use_global##number = global##number
+USE_NUMBERED_GLOBAL(0);
+// NO warnings or fixes expected as global0 is pieced together in a macro
+// expansion.
+
+int global1;
+#define USE_NUMBERED_BAL(prefix, number) \
+  auto use_##prefix##bal##number = prefix##bal##number
+USE_NUMBERED_BAL(glo, 1);
+// NO warnings or fixes expected as global1 is pieced together in a macro
+// expansion.
+
+int global2;
+#define USE_RECONSTRUCTED(glo, bal) auto use_##glo##bal = glo##bal
+USE_RECONSTRUCTED(glo, bal2);
+// NO warnings or fixes expected as global2 is pieced together in a macro
+// expansion.
+
 int global;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'global'
+// CHECK-FIXES: {{^}}int g_global;{{$}}
 #define USE_IN_MACRO(m) auto use_##m = m
 USE_IN_MACRO(global);
-// NO warnings or fixes expected as global is used in a macro expansion
 
-#define BLA int FOO_bar
-BLA;
-// NO warnings or fixes expected as FOO_bar is from macro expansion
+int global3;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'global3'
+// CHECK-FIXES: {{^}}int g_global3;{{$}}
+#define ADD_TO_SELF(m) (m) + (m)
+int g_twice_global3 = ADD_TO_SELF(global3);
+// CHECK-FIXES: {{^}}int g_twice_global3 = ADD_TO_SELF(g_global3);{{$}}
 
 enum my_enumeration {
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for enum 'my_enumeration'
Index: clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -612,27 +612,57 @@
 
 static void addUsage(IdentifierNamingCheck::NamingCheckFailureMap &Failures,
  const IdentifierNamingCheck::NamingCheckId &Decl,
- SourceRange Range) {
+ SourceRange Range, SourceManager *SourceMgr = nullptr) {
   // Do nothing if the provided range is invalid.
   if (Range.getBegin().isInvalid() || Range.getEnd().isInvalid())
 return;
 
+  // If we have a source manager, use it to convert to the spelling location for
+  // performing the fix. This is necessary because macros can map the same
+  // spelling location to different source locations, and we only want to fix
+  // the token once, before it is expanded by the macro.
+  SourceLocation FixLocation = Range.getBegin();
+  if (SourceMgr)
+FixLocation = SourceMgr->getSpellingLoc(FixLocation);
+  if (FixLocation.isInvalid())
+return;
+
   // Try to insert the identifier location in the Usages map, and bail out if it
   // is already in there
   auto &Failure = Failures[Decl];
-  if (!Failure.RawUsageLocs.insert(Range.getBegin().getRawEncoding()).second)
+  if (!Failure.RawUsageLocs.insert(FixLocation.getRawEncoding()).second)
+return;
+
+  if (!Failure.ShouldFix)
 return;
 
-  Failure.ShouldFix = Failure.ShouldFix && !Range.getBegin().isMacroID() &&
-  !Range.getEnd().isMacroID();
+  // Check if the range is entirely contained within a macro argument.
+  SourceLocation MacroArgExpansionStartForRangeBegin;
+  SourceLocation MacroArgExpansionStartForRangeEnd;
+  bool RangeIsEntirelyWithinMacroArgument =
+  SourceMgr &&
+  SourceMgr->isMacroArgExpansion(Range.getBegin(),
+ &MacroArgExpansionStartForRangeBegin) &&
+  SourceMgr->isMacroArgExpansion(Range.getEnd(),
+ &MacroArgExpansionStartForRangeEnd) &&
+  MacroArgExpansionStartForRangeBegin == MacroArgExpansionStartForRangeEnd;
+
+  // Check if the range contains any locations from a macro expansion.
+  bool RangeContainsMacroExpansion = RangeIsEntirelyWithinMacroArgument ||
+ Range.getBegin().isMacroID() ||
+ 

[PATCH] D25731: [analyzer] NumberObjectConversion: Support OSNumber and CFNumberRef.

2016-10-24 Thread Artem Dergachev via cfe-commits
NoQ updated this revision to Diff 75612.
NoQ added a comment.

Do not suggest any API when we're not sure (was already advised by Anna but i 
missed it somehow).


https://reviews.llvm.org/D25731

Files:
  lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
  test/Analysis/number-object-conversion.c
  test/Analysis/number-object-conversion.cpp
  test/Analysis/number-object-conversion.m

Index: test/Analysis/number-object-conversion.m
===
--- test/Analysis/number-object-conversion.m
+++ test/Analysis/number-object-conversion.m
@@ -10,30 +10,35 @@
 
 void bad(NSNumber *p) {
 #ifdef PEDANTIC
-  if (p) {} // expected-warning{{Converting 'NSNumber *' to a plain boolean value for branching; please compare the pointer to nil instead to suppress this warning}}
-  if (!p) {} // expected-warning{{Converting 'NSNumber *' to a plain boolean value for branching; please compare the pointer to nil instead to suppress this warning}}
-  (!p) ? 1 : 2; // expected-warning{{Converting 'NSNumber *' to a plain boolean value for branching; please compare the pointer to nil instead to suppress this warning}}
-  (BOOL)p; // expected-warning{{Converting 'NSNumber *' to a plain BOOL value; please compare the pointer to nil instead to suppress this warning}}
-  if (p == 0) {} // expected-warning{{Converting 'NSNumber *' to a plain integer value; please compare the pointer to nil instead to suppress this warning}}
-  if (p > 0) {} // expected-warning{{Converting 'NSNumber *' to a plain integer value; pointer value is being used instead}}
+  if (p) {} // expected-warning{{Converting a pointer value of type 'NSNumber *' to a primitive boolean value; instead, either compare the pointer to nil or call -boolValue}}
+  if (!p) {} // expected-warning{{Converting a pointer value of type 'NSNumber *' to a primitive boolean value; instead, either compare the pointer to nil or call -boolValue}}
+  (!p) ? 1 : 2; // expected-warning{{Converting a pointer value of type 'NSNumber *' to a primitive boolean value; instead, either compare the pointer to nil or call -boolValue}}
+  if (p == 0) {} // expected-warning{{Comparing a pointer value of type 'NSNumber *' to a primitive integer value; instead, either compare the pointer to nil or compare the result of calling a method on 'NSNumber *' to get the scalar value}}
+#else
+  if (p) {} // no-warning
+  if (!p) {} // no-warning
+  (!p) ? 1 : 2; // no-warning
+  if (p == 0) {} // no-warning
 #endif
-  if (p == YES) {} // expected-warning{{Converting 'NSNumber *' to a plain BOOL value; pointer value is being used instead}}
-  if (p == NO) {} // expected-warning{{Converting 'NSNumber *' to a plain BOOL value; pointer value is being used instead}}
-  BOOL x = p; // expected-warning{{Converting 'NSNumber *' to a plain BOOL value; pointer value is being used instead}}
-  x = p; // expected-warning{{Converting 'NSNumber *' to a plain BOOL value; pointer value is being used instead}}
-  x = (p == YES); // expected-warning{{Converting 'NSNumber *' to a plain BOOL value; pointer value is being used instead}}
-  if (p == 1) {} // expected-warning{{Converting 'NSNumber *' to a plain integer value; pointer value is being used instead}}
-  int y = p; // expected-warning{{Converting 'NSNumber *' to a plain integer value; pointer value is being used instead}}
-  y = p; // expected-warning{{Converting 'NSNumber *' to a plain integer value; pointer value is being used instead}}
-  takes_boolean(p); // expected-warning{{Converting 'NSNumber *' to a plain BOOL value; pointer value is being used instead}}
-  takes_integer(p); // expected-warning{{Converting 'NSNumber *' to a plain integer value; pointer value is being used instead}}
+  (BOOL)p; // expected-warning{{Converting a pointer value of type 'NSNumber *' to a primitive BOOL value; did you mean to call -boolValue?}}
+  if (p > 0) {} // expected-warning{{Comparing a pointer value of type 'NSNumber *' to a primitive integer value; did you mean to compare the result of calling a method on 'NSNumber *' to get the scalar value?}}
+  if (p == YES) {} // expected-warning{{Comparing a pointer value of type 'NSNumber *' to a primitive BOOL value; did you mean to compare the result of calling -boolValue?}}
+  if (p == NO) {} // expected-warning{{Comparing a pointer value of type 'NSNumber *' to a primitive BOOL value; did you mean to compare the result of calling -boolValue?}}
+  BOOL x = p; // expected-warning{{Converting a pointer value of type 'NSNumber *' to a primitive BOOL value; did you mean to call -boolValue?}}
+  x = p; // expected-warning{{Converting a pointer value of type 'NSNumber *' to a primitive BOOL value; did you mean to call -boolValue?}}
+  x = (p == YES); // expected-warning{{Comparing a pointer value of type 'NSNumber *' to a primitive BOOL value; did you mean to compare the result of calling -boolValue?}}
+  if (p == 1) {} // expected-warning{{Comparing a pointer value of type 'NS

Re: [PATCH] D24010: [ReachableCode] Skip over ExprWithCleanups in isConfigurationValue

2016-10-24 Thread David Blaikie via cfe-commits
On Mon, Aug 29, 2016 at 3:45 PM Tim Shen via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> timshen created this revision.
> timshen added reviewers: rsmith, pirama.
> timshen added a subscriber: cfe-commits.
>
> https://reviews.llvm.org/D24010
>
> Files:
>   clang/include/clang/AST/Stmt.h
>   clang/lib/Analysis/ReachableCode.cpp
>   clang/test/SemaCXX/PR29152.cpp
>
> Index: clang/test/SemaCXX/PR29152.cpp
> ===
> --- /dev/null
> +++ clang/test/SemaCXX/PR29152.cpp
> @@ -0,0 +1,19 @@
> +// RUN: %clang_cc1 -fsyntax-only -Wunreachable-code -verify %s
> +
> +static const bool False = false;
> +
> +struct Vector {
> +  struct iterator {
> +bool operator==(const iterator &) const;
> +  };
> +  iterator end();
> +};
> +
> +void Bar();
> +Vector::iterator Find(Vector &a);
> +
> +void Foo(Vector &a) {
> +  if (False && Find(a) == a.end()) {
> +Bar(); // expected-no-diagnostics
> +  }
> +}
>

What are the relevant parts of this test for this change?

Is it the static const bool False that's interesting?

Is it the op==/other interesting side effects on the RHS that are
interesting?

I'd be surprised if it were both (& if it isn't both, I'm guessing it's the
former rather than the latter - in which case the latter can probably be
reduced to just an arbitrary function call to, say: bool Baz())


> Index: clang/lib/Analysis/ReachableCode.cpp
> ===
> --- clang/lib/Analysis/ReachableCode.cpp
> +++ clang/lib/Analysis/ReachableCode.cpp
> @@ -164,6 +164,8 @@
>if (!S)
>  return false;
>
> +  S = S->IgnoreImplicit();
> +
>if (const Expr *Ex = dyn_cast(S))
>  S = Ex->IgnoreCasts();
>
> Index: clang/include/clang/AST/Stmt.h
> ===
> --- clang/include/clang/AST/Stmt.h
> +++ clang/include/clang/AST/Stmt.h
> @@ -387,6 +387,9 @@
>/// Skip past any implicit AST nodes which might surround this
>/// statement, such as ExprWithCleanups or ImplicitCastExpr nodes.
>Stmt *IgnoreImplicit();
> +  const Stmt *IgnoreImplicit() const {
> +return const_cast(this)->IgnoreImplicit();
> +  }
>
>/// \brief Skip no-op (attributed, compound) container stmts and skip
> captured
>/// stmt at the top, if \a IgnoreCaptured is true.
>
>
> ___
> 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] D24954: [Driver] Disable OpenSUSE rules for OpenSUSE/SLES 10 and older

2016-10-24 Thread Bruno Cardoso Lopes via cfe-commits
bruno added inline comments.



Comment at: lib/Driver/ToolChains.cpp:3937
+StringRef Data = File.get()->getBuffer();
+SmallVector Lines;
+Data.split(Lines, "\n");

This file usually has 5-6 lines, can you use 8 instead?



Comment at: lib/Driver/ToolChains.cpp:3940
+for (const StringRef& Line : Lines) {
+  std::pair SplitLine = Line.split('=');
+  int Version;

You probably want to explicitly skip the lines you're not interested to make it 
a bit more clear. AFAIU, the VERSION is usually on the second line. How about:

  if (Line.first.trim() != "VERSION")
continue;
  <... then split and parse the value>


https://reviews.llvm.org/D24954



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


Re: [PATCH] D21508: Make friend function template definition available if class is instantiated.

2016-10-24 Thread Serge Pavlov via cfe-commits
Ping.

Thanks,
--Serge

2016-10-18 0:09 GMT+07:00 Serge Pavlov :

> Ping.
>
> Thanks,
> --Serge
>
> 2016-10-13 11:51 GMT+07:00 Serge Pavlov :
>
>> sepavloff updated the summary for this revision.
>>
>> https://reviews.llvm.org/D21508
>>
>>
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24954: [Driver] Disable OpenSUSE rules for OpenSUSE/SLES 10 and older

2016-10-24 Thread Michał Górny via cfe-commits
mgorny updated this revision to Diff 75615.
mgorny added a comment.

Refactored the code as requested. Also I've noticed that if VERSION had invalid 
value, the code continued reading the file — now it immediately returns 
UnknownDistro in that case.


https://reviews.llvm.org/D24954

Files:
  lib/Driver/ToolChains.cpp


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3931,8 +3931,25 @@
 .Default(UnknownDistro);
   }
 
-  if (VFS.exists("/etc/SuSE-release"))
-return OpenSUSE;
+  File = VFS.getBufferForFile("/etc/SuSE-release");
+  if (File) {
+StringRef Data = File.get()->getBuffer();
+SmallVector Lines;
+Data.split(Lines, "\n");
+for (const StringRef& Line : Lines) {
+  std::pair SplitLine = Line.split('=');
+  int Version;
+  if (SplitLine.first.trim() != "VERSION")
+continue;
+  // OpenSUSE/SLES 10 and older are not supported and not compatible
+  // with our rules, so just treat them as UnknownDistro.
+  if (!SplitLine.second.trim().getAsInteger(10, Version) &&
+  Version > 10)
+return OpenSUSE;
+  return UnknownDistro;
+}
+return UnknownDistro;
+  }
 
   if (VFS.exists("/etc/exherbo-release"))
 return Exherbo;


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3931,8 +3931,25 @@
 .Default(UnknownDistro);
   }
 
-  if (VFS.exists("/etc/SuSE-release"))
-return OpenSUSE;
+  File = VFS.getBufferForFile("/etc/SuSE-release");
+  if (File) {
+StringRef Data = File.get()->getBuffer();
+SmallVector Lines;
+Data.split(Lines, "\n");
+for (const StringRef& Line : Lines) {
+  std::pair SplitLine = Line.split('=');
+  int Version;
+  if (SplitLine.first.trim() != "VERSION")
+continue;
+  // OpenSUSE/SLES 10 and older are not supported and not compatible
+  // with our rules, so just treat them as UnknownDistro.
+  if (!SplitLine.second.trim().getAsInteger(10, Version) &&
+  Version > 10)
+return OpenSUSE;
+  return UnknownDistro;
+}
+return UnknownDistro;
+  }
 
   if (VFS.exists("/etc/exherbo-release"))
 return Exherbo;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25674: [Concepts] Class template associated constraints

2016-10-24 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast added a comment.

Friendly ping...


https://reviews.llvm.org/D25674



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


[PATCH] D25902: [AVX-512] Fix the operand order for all calls to __builtin_ia32_vfmaddss3_mask.

2016-10-24 Thread Elena Demikhovsky via cfe-commits
delena added inline comments.



Comment at: lib/Headers/avx512fintrin.h:8394
   _MM_FROUND_CUR_DIRECTION);
 }
 

Using vfmaddss3_mask is wrong in this case.
It will propagate -B to lower bits if mask==0.



Comment at: lib/Headers/avx512fintrin.h:8453
 {
  return (__m128) __builtin_ia32_vfmaddss3_maskz (-(__v4sf) __A,
   (__v4sf) __B,

This one is, probably, also wrong, because we should copy the upper bits of __A 
as is.

IF k[0]
dst[31:0] := -(a[31:0] * b[31:0]) + c[31:0]
ELSE
dst[31:0] := c[31:0]
FI
dst[127:32] := a[127:32]
dst[MAX:128] := 0


https://reviews.llvm.org/D25902



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


[PATCH] D25916: Modules: emit an error instead of a random crash (or a misleading error) due to use-after-free.

2016-10-24 Thread Manman Ren via cfe-commits
manmanren created this revision.
manmanren added reviewers: benlangmuir, rsmith.
manmanren added a subscriber: cfe-commits.

With implicit modules, it is hard to debug issues that depend on state of the 
module cache before the clang invocation. The state of the module cache can be 
changed by other  parallel clang invocations that share the module cache.

We build a module by spawning a child thread. Even when the parent thread 
already validated some modules and stored the FileEntries, the child thread can 
invalidate those modules, causing use-after-free for the parent thread.

Since this issue is time-sensitive, it is hard to reproduce with a release 
compiler. With an assert or an ASAN'ed compiler the chance of reproducing is 
even smaller. This patch tries to diagnose the use-after-free in the compiler, 
by passing up the list of invalidated modules from the child thread and 
emitting a hard error in the parent thread.

Another option is to pass down the list of validated modules from the parent 
thread, the child thread can emit a warning and not invalidate those modules.
I am open to other suggestions as well.


https://reviews.llvm.org/D25916

Files:
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Serialization/ModuleManager.h
  lib/Frontend/CompilerInstance.cpp
  lib/Serialization/ModuleManager.cpp
  test/Modules/Inputs/system-out-of-date/X.h
  test/Modules/Inputs/system-out-of-date/Y.h
  test/Modules/Inputs/system-out-of-date/Z.h
  test/Modules/Inputs/system-out-of-date/module.map
  test/Modules/system-out-of-date-test.m

Index: test/Modules/system-out-of-date-test.m
===
--- test/Modules/system-out-of-date-test.m
+++ test/Modules/system-out-of-date-test.m
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+// RUN: echo '@import X;' | \
+// RUN:   %clang_cc1 -fmodules -fimplicit-module-maps \
+// RUN: -fmodules-cache-path=%t -I %S/Inputs/system-out-of-date \
+// RUN: -fsyntax-only -x objective-c -
+
+// We have an version built with different diagnostic options.
+// RUN: not %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/system-out-of-date -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module %s -fsyntax-only 2>&1 | FileCheck %s
+
+@import X;
+
+#import 
+// CHECK: fatal error: module 'Y' is invalidated by its child
+// CHECK: fatal error: could not build module 'Z'
Index: test/Modules/Inputs/system-out-of-date/module.map
===
--- test/Modules/Inputs/system-out-of-date/module.map
+++ test/Modules/Inputs/system-out-of-date/module.map
@@ -0,0 +1,12 @@
+module X [system] {
+  header "X.h" // imports Y
+  export *
+}
+module Y {
+  header "Y.h"
+  export *
+}
+module Z {
+  header "Z.h" // imports Y
+  export *
+}
Index: test/Modules/Inputs/system-out-of-date/Z.h
===
--- test/Modules/Inputs/system-out-of-date/Z.h
+++ test/Modules/Inputs/system-out-of-date/Z.h
@@ -0,0 +1 @@
+#import 
Index: test/Modules/Inputs/system-out-of-date/Y.h
===
--- test/Modules/Inputs/system-out-of-date/Y.h
+++ test/Modules/Inputs/system-out-of-date/Y.h
@@ -0,0 +1 @@
+//empty
Index: test/Modules/Inputs/system-out-of-date/X.h
===
--- test/Modules/Inputs/system-out-of-date/X.h
+++ test/Modules/Inputs/system-out-of-date/X.h
@@ -0,0 +1 @@
+#import 
Index: lib/Serialization/ModuleManager.cpp
===
--- lib/Serialization/ModuleManager.cpp
+++ lib/Serialization/ModuleManager.cpp
@@ -182,6 +182,29 @@
   return NewlyLoaded;
 }
 
+// Check to see if the parent thread is holding on to an entry that the child
+// thread invalidated.
+std::string ModuleManager::checkForInvalidateEntries(
+const ModuleMap *modMapInParent, ModuleManager *parentManager) {
+  for (auto E : InvalidatedModules) {
+if (parentManager->lookup(E.first))
+  return E.second;
+
+if (modMapInParent) {
+  if (Module *mod = modMapInParent->findModule(E.second)) {
+if (mod->getASTFile() == E.first)
+  return E.second;
+  }
+}
+  }
+  return "";
+}
+
+void ModuleManager::mergeInvalidatedEntries(ModuleManager *child) {
+  for (auto E : child->InvalidatedModules)
+InvalidatedModules[E.first] = E.second;
+}
+
 void ModuleManager::removeModules(
 ModuleIterator first, ModuleIterator last,
 llvm::SmallPtrSetImpl &LoadedSuccessfully,
@@ -228,8 +251,10 @@
 // Files that didn't make it through ReadASTCore successfully will be
 // rebuilt (or there was an error). Invalidate them so that we can load the
 // new files that will be renamed over the old ones.
-if (LoadedSuccessfully.count(*victim) == 0)
+if (LoadedSuccessfully.count(*victim) == 0) {
+  Inval

[PATCH] D24954: [Driver] Disable OpenSUSE rules for OpenSUSE/SLES 10 and older

2016-10-24 Thread Bruno Cardoso Lopes via cfe-commits
bruno added inline comments.



Comment at: lib/Driver/ToolChains.cpp:3942
+  int Version;
+  if (SplitLine.first.trim() != "VERSION")
+continue;

You can check `Line.trim() != VERSION` before the `split` as to do not try to 
split unnecessary lines.


https://reviews.llvm.org/D24954



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


Re: r284960 - [analyzer] Add StdLibraryFunctions checker.

2016-10-24 Thread Evgenii Stepanov via cfe-commits
This code also fails with UBSan:

tools/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:285:62:
runtime error: signed integer overflow: 9223372036854775807 + 1 cannot
be represented in type 'long'
#0 0x5e1642f in (anonymous
namespace)::StdLibraryFunctionsChecker::ValueRange::applyAsWithinRange(llvm::IntrusiveRefCntPtr, clang::ento::CallEvent const&, (anonymous
namespace)::StdLibraryFunctionsChecker::FunctionSummaryTy const&)
const 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:285:62
#1 0x5e0f4c3 in (anonymous
namespace)::StdLibraryFunctionsChecker::ValueRange::apply(llvm::IntrusiveRefCntPtr, clang::ento::CallEvent const&, (anonymous
namespace)::StdLibraryFunctionsChecker::FunctionSummaryTy const&)
const 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:149:16
#2 0x5e0eb00 in (anonymous
namespace)::StdLibraryFunctionsChecker::checkPostCall(clang::ento::CallEvent
const&, clang::ento::CheckerContext&) const
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:350:21


http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/18/steps/check-clang%20ubsan/logs/stdio


On Mon, Oct 24, 2016 at 6:23 AM, Renato Golin via cfe-commits
 wrote:
> On 24 October 2016 at 14:09, Artem Dergachev  wrote:
>> Strange, i'm not receiving any buildbot emails again. Will look through bots
>> manually next time, that doesn't sound too hard. Pushed a hotfix in r284969.
>
> The buildmaster was restarted this weekend and got all old builds data wiped.
>
> I only know because I have a monitoring page.
>
> Galina,
>
> Any info on the server migration and the email configuration?
>
> Thanks!
> --renato
> ___
> 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] D25916: Modules: emit an error instead of a random crash (or a misleading error) due to use-after-free.

2016-10-24 Thread Manman Ren via cfe-commits
manmanren added a comment.

In this testing case, the first clang invocation builds a system module X and a 
non-system module Y (X imports Y). At the second clang invocation, the parent 
thread validates the existing module X and module Y. Because X is a system 
module, we don't diagnose the differences in diagnostic options. When building 
module Z in the child thread, since Z is not a system module, we will spot the 
diagnostic differences and invalidate module Y. But the parent thread will 
continue accessing the deleted FileEntry for module Y.


https://reviews.llvm.org/D25916



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


r284999 - Fix crash if StmtProfile finds a type-dependent member access for which we have

2016-10-24 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Oct 24 13:47:04 2016
New Revision: 284999

URL: http://llvm.org/viewvc/llvm-project?rev=284999&view=rev
Log:
Fix crash if StmtProfile finds a type-dependent member access for which we have
resolved the -> to a call to a specific operator-> function. The particular
test case added here is actually being mishandled: the implicit member access
should not be type-dependent (because it's accessing a non-type-dependent
member of the current instantiation), but calls to a type-dependent operator->
that is a member of the current instantiation would be liable to hit the same
codepath.

Modified:
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/test/SemaTemplate/dependent-type-identity.cpp

Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=284999&r1=284998&r2=284999&view=diff
==
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Mon Oct 24 13:47:04 2016
@@ -1190,6 +1190,12 @@ void StmtProfiler::VisitCXXOperatorCallE
   if (S->isTypeDependent()) {
 // Type-dependent operator calls are profiled like their underlying
 // syntactic operator.
+//
+// An operator call to operator-> is always implicit, so just skip it. The
+// enclosing MemberExpr will profile the actual member access.
+if (S->getOperator() == OO_Arrow)
+  return Visit(S->getArg(0));
+
 UnaryOperatorKind UnaryOp = UO_Extension;
 BinaryOperatorKind BinaryOp = BO_Comma;
 Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp);

Modified: cfe/trunk/test/SemaTemplate/dependent-type-identity.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/dependent-type-identity.cpp?rev=284999&r1=284998&r2=284999&view=diff
==
--- cfe/trunk/test/SemaTemplate/dependent-type-identity.cpp (original)
+++ cfe/trunk/test/SemaTemplate/dependent-type-identity.cpp Mon Oct 24 13:47:04 
2016
@@ -80,11 +80,20 @@ namespace PR6851 {
 S< S::cond && 1 > foo();
   };
 
+  struct Arrow { Arrow *operator->(); int n; };
+  template struct M {
+Arrow a;
+auto f() -> Mn)>;
+  };
+
   struct Alien;
   bool operator&&(const Alien&, const Alien&);
 
   template 
   S< S::cond && 1 > N::foo() { }
+
+  template
+  auto M::f() -> Mn)> {}
 }
 
 namespace PR7460 {


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


r285000 - [analyzer] Use unsigned integers to rely on well-defined overflow semantics.

2016-10-24 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Oct 24 13:49:04 2016
New Revision: 285000

URL: http://llvm.org/viewvc/llvm-project?rev=285000&view=rev
Log:
[analyzer] Use unsigned integers to rely on well-defined overflow semantics.

Found by the UBSan buildbot.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp?rev=285000&r1=284999&r2=285000&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
(original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp Mon 
Oct 24 13:49:04 2016
@@ -83,7 +83,7 @@ class StdLibraryFunctionsChecker : publi
   /// a non-negative integer, which less than 5 and not equal to 2. For
   /// `ComparesToArgument', holds information about how exactly to compare to
   /// the argument.
-  typedef std::vector> IntRangeVectorTy;
+  typedef std::vector> IntRangeVectorTy;
 
   /// A reference to an argument or return value by its number.
   /// ArgNo in CallExpr and CallEvent is defined as Unsigned, but
@@ -274,7 +274,7 @@ StdLibraryFunctionsChecker::ValueRange::
 const llvm::APSInt &MinusInf = BVF.getMinValue(T);
 const llvm::APSInt &PlusInf = BVF.getMaxValue(T);
 
-const llvm::APSInt &Left = BVF.getValue(R[0].first - 1, T);
+const llvm::APSInt &Left = BVF.getValue(R[0].first - 1ULL, T);
 if (Left != PlusInf) {
   assert(MinusInf <= Left);
   State = CM.assumeWithinInclusiveRange(State, *N, MinusInf, Left, false);
@@ -282,7 +282,7 @@ StdLibraryFunctionsChecker::ValueRange::
 return nullptr;
 }
 
-const llvm::APSInt &Right = BVF.getValue(R[E - 1].second + 1, T);
+const llvm::APSInt &Right = BVF.getValue(R[E - 1].second + 1ULL, T);
 if (Right != MinusInf) {
   assert(Right <= PlusInf);
   State = CM.assumeWithinInclusiveRange(State, *N, Right, PlusInf, false);
@@ -291,8 +291,8 @@ StdLibraryFunctionsChecker::ValueRange::
 }
 
 for (size_t I = 1; I != E; ++I) {
-  const llvm::APSInt &Min = BVF.getValue(R[I - 1].second + 1, T);
-  const llvm::APSInt &Max = BVF.getValue(R[I].first - 1, T);
+  const llvm::APSInt &Min = BVF.getValue(R[I - 1].second + 1ULL, T);
+  const llvm::APSInt &Max = BVF.getValue(R[I].first - 1ULL, T);
   assert(Min <= Max);
   State = CM.assumeWithinInclusiveRange(State, *N, Min, Max, false);
   if (!State)


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


Re: r284960 - [analyzer] Add StdLibraryFunctions checker.

2016-10-24 Thread Artem Dergachev via cfe-commits

Thanks! Should get better with r285000.

On 10/24/16 9:34 PM, Evgenii Stepanov wrote:

This code also fails with UBSan:

tools/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:285:62:
runtime error: signed integer overflow: 9223372036854775807 + 1 cannot
be represented in type 'long'
 #0 0x5e1642f in (anonymous
namespace)::StdLibraryFunctionsChecker::ValueRange::applyAsWithinRange(llvm::IntrusiveRefCntPtr, clang::ento::CallEvent const&, (anonymous
namespace)::StdLibraryFunctionsChecker::FunctionSummaryTy const&)
const 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:285:62
 #1 0x5e0f4c3 in (anonymous
namespace)::StdLibraryFunctionsChecker::ValueRange::apply(llvm::IntrusiveRefCntPtr, clang::ento::CallEvent const&, (anonymous
namespace)::StdLibraryFunctionsChecker::FunctionSummaryTy const&)
const 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:149:16
 #2 0x5e0eb00 in (anonymous
namespace)::StdLibraryFunctionsChecker::checkPostCall(clang::ento::CallEvent
const&, clang::ento::CheckerContext&) const
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:350:21


http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/18/steps/check-clang%20ubsan/logs/stdio


On Mon, Oct 24, 2016 at 6:23 AM, Renato Golin via cfe-commits
 wrote:

On 24 October 2016 at 14:09, Artem Dergachev  wrote:

Strange, i'm not receiving any buildbot emails again. Will look through bots
manually next time, that doesn't sound too hard. Pushed a hotfix in r284969.

The buildmaster was restarted this weekend and got all old builds data wiped.

I only know because I have a monitoring page.

Galina,

Any info on the server migration and the email configuration?

Thanks!
--renato
___
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] D25893: [clang] Remove redundant --check-prefix=CHECK from tests

2016-10-24 Thread Mandeep Singh Grang via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285001: [clang] Remove redundant --check-prefix=CHECK from 
tests (authored by mgrang).

Changed prior to commit:
  https://reviews.llvm.org/D25893?vs=75521&id=75620#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25893

Files:
  cfe/trunk/test/CodeGen/ms-mm-align.c
  cfe/trunk/test/CodeGen/windows-on-arm-stack-probe-size.c


Index: cfe/trunk/test/CodeGen/ms-mm-align.c
===
--- cfe/trunk/test/CodeGen/ms-mm-align.c
+++ cfe/trunk/test/CodeGen/ms-mm-align.c
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 -target-feature +sse \
 // RUN: -triple i686--windows -emit-llvm %s -o - \
-// RUN: | FileCheck %s -check-prefix CHECK
+// RUN: | FileCheck %s
 
 // intrin.h needs size_t, but -ffreestanding prevents us from getting it from
 // stddef.h.  Work around it with this typedef.
Index: cfe/trunk/test/CodeGen/windows-on-arm-stack-probe-size.c
===
--- cfe/trunk/test/CodeGen/windows-on-arm-stack-probe-size.c
+++ cfe/trunk/test/CodeGen/windows-on-arm-stack-probe-size.c
@@ -5,7 +5,7 @@
 // RUN: | FileCheck %s -check-prefix CHECK-4096
 
 // RUN: %clang_cc1 -triple thumbv7-windows-itanium -fms-extensions -O2 
-emit-llvm %s -o - \
-// RUN: | FileCheck %s -check-prefix CHECK
+// RUN: | FileCheck %s
 
 __declspec(dllimport) void initialise(signed char buffer[4096]);
 


Index: cfe/trunk/test/CodeGen/ms-mm-align.c
===
--- cfe/trunk/test/CodeGen/ms-mm-align.c
+++ cfe/trunk/test/CodeGen/ms-mm-align.c
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -target-feature +sse \
 // RUN: -triple i686--windows -emit-llvm %s -o - \
-// RUN: | FileCheck %s -check-prefix CHECK
+// RUN: | FileCheck %s
 
 // intrin.h needs size_t, but -ffreestanding prevents us from getting it from
 // stddef.h.  Work around it with this typedef.
Index: cfe/trunk/test/CodeGen/windows-on-arm-stack-probe-size.c
===
--- cfe/trunk/test/CodeGen/windows-on-arm-stack-probe-size.c
+++ cfe/trunk/test/CodeGen/windows-on-arm-stack-probe-size.c
@@ -5,7 +5,7 @@
 // RUN: | FileCheck %s -check-prefix CHECK-4096
 
 // RUN: %clang_cc1 -triple thumbv7-windows-itanium -fms-extensions -O2 -emit-llvm %s -o - \
-// RUN: | FileCheck %s -check-prefix CHECK
+// RUN: | FileCheck %s
 
 __declspec(dllimport) void initialise(signed char buffer[4096]);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285001 - [clang] Remove redundant --check-prefix=CHECK from tests

2016-10-24 Thread Mandeep Singh Grang via cfe-commits
Author: mgrang
Date: Mon Oct 24 13:53:43 2016
New Revision: 285001

URL: http://llvm.org/viewvc/llvm-project?rev=285001&view=rev
Log:
[clang] Remove redundant --check-prefix=CHECK from tests

Reviewers: mkuper, rengolin, hans

Subscribers: cfe-commits

Tags: #clang-c

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

Modified:
cfe/trunk/test/CodeGen/ms-mm-align.c
cfe/trunk/test/CodeGen/windows-on-arm-stack-probe-size.c

Modified: cfe/trunk/test/CodeGen/ms-mm-align.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-mm-align.c?rev=285001&r1=285000&r2=285001&view=diff
==
--- cfe/trunk/test/CodeGen/ms-mm-align.c (original)
+++ cfe/trunk/test/CodeGen/ms-mm-align.c Mon Oct 24 13:53:43 2016
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 -target-feature +sse \
 // RUN: -triple i686--windows -emit-llvm %s -o - \
-// RUN: | FileCheck %s -check-prefix CHECK
+// RUN: | FileCheck %s
 
 // intrin.h needs size_t, but -ffreestanding prevents us from getting it from
 // stddef.h.  Work around it with this typedef.

Modified: cfe/trunk/test/CodeGen/windows-on-arm-stack-probe-size.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/windows-on-arm-stack-probe-size.c?rev=285001&r1=285000&r2=285001&view=diff
==
--- cfe/trunk/test/CodeGen/windows-on-arm-stack-probe-size.c (original)
+++ cfe/trunk/test/CodeGen/windows-on-arm-stack-probe-size.c Mon Oct 24 
13:53:43 2016
@@ -5,7 +5,7 @@
 // RUN: | FileCheck %s -check-prefix CHECK-4096
 
 // RUN: %clang_cc1 -triple thumbv7-windows-itanium -fms-extensions -O2 
-emit-llvm %s -o - \
-// RUN: | FileCheck %s -check-prefix CHECK
+// RUN: | FileCheck %s
 
 __declspec(dllimport) void initialise(signed char buffer[4096]);
 


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


[PATCH] D25902: [AVX-512] Fix the operand order for all calls to __builtin_ia32_vfmaddss3_mask.

2016-10-24 Thread Craig Topper via cfe-commits
craig.topper added inline comments.



Comment at: lib/Headers/avx512fintrin.h:8394
   _MM_FROUND_CUR_DIRECTION);
 }
 

delena wrote:
> Using vfmaddss3_mask is wrong in this case.
> It will propagate -B to lower bits if mask==0.
I dont' understand this. The passthru should be from the first argument. This 
call should do

if (mask)
   result = _W * _A - _B
else
   result = _W;



Comment at: lib/Headers/avx512fintrin.h:8453
 {
  return (__m128) __builtin_ia32_vfmaddss3_maskz (-(__v4sf) __A,
   (__v4sf) __B,

delena wrote:
> This one is, probably, also wrong, because we should copy the upper bits of 
> __A as is.
> 
> IF k[0]
>   dst[31:0] := -(a[31:0] * b[31:0]) + c[31:0]
> ELSE
>   dst[31:0] := c[31:0]
> FI
> dst[127:32] := a[127:32]
> dst[MAX:128] := 0
Agree this is also wrong. I was going to try to fix one intrinsic at a time. We 
have some problems with __builtin_ia32_vfmaddss3_mask3 usages as well.


https://reviews.llvm.org/D25902



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


Re: [PATCH] D25817: [Sema] Improve the error diagnostic for dot destructor calls on pointer objects

2016-10-24 Thread David Blaikie via cfe-commits
On Fri, Oct 21, 2016 at 3:16 AM Alex Lorenz  wrote:

> arphaman updated this revision to Diff 75403.
> arphaman added a comment.
>
> The updated patch improves error handling and adds a test for the fixit.
>
> > If we issue a fixit we should recover as-if the code was written with
> the fixit in. Does this code do that? (can we test it? I know we test some
> fixits - not sure it's necessary/worthwhile to test them all, but maybe we
> have a good idiom for testing that the recovery is correct)
>
> This code does perform recovery, but the constructed AST for the
> destructor calls is different from the AST that would have been constructed
> if the code was correct: we still end up building the pseudo destructor
> expression. I'm not sure how important is that though, so please let me
> know if I should try and make the ASTs the same.
>

I imagine we need the matching AST, but don't know for sure/how the
difference might result in different behavior downstream (CC'd Mr. Smith in
case he can quickly provide an opinion here)


>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D25817
>
> Files:
>   lib/Sema/SemaExprCXX.cpp
>   test/CXX/special/class.dtor/p10-0x.cpp
>   test/FixIt/fixit.cpp
>   test/SemaCXX/pseudo-destructors.cpp
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25895: [MS ABI] Reuse getVFPtrOffsets instead of using getClassAtVTableLocation

2016-10-24 Thread Reid Kleckner 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/MicrosoftCXXABI.cpp:1779-1780
+  MicrosoftVTableContext &VFTContext = CGM.getMicrosoftVTableContext();
   MicrosoftVTableContext::MethodVFTableLocation ML =
-  CGM.getMicrosoftVTableContext().getMethodVFTableLocation(GD);
+  VFTContext.getMethodVFTableLocation(GD);
+

Idle thought for future patches: we should feel ML into 
adjustThisArgumentForVirtualCall to save the double hash lookup.


https://reviews.llvm.org/D25895



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


[PATCH] D25063: [x86][inline-asm][AVX512][clang][PART-1] Introducing "k" and "Yk" constraints for extended inline assembly, enabling use of AVX512 masked vectorized instructions.

2016-10-24 Thread Reid Kleckner 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/D25063



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


[PATCH] D25920: AMDGPU: Add missing ISA versions gfx7.x.x and 8.x.x.

2016-10-24 Thread Yaxun Liu via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tstellarAMD, arsenm.
yaxunl added a subscriber: cfe-commits.
Herald added subscribers: tony-tye, wdng, kzhuravl.

Patch by Laurent Morichetti.


https://reviews.llvm.org/D25920

Files:
  lib/Basic/Targets.cpp


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2176,6 +2176,9 @@
   .Case("kaveri",GK_GFX7)
   .Case("hawaii",GK_GFX7)
   .Case("mullins",   GK_GFX7)
+  .Case("gfx700",GK_GFX7)
+  .Case("gfx701",GK_GFX7)
+  .Case("gfx702",GK_GFX7)
   .Case("tonga", GK_GFX8)
   .Case("iceland",   GK_GFX8)
   .Case("carrizo",   GK_GFX8)
@@ -2183,6 +2186,12 @@
   .Case("stoney",GK_GFX8)
   .Case("polaris10", GK_GFX8)
   .Case("polaris11", GK_GFX8)
+  .Case("gfx800",GK_GFX8)
+  .Case("gfx801",GK_GFX8)
+  .Case("gfx802",GK_GFX8)
+  .Case("gfx803",GK_GFX8)
+  .Case("gfx804",GK_GFX8)
+  .Case("gfx810",GK_GFX8)
   .Default(GK_NONE);
   }
 


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2176,6 +2176,9 @@
   .Case("kaveri",GK_GFX7)
   .Case("hawaii",GK_GFX7)
   .Case("mullins",   GK_GFX7)
+  .Case("gfx700",GK_GFX7)
+  .Case("gfx701",GK_GFX7)
+  .Case("gfx702",GK_GFX7)
   .Case("tonga", GK_GFX8)
   .Case("iceland",   GK_GFX8)
   .Case("carrizo",   GK_GFX8)
@@ -2183,6 +2186,12 @@
   .Case("stoney",GK_GFX8)
   .Case("polaris10", GK_GFX8)
   .Case("polaris11", GK_GFX8)
+  .Case("gfx800",GK_GFX8)
+  .Case("gfx801",GK_GFX8)
+  .Case("gfx802",GK_GFX8)
+  .Case("gfx803",GK_GFX8)
+  .Case("gfx804",GK_GFX8)
+  .Case("gfx810",GK_GFX8)
   .Default(GK_NONE);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285007 - Revert "Add support for __builtin_os_log_format[_buffer_size]"

2016-10-24 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Mon Oct 24 14:41:36 2016
New Revision: 285007

URL: http://llvm.org/viewvc/llvm-project?rev=285007&view=rev
Log:
Revert "Add support for __builtin_os_log_format[_buffer_size]"

This reverts commit r284990, two opencl test are broken

Removed:
cfe/trunk/include/clang/Analysis/Analyses/OSLog.h
cfe/trunk/lib/Analysis/OSLog.cpp
cfe/trunk/test/CodeGenObjC/os_log.m
cfe/trunk/test/SemaObjC/format-strings-oslog.m
Modified:
cfe/trunk/include/clang/Analysis/Analyses/FormatString.h
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Analysis/CMakeLists.txt
cfe/trunk/lib/Analysis/FormatString.cpp
cfe/trunk/lib/Analysis/PrintfFormatString.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/CodeGen/builtins.c

Modified: cfe/trunk/include/clang/Analysis/Analyses/FormatString.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/FormatString.h?rev=285007&r1=285006&r2=285007&view=diff
==
--- cfe/trunk/include/clang/Analysis/Analyses/FormatString.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/FormatString.h Mon Oct 24 
14:41:36 2016
@@ -35,7 +35,7 @@ class OptionalFlag {
 public:
   OptionalFlag(const char *Representation)
   : representation(Representation), flag(false) {}
-  bool isSet() const { return flag; }
+  bool isSet() { return flag; }
   void set() { flag = true; }
   void clear() { flag = false; }
   void setPosition(const char *position) {
@@ -122,13 +122,12 @@ class ConversionSpecifier {
 public:
   enum Kind {
 InvalidSpecifier = 0,
-// C99 conversion specifiers.
+  // C99 conversion specifiers.
 cArg,
 dArg,
 DArg, // Apple extension
 iArg,
-IntArgBeg = dArg,
-IntArgEnd = iArg,
+IntArgBeg = dArg, IntArgEnd = iArg,
 
 oArg,
 OArg, // Apple extension
@@ -136,8 +135,7 @@ public:
 UArg, // Apple extension
 xArg,
 XArg,
-UIntArgBeg = oArg,
-UIntArgEnd = XArg,
+UIntArgBeg = oArg, UIntArgEnd = XArg,
 
 fArg,
 FArg,
@@ -147,8 +145,7 @@ public:
 GArg,
 aArg,
 AArg,
-DoubleArgBeg = fArg,
-DoubleArgEnd = AArg,
+DoubleArgBeg = fArg, DoubleArgEnd = AArg,
 
 sArg,
 pArg,
@@ -157,19 +154,13 @@ public:
 CArg,
 SArg,
 
-// Apple extension: P specifies to os_log that the data being pointed to is
-// to be copied by os_log. The precision indicates the number of bytes to
-// copy.
-PArg,
-
 // ** Printf-specific **
 
 ZArg, // MS extension
 
 // Objective-C specific specifiers.
-ObjCObjArg, // '@'
-ObjCBeg = ObjCObjArg,
-ObjCEnd = ObjCObjArg,
+ObjCObjArg,  // '@'
+ObjCBeg = ObjCObjArg, ObjCEnd = ObjCObjArg,
 
 // FreeBSD kernel specific specifiers.
 FreeBSDbArg,
@@ -178,15 +169,13 @@ public:
 FreeBSDyArg,
 
 // GlibC specific specifiers.
-PrintErrno, // 'm'
+PrintErrno,   // 'm'
 
-PrintfConvBeg = ObjCObjArg,
-PrintfConvEnd = PrintErrno,
+PrintfConvBeg = ObjCObjArg, PrintfConvEnd = PrintErrno,
 
 // ** Scanf-specific **
 ScanListArg, // '['
-ScanfConvBeg = ScanListArg,
-ScanfConvEnd = ScanListArg
+ScanfConvBeg = ScanListArg, ScanfConvEnd = ScanListArg
   };
 
   ConversionSpecifier(bool isPrintf = true)
@@ -448,15 +437,13 @@ class PrintfSpecifier : public analyze_f
   OptionalFlag HasAlternativeForm; // '#'
   OptionalFlag HasLeadingZeroes; // '0'
   OptionalFlag HasObjCTechnicalTerm; // '[tt]'
-  OptionalFlag IsPrivate;// '{private}'
-  OptionalFlag IsPublic; // '{public}'
   OptionalAmount Precision;
 public:
-  PrintfSpecifier()
-  : FormatSpecifier(/* isPrintf = */ true), HasThousandsGrouping("'"),
-IsLeftJustified("-"), HasPlusPrefix("+"), HasSpacePrefix(" "),
-HasAlternativeForm("#"), HasLeadingZeroes("0"),
-HasObjCTechnicalTerm("tt"), IsPrivate("private"), IsPublic("public") {}
+  PrintfSpecifier() :
+FormatSpecifier(/* isPrintf = */ true),
+HasThousandsGrouping("'"), IsLeftJustified("-"), HasPlusPrefix("+"),
+HasSpacePrefix(" "), HasAlternativeForm("#"), HasLeadingZeroes("0"),
+HasObjCTechnicalTerm("tt") {}
 
   static PrintfSpecifier Parse(const char *beg, const char *end);
 
@@ -485,8 +472,6 @@ public:
   void setHasObjCTechnicalTerm(const char *position) {
 HasObjCTechnicalTerm.setPosition(position);
   }
-  void setIsPrivate(const char *position) { IsPrivate.setPosition(position); }
-  void setIsPublic(const char *position) { IsPublic.setPosition(position); }
   void setUsesPositionalArg() { UsesPositionalArg = true; }
 
 // Methods for querying the format specifier.
@@ -524,8 +509,6 @@ public:
   const OptionalFlag &hasLeadingZeros() const { return H

RE: [PATCH] D25343: [OpenCL] Mark group functions as convergent in opencl-c.h

2016-10-24 Thread Liu, Yaxun (Sam) via cfe-commits
Just my two cents.

Let's consider a simple example:

for (int I = 0; I < 2; I++) {
  A = Compute();
  barrier();
  Use(A);
}

This does not mean Compute() needs to be executed for all the loop iterations 
before barrier() being executed. This only means that during each loop 
iteration, Compute() needs to be executed by all threads before barrier is 
executed by all threads. Otherwise, we cannot use barrier() in a loop at all.

Semantically the above program is not different from the following one:

  A = Compute();
  barrier();
  Use(A);
  A = Compute();
  barrier();
  Use(A);

Even if Compute() and Use() have side effect, they are still equivalent 
programs.

Sam

-Original Message-
From: Anastasia Stulova [mailto:anastasia.stul...@arm.com] 
Sent: Monday, October 24, 2016 1:08 PM
To: Liu, Yaxun (Sam) ; alexey.ba...@intel.com; 
anastasia.stul...@arm.com; aaron.ball...@gmail.com
Cc: Stellard, Thomas ; Arsenault, Matthew 
; Sumner, Brian ; 
cfe-commits@lists.llvm.org
Subject: [PATCH] D25343: [OpenCL] Mark group functions as convergent in 
opencl-c.h

Anastasia added a comment.

In https://reviews.llvm.org/D25343#567374, @tstellarAMD wrote:

> In https://reviews.llvm.org/D25343#565288, @Anastasia wrote:
>
> > Do you have any code example where Clang/LLVM performs wrong optimizations 
> > with respect to the control flow of SPMD execution?
> >
> > My understanding from the earlier discussion we have had: 
> > https://www.mail-archive.com/cfe-commits@lists.llvm.org/msg22643.html that 
> > noduplicate is essentially enough for the frontend to prevent erroneous 
> > optimizations. Because in general compiler can't do much with unknown 
> > function calls.
>
>
> noduplicate is enough for correctness, but it prevents legal optimizations, 
> like unrolling loops with barriers.  The convergent attribute was added 
> specifically for these kinds of builtins, so we should be using it here 
> instead of noduplicate.
>
> > For LLVM intrinsics it is slightly different as I can deduce from this 
> > discussion:http://lists.llvm.org/pipermail/llvm-dev/2015-May/085558.html . 
> > It seems like by default it's assumed to be side effect free and can be 
> > optimized in various ways.




In https://reviews.llvm.org/D25343#567374, @tstellarAMD wrote:

> In https://reviews.llvm.org/D25343#565288, @Anastasia wrote:
>
> > Do you have any code example where Clang/LLVM performs wrong optimizations 
> > with respect to the control flow of SPMD execution?
> >
> > My understanding from the earlier discussion we have had: 
> > https://www.mail-archive.com/cfe-commits@lists.llvm.org/msg22643.html that 
> > noduplicate is essentially enough for the frontend to prevent erroneous 
> > optimizations. Because in general compiler can't do much with unknown 
> > function calls.
>
>
> noduplicate is enough for correctness, but it prevents legal optimizations, 
> like unrolling loops with barriers.  The convergent attribute was added 
> specifically for these kinds of builtins, so we should be using it here 
> instead of noduplicate.
>
> > For LLVM intrinsics it is slightly different as I can deduce from this 
> > discussion:http://lists.llvm.org/pipermail/llvm-dev/2015-May/085558.html . 
> > It seems like by default it's assumed to be side effect free and can be 
> > optimized in various ways.


Tom, as far as I understand a valid generalized use case with a barrier is as 
follows:

  a = compute() 
  barrier()
  use(a)

Regarding unrolling I don't see how the barrier can be unrolled without 
breaking the correctness of OpenCL programs because all compute() calls of one 
WG have to complete before use(a) is invoked for the first time. I am not an 
expert in LLVM transformations but if I read the description of both 
noduplicate and convergent (http://llvm.org/docs/LangRef.html) none of those 
seem to make sense to me for the barrier because both allow reordering within 
the same function or BB respectively and the only valid way seems to mark it as 
a side-effect intrinsic to prevent any reordering of the barrier itself. I 
understand within compute() or use() independently there are not limitations on 
ordering of instructions.

If you have any specific example in mind where the unrolling would work could 
you please elaborate on it. I think it's essential for the community to 
undertsnad the use cases for noduplicate/convergent/sideeffect to make better 
use of them also across similar models i.e. OpenCL, CUDA, etc.


https://reviews.llvm.org/D25343



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


[PATCH] D25439: Fixed column shift when formatting line containing bit shift operators

2016-10-24 Thread Paweł Żukowski via cfe-commits
idlecode added a comment.

Thanks for pointing it out, just a minute ago I found a proper document 
 mentioning it (I have no idea how I 
could miss it).
I hope to be more use in future :)




Comment at: unittests/Format/FormatTest.cpp:11365
+TEST_F(FormatTest, BitshiftOperatorWidth) {
+  std::string left = "int a = 1 << 2; /* foo\n"
+ "   bar */";

djasper wrote:
> It's always useful to have some other formatting being done in the same test. 
> We repeatedly ran into cases in the past where a test only passed because 
> some change effectively disabled formatting for a specific line. I suggest 
> writing these as:
> 
>   EXPECT_EQ("int a = 1 << 2; /* foo\n"
> "   bar */",
> format("inta=1<<2;  /* foo\n"
>"   bar */"));
Oh, that is worth mentioning, thanks :)



Comment at: unittests/Format/FormatTest.cpp:11365
+TEST_F(FormatTest, BitshiftOperatorWidth) {
+  std::string left = "int a = 1 << 2; /* foo\n"
+ "   bar */";

idlecode wrote:
> djasper wrote:
> > It's always useful to have some other formatting being done in the same 
> > test. We repeatedly ran into cases in the past where a test only passed 
> > because some change effectively disabled formatting for a specific line. I 
> > suggest writing these as:
> > 
> >   EXPECT_EQ("int a = 1 << 2; /* foo\n"
> > "   bar */",
> > format("inta=1<<2;  /* foo\n"
> >"   bar */"));
> Oh, that is worth mentioning, thanks :)
Oh, that is good to know; Done


https://reviews.llvm.org/D25439



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


[PATCH] D25439: Fixed column shift when formatting line containing bit shift operators

2016-10-24 Thread Paweł Żukowski via cfe-commits
idlecode updated this revision to Diff 75635.

https://reviews.llvm.org/D25439

Files:
  lib/Format/FormatTokenLexer.cpp
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -5501,6 +5501,18 @@
   verifyFormat("< < < < < < < < < < < < < < < < < < < < < < < < < < < < < <");
 }
 
+TEST_F(FormatTest, BitshiftOperatorWidth) {
+  EXPECT_EQ("int a = 1 << 2; /* foo\n"
+"   bar */",
+format("inta=1<<2;  /* foo\n"
+   "   bar */"));
+
+  EXPECT_EQ("int b = 256 >> 1; /* foo\n"
+" bar */",
+format("int  b  =256>>1 ;  /* foo\n"
+   "  bar */"));
+}
+
 TEST_F(FormatTest, UnderstandsBinaryOperators) {
   verifyFormat("COMPARE(a, ==, b);");
   verifyFormat("auto s = sizeof...(Ts) - 1;");
Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -525,10 +525,12 @@
   } else if (FormatTok->Tok.is(tok::greatergreater)) {
 FormatTok->Tok.setKind(tok::greater);
 FormatTok->TokenText = FormatTok->TokenText.substr(0, 1);
+++Column;
 StateStack.push(LexerState::TOKEN_STASHED);
   } else if (FormatTok->Tok.is(tok::lessless)) {
 FormatTok->Tok.setKind(tok::less);
 FormatTok->TokenText = FormatTok->TokenText.substr(0, 1);
+++Column;
 StateStack.push(LexerState::TOKEN_STASHED);
   }
 


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -5501,6 +5501,18 @@
   verifyFormat("< < < < < < < < < < < < < < < < < < < < < < < < < < < < < <");
 }
 
+TEST_F(FormatTest, BitshiftOperatorWidth) {
+  EXPECT_EQ("int a = 1 << 2; /* foo\n"
+"   bar */",
+format("inta=1<<2;  /* foo\n"
+   "   bar */"));
+
+  EXPECT_EQ("int b = 256 >> 1; /* foo\n"
+" bar */",
+format("int  b  =256>>1 ;  /* foo\n"
+   "  bar */"));
+}
+
 TEST_F(FormatTest, UnderstandsBinaryOperators) {
   verifyFormat("COMPARE(a, ==, b);");
   verifyFormat("auto s = sizeof...(Ts) - 1;");
Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -525,10 +525,12 @@
   } else if (FormatTok->Tok.is(tok::greatergreater)) {
 FormatTok->Tok.setKind(tok::greater);
 FormatTok->TokenText = FormatTok->TokenText.substr(0, 1);
+++Column;
 StateStack.push(LexerState::TOKEN_STASHED);
   } else if (FormatTok->Tok.is(tok::lessless)) {
 FormatTok->Tok.setKind(tok::less);
 FormatTok->TokenText = FormatTok->TokenText.substr(0, 1);
+++Column;
 StateStack.push(LexerState::TOKEN_STASHED);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25439: Fixed column shift when formatting line containing bit shift operators

2016-10-24 Thread Daniel Jasper via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good. Thank you!


https://reviews.llvm.org/D25439



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


[libcxx] r285011 - Fix shadow warnings in string_view tests. Patch from s...@microsoft.com

2016-10-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Oct 24 15:10:00 2016
New Revision: 285011

URL: http://llvm.org/viewvc/llvm-project?rev=285011&view=rev
Log:
Fix shadow warnings in string_view tests. Patch from s...@microsoft.com

Modified:

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp?rev=285011&r1=285010&r2=285011&view=diff
==
--- 
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp
 Mon Oct 24 15:10:00 2016
@@ -120,11 +120,10 @@ int main()
 test_npos(S(), SV("12345"), 5, S(""));
 test_npos(S(), SV("12345"), 6, S("not happening"));
 }
+
 {
-typedef std::string S;
-typedef std::string_view SV;
-S s;
-SV sv = "EFGH";
+std::string s;
+std::string_view sv = "EFGH";
 char arr[] = "IJKL";
 
 s.append("CDEF", 0);// calls append(const char *, len)
@@ -138,7 +137,7 @@ int main()
 s.append(sv, 0);  // calls append(T, pos, npos)
 assert(s == sv);
 s.clear();
-
+
 s.append(sv, 0, std::string::npos);   // calls append(T, pos, npos)
 assert(s == sv);
 s.clear();
@@ -154,10 +153,11 @@ int main()
 s.append(arr, 0); // calls append(const char *, len)
 assert(s == "");
 s.clear();
+}
 
 {
-S s = "ABCD";
-SV sv = s;
+std::string s = "ABCD";
+std::string_view sv = s;
 s.append(sv);
 assert(s == "ABCDABCD");
 
@@ -169,10 +169,10 @@ int main()
 s.append(sv, sv.size());
 assert(s == "ABCDABCDABCDABCD");
 }
-
+
 {
-S s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-SV sv = s;
+std::string s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+std::string_view sv = s;
 s.append(sv);
 assert(s == "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ");
 
@@ -180,5 +180,4 @@ int main()
 s.append(sv, 0, std::string::npos);
 assert(s == 
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ");
 }
-}
 }

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp?rev=285011&r1=285010&r2=285011&view=diff
==
--- 
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp
 Mon Oct 24 15:10:00 2016
@@ -119,11 +119,10 @@ int main()
 test_npos(S(), SV("12345"), 5, S(""));
 test_npos(S(), SV("12345"), 6, S("not happening"));
 }
+
 {
-typedef std::string S;
-typedef std::string_view SV;
-S s = "ABCD";
-SV sv = "EFGH";
+std::string s = "ABCD";
+std::string_view sv = "EFGH";
 char arr[] = "IJKL";
 
 s.assign("CDEF", 0);// calls assign(const char *, len)
@@ -137,7 +136,7 @@ int main()
 s.assign(sv, 0);  // calls assign(T, pos, npos)
 assert(s == sv);
 s.clear();
-
+
 s.assign(sv, 0, std::string::npos);   // calls assign(T, pos, npos)
 assert(s == sv);
 s.clear();
@@ -153,10 +152,11 @@ int main()
 s.assign(arr, 0); // calls assign(const char *, len)
 assert(s == "");
 s.clear();
+}
 
 {
-S s = "ABCD";
-SV sv = s;
+std::string s = "ABCD";
+std::string_view sv = s;
 s.assign(sv);
 assert(s == "ABCD");
 
@@ -164,10 +164,10 @@ int main()
 s.assign(sv, 0, std::string::npos);
 assert(s == "ABCD");
 }
-
+
 {
-S s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-SV sv = s;
+std::string s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+std::string_view sv = s;
 s.assign(sv);
 assert(s == "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
 
@@ -175,5 +175,4 @@ int main()
 s.assign(sv, 0, std::string::npos);
 assert(s == "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
 }
-}
 }


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


[libcxx] r285012 - Add missing include in string_view tests. Patch from Billy ONeil @ microsoft

2016-10-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Oct 24 15:11:17 2016
New Revision: 285012

URL: http://llvm.org/viewvc/llvm-project?rev=285012&view=rev
Log:
Add missing include in string_view tests. Patch from Billy ONeil @ microsoft

Modified:
libcxx/trunk/test/std/strings/string.view/string.view.ops/copy.pass.cpp

Modified: 
libcxx/trunk/test/std/strings/string.view/string.view.ops/copy.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/string.view/string.view.ops/copy.pass.cpp?rev=285012&r1=285011&r2=285012&view=diff
==
--- libcxx/trunk/test/std/strings/string.view/string.view.ops/copy.pass.cpp 
(original)
+++ libcxx/trunk/test/std/strings/string.view/string.view.ops/copy.pass.cpp Mon 
Oct 24 15:11:17 2016
@@ -19,6 +19,7 @@
 
 
 #include 
+#include 
 #include 
 
 #include "test_macros.h"


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


[PATCH] D25492: [libcxx] [test] Fix shadowing in string.assign and string.append

2016-10-24 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

r285011.


https://reviews.llvm.org/D25492



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


[PATCH] D25531: [libcxx] [test] Include in string_view::copy test

2016-10-24 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

r285012.


https://reviews.llvm.org/D25531



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


[PATCH] D24010: [ReachableCode] Skip over ExprWithCleanups in isConfigurationValue

2016-10-24 Thread Tim Shen via cfe-commits
timshen updated this revision to Diff 75644.
timshen added a comment.

Simplified the test.


https://reviews.llvm.org/D24010

Files:
  clang/include/clang/AST/Stmt.h
  clang/lib/Analysis/ReachableCode.cpp
  clang/test/SemaCXX/PR29152.cpp


Index: clang/test/SemaCXX/PR29152.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/PR29152.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunreachable-code -verify %s
+
+static const bool False = false;
+
+struct A {
+  ~A();
+  operator bool();
+};
+void Bar();
+
+void Foo() {
+  if (False && A()) {
+Bar(); // expected-no-diagnostics
+  }
+}
Index: clang/lib/Analysis/ReachableCode.cpp
===
--- clang/lib/Analysis/ReachableCode.cpp
+++ clang/lib/Analysis/ReachableCode.cpp
@@ -164,6 +164,8 @@
   if (!S)
 return false;
 
+  S = S->IgnoreImplicit();
+
   if (const Expr *Ex = dyn_cast(S))
 S = Ex->IgnoreCasts();
 
Index: clang/include/clang/AST/Stmt.h
===
--- clang/include/clang/AST/Stmt.h
+++ clang/include/clang/AST/Stmt.h
@@ -387,6 +387,9 @@
   /// Skip past any implicit AST nodes which might surround this
   /// statement, such as ExprWithCleanups or ImplicitCastExpr nodes.
   Stmt *IgnoreImplicit();
+  const Stmt *IgnoreImplicit() const {
+return const_cast(this)->IgnoreImplicit();
+  }
 
   /// \brief Skip no-op (attributed, compound) container stmts and skip 
captured
   /// stmt at the top, if \a IgnoreCaptured is true.


Index: clang/test/SemaCXX/PR29152.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/PR29152.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunreachable-code -verify %s
+
+static const bool False = false;
+
+struct A {
+  ~A();
+  operator bool();
+};
+void Bar();
+
+void Foo() {
+  if (False && A()) {
+Bar(); // expected-no-diagnostics
+  }
+}
Index: clang/lib/Analysis/ReachableCode.cpp
===
--- clang/lib/Analysis/ReachableCode.cpp
+++ clang/lib/Analysis/ReachableCode.cpp
@@ -164,6 +164,8 @@
   if (!S)
 return false;
 
+  S = S->IgnoreImplicit();
+
   if (const Expr *Ex = dyn_cast(S))
 S = Ex->IgnoreCasts();
 
Index: clang/include/clang/AST/Stmt.h
===
--- clang/include/clang/AST/Stmt.h
+++ clang/include/clang/AST/Stmt.h
@@ -387,6 +387,9 @@
   /// Skip past any implicit AST nodes which might surround this
   /// statement, such as ExprWithCleanups or ImplicitCastExpr nodes.
   Stmt *IgnoreImplicit();
+  const Stmt *IgnoreImplicit() const {
+return const_cast(this)->IgnoreImplicit();
+  }
 
   /// \brief Skip no-op (attributed, compound) container stmts and skip captured
   /// stmt at the top, if \a IgnoreCaptured is true.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24010: [ReachableCode] Skip over ExprWithCleanups in isConfigurationValue

2016-10-24 Thread Tim Shen via cfe-commits
On Mon, Oct 24, 2016 at 10:33 AM David Blaikie  wrote:

> On Mon, Aug 29, 2016 at 3:45 PM Tim Shen via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> timshen created this revision.
> timshen added reviewers: rsmith, pirama.
> timshen added a subscriber: cfe-commits.
>
> https://reviews.llvm.org/D24010
>
> Files:
>   clang/include/clang/AST/Stmt.h
>   clang/lib/Analysis/ReachableCode.cpp
>   clang/test/SemaCXX/PR29152.cpp
>
> Index: clang/test/SemaCXX/PR29152.cpp
> ===
> --- /dev/null
> +++ clang/test/SemaCXX/PR29152.cpp
> @@ -0,0 +1,19 @@
> +// RUN: %clang_cc1 -fsyntax-only -Wunreachable-code -verify %s
> +
> +static const bool False = false;
> +
> +struct Vector {
> +  struct iterator {
> +bool operator==(const iterator &) const;
> +  };
> +  iterator end();
> +};
> +
> +void Bar();
> +Vector::iterator Find(Vector &a);
> +
> +void Foo(Vector &a) {
> +  if (False && Find(a) == a.end()) {
> +Bar(); // expected-no-diagnostics
> +  }
> +}
>
>
> What are the relevant parts of this test for this change?
>
> Is it the static const bool False that's interesting?
>
> Is it the op==/other interesting side effects on the RHS that are
> interesting?
>
> I'd be surprised if it were both (& if it isn't both, I'm guessing it's
> the former rather than the latter - in which case the latter can probably
> be reduced to just an arbitrary function call to, say: bool Baz())
>

It's the static const bool False. I actually managed to simplify the code
to remove the operator==() call.


>
>
> Index: clang/lib/Analysis/ReachableCode.cpp
> ===
> --- clang/lib/Analysis/ReachableCode.cpp
> +++ clang/lib/Analysis/ReachableCode.cpp
> @@ -164,6 +164,8 @@
>if (!S)
>  return false;
>
> +  S = S->IgnoreImplicit();
> +
>if (const Expr *Ex = dyn_cast(S))
>  S = Ex->IgnoreCasts();
>
> Index: clang/include/clang/AST/Stmt.h
> ===
> --- clang/include/clang/AST/Stmt.h
> +++ clang/include/clang/AST/Stmt.h
> @@ -387,6 +387,9 @@
>/// Skip past any implicit AST nodes which might surround this
>/// statement, such as ExprWithCleanups or ImplicitCastExpr nodes.
>Stmt *IgnoreImplicit();
> +  const Stmt *IgnoreImplicit() const {
> +return const_cast(this)->IgnoreImplicit();
> +  }
>
>/// \brief Skip no-op (attributed, compound) container stmts and skip
> captured
>/// stmt at the top, if \a IgnoreCaptured is true.
>
>
> ___
> 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


r285015 - Fix mangling of implicit calls to operator-> to only include a single "pt",

2016-10-24 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Oct 24 15:29:40 2016
New Revision: 285015

URL: http://llvm.org/viewvc/llvm-project?rev=285015&view=rev
Log:
Fix mangling of implicit calls to operator-> to only include a single "pt",
rather than including an extra one for each level of 'operator->()' invoked.

Modified:
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle.cpp

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=285015&r1=285014&r2=285015&view=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Mon Oct 24 15:29:40 2016
@@ -3735,7 +3735,10 @@ recurse:
   case Expr::CXXOperatorCallExprClass: {
 const CXXOperatorCallExpr *CE = cast(E);
 unsigned NumArgs = CE->getNumArgs();
-mangleOperatorName(CE->getOperator(), /*Arity=*/NumArgs);
+// A CXXOperatorCallExpr for OO_Arrow models only semantics, not syntax
+// (the enclosing MemberExpr covers the syntactic portion).
+if (CE->getOperator() != OO_Arrow)
+  mangleOperatorName(CE->getOperator(), /*Arity=*/NumArgs);
 // Mangle the arguments.
 for (unsigned i = 0; i != NumArgs; ++i)
   mangleExpression(CE->getArg(i));

Modified: cfe/trunk/test/CodeGenCXX/mangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle.cpp?rev=285015&r1=285014&r2=285015&view=diff
==
--- cfe/trunk/test/CodeGenCXX/mangle.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle.cpp Mon Oct 24 15:29:40 2016
@@ -,3 +,10 @@ void fn(T, __underlying_type(T)) {}
 template void fn(E, __underlying_type(E));
 // CHECK-LABEL: @_ZN6test552fnINS_1vT_U3eutS2_
 }
+
+namespace test56 {
+  struct A { A *operator->(); int n; } a;
+  template void f(decltype(a->n + N)) {}
+  // CHECK-LABEL: @_ZN6test561fILi0EEEvDTplptL_ZNS_1aEE1nT_E
+  template void f<0>(int);
+}


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


[PATCH] D25925: [clang-tidy] Update cert-err58-cpp to match its new generalised form.

2016-10-24 Thread Malcolm Parsons via cfe-commits
malcolm.parsons created this revision.
malcolm.parsons added a reviewer: aaron.ballman.
malcolm.parsons added a subscriber: cfe-commits.

Aaron modified cert-err58-cpp to include all exceptions thrown before main()
Update the check to match.


https://reviews.llvm.org/D25925

Files:
  clang-tidy/cert/StaticObjectExceptionCheck.cpp
  docs/clang-tidy/checks/cert-err58-cpp.rst
  test/clang-tidy/cert-static-object-exception.cpp

Index: test/clang-tidy/cert-static-object-exception.cpp
===
--- test/clang-tidy/cert-static-object-exception.cpp
+++ test/clang-tidy/cert-static-object-exception.cpp
@@ -16,39 +16,58 @@
   explicit V(const char *) {} // Can throw
 };
 
-struct Cleanup
-{
+struct Cleanup {
   ~Cleanup() {}
 };
 
 struct W {
   W(Cleanup c = {}) noexcept(false);
 };
 
+struct X {
+  X(S = {}) noexcept;
+};
+
+int f();
+int g() noexcept(false);
+int h() noexcept(true);
+
 
 S s;
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 's' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp]
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: initialization of 's' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp]
 // CHECK-MESSAGES: 4:3: note: possibly throwing constructor declared here
 T t; // ok
 U u;
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 'u' with static storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: initialization of 'u' with static storage duration may throw an exception that cannot be caught
 // CHECK-MESSAGES: 12:3: note: possibly throwing constructor declared here
 V v("v");
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 'v' with static storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: initialization of 'v' with static storage duration may throw an exception that cannot be caught
 // CHECK-MESSAGES: 16:12: note: possibly throwing constructor declared here
 W w;
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 'w' with static storage duration may throw an exception that cannot be caught
-// CHECK-MESSAGES: 25:3: note: possibly throwing constructor declared here
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: initialization of 'w' with static storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: 24:3: note: possibly throwing constructor declared here
+X x1(S{});
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: initialization of 'x1' with static storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: 4:3: note: possibly throwing constructor declared here
+// FIXME: Handle default arguments
+X x2();
+int i = f();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: initialization of 'i' with static storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: 31:5: note: possibly throwing function declared here
+int j = g();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: initialization of 'j' with static storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: 32:5: note: possibly throwing function declared here
+int k = h();
 
 thread_local S s3;
-// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: construction of 's3' with thread_local storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: initialization of 's3' with thread_local storage duration may throw an exception that cannot be caught
 thread_local T t3; // ok
 thread_local U u3;
-// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: construction of 'u3' with thread_local storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: initialization of 'u3' with thread_local storage duration may throw an exception that cannot be caught
 thread_local V v3("v");
-// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: construction of 'v3' with thread_local storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: initialization of 'v3' with thread_local storage duration may throw an exception that cannot be caught
 thread_local W w3;
-// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: construction of 'w3' with thread_local storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: initialization of 'w3' with thread_local storage duration may throw an exception that cannot be caught
 
 void f(S s1, T t1, U u1, V v1, W w1) { // ok, ok, ok, ok, ok
   S s2; // ok
@@ -72,44 +91,36 @@
 
 namespace {
 S s;
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 's' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp]
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: initialization of 's' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp

r285019 - Add support for __builtin_os_log_format[_buffer_size]

2016-10-24 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Mon Oct 24 15:39:34 2016
New Revision: 285019

URL: http://llvm.org/viewvc/llvm-project?rev=285019&view=rev
Log:
Add support for __builtin_os_log_format[_buffer_size]

This reverts commit r285007 and reapply r284990, with a fix for the
opencl test that I broke. Original commit message follows:

These new builtins support a mechanism for logging OS events, using a
printf-like format string to specify the layout of data in a buffer.
The _buffer_size version of the builtin can be used to determine the size
of the buffer to allocate to hold the data, and then __builtin_os_log_format
can write data into that buffer. This implements format checking to report
mismatches between the format string and the data arguments. Most of this
code was written by Chris Willmore.

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

Added:
cfe/trunk/include/clang/Analysis/Analyses/OSLog.h
cfe/trunk/lib/Analysis/OSLog.cpp
cfe/trunk/test/CodeGenObjC/os_log.m
cfe/trunk/test/SemaObjC/format-strings-oslog.m
Modified:
cfe/trunk/include/clang/Analysis/Analyses/FormatString.h
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Analysis/CMakeLists.txt
cfe/trunk/lib/Analysis/FormatString.cpp
cfe/trunk/lib/Analysis/PrintfFormatString.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/CodeGen/builtins.c

Modified: cfe/trunk/include/clang/Analysis/Analyses/FormatString.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/FormatString.h?rev=285019&r1=285018&r2=285019&view=diff
==
--- cfe/trunk/include/clang/Analysis/Analyses/FormatString.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/FormatString.h Mon Oct 24 
15:39:34 2016
@@ -35,7 +35,7 @@ class OptionalFlag {
 public:
   OptionalFlag(const char *Representation)
   : representation(Representation), flag(false) {}
-  bool isSet() { return flag; }
+  bool isSet() const { return flag; }
   void set() { flag = true; }
   void clear() { flag = false; }
   void setPosition(const char *position) {
@@ -122,12 +122,13 @@ class ConversionSpecifier {
 public:
   enum Kind {
 InvalidSpecifier = 0,
-  // C99 conversion specifiers.
+// C99 conversion specifiers.
 cArg,
 dArg,
 DArg, // Apple extension
 iArg,
-IntArgBeg = dArg, IntArgEnd = iArg,
+IntArgBeg = dArg,
+IntArgEnd = iArg,
 
 oArg,
 OArg, // Apple extension
@@ -135,7 +136,8 @@ public:
 UArg, // Apple extension
 xArg,
 XArg,
-UIntArgBeg = oArg, UIntArgEnd = XArg,
+UIntArgBeg = oArg,
+UIntArgEnd = XArg,
 
 fArg,
 FArg,
@@ -145,7 +147,8 @@ public:
 GArg,
 aArg,
 AArg,
-DoubleArgBeg = fArg, DoubleArgEnd = AArg,
+DoubleArgBeg = fArg,
+DoubleArgEnd = AArg,
 
 sArg,
 pArg,
@@ -154,13 +157,19 @@ public:
 CArg,
 SArg,
 
+// Apple extension: P specifies to os_log that the data being pointed to is
+// to be copied by os_log. The precision indicates the number of bytes to
+// copy.
+PArg,
+
 // ** Printf-specific **
 
 ZArg, // MS extension
 
 // Objective-C specific specifiers.
-ObjCObjArg,  // '@'
-ObjCBeg = ObjCObjArg, ObjCEnd = ObjCObjArg,
+ObjCObjArg, // '@'
+ObjCBeg = ObjCObjArg,
+ObjCEnd = ObjCObjArg,
 
 // FreeBSD kernel specific specifiers.
 FreeBSDbArg,
@@ -169,13 +178,15 @@ public:
 FreeBSDyArg,
 
 // GlibC specific specifiers.
-PrintErrno,   // 'm'
+PrintErrno, // 'm'
 
-PrintfConvBeg = ObjCObjArg, PrintfConvEnd = PrintErrno,
+PrintfConvBeg = ObjCObjArg,
+PrintfConvEnd = PrintErrno,
 
 // ** Scanf-specific **
 ScanListArg, // '['
-ScanfConvBeg = ScanListArg, ScanfConvEnd = ScanListArg
+ScanfConvBeg = ScanListArg,
+ScanfConvEnd = ScanListArg
   };
 
   ConversionSpecifier(bool isPrintf = true)
@@ -437,13 +448,15 @@ class PrintfSpecifier : public analyze_f
   OptionalFlag HasAlternativeForm; // '#'
   OptionalFlag HasLeadingZeroes; // '0'
   OptionalFlag HasObjCTechnicalTerm; // '[tt]'
+  OptionalFlag IsPrivate;// '{private}'
+  OptionalFlag IsPublic; // '{public}'
   OptionalAmount Precision;
 public:
-  PrintfSpecifier() :
-FormatSpecifier(/* isPrintf = */ true),
-HasThousandsGrouping("'"), IsLeftJustified("-"), HasPlusPrefix("+"),
-HasSpacePrefix(" "), HasAlternativeForm("#"), HasLeadingZeroes("0"),
-HasObjCTechnicalTerm("tt") {}
+  PrintfSpecifier()
+  : FormatSpecifier(/* isPrintf = */ true), HasThousandsGrouping("'"),
+IsLeftJustified("-"), HasPlusPrefix("+"), HasSpacePrefix(" "),
+HasAlternativeForm("#"), HasLeadingZeroes("0"),
+HasObjCTechnicalTerm("tt"), IsPrivate("private

[libcxx] r285020 - Fix non-portable tests for temp_directory_path(...)

2016-10-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Oct 24 15:40:35 2016
New Revision: 285020

URL: http://llvm.org/viewvc/llvm-project?rev=285020&view=rev
Log:
Fix non-portable tests for temp_directory_path(...)

Modified:

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp?rev=285020&r1=285019&r2=285020&view=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp
 Mon Oct 24 15:40:35 2016
@@ -51,7 +51,6 @@ TEST_CASE(basic_tests)
 const path dir_perms = env.create_dir("bad_perms_dir");
 const path nested_dir = env.create_dir("bad_perms_dir/nested");
 permissions(dir_perms, perms::none);
-const std::error_code set_ec = 
std::make_error_code(std::errc::address_in_use);
 const std::error_code expect_ec = 
std::make_error_code(std::errc::not_a_directory);
 struct TestCase {
   std::string name;
@@ -66,7 +65,7 @@ TEST_CASE(basic_tests)
 PutEnv(TC.name, TC.p);
 }
 for (auto& TC : cases) {
-std::error_code ec = set_ec;
+std::error_code ec = GetTestEC();
 path ret = temp_directory_path(ec);
 TEST_CHECK(!ec);
 TEST_CHECK(ret == TC.p);
@@ -75,21 +74,25 @@ TEST_CASE(basic_tests)
 // Set the env variable to a path that does not exist and check
 // that it fails.
 PutEnv(TC.name, dne);
-ec = set_ec;
+ec = GetTestEC();
 ret = temp_directory_path(ec);
-TEST_CHECK(ec == expect_ec);
+LIBCPP_ONLY(TEST_CHECK(ec == expect_ec));
+TEST_CHECK(ec != GetTestEC());
+TEST_CHECK(ec);
 TEST_CHECK(ret == "");
 
 // Set the env variable to point to a file and check that it fails.
 PutEnv(TC.name, file);
-ec = set_ec;
+ec = GetTestEC();
 ret = temp_directory_path(ec);
-TEST_CHECK(ec == expect_ec);
+LIBCPP_ONLY(TEST_CHECK(ec == expect_ec));
+TEST_CHECK(ec != GetTestEC());
+TEST_CHECK(ec);
 TEST_CHECK(ret == "");
 
 // Set the env variable to point to a dir we can't access
 PutEnv(TC.name, nested_dir);
-ec = set_ec;
+ec = GetTestEC();
 ret = temp_directory_path(ec);
 TEST_CHECK(ec == std::make_error_code(std::errc::permission_denied));
 TEST_CHECK(ret == "");
@@ -99,7 +102,7 @@ TEST_CASE(basic_tests)
 }
 // No env variables are defined
 {
-std::error_code ec = set_ec;
+std::error_code ec = GetTestEC();
 path ret = temp_directory_path(ec);
 TEST_CHECK(!ec);
 TEST_CHECK(ret == "/tmp");


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


r285022 - Fix bug where one of the cases where we mangle a failed

2016-10-24 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Oct 24 15:47:04 2016
New Revision: 285022

URL: http://llvm.org/viewvc/llvm-project?rev=285022&view=rev
Log:
Fix bug where one of the cases where we mangle a  failed
to emit the  portion. Refactor so that mangleUnresolvedName
actually emits the entire , so this mistake is harder to make
again.

Modified:
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle.cpp

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=285022&r1=285021&r2=285022&view=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Mon Oct 24 15:47:04 2016
@@ -467,6 +467,8 @@ private:
   bool recursive = false);
   void mangleUnresolvedName(NestedNameSpecifier *qualifier,
 DeclarationName name,
+const TemplateArgumentLoc *TemplateArgs,
+unsigned NumTemplateArgs,
 unsigned KnownArity = UnknownArity);
 
   void mangleFunctionEncodingBareType(const FunctionDecl *FD);
@@ -541,6 +543,8 @@ private:
 NestedNameSpecifier *qualifier,
 NamedDecl *firstQualifierLookup,
 DeclarationName name,
+const TemplateArgumentLoc *TemplateArgs,
+unsigned NumTemplateArgs,
 unsigned knownArity);
   void mangleCastExpression(const Expr *E, StringRef CastEncoding);
   void mangleInitListElements(const InitListExpr *InitList);
@@ -1159,9 +1163,10 @@ void CXXNameMangler::mangleUnresolvedPre
 
 /// Mangle an unresolved-name, which is generally used for names which
 /// weren't resolved to specific entities.
-void CXXNameMangler::mangleUnresolvedName(NestedNameSpecifier *qualifier,
-  DeclarationName name,
-  unsigned knownArity) {
+void CXXNameMangler::mangleUnresolvedName(
+NestedNameSpecifier *qualifier, DeclarationName name,
+const TemplateArgumentLoc *TemplateArgs, unsigned NumTemplateArgs,
+unsigned knownArity) {
   if (qualifier) mangleUnresolvedPrefix(qualifier);
   switch (name.getNameKind()) {
 //  ::= 
@@ -1189,6 +1194,11 @@ void CXXNameMangler::mangleUnresolvedNam
 case DeclarationName::ObjCZeroArgSelector:
   llvm_unreachable("Can't mangle Objective-C selector names here!");
   }
+
+  // The  and on  productions end in an optional
+  // .
+  if (TemplateArgs)
+mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
 }
 
 void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND,
@@ -3143,12 +3153,14 @@ void CXXNameMangler::mangleMemberExpr(co
   NestedNameSpecifier *qualifier,
   NamedDecl *firstQualifierLookup,
   DeclarationName member,
+  const TemplateArgumentLoc *TemplateArgs,
+  unsigned NumTemplateArgs,
   unsigned arity) {
   //  ::= dt  
   //  ::= pt  
   if (base)
 mangleMemberExprBase(base, isArrow);
-  mangleUnresolvedName(qualifier, member, arity);
+  mangleUnresolvedName(qualifier, member, TemplateArgs, NumTemplateArgs, 
arity);
 }
 
 /// Look at the callee of the given call expression and determine if
@@ -3446,7 +3458,9 @@ recurse:
 const MemberExpr *ME = cast(E);
 mangleMemberExpr(ME->getBase(), ME->isArrow(),
  ME->getQualifier(), nullptr,
- ME->getMemberDecl()->getDeclName(), Arity);
+ ME->getMemberDecl()->getDeclName(),
+ ME->getTemplateArgs(), ME->getNumTemplateArgs(),
+ Arity);
 break;
   }
 
@@ -3454,9 +3468,9 @@ recurse:
 const UnresolvedMemberExpr *ME = cast(E);
 mangleMemberExpr(ME->isImplicitAccess() ? nullptr : ME->getBase(),
  ME->isArrow(), ME->getQualifier(), nullptr,
- ME->getMemberName(), Arity);
-if (ME->hasExplicitTemplateArgs())
-  mangleTemplateArgs(ME->getTemplateArgs(), ME->getNumTemplateArgs());
+ ME->getMemberName(),
+ ME->getTemplateArgs(), ME->getNumTemplateArgs(),
+ Arity);
 break;
   }
 
@@ -3466,21 +3480,17 @@ recurse:
 mangleMemberExpr(ME->isImplicitAccess() ? nullptr : ME->getBase(),
  ME->isArrow(), ME->getQualifier(),
  ME->getFirstQualifierFoundInScope(),
- ME->getMember(), Arity);
-if (ME->hasExplicitTemplateArgs())
-  mangleTemplateArgs(ME->getTemplateArgs(), ME->getNumTemplateArgs());
+ ME->getMember(),
+ ME->getTem

r285023 - CodeGen: centralise label construction for method lists

2016-10-24 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon Oct 24 15:47:58 2016
New Revision: 285023

URL: http://llvm.org/viewvc/llvm-project?rev=285023&view=rev
Log:
CodeGen: centralise label construction for method lists

Move all the label construction for the various method list emission into
EmitMethodList.  Rather than have all the names be constructed in pieces in all
of the callers of EmitMethodList, have this occur in one site.  This also makes
the calls much easier to understand as we simplify identify the type of the
method list being emitted and the interface name for which it is being emitted.
NFC.

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

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=285023&r1=285022&r2=285023&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Mon Oct 24 15:47:58 2016
@@ -1082,6 +1082,17 @@ public:
QualType T) override;
 };
 
+enum class MethodListType {
+  CategoryInstanceMethods,
+  CategoryClassMethods,
+  InstanceMethods,
+  ClassMethods,
+  ProtocolInstanceMethods,
+  ProtocolClassMethods,
+  OptionalProtocolInstanceMethods,
+  OptionalProtocolClassMethods,
+};
+
 class CGObjCMac : public CGObjCCommonMac {
 private:
   ObjCTypesHelper ObjCTypes;
@@ -1144,7 +1155,7 @@ private:
 
   /// EmitMethodList - Emit the method list for the given
   /// implementation. The return value has type MethodListPtrTy.
-  llvm::Constant *EmitMethodList(Twine Name, StringRef Section,
+  llvm::Constant *EmitMethodList(Twine Name, MethodListType MLT,
  ArrayRef Methods);
 
   /// EmitMethodDescList - Emit a method description list for a list of
@@ -1336,8 +1347,9 @@ private:
 
   /// EmitMethodList - Emit the method list for the given
   /// implementation. The return value has type MethodListnfABITy.
-  llvm::Constant *EmitMethodList(Twine Name, StringRef Section,
+  llvm::Constant *EmitMethodList(Twine Name, MethodListType MLT,
  ArrayRef Methods);
+
   /// EmitIvarList - Emit the ivar list for the given
   /// implementation. If ForClass is true the list of class ivars
   /// (i.e. metaclass ivars) is emitted, otherwise the list of
@@ -3123,11 +3135,10 @@ void CGObjCMac::GenerateCategory(const O
   Values[0] = GetClassName(OCD->getName());
   Values[1] = GetClassName(Interface->getObjCRuntimeNameAsString());
   LazySymbols.insert(Interface->getIdentifier());
-  Values[2] = EmitMethodList("OBJC_CATEGORY_INSTANCE_METHODS_" + ExtName.str(),
- "__OBJC,__cat_inst_meth,regular,no_dead_strip",
+
+  Values[2] = EmitMethodList(ExtName, MethodListType::CategoryInstanceMethods,
  InstanceMethods);
-  Values[3] = EmitMethodList("OBJC_CATEGORY_CLASS_METHODS_" + ExtName.str(),
- "__OBJC,__cat_cls_meth,regular,no_dead_strip",
+  Values[3] = EmitMethodList(ExtName, MethodListType::CategoryClassMethods,
  ClassMethods);
   if (Category) {
 Values[4] =
@@ -3334,9 +3345,8 @@ void CGObjCMac::GenerateClass(const ObjC
   Values[ 4] = llvm::ConstantInt::get(ObjCTypes.LongTy, Flags);
   Values[ 5] = llvm::ConstantInt::get(ObjCTypes.LongTy, Size.getQuantity());
   Values[ 6] = EmitIvarList(ID, false);
-  Values[7] = EmitMethodList("OBJC_INSTANCE_METHODS_" + ID->getName(),
- "__OBJC,__inst_meth,regular,no_dead_strip",
- InstanceMethods);
+  Values[ 7] = EmitMethodList(ID->getName(), MethodListType::InstanceMethods,
+  InstanceMethods);
   // cache is always NULL.
   Values[ 8] = llvm::Constant::getNullValue(ObjCTypes.CachePtrTy);
   Values[ 9] = Protocols;
@@ -3398,9 +3408,8 @@ llvm::Constant *CGObjCMac::EmitMetaClass
   Values[ 4] = llvm::ConstantInt::get(ObjCTypes.LongTy, Flags);
   Values[ 5] = llvm::ConstantInt::get(ObjCTypes.LongTy, Size);
   Values[ 6] = EmitIvarList(ID, true);
-  Values[7] =
-  EmitMethodList("OBJC_CLASS_METHODS_" + ID->getNameAsString(),
- "__OBJC,__cls_meth,regular,no_dead_strip", Methods);
+  Values[ 7] = EmitMethodList(ID->getName(), MethodListType::ClassMethods,
+  Methods);
   // cache is always NULL.
   Values[ 8] = llvm::Constant::getNullValue(ObjCTypes.CachePtrTy);
   Values[ 9] = Protocols;
@@ -3608,7 +3617,7 @@ llvm::Constant *CGObjCMac::GetMethodCons
   return llvm::ConstantStruct::get(ObjCTypes.MethodTy, Method);
 }
 
-llvm::Constant *CGObjCMac::EmitMethodList(Twine Name, StringRef Section,
+llvm::Constant *CGObjCMac::EmitMethodList(Twine Name, MethodListType MLT,
   ArrayRef Methods) {
   // Return null for empty list.
   if (Methods.empty())
@@ -3622,8 +3631,35 @@ llvm::Constant *CGObjCMac::EmitMethodLis
 

[PATCH] D25925: [clang-tidy] Update cert-err58-cpp to match its new generalised form.

2016-10-24 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

Thank you for working on this! I have a few more test cases to try, but I think 
you're already handling them properly.




Comment at: test/clang-tidy/cert-static-object-exception.cpp:29
+  X(S = {}) noexcept;
+};
+

We should also have a test for implicitly-provided constructors, since those 
are `noexcept` if the data members all have `noexcept` constructors. Something 
like:
```
struct Y {
  S s;
};

Y y; // Diagnose

struct Z {
  T t;
};

Z z; // Do not diagnose
```



Comment at: test/clang-tidy/cert-static-object-exception.cpp:60
+// CHECK-MESSAGES: 32:5: note: possibly throwing function declared here
+int k = h();
 

Let's also make sure that we're properly catching conversion operators with a 
test like:
```
struct UserConv_Bad {
  operator int() noexcept(false);
};

struct UserConv_Good {
  operator int() noexcept;
};

UserConv_Bad some_bad_func();
UserConv_Good some_good_func();

int l = some_bad_func(); // Diagnose
int m = some_good_func(); // Do not diagnose
```


https://reviews.llvm.org/D25925



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


[PATCH] D24954: [Driver] Disable OpenSUSE rules for OpenSUSE/SLES 10 and older

2016-10-24 Thread Michał Górny via cfe-commits
mgorny added inline comments.



Comment at: lib/Driver/ToolChains.cpp:3942
+  int Version;
+  if (SplitLine.first.trim() != "VERSION")
+continue;

bruno wrote:
> You can check `Line.trim() != VERSION` before the `split` as to do not try to 
> split unnecessary lines.
You mean `line.trim().startswith()`, correct?


https://reviews.llvm.org/D24954



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


r285027 - Fix test on non-X86 platforms

2016-10-24 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Mon Oct 24 16:22:01 2016
New Revision: 285027

URL: http://llvm.org/viewvc/llvm-project?rev=285027&view=rev
Log:
Fix test on non-X86 platforms

This is a fixup for r285019, adding an `#ifdef __x86_64__` since
the os_log builtin is platform specific.

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

Modified: cfe/trunk/test/CodeGen/builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins.c?rev=285027&r1=285026&r2=285027&view=diff
==
--- cfe/trunk/test/CodeGen/builtins.c (original)
+++ cfe/trunk/test/CodeGen/builtins.c Mon Oct 24 16:22:01 2016
@@ -369,6 +369,9 @@ long long test_builtin_readcyclecounter(
   return __builtin_readcyclecounter();
 }
 
+// Behavior of __builtin_os_log differs between platforms, so only test on X86
+#ifdef __x86_64__
+
 // CHECK-LABEL: define void @test_builtin_os_log
 // CHECK: (i8* [[BUF:%.*]], i32 [[I:%.*]], i8* [[DATA:%.*]])
 void test_builtin_os_log(void *buf, int i, const char *data) {
@@ -506,3 +509,5 @@ void test_builtin_os_log_percent(void *b
   // CHECK: store i8* [[DATA2]], i8** [[ARG1_PTR]]
   __builtin_os_log_format(buf, "%s %%", data);
 }
+
+#endif
\ No newline at end of file


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


[PATCH] D24954: [Driver] Disable OpenSUSE rules for OpenSUSE/SLES 10 and older

2016-10-24 Thread Bruno Cardoso Lopes via cfe-commits
bruno added inline comments.



Comment at: lib/Driver/ToolChains.cpp:3942
+  int Version;
+  if (SplitLine.first.trim() != "VERSION")
+continue;

mgorny wrote:
> bruno wrote:
> > You can check `Line.trim() != VERSION` before the `split` as to do not try 
> > to split unnecessary lines.
> You mean `line.trim().startswith()`, correct?
Yep, you got the idea :-)


https://reviews.llvm.org/D24954



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


r285028 - CodeGen: remove incorrect temporary Twine

2016-10-24 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon Oct 24 16:25:57 2016
New Revision: 285028

URL: http://llvm.org/viewvc/llvm-project?rev=285028&view=rev
Log:
CodeGen: remove incorrect temporary Twine

Twines should not be stack allocated.  This somehow managed to get past me.

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

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=285028&r1=285027&r2=285028&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Mon Oct 24 16:25:57 2016
@@ -6282,8 +6282,8 @@ void CGObjCNonFragileABIMac::GenerateCat
 
   Values[1] = ClassGV;
   std::vector Methods;
-  Twine ListName =
-  Interface->getObjCRuntimeNameAsString() + "_$_" + OCD->getName();
+  std::string ListName =
+  (Interface->getObjCRuntimeNameAsString() + "_$_" + OCD->getName()).str();
 
   for (const auto *I : OCD->instance_methods())
 // Instance methods should always be defined.


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


[PATCH] D25838: [Basic] Support 32-bit x86 and ARM targets for Fuchsia

2016-10-24 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a reviewer: bkramer.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


Repository:
  rL LLVM

https://reviews.llvm.org/D25838



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


Re: [PATCH] D24010: [ReachableCode] Skip over ExprWithCleanups in isConfigurationValue

2016-10-24 Thread David Blaikie via cfe-commits
Simplify it further by replacing A() with just a function instead of a
class? Or does that break the repro?

bool Foo();
void Bar();
void Baz() {
  if (False && Foo())
Bar();
}

On Mon, Oct 24, 2016 at 1:38 PM Tim Shen  wrote:

> On Mon, Oct 24, 2016 at 10:33 AM David Blaikie  wrote:
>
> On Mon, Aug 29, 2016 at 3:45 PM Tim Shen via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> timshen created this revision.
> timshen added reviewers: rsmith, pirama.
> timshen added a subscriber: cfe-commits.
>
> https://reviews.llvm.org/D24010
>
> Files:
>   clang/include/clang/AST/Stmt.h
>   clang/lib/Analysis/ReachableCode.cpp
>   clang/test/SemaCXX/PR29152.cpp
>
> Index: clang/test/SemaCXX/PR29152.cpp
> ===
> --- /dev/null
> +++ clang/test/SemaCXX/PR29152.cpp
> @@ -0,0 +1,19 @@
> +// RUN: %clang_cc1 -fsyntax-only -Wunreachable-code -verify %s
> +
> +static const bool False = false;
> +
> +struct Vector {
> +  struct iterator {
> +bool operator==(const iterator &) const;
> +  };
> +  iterator end();
> +};
> +
> +void Bar();
> +Vector::iterator Find(Vector &a);
> +
> +void Foo(Vector &a) {
> +  if (False && Find(a) == a.end()) {
> +Bar(); // expected-no-diagnostics
> +  }
> +}
>
>
> What are the relevant parts of this test for this change?
>
> Is it the static const bool False that's interesting?
>
> Is it the op==/other interesting side effects on the RHS that are
> interesting?
>
> I'd be surprised if it were both (& if it isn't both, I'm guessing it's
> the former rather than the latter - in which case the latter can probably
> be reduced to just an arbitrary function call to, say: bool Baz())
>
>
> It's the static const bool False. I actually managed to simplify the code
> to remove the operator==() call.
>
>
>
>
> Index: clang/lib/Analysis/ReachableCode.cpp
> ===
> --- clang/lib/Analysis/ReachableCode.cpp
> +++ clang/lib/Analysis/ReachableCode.cpp
> @@ -164,6 +164,8 @@
>if (!S)
>  return false;
>
> +  S = S->IgnoreImplicit();
> +
>if (const Expr *Ex = dyn_cast(S))
>  S = Ex->IgnoreCasts();
>
> Index: clang/include/clang/AST/Stmt.h
> ===
> --- clang/include/clang/AST/Stmt.h
> +++ clang/include/clang/AST/Stmt.h
> @@ -387,6 +387,9 @@
>/// Skip past any implicit AST nodes which might surround this
>/// statement, such as ExprWithCleanups or ImplicitCastExpr nodes.
>Stmt *IgnoreImplicit();
> +  const Stmt *IgnoreImplicit() const {
> +return const_cast(this)->IgnoreImplicit();
> +  }
>
>/// \brief Skip no-op (attributed, compound) container stmts and skip
> captured
>/// stmt at the top, if \a IgnoreCaptured is true.
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24010: [ReachableCode] Skip over ExprWithCleanups in isConfigurationValue

2016-10-24 Thread Tim Shen via cfe-commits
On Mon, Oct 24, 2016 at 2:38 PM David Blaikie  wrote:

> Simplify it further by replacing A() with just a function instead of a
> class? Or does that break the repro?
>
> bool Foo();
> void Bar();
> void Baz() {
>   if (False && Foo())
> Bar();
> }
>

This actually breaks the repro. My test introduces a non-trivially
destructible temporary object in the condition expression, which creates a
ExprWithCleanups node at the full expression entry.


>
> On Mon, Oct 24, 2016 at 1:38 PM Tim Shen  wrote:
>
> On Mon, Oct 24, 2016 at 10:33 AM David Blaikie  wrote:
>
> On Mon, Aug 29, 2016 at 3:45 PM Tim Shen via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> timshen created this revision.
> timshen added reviewers: rsmith, pirama.
> timshen added a subscriber: cfe-commits.
>
> https://reviews.llvm.org/D24010
>
> Files:
>   clang/include/clang/AST/Stmt.h
>   clang/lib/Analysis/ReachableCode.cpp
>   clang/test/SemaCXX/PR29152.cpp
>
> Index: clang/test/SemaCXX/PR29152.cpp
> ===
> --- /dev/null
> +++ clang/test/SemaCXX/PR29152.cpp
> @@ -0,0 +1,19 @@
> +// RUN: %clang_cc1 -fsyntax-only -Wunreachable-code -verify %s
> +
> +static const bool False = false;
> +
> +struct Vector {
> +  struct iterator {
> +bool operator==(const iterator &) const;
> +  };
> +  iterator end();
> +};
> +
> +void Bar();
> +Vector::iterator Find(Vector &a);
> +
> +void Foo(Vector &a) {
> +  if (False && Find(a) == a.end()) {
> +Bar(); // expected-no-diagnostics
> +  }
> +}
>
>
> What are the relevant parts of this test for this change?
>
> Is it the static const bool False that's interesting?
>
> Is it the op==/other interesting side effects on the RHS that are
> interesting?
>
> I'd be surprised if it were both (& if it isn't both, I'm guessing it's
> the former rather than the latter - in which case the latter can probably
> be reduced to just an arbitrary function call to, say: bool Baz())
>
>
> It's the static const bool False. I actually managed to simplify the code
> to remove the operator==() call.
>
>
>
>
> Index: clang/lib/Analysis/ReachableCode.cpp
> ===
> --- clang/lib/Analysis/ReachableCode.cpp
> +++ clang/lib/Analysis/ReachableCode.cpp
> @@ -164,6 +164,8 @@
>if (!S)
>  return false;
>
> +  S = S->IgnoreImplicit();
> +
>if (const Expr *Ex = dyn_cast(S))
>  S = Ex->IgnoreCasts();
>
> Index: clang/include/clang/AST/Stmt.h
> ===
> --- clang/include/clang/AST/Stmt.h
> +++ clang/include/clang/AST/Stmt.h
> @@ -387,6 +387,9 @@
>/// Skip past any implicit AST nodes which might surround this
>/// statement, such as ExprWithCleanups or ImplicitCastExpr nodes.
>Stmt *IgnoreImplicit();
> +  const Stmt *IgnoreImplicit() const {
> +return const_cast(this)->IgnoreImplicit();
> +  }
>
>/// \brief Skip no-op (attributed, compound) container stmts and skip
> captured
>/// stmt at the top, if \a IgnoreCaptured is true.
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24010: [ReachableCode] Skip over ExprWithCleanups in isConfigurationValue

2016-10-24 Thread David Blaikie via cfe-commits
Ah, right - thanks for reminding/explaining!

On Mon, Oct 24, 2016 at 2:42 PM Tim Shen  wrote:

> On Mon, Oct 24, 2016 at 2:38 PM David Blaikie  wrote:
>
> Simplify it further by replacing A() with just a function instead of a
> class? Or does that break the repro?
>
> bool Foo();
> void Bar();
> void Baz() {
>   if (False && Foo())
> Bar();
> }
>
>
> This actually breaks the repro. My test introduces a non-trivially
> destructible temporary object in the condition expression, which creates a
> ExprWithCleanups node at the full expression entry.
>
>
>
> On Mon, Oct 24, 2016 at 1:38 PM Tim Shen  wrote:
>
> On Mon, Oct 24, 2016 at 10:33 AM David Blaikie  wrote:
>
> On Mon, Aug 29, 2016 at 3:45 PM Tim Shen via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> timshen created this revision.
> timshen added reviewers: rsmith, pirama.
> timshen added a subscriber: cfe-commits.
>
> https://reviews.llvm.org/D24010
>
> Files:
>   clang/include/clang/AST/Stmt.h
>   clang/lib/Analysis/ReachableCode.cpp
>   clang/test/SemaCXX/PR29152.cpp
>
> Index: clang/test/SemaCXX/PR29152.cpp
> ===
> --- /dev/null
> +++ clang/test/SemaCXX/PR29152.cpp
> @@ -0,0 +1,19 @@
> +// RUN: %clang_cc1 -fsyntax-only -Wunreachable-code -verify %s
> +
> +static const bool False = false;
> +
> +struct Vector {
> +  struct iterator {
> +bool operator==(const iterator &) const;
> +  };
> +  iterator end();
> +};
> +
> +void Bar();
> +Vector::iterator Find(Vector &a);
> +
> +void Foo(Vector &a) {
> +  if (False && Find(a) == a.end()) {
> +Bar(); // expected-no-diagnostics
> +  }
> +}
>
>
> What are the relevant parts of this test for this change?
>
> Is it the static const bool False that's interesting?
>
> Is it the op==/other interesting side effects on the RHS that are
> interesting?
>
> I'd be surprised if it were both (& if it isn't both, I'm guessing it's
> the former rather than the latter - in which case the latter can probably
> be reduced to just an arbitrary function call to, say: bool Baz())
>
>
> It's the static const bool False. I actually managed to simplify the code
> to remove the operator==() call.
>
>
>
>
> Index: clang/lib/Analysis/ReachableCode.cpp
> ===
> --- clang/lib/Analysis/ReachableCode.cpp
> +++ clang/lib/Analysis/ReachableCode.cpp
> @@ -164,6 +164,8 @@
>if (!S)
>  return false;
>
> +  S = S->IgnoreImplicit();
> +
>if (const Expr *Ex = dyn_cast(S))
>  S = Ex->IgnoreCasts();
>
> Index: clang/include/clang/AST/Stmt.h
> ===
> --- clang/include/clang/AST/Stmt.h
> +++ clang/include/clang/AST/Stmt.h
> @@ -387,6 +387,9 @@
>/// Skip past any implicit AST nodes which might surround this
>/// statement, such as ExprWithCleanups or ImplicitCastExpr nodes.
>Stmt *IgnoreImplicit();
> +  const Stmt *IgnoreImplicit() const {
> +return const_cast(this)->IgnoreImplicit();
> +  }
>
>/// \brief Skip no-op (attributed, compound) container stmts and skip
> captured
>/// stmt at the top, if \a IgnoreCaptured is true.
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r285027 - Fix test on non-X86 platforms

2016-10-24 Thread Craig Topper via cfe-commits
Doesn't this exclude 32-bit x86?

~Craig

On Mon, Oct 24, 2016 at 2:22 PM, Mehdi Amini via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: mehdi_amini
> Date: Mon Oct 24 16:22:01 2016
> New Revision: 285027
>
> URL: http://llvm.org/viewvc/llvm-project?rev=285027&view=rev
> Log:
> Fix test on non-X86 platforms
>
> This is a fixup for r285019, adding an `#ifdef __x86_64__` since
> the os_log builtin is platform specific.
>
> Modified:
> cfe/trunk/test/CodeGen/builtins.c
>
> Modified: cfe/trunk/test/CodeGen/builtins.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> CodeGen/builtins.c?rev=285027&r1=285026&r2=285027&view=diff
> 
> ==
> --- cfe/trunk/test/CodeGen/builtins.c (original)
> +++ cfe/trunk/test/CodeGen/builtins.c Mon Oct 24 16:22:01 2016
> @@ -369,6 +369,9 @@ long long test_builtin_readcyclecounter(
>return __builtin_readcyclecounter();
>  }
>
> +// Behavior of __builtin_os_log differs between platforms, so only test
> on X86
> +#ifdef __x86_64__
> +
>  // CHECK-LABEL: define void @test_builtin_os_log
>  // CHECK: (i8* [[BUF:%.*]], i32 [[I:%.*]], i8* [[DATA:%.*]])
>  void test_builtin_os_log(void *buf, int i, const char *data) {
> @@ -506,3 +509,5 @@ void test_builtin_os_log_percent(void *b
>// CHECK: store i8* [[DATA2]], i8** [[ARG1_PTR]]
>__builtin_os_log_format(buf, "%s %%", data);
>  }
> +
> +#endif
> \ No newline at end of file
>
>
> ___
> 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


r285031 - [Sema][ObjC] Warn about implicitly autoreleasing out-parameters captured

2016-10-24 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Mon Oct 24 16:45:54 2016
New Revision: 285031

URL: http://llvm.org/viewvc/llvm-project?rev=285031&view=rev
Log:
[Sema][ObjC] Warn about implicitly autoreleasing out-parameters captured
by blocks.

Add a new warning "-Wblock-capture-autoreleasing". The warning warns
about implicitly autoreleasing out-parameters captured by blocks which
can introduce use-after-free bugs that are hard to debug.

rdar://problem/15377548

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaObjC/arc.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=285031&r1=285030&r2=285031&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Mon Oct 24 16:45:54 2016
@@ -498,6 +498,7 @@ def AutomaticReferenceCounting : DiagGro
 def ARCRepeatedUseOfWeakMaybe : DiagGroup<"arc-maybe-repeated-use-of-weak">;
 def ARCRepeatedUseOfWeak : DiagGroup<"arc-repeated-use-of-weak",
  [ARCRepeatedUseOfWeakMaybe]>;
+def BlockCaptureAutoReleasing : DiagGroup<"block-capture-autoreleasing">;
 def ObjCBridge : DiagGroup<"bridge-cast">;
 
 def DeallocInCategory:DiagGroup<"dealloc-in-category">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=285031&r1=285030&r2=285031&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Oct 24 16:45:54 
2016
@@ -5077,6 +5077,16 @@ def err_arc_inconsistent_property_owners
 
 } // end "ARC and @properties" category
 
+def warn_block_capture_autoreleasing : Warning<
+  "block captures an autoreleasing out-parameter, which may result in "
+  "use-after-free bugs">,
+  InGroup, DefaultIgnore;
+def note_declare_parameter_autoreleasing : Note<
+  "declare the parameter __autoreleasing explicitly to suppress this warning">;
+def note_declare_parameter_strong : Note<
+  "declare the parameter __strong or capture a __block __strong variable to "
+  "keep values alive across autorelease pools">;
+
 def err_arc_atomic_ownership : Error<
   "cannot perform atomic operation on a pointer to type %0: type has "
   "non-trivial ownership">;

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=285031&r1=285030&r2=285031&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Oct 24 16:45:54 2016
@@ -13502,6 +13502,23 @@ static bool captureInBlock(BlockScopeInf
 }
 return false;
   }
+
+  // Warn about implicitly autoreleasing indirect parameters captured by 
blocks.
+  if (auto *PT = dyn_cast(CaptureType)) {
+QualType PointeeTy = PT->getPointeeType();
+if (isa(PointeeTy.getCanonicalType()) &&
+PointeeTy.getObjCLifetime() == Qualifiers::OCL_Autoreleasing &&
+!isa(PointeeTy)) {
+  if (BuildAndDiagnose) {
+SourceLocation VarLoc = Var->getLocation();
+S.Diag(Loc, diag::warn_block_capture_autoreleasing);
+S.Diag(VarLoc, diag::note_declare_parameter_autoreleasing) <<
+FixItHint::CreateInsertion(VarLoc, "__autoreleasing");
+S.Diag(VarLoc, diag::note_declare_parameter_strong);
+  }
+}
+  }
+
   const bool HasBlocksAttr = Var->hasAttr();
   if (HasBlocksAttr || CaptureType->isReferenceType() ||
   (S.getLangOpts().OpenMP && S.IsOpenMPCapturedDecl(Var))) {

Modified: cfe/trunk/test/SemaObjC/arc.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc.m?rev=285031&r1=285030&r2=285031&view=diff
==
--- cfe/trunk/test/SemaObjC/arc.m (original)
+++ cfe/trunk/test/SemaObjC/arc.m Mon Oct 24 16:45:54 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak 
-fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak 
-fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class 
-Wblock-capture-autoreleasing %s
 
 typedef unsigned long NSUInteger;
 typedef const void * CFTypeRef;
@@ -808,3 +808,10 @@ int garf() {
   TKAssertEqual(object, nil);
   TKAssertEqual(object, (id)nil);
 }
+
+void block_capture_autoreleasing(A * __autoreleasing *a, A **b) { // 
expected-note {{declare the parameter __autoreleasing explicit

  1   2   >