Re: [PATCH] D13802: [OPENMP] Make -fopenmp to turn on OpenMP support by default.

2015-10-26 Thread Alexey Bataev via cfe-commits
ABataev added reviewers: hans, tstellarAMD.
ABataev updated this revision to Diff 38374.
ABataev marked an inline comment as done.

http://reviews.llvm.org/D13802

Files:
  autoconf/configure.ac
  configure
  docs/GettingStarted.rst
  docs/ReleaseProcess.rst
  utils/release/test-release.sh

Index: autoconf/configure.ac
===
--- autoconf/configure.ac
+++ autoconf/configure.ac
@@ -1340,7 +1340,7 @@
 AC_ARG_WITH(clang-default-openmp-runtime,
   AS_HELP_STRING([--with-clang-default-openmp-runtime],
 [The default OpenMP runtime for Clang.]),,
-withval="libgomp")
+withval="libomp")
 AC_DEFINE_UNQUOTED(CLANG_DEFAULT_OPENMP_RUNTIME,"$withval",
[Default OpenMP runtime used by -fopenmp.])
 
Index: utils/release/test-release.sh
===
--- utils/release/test-release.sh
+++ utils/release/test-release.sh
@@ -34,7 +34,7 @@
 do_libs="yes"
 do_libunwind="yes"
 do_test_suite="yes"
-do_openmp="no"
+do_openmp="yes"
 BuildDir="`pwd`"
 use_autoconf="no"
 ExtraConfigureFlags=""
@@ -62,7 +62,7 @@
 echo " -no-libs Disable check-out & build libcxx/libcxxabi/libunwind"
 echo " -no-libunwindDisable check-out & build libunwind"
 echo " -no-test-suite   Disable check-out & build test-suite"
-echo " -openmp  Check out and build the OpenMP run-time (experimental)"
+echo " -no-openmp   Disable check-out & build libomp"
 }
 
 if [ `uname -s` = "Darwin" ]; then
@@ -143,8 +143,8 @@
 -no-test-suite )
 do_test_suite="no"
 ;;
--openmp )
-do_openmp="yes"
+-no-openmp )
+do_openmp="no"
 ;;
 -help | --help | -h | --h | -\? )
 usage
@@ -293,6 +293,9 @@
 if [ -d $BuildDir/compiler-rt.src ] && [ ! -h compiler-rt ]; then
 ln -s ../../compiler-rt.src compiler-rt
 fi
+if [ -d $BuildDir/openmp.src ] && [ ! -h openmp ]; then
+ln -s ../../openmp.src openmp
+fi
 if [ -d $BuildDir/libcxx.src ] && [ ! -h libcxx ]; then
 ln -s ../../libcxx.src libcxx
 fi
@@ -443,46 +446,6 @@
 cd $cwd
 }
 
-# Build and package the OpenMP run-time. This is still experimental and not
-# meant for official testing in the release, but as a way for providing
-# binaries as a convenience to those who want to try it out.
-function build_OpenMP() {
-cwd=`pwd`
-
-rm -rf $BuildDir/Phase3/openmp
-rm -rf $BuildDir/Phase3/openmp.install
-mkdir -p $BuildDir/Phase3/openmp
-cd $BuildDir/Phase3/openmp
-clang=$BuildDir/Phase3/Release/llvmCore-$Release-$RC.install/usr/local/bin/clang
-
-echo "#" cmake -DCMAKE_C_COMPILER=${clang} -DCMAKE_CXX_COMPILER=${clang}++ \
--DCMAKE_BUILD_TYPE=Release -DLIBOMP_MICRO_TESTS=on \
-$BuildDir/openmp.src/runtime
-cmake -DCMAKE_C_COMPILER=${clang} -DCMAKE_CXX_COMPILER=${clang}++ \
--DCMAKE_BUILD_TYPE=Release -DLIBOMP_MICRO_TESTS=on \
-$BuildDir/openmp.src/runtime
-
-echo "# Building OpenMP run-time"
-echo "# ${MAKE} -j $NumJobs VERBOSE=1"
-${MAKE} -j $NumJobs VERBOSE=1
-echo "# ${MAKE} libomp-micro-tests VERBOSE=1"
-${MAKE} libomp-micro-tests VERBOSE=1
-echo "# ${MAKE} install DESTDIR=$BuildDir/Phase3/openmp.install"
-${MAKE} install DESTDIR=$BuildDir/Phase3/openmp.install
-
-OpenMPPackage=OpenMP-$Release
-if [ $RC != "final" ]; then
-OpenMPPackage=$OpenMPPackage-$RC
-fi
-OpenMPPackage=$OpenMPPackage-$Triple
-
-mv $BuildDir/Phase3/openmp.install/usr/local $BuildDir/$OpenMPPackage
-cd $BuildDir
-tar cvfJ $BuildDir/$OpenMPPackage.tar.xz $OpenMPPackage
-mv $OpenMPPackage $BuildDir/Phase3/openmp.install/usr/local
-cd $cwd
-}
-
 # Exit if any command fails
 # Note: pipefail is necessary for running build commands through
 # a pipe (i.e. it changes the output of ``false | tee /dev/null ; echo $?``)
@@ -594,10 +557,6 @@
 fi
 done
 
-if [ $do_openmp = "yes" ]; then
-  build_OpenMP
-fi
-
 ) 2>&1 | tee $LogDir/testing.$Release-$RC.log
 
 package_release
Index: docs/ReleaseProcess.rst
===
--- docs/ReleaseProcess.rst
+++ docs/ReleaseProcess.rst
@@ -53,7 +53,7 @@
 ---
 
 This script will check-out, configure and compile LLVM+Clang (+ most add-ons, like ``compiler-rt``,
-``libcxx`` and ``clang-extra-tools``) in three stages, and will test the final stage.
+``libcxx``, ``libomp`` and ``clang-extra-tools``) in three stages, and will test the final stage.
 It'll have installed the final binaries on the Phase3/Releasei(+Asserts) directory, and
 that's the one you should use for the test-suite and other external tests.
 
Index: docs/GettingStarted.rst
===
--- docs/GettingStarted.rst
+++ docs/GettingStarted.rst
@@ -55,6 

[clang-tools-extra] r251279 - Drop dead return after llvm_unreachable. NFC.

2015-10-26 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Oct 26 04:57:00 2015
New Revision: 251279

URL: http://llvm.org/viewvc/llvm-project?rev=251279=rev
Log:
Drop dead return after llvm_unreachable. NFC.

Modified:
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp?rev=251279=251278=251279=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp 
Mon Oct 26 04:57:00 2015
@@ -84,7 +84,6 @@ getZeroLiteralToCompareWithForGivenType(
   default:
 llvm_unreachable("Unexpected cast kind");
   }
-  return "";
 }
 
 bool isUnaryLogicalNotOperator(const Stmt *Statement) {


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


Re: [PATCH] D14052: clang-format: Format std::function template parameter consistently inside function

2015-10-26 Thread Daniel Jasper via cfe-commits
djasper added a comment.

I'll take a look. I agree that there should be a better approach.

Also, you seem to have created the inverse patch :-).


http://reviews.llvm.org/D14052



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


Re: [PATCH] D13802: [OPENMP] Make -fopenmp to turn on OpenMP support by default.

2015-10-26 Thread Alexey Bataev via cfe-commits
ABataev marked an inline comment as done.
ABataev added a comment.

Hi Chandler, thanks for the review.

In http://reviews.llvm.org/D13802#272053, @chandlerc wrote:

> Some minor issues below. Also, Hans and Tom should have a glance at the 
> release bits of this, I don't know any of that stuff.
>
> Also, there are still some bugs with check-libomp. The immediate one I 
> noticed was that when i run it in a clean build with enough parallelism, it 
> fails to find the just-built clang binary. I suspect that the 'check-libomp' 
> CMake target is missing dependencies on all of the binaries used when running 
> the lit tests because it copied the libc++ CMake rules for it. While the 
> libc++ CMake rules are *mostly* a good proxy, the *testing* strategy for 
> libc++ is notably different here. In fact, libomp's testing is (IMO) quite a 
> bit *better* here, and uncovers a nasty missing dependency.
>
> The libc++ test suite tests libc++ with the *host* compiler, not the 
> just-built compiler. This has some advantages and disadvantages, but for a 
> library with close coupling to the compiler (such as compiler-rt or libomp) 
> it is inappropriate. Your libomp tests very correctly use the just-built 
> Clang, but the CMake needs to model this now. You can see in 
> projects/compiler-rt/test/CMakeLists.txt lines 19-33 how compiler-rt sets up 
> variables with these tools (clang, clang-headers, etc) which end up used on 
> line 99 of projects/compiler-rt/test/asan/CMakeLists.txt for example.
>
> I don't know what all tools you need (other than clang and probably 
> clang-headers), probably not as many as the sanitizers do, so I'll let you 
> put together a correct patch here. I've hacked around it locally to test 
> further.


I created a separate patch for libomp, that fixes this issue.

> I've also had one test fail, and then start passing for me on Linux (after 
> fixing the above). I haven't had it fail again, but I don't have a good way 
> of running tests repeatedly (see below, llvm-lit doesn't yet work). It might 
> be good to give the test suite a good 10 or 50 runs and see if anything 
> starts failing. I'll do that overnight and report back if so.


Actually, these tests are written so, that they repeats about 1000 times to be 
sure that they are correct. But some of them might be sensible to system load.



Comment at: configure:5953
@@ -5952,3 +5952,3 @@
 else
-  withval="libgomp"
+  withval="libomp"
 fi

chandlerc wrote:
> You should be modifying the configure.ac file and regenerating this?
Ok, done


Comment at: utils/llvm-lit/llvm-lit.in:42-46
@@ -41,2 +41,7 @@
 
+openmp_obj_root = os.path.join(llvm_obj_root, 'projects', 'openmp')
+if os.path.exists(openmp_obj_root):
+builtin_parameters['openmp_site_basedir'] = \
+os.path.join(openmp_obj_root, 'runtime', 'test')
+
 if __name__=='__main__':

chandlerc wrote:
> This change is independent of enabling anything; can you break it out?
> 
> Also, manually patching this bit in order to test things didn't actually 
> allow me to use llvm-lit with libomp, so I don't think this is quite working 
> as intended yet.
Ok, reverted it


http://reviews.llvm.org/D13802



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


Re: [PATCH] D9898: MismatchingNewDeleteDetector uses incorrect field, and finds no initializer

2015-10-26 Thread Ismail Pazarbasi via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL251335: MismatchingNewDeleteDetector uses incorrect field, 
and finds no initializer (authored by ismailp).

Changed prior to commit:
  http://reviews.llvm.org/D9898?vs=26271=38449#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D9898

Files:
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/test/SemaCXX/delete.cpp

Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -2500,8 +2500,10 @@
 MismatchingNewDeleteDetector::MismatchResult
 MismatchingNewDeleteDetector::analyzeInClassInitializer() {
   assert(Field != nullptr && "This should be called only for members");
-  if (const CXXNewExpr *NE =
-  getNewExprFromInitListOrExpr(Field->getInClassInitializer())) {
+  const Expr *InitExpr = Field->getInClassInitializer();
+  if (!InitExpr)
+return EndOfTU ? NoMismatch : AnalyzeLater;
+  if (const CXXNewExpr *NE = getNewExprFromInitListOrExpr(InitExpr)) {
 if (NE->isArray() != IsArrayForm) {
   NewExprs.push_back(NE);
   return MemberInitMismatches;
Index: cfe/trunk/test/SemaCXX/delete.cpp
===
--- cfe/trunk/test/SemaCXX/delete.cpp
+++ cfe/trunk/test/SemaCXX/delete.cpp
@@ -120,6 +120,22 @@
   DELETE(d);  // expected-warning {{'delete' applied to a pointer that 
was allocated with 'new[]'; did you mean 'delete[]'?}}
 }
 }
+
+namespace MissingInitializer {
+template
+struct Base {
+  struct S {
+const T *p1 = nullptr;
+const T *p2 = new T[3];
+  };
+};
+
+void null_init(Base::S s) {
+  delete s.p1;
+  delete s.p2;
+}
+}
+
 #ifndef WITH_PCH
 pch_test::X::X()
   : a(new int[1])  // expected-note{{allocated with 'new[]' here}}


Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -2500,8 +2500,10 @@
 MismatchingNewDeleteDetector::MismatchResult
 MismatchingNewDeleteDetector::analyzeInClassInitializer() {
   assert(Field != nullptr && "This should be called only for members");
-  if (const CXXNewExpr *NE =
-  getNewExprFromInitListOrExpr(Field->getInClassInitializer())) {
+  const Expr *InitExpr = Field->getInClassInitializer();
+  if (!InitExpr)
+return EndOfTU ? NoMismatch : AnalyzeLater;
+  if (const CXXNewExpr *NE = getNewExprFromInitListOrExpr(InitExpr)) {
 if (NE->isArray() != IsArrayForm) {
   NewExprs.push_back(NE);
   return MemberInitMismatches;
Index: cfe/trunk/test/SemaCXX/delete.cpp
===
--- cfe/trunk/test/SemaCXX/delete.cpp
+++ cfe/trunk/test/SemaCXX/delete.cpp
@@ -120,6 +120,22 @@
   DELETE(d);  // expected-warning {{'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'?}}
 }
 }
+
+namespace MissingInitializer {
+template
+struct Base {
+  struct S {
+const T *p1 = nullptr;
+const T *p2 = new T[3];
+  };
+};
+
+void null_init(Base::S s) {
+  delete s.p1;
+  delete s.p2;
+}
+}
+
 #ifndef WITH_PCH
 pch_test::X::X()
   : a(new int[1])  // expected-note{{allocated with 'new[]' here}}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r251335 - MismatchingNewDeleteDetector uses incorrect field, and finds no initializer

2015-10-26 Thread Ismail Pazarbasi via cfe-commits
Hi,

this patch addresses a crash-on-valid on 3.7. Could you please merge
this to 3.7 branch?

Ismail

On Mon, Oct 26, 2015 at 8:20 PM, Ismail Pazarbasi via cfe-commits
 wrote:
> Author: ismailp
> Date: Mon Oct 26 14:20:24 2015
> New Revision: 251335
>
> URL: http://llvm.org/viewvc/llvm-project?rev=251335=rev
> Log:
> MismatchingNewDeleteDetector uses incorrect field, and finds no initializer
>
> Summary:
> In `MismatchingNewDeleteDetector::analyzeInClassInitializer`, if
> `Field`'s initializer expression is null, lookup the field in
> implicit instantiation, and use found field's the initializer.
>
> Reviewers: rsmith, rtrieu
>
> Subscribers: cfe-commits
>
> Differential Revision: http://reviews.llvm.org/D9898
>
> Modified:
> cfe/trunk/lib/Sema/SemaExprCXX.cpp
> cfe/trunk/test/SemaCXX/delete.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=251335=251334=251335=diff
> ==
> --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Mon Oct 26 14:20:24 2015
> @@ -2500,8 +2500,10 @@ bool MismatchingNewDeleteDetector::hasMa
>  MismatchingNewDeleteDetector::MismatchResult
>  MismatchingNewDeleteDetector::analyzeInClassInitializer() {
>assert(Field != nullptr && "This should be called only for members");
> -  if (const CXXNewExpr *NE =
> -  getNewExprFromInitListOrExpr(Field->getInClassInitializer())) {
> +  const Expr *InitExpr = Field->getInClassInitializer();
> +  if (!InitExpr)
> +return EndOfTU ? NoMismatch : AnalyzeLater;
> +  if (const CXXNewExpr *NE = getNewExprFromInitListOrExpr(InitExpr)) {
>  if (NE->isArray() != IsArrayForm) {
>NewExprs.push_back(NE);
>return MemberInitMismatches;
>
> Modified: cfe/trunk/test/SemaCXX/delete.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/delete.cpp?rev=251335=251334=251335=diff
> ==
> --- cfe/trunk/test/SemaCXX/delete.cpp (original)
> +++ cfe/trunk/test/SemaCXX/delete.cpp Mon Oct 26 14:20:24 2015
> @@ -120,6 +120,22 @@ void f() {
>DELETE(d);  // expected-warning {{'delete' applied to a pointer 
> that was allocated with 'new[]'; did you mean 'delete[]'?}}
>  }
>  }
> +
> +namespace MissingInitializer {
> +template
> +struct Base {
> +  struct S {
> +const T *p1 = nullptr;
> +const T *p2 = new T[3];
> +  };
> +};
> +
> +void null_init(Base::S s) {
> +  delete s.p1;
> +  delete s.p2;
> +}
> +}
> +
>  #ifndef WITH_PCH
>  pch_test::X::X()
>: a(new int[1])  // expected-note{{allocated with 'new[]' here}}
>
>
> ___
> 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] D12382: Extend linux header search to find libc++ headers in c++/vN for any N.

2015-10-26 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

LGTM



Comment at: lib/Driver/ToolChains.cpp:3545
@@ +3544,3 @@
+!VersionText.slice(1, StringRef::npos).getAsInteger(10, Version)) {
+  if (Version > MaxVersion) {
+MaxVersion = Version;

Since you've got logic here to pick the newest headers, you should also have a 
tree that has both `usr/include/c++/v1` and `usr/include/c++/v2` to test that 
part of this change.

It's probably also a good idea to have a tree laid out as if libstdc++ and 
libc++ were both installed, i.e. both `usr/include/c++/v1` and 
`usr/include/c++/5.0` in it.


http://reviews.llvm.org/D12382



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


Re: [PATCH] D13640: [clang-tidy] Add new check cppcoreguidelines-pro-bounds-array-to-pointer-decay

2015-10-26 Thread Matthias Gehre via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL251358: [clang-tidy] Add new check 
cppcoreguidelines-pro-bounds-array-to-pointer-decay (authored by mgehre).

Changed prior to commit:
  http://reviews.llvm.org/D13640?vs=38353=38467#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13640

Files:
  clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h
  
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-array-to-pointer-decay.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp

Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
@@ -2,6 +2,7 @@
 
 add_clang_library(clangTidyCppCoreGuidelinesModule
   CppCoreGuidelinesTidyModule.cpp
+  ProBoundsArrayToPointerDecayCheck.cpp
   ProBoundsPointerArithmeticCheck.cpp
   ProTypeConstCastCheck.cpp
   ProTypeReinterpretCastCheck.cpp
Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h
@@ -0,0 +1,34 @@
+//===--- ProBoundsArrayToPointerDecayCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_BOUNDS_ARRAY_TO_POINTER_DECAY_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_BOUNDS_ARRAY_TO_POINTER_DECAY_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+
+/// This check flags all array to pointer decays
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-pro-bounds-array-to-pointer-decay.html
+class ProBoundsArrayToPointerDecayCheck : public ClangTidyCheck {
+public:
+  ProBoundsArrayToPointerDecayCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_BOUNDS_ARRAY_TO_POINTER_DECAY_H
+
Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
@@ -0,0 +1,60 @@
+//===--- ProBoundsArrayToPointerDecayCheck.cpp - clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ProBoundsArrayToPointerDecayCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+
+AST_MATCHER_P(CXXForRangeStmt, hasRangeBeginEndStmt,
+  ast_matchers::internal::Matcher, InnerMatcher) {
+  const DeclStmt *const Stmt = Node.getBeginEndStmt();
+  return (Stmt != nullptr && InnerMatcher.matches(*Stmt, Finder, Builder));
+}
+
+AST_MATCHER(Stmt, isInsideOfRangeBeginEndStmt) {
+  return stmt(hasAncestor(cxxForRangeStmt(
+  hasRangeBeginEndStmt(hasDescendant(equalsNode())
+  .matches(Node, Finder, Builder);
+}
+
+void ProBoundsArrayToPointerDecayCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  // The only allowed array to pointer decay
+  // 1) just before array subscription
+  // 2) inside a range-for over an array
+  // 3) if it converts a string literal to a pointer
+  Finder->addMatcher(
+  implicitCastExpr(unless(hasParent(arraySubscriptExpr())),
+   

Re: [PATCH] D14049: clang-tidy/add_new_check.py: Adapt to use %check_clang_tidy in tests

2015-10-26 Thread Matthias Gehre via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL251355: clang-tidy/add_new_check.py: Adapt to use 
%check_clang_tidy in tests (authored by mgehre).

Changed prior to commit:
  http://reviews.llvm.org/D14049?vs=38354=38466#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14049

Files:
  clang-tools-extra/trunk/clang-tidy/add_new_check.py

Index: clang-tools-extra/trunk/clang-tidy/add_new_check.py
===
--- clang-tools-extra/trunk/clang-tidy/add_new_check.py
+++ clang-tools-extra/trunk/clang-tidy/add_new_check.py
@@ -193,7 +193,7 @@
   print('Creating %s...' % filename)
   with open(filename, 'wb') as f:
 f.write(
-"""// RUN: %%python %%S/check_clang_tidy.py %%s %(check_name_dashes)s %%t
+"""// RUN: %%check_clang_tidy %%s %(check_name_dashes)s %%t
 
 // FIXME: Add something that triggers the check here.
 void f();


Index: clang-tools-extra/trunk/clang-tidy/add_new_check.py
===
--- clang-tools-extra/trunk/clang-tidy/add_new_check.py
+++ clang-tools-extra/trunk/clang-tidy/add_new_check.py
@@ -193,7 +193,7 @@
   print('Creating %s...' % filename)
   with open(filename, 'wb') as f:
 f.write(
-"""// RUN: %%python %%S/check_clang_tidy.py %%s %(check_name_dashes)s %%t
+"""// RUN: %%check_clang_tidy %%s %(check_name_dashes)s %%t
 
 // FIXME: Add something that triggers the check here.
 void f();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r251355 - clang-tidy/add_new_check.py: Adapt to use %check_clang_tidy in tests

2015-10-26 Thread Matthias Gehre via cfe-commits
Author: mgehre
Date: Mon Oct 26 16:48:08 2015
New Revision: 251355

URL: http://llvm.org/viewvc/llvm-project?rev=251355=rev
Log:
clang-tidy/add_new_check.py: Adapt to use %check_clang_tidy in tests

Summary: Adapt clang-tidy/add_new_check.py according to commit r251010 "Add 
%check_clang_tidy and %clang_tidy_diff"

Reviewers: alexfh, sbenza, bkramer, aaron.ballman

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/add_new_check.py

Modified: clang-tools-extra/trunk/clang-tidy/add_new_check.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/add_new_check.py?rev=251355=251354=251355=diff
==
--- clang-tools-extra/trunk/clang-tidy/add_new_check.py (original)
+++ clang-tools-extra/trunk/clang-tidy/add_new_check.py Mon Oct 26 16:48:08 2015
@@ -193,7 +193,7 @@ def write_test(module_path, module, chec
   print('Creating %s...' % filename)
   with open(filename, 'wb') as f:
 f.write(
-"""// RUN: %%python %%S/check_clang_tidy.py %%s %(check_name_dashes)s %%t
+"""// RUN: %%check_clang_tidy %%s %(check_name_dashes)s %%t
 
 // FIXME: Add something that triggers the check here.
 void f();


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


[libcxx] r251334 - Fix test suite configuration. Sorry Marshall

2015-10-26 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Oct 26 14:08:53 2015
New Revision: 251334

URL: http://llvm.org/viewvc/llvm-project?rev=251334=rev
Log:
Fix test suite configuration. Sorry Marshall

Modified:
libcxx/trunk/test/libcxx/test/config.py

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=251334=251333=251334=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Mon Oct 26 14:08:53 2015
@@ -197,7 +197,7 @@ class Configuration(object):
 def configure_obj_root(self):
 self.project_obj_root = self.get_lit_conf('project_obj_root')
 self.libcxx_obj_root = self.get_lit_conf('libcxx_obj_root')
-if not self.libcxx_obj_root:
+if not self.libcxx_obj_root and self.project_obj_root is not None:
 possible_root = os.path.join(self.project_obj_root, 'projects', 
'libcxx')
 if os.path.isdir(possible_root):
 self.libcxx_obj_root = possible_root
@@ -425,6 +425,8 @@ class Configuration(object):
 def configure_config_site_header(self):
 # Check for a possible __config_site in the build directory. We
 # use this if it exists.
+if self.libcxx_obj_root is None:
+return
 config_site_header = os.path.join(self.libcxx_obj_root, 
'__config_site')
 if not os.path.isfile(config_site_header):
 return


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


Re: [PATCH] D13969: Tweak how -Wunused-value interacts with macros

2015-10-26 Thread Nico Weber via cfe-commits
thakis added a reviewer: rnk.
thakis added a comment.

rnk: Can you look at this if Richard is still away doing committee thing?


http://reviews.llvm.org/D13969



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


Re: [PATCH] D13336: [MSVC] 'property' with an empty array in array subscript expression.

2015-10-26 Thread John McCall via cfe-commits
rjmccall added inline comments.


Comment at: include/clang/AST/ExprCXX.h:689
@@ +688,3 @@
+/// indices. In this case, i=p->x[a][b] will be turned into i=p->GetX(a, b), 
and
+/// p->x[a][b] = i will be turned into p->PutX(a, b, i).
+class MSPropertySubscriptExpr : public Expr {

Please add to the comment here that this is a syntactic pseudo-object 
expression.


Comment at: lib/Sema/SemaExpr.cpp:3926
@@ -3921,1 +3925,3 @@
+  if (base->getType()->isNonOverloadPlaceholderType() &&
+  !IsMSPropertySubscript) {
 ExprResult result = CheckPlaceholderExpr(base);

Please factor this check so that it only does extra work when the base has 
placeholder type, and please extract a function to compute 
IsMSPropertySubscript.


Comment at: lib/Sema/SemaPseudoObject.cpp:1419
@@ +1418,3 @@
+MSPropertyOpBuilder::getBaseMSProperty(MSPropertySubscriptExpr *E) {
+  Expr *Base = E->getBase();
+  CallArgs.insert(CallArgs.begin(), E->getIdx());

This code will look slightly nicer and be slightly more efficient if you 
maintain the invariant that parens have been ignored on Base.  That is, 
IgnoreParens here and when assigning in the loop, and then you can remove them 
from the type-checks.

Oh.  You also need to capture the index expressions so that they aren't 
evaluated multiple times when this expression is used as the l-value of an 
increment, decrement, or compound-assignment.  You then need to un-capture them 
in the Rebuilder.  Please add code-generation tests that check that the index 
expression is only evaluated once in these cases.


http://reviews.llvm.org/D13336



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


[clang-tools-extra] r251358 - [clang-tidy] Add new check cppcoreguidelines-pro-bounds-array-to-pointer-decay

2015-10-26 Thread Matthias Gehre via cfe-commits
Author: mgehre
Date: Mon Oct 26 16:56:02 2015
New Revision: 251358

URL: http://llvm.org/viewvc/llvm-project?rev=251358=rev
Log:
[clang-tidy] Add new check cppcoreguidelines-pro-bounds-array-to-pointer-decay

Summary:
This check flags all array to pointer decays.

Pointers should not be used as arrays. array_view is a bounds-checked,
safe alternative to using pointers to access arrays.

This rule is part of the "Bounds safety" profile of the C++ Core
Guidelines, see
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-bounds3-no-array-to-pointer-decay

Reviewers: alexfh, sbenza, bkramer, aaron.ballman

Subscribers: cfe-commits

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

Added:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-array-to-pointer-decay.rst

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt?rev=251358=251357=251358=diff
==
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt 
(original)
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt Mon Oct 
26 16:56:02 2015
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyCppCoreGuidelinesModule
   CppCoreGuidelinesTidyModule.cpp
+  ProBoundsArrayToPointerDecayCheck.cpp
   ProBoundsPointerArithmeticCheck.cpp
   ProTypeConstCastCheck.cpp
   ProTypeReinterpretCastCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp?rev=251358=251357=251358=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 Mon Oct 26 16:56:02 2015
@@ -11,6 +11,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 #include "../misc/AssignOperatorSignatureCheck.h"
+#include "ProBoundsArrayToPointerDecayCheck.h"
 #include "ProBoundsPointerArithmeticCheck.h"
 #include "ProTypeConstCastCheck.h"
 #include "ProTypeReinterpretCastCheck.h"
@@ -26,6 +27,8 @@ namespace cppcoreguidelines {
 class CppCoreGuidelinesModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories ) override {
+CheckFactories.registerCheck(
+"cppcoreguidelines-pro-bounds-array-to-pointer-decay");
 CheckFactories.registerCheck(
 "cppcoreguidelines-pro-bounds-pointer-arithmetic");
 CheckFactories.registerCheck(

Added: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp?rev=251358=auto
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
 (added)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
 Mon Oct 26 16:56:02 2015
@@ -0,0 +1,60 @@
+//===--- ProBoundsArrayToPointerDecayCheck.cpp - 
clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ProBoundsArrayToPointerDecayCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+
+AST_MATCHER_P(CXXForRangeStmt, hasRangeBeginEndStmt,
+  ast_matchers::internal::Matcher, InnerMatcher) {
+  const DeclStmt *const Stmt = Node.getBeginEndStmt();
+  return (Stmt != nullptr && InnerMatcher.matches(*Stmt, Finder, Builder));
+}
+
+AST_MATCHER(Stmt, isInsideOfRangeBeginEndStmt) {
+  return stmt(hasAncestor(cxxForRangeStmt(
+  hasRangeBeginEndStmt(hasDescendant(equalsNode())
+  .matches(Node, Finder, Builder);
+}
+

[PATCH] D14096: [clang-tidy] add new check cppcoreguidelines-pro-type-cstyle-cast

2015-10-26 Thread Matthias Gehre via cfe-commits
mgehre created this revision.
mgehre added reviewers: alexfh, sbenza, bkramer, aaron.ballman.
mgehre added a subscriber: cfe-commits.

This check flags all use of c-style casts that perform a static_cast
downcast, const_cast, or reinterpret_cast.

Use of these casts can violate type safety and cause the program to
access a
variable that is actually of type X to be accessed as if it were of an
unrelated type Z. Note that a C-style (T)expression cast means to
perform
the first of the following that is possible: a const_cast, a
static_cast, a
static_cast followed by a const_cast, a reinterpret_cast, or a
reinterpret_cast followed by a const_cast. This rule bans (T)expression
only when used to perform an unsafe cast.

This rule is part of the "Type safety" profile of the C++ Core
Guidelines, see
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-type4-dont-use-c-style-texpression-casts-that-would-perform-a-static_cast-downcast-const_cast-or-reinterpret_cast.

http://reviews.llvm.org/D14096

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp
  clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.h
  docs/clang-tidy/checks/cppcoreguidelines-pro-type-cstyle-cast.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-pro-type-cstyle-cast.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-type-cstyle-cast.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-pro-type-cstyle-cast.cpp
@@ -0,0 +1,141 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-cstyle-cast %t
+
+void reinterpretcast() {
+  int i = 0;
+  void *j;
+  j = (int*)j;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not use c-style cast to perform a reinterpret_cast [cppcoreguidelines-pro-type-cstyle-cast]
+}
+
+void constcast() {
+  int* i;
+  const int* j;
+  i = (int*)j;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not use c-style cast to perform a const_cast [cppcoreguidelines-pro-type-cstyle-cast]
+
+  (void)j; // OK, not a const_cast
+}
+
+void const_and_reinterpret() {
+  int* i;
+  const void* j;
+  i = (int*)j;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not use c-style cast to perform a reinterpret_cast [cppcoreguidelines-pro-type-cstyle-cast]
+}
+
+class Base {
+};
+
+class Derived : public Base {
+};
+
+class Base2 {
+};
+
+class MultiDerived : public Base, public Base2 {
+};
+
+class PolymorphicBase {
+public:
+  virtual ~PolymorphicBase();
+};
+
+class PolymorphicDerived : public PolymorphicBase {
+};
+
+class PolymorphicMultiDerived : public Base, public PolymorphicBase {
+};
+
+void pointers() {
+
+  auto P0 = (Derived*)new Base();
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not use c-style cast to downcast from a base to a derived class [cppcoreguidelines-pro-type-cstyle-cast]
+
+  const Base* B0;
+  auto PC0 = (const Derived*)(B0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: do not use c-style cast to downcast from a base to a derived class [cppcoreguidelines-pro-type-cstyle-cast]
+
+  auto P1 = (Base*)new Derived(); // OK, upcast to a public base
+  auto P2 = (Base*)new MultiDerived(); // OK, upcast to a public base
+  auto P3 = (Base2*)new MultiDerived(); // OK, upcast to a public base
+}
+
+void pointers_polymorphic() {
+
+  auto PP0 = (PolymorphicDerived*)new PolymorphicBase();
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: do not use c-style cast to downcast from a base to a derived class; use dynamic_cast instead [cppcoreguidelines-pro-type-cstyle-cast]
+  // CHECK-FIXES: auto PP0 = dynamic_cast(new PolymorphicBase());
+
+  const PolymorphicBase* B0;
+  auto PPC0 = (const PolymorphicDerived*)B0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: do not use c-style cast to downcast from a base to a derived class; use dynamic_cast instead [cppcoreguidelines-pro-type-cstyle-cast]
+  // CHECK-FIXES: auto PPC0 = dynamic_cast(B0);
+
+
+  auto B1 = (PolymorphicBase*)new PolymorphicDerived(); // OK, upcast to a public base
+  auto B2 = (PolymorphicBase*)new PolymorphicMultiDerived(); // OK, upcast to a public base
+  auto B3 = (Base*)new PolymorphicMultiDerived(); // OK, upcast to a public base
+}
+
+void arrays() {
+  Base ArrayOfBase[10];
+  auto A0 = (Derived*)ArrayOfBase;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not use c-style cast to downcast from a base to a derived class [cppcoreguidelines-pro-type-cstyle-cast]
+}
+
+void arrays_polymorphic() {
+  PolymorphicBase ArrayOfPolymorphicBase[10];
+  auto AP0 = (PolymorphicDerived*)ArrayOfPolymorphicBase;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: do not use c-style cast to downcast from a base to a derived class; use dynamic_cast instead
+  // CHECK-FIXES: auto AP0 = dynamic_cast(ArrayOfPolymorphicBase);
+}
+
+void references() {
+  Base B0;
+  auto R0 = 

Re: r251371 - Use early exits to reduce indentation.

2015-10-26 Thread David Blaikie via cfe-commits
On Mon, Oct 26, 2015 at 5:06 PM, Eric Christopher via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: echristo
> Date: Mon Oct 26 19:06:21 2015
> New Revision: 251371
>
> URL: http://llvm.org/viewvc/llvm-project?rev=251371=rev
> Log:
> Use early exits to reduce indentation.
>
> Modified:
> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=251371=251370=251371=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Oct 26 19:06:21 2015
> @@ -296,53 +296,55 @@ bool CodeGenFunction::checkBuiltinTarget
>if (!TargetDecl)
>  return true;
>
> -  // Get the current enclosing function if it exists.
> -  if (const FunctionDecl *FD =
> dyn_cast_or_null(CurFuncDecl)) {
> -unsigned BuiltinID = TargetDecl->getBuiltinID();
> -const char *FeatureList =
> -CGM.getContext().BuiltinInfo.getRequiredFeatures(BuiltinID);
> -if (FeatureList && StringRef(FeatureList) != "") {
> -  StringRef TargetCPU = Target.getTargetOpts().CPU;
> -  llvm::StringMap FeatureMap;
> -
> -  if (const auto *TD = FD->getAttr()) {
> -// If we have a TargetAttr build up the feature map based on that.
> -TargetAttr::ParsedTargetAttr ParsedAttr = TD->parse();
> -
> -// Make a copy of the features as passed on the command line into
> the
> -// beginning of the additional features from the function to
> override.
> -ParsedAttr.first.insert(
> -ParsedAttr.first.begin(),
> -Target.getTargetOpts().FeaturesAsWritten.begin(),
> -Target.getTargetOpts().FeaturesAsWritten.end());
> -
> -if (ParsedAttr.second != "")
> -  TargetCPU = ParsedAttr.second;
> -
> -// Now populate the feature map, first with the TargetCPU which is
> -// either
> -// the default or a new one from the target attribute string.
> Then we'll
> -// use the passed in features (FeaturesAsWritten) along with the
> new
> -// ones
> -// from the attribute.
> -Target.initFeatureMap(FeatureMap, CGM.getDiags(), TargetCPU,
> -  ParsedAttr.first);
> -  } else {
> -Target.initFeatureMap(FeatureMap, CGM.getDiags(), TargetCPU,
> -  Target.getTargetOpts().Features);
> -  }
> -
> -  // If we have at least one of the features in the feature list
> return
> -  // true, otherwise return false.
> -  SmallVector AttrFeatures;
> -  StringRef(FeatureList).split(AttrFeatures, ",");
> -  for (const auto  : AttrFeatures)
> -if (FeatureMap[Feature])
> - return true;
> -  return false;
> -}
> +  // Get the current enclosing function if it exists. If it doesn't
> +  // we can't check the target features anyhow.
> +  const FunctionDecl *FD = dyn_cast_or_null(CurFuncDecl);
> +  if (!FD) return true;
> +
> +  unsigned BuiltinID = TargetDecl->getBuiltinID();
> +  const char *FeatureList =
> +  CGM.getContext().BuiltinInfo.getRequiredFeatures(BuiltinID);
> +
> +  if (!FeatureList || StringRef(FeatureList) == "")
> +return true;
> +
> +  StringRef TargetCPU = Target.getTargetOpts().CPU;
> +  llvm::StringMap FeatureMap;
> +
> +  if (const auto *TD = FD->getAttr()) {
> +// If we have a TargetAttr build up the feature map based on that.
> +TargetAttr::ParsedTargetAttr ParsedAttr = TD->parse();
> +
> +// Make a copy of the features as passed on the command line into the
> +// beginning of the additional features from the function to override.
> +ParsedAttr.first.insert(ParsedAttr.first.begin(),
> +
> Target.getTargetOpts().FeaturesAsWritten.begin(),
> +
> Target.getTargetOpts().FeaturesAsWritten.end());
> +
> +if (ParsedAttr.second != "")
> +  TargetCPU = ParsedAttr.second;
> +
> +// Now populate the feature map, first with the TargetCPU which is
> +// either
> +// the default or a new one from the target attribute string. Then
> we'll
> +// use the passed in features (FeaturesAsWritten) along with the new
> +// ones
> +// from the attribute.
> +Target.initFeatureMap(FeatureMap, CGM.getDiags(), TargetCPU,
> +  ParsedAttr.first);
> +  } else {
> +Target.initFeatureMap(FeatureMap, CGM.getDiags(), TargetCPU,
> +  Target.getTargetOpts().Features);
>}
> -  return true;
> +
> +  // If we have at least one of the features in the feature list return
> +  // true, otherwise return false.
> +  SmallVector AttrFeatures;
> +  StringRef(FeatureList).split(AttrFeatures, ",");
> +  for (const auto  : AttrFeatures)
> +if (FeatureMap[Feature])
> +  return true;
> +  return false;
>

This last bit could be written as:

return 

Re: [PATCH] D12382: Extend linux header search to find libc++ headers in c++/vN for any N.

2015-10-26 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

ping
We will need this when libc++ is bumped to v2. There are no plans to do this 
AFAIK but the ABI version macros are in so it is possible and clang should be 
ready.


http://reviews.llvm.org/D12382



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


r251335 - MismatchingNewDeleteDetector uses incorrect field, and finds no initializer

2015-10-26 Thread Ismail Pazarbasi via cfe-commits
Author: ismailp
Date: Mon Oct 26 14:20:24 2015
New Revision: 251335

URL: http://llvm.org/viewvc/llvm-project?rev=251335=rev
Log:
MismatchingNewDeleteDetector uses incorrect field, and finds no initializer

Summary:
In `MismatchingNewDeleteDetector::analyzeInClassInitializer`, if
`Field`'s initializer expression is null, lookup the field in
implicit instantiation, and use found field's the initializer.

Reviewers: rsmith, rtrieu

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/SemaCXX/delete.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=251335=251334=251335=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Mon Oct 26 14:20:24 2015
@@ -2500,8 +2500,10 @@ bool MismatchingNewDeleteDetector::hasMa
 MismatchingNewDeleteDetector::MismatchResult
 MismatchingNewDeleteDetector::analyzeInClassInitializer() {
   assert(Field != nullptr && "This should be called only for members");
-  if (const CXXNewExpr *NE =
-  getNewExprFromInitListOrExpr(Field->getInClassInitializer())) {
+  const Expr *InitExpr = Field->getInClassInitializer();
+  if (!InitExpr)
+return EndOfTU ? NoMismatch : AnalyzeLater;
+  if (const CXXNewExpr *NE = getNewExprFromInitListOrExpr(InitExpr)) {
 if (NE->isArray() != IsArrayForm) {
   NewExprs.push_back(NE);
   return MemberInitMismatches;

Modified: cfe/trunk/test/SemaCXX/delete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/delete.cpp?rev=251335=251334=251335=diff
==
--- cfe/trunk/test/SemaCXX/delete.cpp (original)
+++ cfe/trunk/test/SemaCXX/delete.cpp Mon Oct 26 14:20:24 2015
@@ -120,6 +120,22 @@ void f() {
   DELETE(d);  // expected-warning {{'delete' applied to a pointer that 
was allocated with 'new[]'; did you mean 'delete[]'?}}
 }
 }
+
+namespace MissingInitializer {
+template
+struct Base {
+  struct S {
+const T *p1 = nullptr;
+const T *p2 = new T[3];
+  };
+};
+
+void null_init(Base::S s) {
+  delete s.p1;
+  delete s.p2;
+}
+}
+
 #ifndef WITH_PCH
 pch_test::X::X()
   : a(new int[1])  // expected-note{{allocated with 'new[]' here}}


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


Re: [PATCH] D7639: Add readability-redundant-void-arg check to clang-tidy

2015-10-26 Thread Samuel Benzaquen via cfe-commits
sbenza added a comment.

Just fyi, I am looking at this diff. It is very large with a lot of rounds of 
comments and I didn't have the context.
I don't know if I should giving comments at this point of the change, but here 
it is.
Have you considered matching on typeLoc() instead of having a large list of 
different cases?
For example, if you match `typeLoc(loc(functionType()))` it will match all the 
places where a function type is mentioned, including things like 
`static_cast`, variable declarations, lambda return type declarations, 
etc. Might help remove redundancy in the check.


http://reviews.llvm.org/D7639



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


r251371 - Use early exits to reduce indentation.

2015-10-26 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Mon Oct 26 19:06:21 2015
New Revision: 251371

URL: http://llvm.org/viewvc/llvm-project?rev=251371=rev
Log:
Use early exits to reduce indentation.

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

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=251371=251370=251371=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Oct 26 19:06:21 2015
@@ -296,53 +296,55 @@ bool CodeGenFunction::checkBuiltinTarget
   if (!TargetDecl)
 return true;
 
-  // Get the current enclosing function if it exists.
-  if (const FunctionDecl *FD = dyn_cast_or_null(CurFuncDecl)) {
-unsigned BuiltinID = TargetDecl->getBuiltinID();
-const char *FeatureList =
-CGM.getContext().BuiltinInfo.getRequiredFeatures(BuiltinID);
-if (FeatureList && StringRef(FeatureList) != "") {
-  StringRef TargetCPU = Target.getTargetOpts().CPU;
-  llvm::StringMap FeatureMap;
-
-  if (const auto *TD = FD->getAttr()) {
-// If we have a TargetAttr build up the feature map based on that.
-TargetAttr::ParsedTargetAttr ParsedAttr = TD->parse();
-
-// Make a copy of the features as passed on the command line into the
-// beginning of the additional features from the function to override.
-ParsedAttr.first.insert(
-ParsedAttr.first.begin(),
-Target.getTargetOpts().FeaturesAsWritten.begin(),
-Target.getTargetOpts().FeaturesAsWritten.end());
-
-if (ParsedAttr.second != "")
-  TargetCPU = ParsedAttr.second;
-
-// Now populate the feature map, first with the TargetCPU which is
-// either
-// the default or a new one from the target attribute string. Then 
we'll
-// use the passed in features (FeaturesAsWritten) along with the new
-// ones
-// from the attribute.
-Target.initFeatureMap(FeatureMap, CGM.getDiags(), TargetCPU,
-  ParsedAttr.first);
-  } else {
-Target.initFeatureMap(FeatureMap, CGM.getDiags(), TargetCPU,
-  Target.getTargetOpts().Features);
-  }
-
-  // If we have at least one of the features in the feature list return
-  // true, otherwise return false.
-  SmallVector AttrFeatures;
-  StringRef(FeatureList).split(AttrFeatures, ",");
-  for (const auto  : AttrFeatures)
-if (FeatureMap[Feature])
- return true;
-  return false;
-}
+  // Get the current enclosing function if it exists. If it doesn't
+  // we can't check the target features anyhow.
+  const FunctionDecl *FD = dyn_cast_or_null(CurFuncDecl);
+  if (!FD) return true;
+
+  unsigned BuiltinID = TargetDecl->getBuiltinID();
+  const char *FeatureList =
+  CGM.getContext().BuiltinInfo.getRequiredFeatures(BuiltinID);
+
+  if (!FeatureList || StringRef(FeatureList) == "")
+return true;
+
+  StringRef TargetCPU = Target.getTargetOpts().CPU;
+  llvm::StringMap FeatureMap;
+
+  if (const auto *TD = FD->getAttr()) {
+// If we have a TargetAttr build up the feature map based on that.
+TargetAttr::ParsedTargetAttr ParsedAttr = TD->parse();
+
+// Make a copy of the features as passed on the command line into the
+// beginning of the additional features from the function to override.
+ParsedAttr.first.insert(ParsedAttr.first.begin(),
+Target.getTargetOpts().FeaturesAsWritten.begin(),
+Target.getTargetOpts().FeaturesAsWritten.end());
+
+if (ParsedAttr.second != "")
+  TargetCPU = ParsedAttr.second;
+
+// Now populate the feature map, first with the TargetCPU which is
+// either
+// the default or a new one from the target attribute string. Then we'll
+// use the passed in features (FeaturesAsWritten) along with the new
+// ones
+// from the attribute.
+Target.initFeatureMap(FeatureMap, CGM.getDiags(), TargetCPU,
+  ParsedAttr.first);
+  } else {
+Target.initFeatureMap(FeatureMap, CGM.getDiags(), TargetCPU,
+  Target.getTargetOpts().Features);
   }
-  return true;
+
+  // If we have at least one of the features in the feature list return
+  // true, otherwise return false.
+  SmallVector AttrFeatures;
+  StringRef(FeatureList).split(AttrFeatures, ",");
+  for (const auto  : AttrFeatures)
+if (FeatureMap[Feature])
+  return true;
+  return false;
 }
 
 RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,


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


Re: [PATCH] D14096: [clang-tidy] add new check cppcoreguidelines-pro-type-cstyle-cast

2015-10-26 Thread Samuel Benzaquen via cfe-commits
sbenza added inline comments.


Comment at: clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp:44
@@ +43,3 @@
+  if (MatchedCast->getCastKind() == CK_BitCast ||
+  MatchedCast->getCastKind() == CK_LValueBitCast ||
+  MatchedCast->getCastKind() == CK_IntegralToPointer ||

Seems to be missing CK_ReinterpretMemberPointer


Comment at: clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp:48
@@ +47,3 @@
+diag(MatchedCast->getLocStart(),
+ "do not use c-style cast to perform a reinterpret_cast");
+return;

From reading warning this I would think the way to fix the code is to use a 
reinterpret_cast directly, but that is also against the guidelines.


Comment at: clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp:55
@@ +54,3 @@
+  if (MatchedCast->getCastKind() == CK_BaseToDerived) {
+
+const auto *SourceDecl = SourceType->getPointeeCXXRecordDecl();

remove blank line


http://reviews.llvm.org/D14096



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


Re: r251371 - Use early exits to reduce indentation.

2015-10-26 Thread Eric Christopher via cfe-commits
On Mon, Oct 26, 2015 at 5:11 PM David Blaikie  wrote:

> On Mon, Oct 26, 2015 at 5:06 PM, Eric Christopher via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: echristo
>> Date: Mon Oct 26 19:06:21 2015
>> New Revision: 251371
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=251371=rev
>> Log:
>> Use early exits to reduce indentation.
>>
>> Modified:
>> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>>
>> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=251371=251370=251371=diff
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Oct 26 19:06:21 2015
>> @@ -296,53 +296,55 @@ bool CodeGenFunction::checkBuiltinTarget
>>if (!TargetDecl)
>>  return true;
>>
>> -  // Get the current enclosing function if it exists.
>> -  if (const FunctionDecl *FD =
>> dyn_cast_or_null(CurFuncDecl)) {
>> -unsigned BuiltinID = TargetDecl->getBuiltinID();
>> -const char *FeatureList =
>> -CGM.getContext().BuiltinInfo.getRequiredFeatures(BuiltinID);
>> -if (FeatureList && StringRef(FeatureList) != "") {
>> -  StringRef TargetCPU = Target.getTargetOpts().CPU;
>> -  llvm::StringMap FeatureMap;
>> -
>> -  if (const auto *TD = FD->getAttr()) {
>> -// If we have a TargetAttr build up the feature map based on
>> that.
>> -TargetAttr::ParsedTargetAttr ParsedAttr = TD->parse();
>> -
>> -// Make a copy of the features as passed on the command line
>> into the
>> -// beginning of the additional features from the function to
>> override.
>> -ParsedAttr.first.insert(
>> -ParsedAttr.first.begin(),
>> -Target.getTargetOpts().FeaturesAsWritten.begin(),
>> -Target.getTargetOpts().FeaturesAsWritten.end());
>> -
>> -if (ParsedAttr.second != "")
>> -  TargetCPU = ParsedAttr.second;
>> -
>> -// Now populate the feature map, first with the TargetCPU which
>> is
>> -// either
>> -// the default or a new one from the target attribute string.
>> Then we'll
>> -// use the passed in features (FeaturesAsWritten) along with the
>> new
>> -// ones
>> -// from the attribute.
>> -Target.initFeatureMap(FeatureMap, CGM.getDiags(), TargetCPU,
>> -  ParsedAttr.first);
>> -  } else {
>> -Target.initFeatureMap(FeatureMap, CGM.getDiags(), TargetCPU,
>> -  Target.getTargetOpts().Features);
>> -  }
>> -
>> -  // If we have at least one of the features in the feature list
>> return
>> -  // true, otherwise return false.
>> -  SmallVector AttrFeatures;
>> -  StringRef(FeatureList).split(AttrFeatures, ",");
>> -  for (const auto  : AttrFeatures)
>> -if (FeatureMap[Feature])
>> - return true;
>> -  return false;
>> -}
>> +  // Get the current enclosing function if it exists. If it doesn't
>> +  // we can't check the target features anyhow.
>> +  const FunctionDecl *FD = dyn_cast_or_null(CurFuncDecl);
>> +  if (!FD) return true;
>> +
>> +  unsigned BuiltinID = TargetDecl->getBuiltinID();
>> +  const char *FeatureList =
>> +  CGM.getContext().BuiltinInfo.getRequiredFeatures(BuiltinID);
>> +
>> +  if (!FeatureList || StringRef(FeatureList) == "")
>> +return true;
>> +
>> +  StringRef TargetCPU = Target.getTargetOpts().CPU;
>> +  llvm::StringMap FeatureMap;
>> +
>> +  if (const auto *TD = FD->getAttr()) {
>> +// If we have a TargetAttr build up the feature map based on that.
>> +TargetAttr::ParsedTargetAttr ParsedAttr = TD->parse();
>> +
>> +// Make a copy of the features as passed on the command line into the
>> +// beginning of the additional features from the function to
>> override.
>> +ParsedAttr.first.insert(ParsedAttr.first.begin(),
>> +
>> Target.getTargetOpts().FeaturesAsWritten.begin(),
>> +
>> Target.getTargetOpts().FeaturesAsWritten.end());
>> +
>> +if (ParsedAttr.second != "")
>> +  TargetCPU = ParsedAttr.second;
>> +
>> +// Now populate the feature map, first with the TargetCPU which is
>> +// either
>> +// the default or a new one from the target attribute string. Then
>> we'll
>> +// use the passed in features (FeaturesAsWritten) along with the new
>> +// ones
>> +// from the attribute.
>> +Target.initFeatureMap(FeatureMap, CGM.getDiags(), TargetCPU,
>> +  ParsedAttr.first);
>> +  } else {
>> +Target.initFeatureMap(FeatureMap, CGM.getDiags(), TargetCPU,
>> +  Target.getTargetOpts().Features);
>>}
>> -  return true;
>> +
>> +  // If we have at least one of the features in the feature list return
>> +  // true, otherwise return false.
>> +  SmallVector AttrFeatures;
>> +  

Re: r251284 - clang-format: Fix false positive in cast detection.

2015-10-26 Thread David Blaikie via cfe-commits
On Mon, Oct 26, 2015 at 9:43 PM, Daniel Jasper  wrote:

> If you look closely, there are multiple tests for different configuration
> options.
>

Ah, I see one that's "( int, int )" now - cool, thanks!


> The before/after is always just one example.
>
> On Tue, Oct 27, 2015 at 5:42 AM, David Blaikie  wrote:
>
>>
>>
>> On Mon, Oct 26, 2015 at 9:21 PM, Daniel Jasper 
>> wrote:
>>
>>> I mixed up before and after. Other than that, I don't see a typo.
>>>
>>
>> It looks like the test case "+  verifyFormat("std::function< void(int,
>> int) > fct;", Spaces);" ensures no spaces between the parameters and the ()
>> in the function type ("void(int, int)") but the commit message says "void(
>> int, int )" -> "void( int, int)", neither of which is what the test case
>> tests, right?
>>
>>
>>>
>>> On Mon, Oct 26, 2015 at 5:44 PM, David Blaikie 
>>> wrote:
>>>


 On Mon, Oct 26, 2015 at 5:08 AM, Daniel Jasper via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:

> Author: djasper
> Date: Mon Oct 26 07:08:47 2015
> New Revision: 251284
>
> URL: http://llvm.org/viewvc/llvm-project?rev=251284=rev
> Log:
> clang-format: Fix false positive in cast detection.
>
> Before (with spaces in parentheses):
>   void inFunction() { std::function fct; }
>
> After:
>   void inFunction() { std::function fct; }
>

 I take it the typo in ^ between the "(" and the "int" is just a typo in
 the commit message, not reflected in the actual behavior? (judging by the
 test that seems to be the case)


>
> Modified:
> cfe/trunk/lib/Format/TokenAnnotator.cpp
> cfe/trunk/unittests/Format/FormatTest.cpp
>
> Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=251284=251283=251284=diff
>
> ==
> --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
> +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Oct 26 07:08:47 2015
> @@ -1086,7 +1086,8 @@ private:
>  Tok.Previous->isOneOf(TT_PointerOrReference,
> TT_TemplateCloser) ||
>  Tok.Previous->isSimpleTypeSpecifier();
>  bool ParensCouldEndDecl =
> -Tok.Next && Tok.Next->isOneOf(tok::equal, tok::semi,
> tok::l_brace);
> +Tok.Next &&
> +Tok.Next->isOneOf(tok::equal, tok::semi, tok::l_brace,
> tok::greater);
>  bool IsSizeOfOrAlignOf =
>  LeftOfParens && LeftOfParens->isOneOf(tok::kw_sizeof,
> tok::kw_alignof);
>  if (ParensAreType && !ParensCouldEndDecl && !IsSizeOfOrAlignOf &&
>
> Modified: cfe/trunk/unittests/Format/FormatTest.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=251284=251283=251284=diff
>
> ==
> --- cfe/trunk/unittests/Format/FormatTest.cpp (original)
> +++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Oct 26 07:08:47 2015
> @@ -8398,6 +8398,8 @@ TEST_F(FormatTest, ConfigurableSpacesInP
>verifyFormat("call( x, y, z );", Spaces);
>verifyFormat("call();", Spaces);
>verifyFormat("std::function callback;", Spaces);
> +  verifyFormat("void inFunction() { std::function
> fct; }",
> +   Spaces);
>verifyFormat("while ( (bool)1 )\n"
> "  continue;",
> Spaces);
> @@ -10633,6 +10635,9 @@ TEST_F(FormatTest, SpacesInAngles) {
>verifyFormat("f< int, float >();", Spaces);
>verifyFormat("template <> g() {}", Spaces);
>verifyFormat("template < std::vector< int > > f() {}", Spaces);
> +  verifyFormat("std::function< void(int, int) > fct;", Spaces);
> +  verifyFormat("void inFunction() { std::function< void(int, int) >
> fct; }",
> +   Spaces);
>
>Spaces.Standard = FormatStyle::LS_Cpp03;
>Spaces.SpacesInAngles = 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


r251384 - Be more conservative about diagnosing "incorrect" uses of __weak:

2015-10-26 Thread John McCall via cfe-commits
Author: rjmccall
Date: Mon Oct 26 23:54:50 2015
New Revision: 251384

URL: http://llvm.org/viewvc/llvm-project?rev=251384=rev
Log:
Be more conservative about diagnosing "incorrect" uses of __weak:
allow them to be written in certain kinds of user declaration and
diagnose on the use-site instead.

Also, improve and fix some diagnostics relating to __weak and
properties.

rdar://23228631

Added:
cfe/trunk/test/SemaObjC/mrc-no-weak.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/test/SemaObjC/arc-no-runtime.m
cfe/trunk/test/SemaObjC/arc-property-decl-attrs.m
cfe/trunk/test/SemaObjC/arc-system-header.m
cfe/trunk/test/SemaObjC/arc-unavailable-system-function.m
cfe/trunk/test/SemaObjC/no-gc-weak-test.m
cfe/trunk/test/SemaObjC/synthesized-ivar.m
cfe/trunk/test/SemaObjCXX/arc-system-header.mm

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=251384=251383=251384=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Oct 26 23:54:50 
2015
@@ -3992,6 +3992,8 @@ def err_unavailable_message : Error<"%0
 def warn_unavailable_fwdclass_message : Warning<
 "%0 may be unavailable because the receiver type is unknown">,
 InGroup;
+def note_unavailability_inferred_here : Note<
+"unsupported declaration here">;
 def note_availability_specified_here : Note<
   "%0 has been explicitly marked "
   "%select{unavailable|deleted|deprecated|partial}1 here">;
@@ -4524,9 +4526,15 @@ let CategoryName = "ARC Semantic Issue"
 let CategoryName = "ARC Weak References" in {
 
 def err_arc_weak_no_runtime : Error<
-  "the current deployment target does not support automated __weak 
references">;
+  "cannot create __weak reference because the current deployment target "
+  "does not support weak references">;
 def err_arc_weak_disabled : Error<
-  "automated __weak references are disabled in manual reference counting">;
+  "cannot create __weak reference in file using manual reference counting">;
+def err_synthesizing_arc_weak_property_disabled : Error<
+  "cannot synthesize weak property in file using manual reference counting">;
+def err_synthesizing_arc_weak_property_no_runtime : Error<
+  "cannot synthesize weak property because the current deployment target "
+  "does not support weak references">;
 def warn_objc_weak_compat : Warning<
   "the meaning of __weak has changed in manual reference-counting">,
   InGroup>, DefaultIgnore;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=251384=251383=251384=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Oct 26 23:54:50 2015
@@ -1212,16 +1212,6 @@ public:
 
   bool CheckFunctionReturnType(QualType T, SourceLocation Loc);
 
-  unsigned deduceWeakPropertyFromType(QualType T) {
-if ((getLangOpts().getGC() != LangOptions::NonGC &&
- T.isObjCGCWeak()) ||
-(getLangOpts().ObjCAutoRefCount &&
- T.getObjCLifetime() == Qualifiers::OCL_Weak))
-return ObjCDeclSpec::DQ_PR_weak;
-return 0;
-  }
-
-
   /// \brief Build a function type.
   ///
   /// This routine checks the function type according to C++ rules and

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=251384=251383=251384=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Oct 26 23:54:50 2015
@@ -5332,26 +5332,53 @@ void Sema::ProcessDeclAttributes(Scope *
 }
 
 /// Is the given declaration allowed to use a forbidden type?
-static bool isForbiddenTypeAllowed(Sema , Decl *decl) {
+/// If so, it'll still be annotated with an attribute that makes it
+/// illegal to actually use.
+static bool isForbiddenTypeAllowed(Sema , Decl *decl,
+   const DelayedDiagnostic ,
+   llvm::StringRef ) {
   // Private ivars are always okay.  Unfortunately, people don't
   // always properly make their ivars private, even in system headers.
   // Plus we need to make fields okay, too.
-  // Function declarations in sys headers will be marked unavailable.
   if (!isa(decl) && !isa(decl) &&
   !isa(decl))
 return false;
 
-  // Require it to be declared in a system header.
-  return 

r251385 - Create undef reference to profile hook symbol

2015-10-26 Thread Xinliang David Li via cfe-commits
Author: davidxl
Date: Tue Oct 27 00:15:35 2015
New Revision: 251385

URL: http://llvm.org/viewvc/llvm-project?rev=251385=rev
Log:
Create undef reference to profile hook symbol 

Create undef reference to profile hook symbol when
PGO instrumentation is turned on. This allows 
LLVM to omit emission of hook variable use method
for every single module instrumented.

Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=251385=251384=251385=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Oct 27 00:15:35 2015
@@ -25,6 +25,7 @@
 #include "llvm/Option/ArgList.h"
 #include "llvm/Option/OptTable.h"
 #include "llvm/Option/Option.h"
+#include "llvm/ProfileData/InstrProf.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -3811,6 +3812,18 @@ SanitizerMask Linux::getSupportedSanitiz
   return Res;
 }
 
+void Linux::addProfileRTLibs(const llvm::opt::ArgList ,
+ llvm::opt::ArgStringList ) const {
+  if (!needsProfileRT(Args)) return;
+
+  // Add linker option -u__llvm_runtime_variable to cause runtime
+  // initialization module to be linked in.
+  if (!Args.hasArg(options::OPT_coverage))
+CmdArgs.push_back(Args.MakeArgString(
+Twine("-u", llvm::getInstrProfRuntimeHookVarName(;
+  ToolChain::addProfileRTLibs(Args, CmdArgs);
+}
+
 /// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly.
 
 DragonFly::DragonFly(const Driver , const llvm::Triple ,

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=251385=251384=251385=diff
==
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Tue Oct 27 00:15:35 2015
@@ -744,6 +744,8 @@ public:
   llvm::opt::ArgStringList ) const override;
   bool isPIEDefault() const override;
   SanitizerMask getSupportedSanitizers() const override;
+  void addProfileRTLibs(const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ) const override;
 
   std::string Linker;
   std::vector ExtraOpts;


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


Re: r251284 - clang-format: Fix false positive in cast detection.

2015-10-26 Thread Daniel Jasper via cfe-commits
I mixed up before and after. Other than that, I don't see a typo.

On Mon, Oct 26, 2015 at 5:44 PM, David Blaikie  wrote:

>
>
> On Mon, Oct 26, 2015 at 5:08 AM, Daniel Jasper via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: djasper
>> Date: Mon Oct 26 07:08:47 2015
>> New Revision: 251284
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=251284=rev
>> Log:
>> clang-format: Fix false positive in cast detection.
>>
>> Before (with spaces in parentheses):
>>   void inFunction() { std::function fct; }
>>
>> After:
>>   void inFunction() { std::function fct; }
>>
>
> I take it the typo in ^ between the "(" and the "int" is just a typo in
> the commit message, not reflected in the actual behavior? (judging by the
> test that seems to be the case)
>
>
>>
>> Modified:
>> cfe/trunk/lib/Format/TokenAnnotator.cpp
>> cfe/trunk/unittests/Format/FormatTest.cpp
>>
>> Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=251284=251283=251284=diff
>>
>> ==
>> --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
>> +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Oct 26 07:08:47 2015
>> @@ -1086,7 +1086,8 @@ private:
>>  Tok.Previous->isOneOf(TT_PointerOrReference, TT_TemplateCloser)
>> ||
>>  Tok.Previous->isSimpleTypeSpecifier();
>>  bool ParensCouldEndDecl =
>> -Tok.Next && Tok.Next->isOneOf(tok::equal, tok::semi,
>> tok::l_brace);
>> +Tok.Next &&
>> +Tok.Next->isOneOf(tok::equal, tok::semi, tok::l_brace,
>> tok::greater);
>>  bool IsSizeOfOrAlignOf =
>>  LeftOfParens && LeftOfParens->isOneOf(tok::kw_sizeof,
>> tok::kw_alignof);
>>  if (ParensAreType && !ParensCouldEndDecl && !IsSizeOfOrAlignOf &&
>>
>> Modified: cfe/trunk/unittests/Format/FormatTest.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=251284=251283=251284=diff
>>
>> ==
>> --- cfe/trunk/unittests/Format/FormatTest.cpp (original)
>> +++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Oct 26 07:08:47 2015
>> @@ -8398,6 +8398,8 @@ TEST_F(FormatTest, ConfigurableSpacesInP
>>verifyFormat("call( x, y, z );", Spaces);
>>verifyFormat("call();", Spaces);
>>verifyFormat("std::function callback;", Spaces);
>> +  verifyFormat("void inFunction() { std::function fct;
>> }",
>> +   Spaces);
>>verifyFormat("while ( (bool)1 )\n"
>> "  continue;",
>> Spaces);
>> @@ -10633,6 +10635,9 @@ TEST_F(FormatTest, SpacesInAngles) {
>>verifyFormat("f< int, float >();", Spaces);
>>verifyFormat("template <> g() {}", Spaces);
>>verifyFormat("template < std::vector< int > > f() {}", Spaces);
>> +  verifyFormat("std::function< void(int, int) > fct;", Spaces);
>> +  verifyFormat("void inFunction() { std::function< void(int, int) > fct;
>> }",
>> +   Spaces);
>>
>>Spaces.Standard = FormatStyle::LS_Cpp03;
>>Spaces.SpacesInAngles = 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] D12922: Add support for function attribute "notail"

2015-10-26 Thread Akira Hatanaka via cfe-commits
ping

On Mon, Oct 19, 2015 at 5:59 PM, Akira Hatanaka  wrote:

> ahatanak updated this revision to Diff 37816.
> ahatanak added a comment.
>
> Address review comments:
>
> 1. Renamed the attribute to "not_tail_called".
>
> I chose "not_tail_called" over "notailcall" or "notail" to better
> distinguish it from the attribute that is proposed in
> http://reviews.llvm.org/D12547 (which is tentatively named
> "disable_tail_calls").
>
> 2. Made changes to error-out if a virtual function or an objective-c
> method is marked "not_tail_called".
>
> I made this change because this attribute isn't useful when the compiler
> cannot resolve the function call statically at compile time and it isn't
> important for the use case I have.
>
> 3. Added code examples to AttrDocs.td.
>
>
> http://reviews.llvm.org/D12922
>
> Files:
>   include/clang/Basic/Attr.td
>   include/clang/Basic/AttrDocs.td
>   include/clang/Basic/DiagnosticSemaKinds.td
>   lib/CodeGen/CGCall.cpp
>   lib/Sema/SemaDecl.cpp
>   lib/Sema/SemaDeclAttr.cpp
>   test/CodeGen/attr-no-tail.c
>   test/CodeGenCXX/attr-notail.cpp
>   test/Sema/attr-notail.c
>   test/SemaCXX/attr-notail.cpp
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D14104: clang-format: Add an additional value to AlignAfterOpenBracket: AlwaysBreak.

2015-10-26 Thread Daniel Jasper via cfe-commits
djasper created this revision.
djasper added a reviewer: klimek.
djasper added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

If this option is set, clang-format will always insert a line wrap, e.g.
before the first parameter of a function call unless all parameters fit
on the same line. This obviates the need to make a decision on the
alignment itself.

Use this style for Google's JavaScript style and add some minor tweaks
to correctly handle nested blocks etc. with it. Don't use this option
for for/while loops.

http://reviews.llvm.org/D14104

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/FormatToken.cpp
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp
  unittests/Format/FormatTestJS.cpp

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -49,7 +49,8 @@
   static void verifyFormat(
   llvm::StringRef Code,
   const FormatStyle  = getGoogleStyle(FormatStyle::LK_JavaScript)) {
-EXPECT_EQ(Code.str(), format(test::messUp(Code), Style));
+std::string result = format(test::messUp(Code), Style);
+EXPECT_EQ(Code.str(), result) << "Formatted:\n" << result;
   }
 };
 
@@ -292,13 +293,14 @@
"  bbb,\n"
"  ccc\n"
"]);");
-  verifyFormat("var someVariable = SomeFuntion(,\n"
-   "   [\n"
-   " aaa,\n"
-   " bbb,\n"
-   " ccc\n"
-   "   ],\n"
-   "   );");
+  verifyFormat("var someVariable = SomeFuntion(\n"
+   ",\n"
+   "[\n"
+   "  aaa,\n"
+   "  bbb,\n"
+   "  ccc\n"
+   "],\n"
+   ");");
 
   verifyFormat("someFunction([], {a: a});");
 }
@@ -320,14 +322,11 @@
"style: {direction: ''}\n"
"  }\n"
"};");
-  EXPECT_EQ("abc = xyz ?\n"
-"  function() {\n"
-"return 1;\n"
-"  } :\n"
-"  function() {\n"
-"return -1;\n"
-"  };",
-format("abc=xyz?function(){return 1;}:function(){return -1;};"));
+  verifyFormat("abc = xyz ? function() {\n"
+   "  return 1;\n"
+   "} : function() {\n"
+   "  return -1;\n"
+   "};");
 
   verifyFormat("var closure = goog.bind(\n"
"function() {  // comment\n"
@@ -379,17 +378,13 @@
"  someFunction();\n"
"}, this), a);");
 
-  // FIXME: This is not ideal yet.
-  verifyFormat("someFunction(goog.bind(\n"
-   " function() {\n"
-   "   doSomething();\n"
-   "   doSomething();\n"
-   " },\n"
-   " this),\n"
-   " goog.bind(function() {\n"
-   "   doSomething();\n"
-   "   doSomething();\n"
-   " }, this));");
+  verifyFormat("someFunction(goog.bind(function() {\n"
+   "  doSomething();\n"
+   "  doSomething();\n"
+   "}, this), goog.bind(function() {\n"
+   "  doSomething();\n"
+   "  doSomething();\n"
+   "}, this));");
 
   // FIXME: This is bad, we should be wrapping before "function() {".
   verifyFormat("someFunction(function() {\n"
@@ -472,16 +467,16 @@
"  doFoo();\n"
"  doBaz();\n"
"});\n");
-  // FIXME: Here, we should probably break right after the "(" for consistency.
-  verifyFormat("promise.then([],\n"
-   " function success() {\n"
-   "   doFoo();\n"
-   "   doBar();\n"
-   " },\n"
-   " function error() {\n"
-   "   doFoo();\n"
-   "   doBaz();\n"
-   " });\n");
+  verifyFormat("promise.then(\n"
+   "[],\n"
+   "function success() {\n"
+   "  doFoo();\n"
+   "  doBar();\n"
+   "},\n"
+   "function error() {\n"
+   "  

[PATCH] D14105: clang-format: When a line is formatted, also format subsequence lines if their indent is off.

2015-10-26 Thread Daniel Jasper via cfe-commits
djasper created this revision.
djasper added a reviewer: klimek.
djasper added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

This is especially important so that if a change is solely inserting a block 
around a few statements, clang-format-diff.py will still clean up and add 
indentation to the inner parts.

http://reviews.llvm.org/D14105

Files:
  lib/Format/UnwrappedLineFormatter.cpp
  test/Format/adjust-indent.cpp
  test/Format/line-ranges.cpp
  test/Format/ranges.cpp
  unittests/Format/FormatTestSelective.cpp

Index: unittests/Format/FormatTestSelective.cpp
===
--- unittests/Format/FormatTestSelective.cpp
+++ unittests/Format/FormatTestSelective.cpp
@@ -45,8 +45,14 @@
 }
 
 TEST_F(FormatTestSelective, FormatsCorrectRegionForLeadingWhitespace) {
-  EXPECT_EQ("int b;\nint a;", format("int b;\n   int a;", 7, 0));
-  EXPECT_EQ("int b;\n   int a;", format("int b;\n   int a;", 6, 0));
+  EXPECT_EQ("{int b;\n"
+"  int a;\n"
+"}",
+format("{int b;\n  int  a;}", 8, 0));
+  EXPECT_EQ("{\n"
+"  int b;\n"
+"  int  a;}",
+format("{int b;\n  int  a;}", 7, 0));
 
   Style.ColumnLimit = 12;
   EXPECT_EQ("#define A  \\\n"
@@ -84,11 +90,11 @@
   "template  T *getFETokenInfo() const {\n"
   "  return static_cast(FETokenInfo);\n"
   "}\n"
-  "  int a; // <- Should not be formatted",
+  "int  a; // <- Should not be formatted",
   format(
   "template\n"
   "T *getFETokenInfo() const { return static_cast(FETokenInfo); }\n"
-  "  int a; // <- Should not be formatted",
+  "int  a; // <- Should not be formatted",
   9, 5));
 }
 
@@ -142,12 +148,12 @@
 "   // is\n"
 "   // a\n"
 "\n"
-"  // This is unrelated",
+"//This is unrelated",
 format("int a; // This\n"
" // is\n"
" // a\n"
"\n"
-   "  // This is unrelated",
+   "//This is unrelated",
0, 0));
   EXPECT_EQ("int a;\n"
 "// This is\n"
@@ -310,13 +316,17 @@
   EXPECT_EQ("{\n"
 "{\n"
 "  a;\n"
-"b;\n"
+"  b;\n"
+"  c;\n"
+" d;\n"
 "}\n"
 "}",
 format("{\n"
"{\n"
" a;\n"
-   "b;\n"
+   "   b;\n"
+   "  c;\n"
+   " d;\n"
"}\n"
"}",
9, 2));
Index: test/Format/ranges.cpp
===
--- test/Format/ranges.cpp
+++ test/Format/ranges.cpp
@@ -2,10 +2,10 @@
 // RUN:   | clang-format -style=LLVM -offset=2 -length=0 -offset=28 -length=0 \
 // RUN:   | FileCheck -strict-whitespace %s
 // CHECK: {{^int\ \*i;$}}
-  int*i;
+int*i;
 
-// CHECK: {{^\ \ int\ \ \*\ \ i;$}}
-  int  *  i; 
+// CHECK: {{^int\ \ \*\ \ i;$}}
+int  *  i; 
 
-// CHECK: {{^\ \ int\ \*i;$}}
-  int   *   i;
+// CHECK: {{^int\ \*i;$}}
+int   *   i;
Index: test/Format/line-ranges.cpp
===
--- test/Format/line-ranges.cpp
+++ test/Format/line-ranges.cpp
@@ -4,8 +4,8 @@
 // CHECK: {{^int\ \*i;$}}
   int*i;
 
-// CHECK: {{^\ \ int\ \ \*\ \ i;$}}
-  int  *  i; 
+// CHECK: {{^int\ \ \*\ \ i;$}}
+int  *  i; 
 
-// CHECK: {{^\ \ int\ \*i;$}}
-  int   *   i;
+// CHECK: {{^int\ \*i;$}}
+int   *   i;
Index: test/Format/adjust-indent.cpp
===
--- /dev/null
+++ test/Format/adjust-indent.cpp
@@ -0,0 +1,10 @@
+// RUN: grep -Ev "// *[A-Z-]+:" %s | clang-format -lines=2:2 \
+// RUN:   | FileCheck -strict-whitespace %s
+
+void  f() {
+// CHECK: void f() {
+int i;
+// CHECK: {{^  int\ i;}}
+ int j;
+// CHECK: {{^  int\ j;}}
+}
Index: lib/Format/UnwrappedLineFormatter.cpp
===
--- lib/Format/UnwrappedLineFormatter.cpp
+++ lib/Format/UnwrappedLineFormatter.cpp
@@ -812,13 +812,14 @@
AdditionalIndent);
   const AnnotatedLine *PreviousLine = nullptr;
   const AnnotatedLine *NextLine = nullptr;
+  bool PreviousLineFormatted = false;
   for (const AnnotatedLine *Line =
Joiner.getNextMergedLine(DryRun, IndentTracker);
Line; Line = NextLine) {
 const AnnotatedLine  = *Line;
 unsigned Indent = IndentTracker.getIndent();
-bool FixIndentation =
-FixBadIndentation && (Indent != TheLine.First->OriginalColumn);
+bool FixIndentation = (FixBadIndentation || PreviousLineFormatted) &&
+  Indent != TheLine.First->OriginalColumn;
 bool ShouldFormat = TheLine.Affected || FixIndentation;
 // We cannot format this 

Re: r251284 - clang-format: Fix false positive in cast detection.

2015-10-26 Thread Daniel Jasper via cfe-commits
If you look closely, there are multiple tests for different configuration
options. The before/after is always just one example.

On Tue, Oct 27, 2015 at 5:42 AM, David Blaikie  wrote:

>
>
> On Mon, Oct 26, 2015 at 9:21 PM, Daniel Jasper  wrote:
>
>> I mixed up before and after. Other than that, I don't see a typo.
>>
>
> It looks like the test case "+  verifyFormat("std::function< void(int,
> int) > fct;", Spaces);" ensures no spaces between the parameters and the ()
> in the function type ("void(int, int)") but the commit message says "void(
> int, int )" -> "void( int, int)", neither of which is what the test case
> tests, right?
>
>
>>
>> On Mon, Oct 26, 2015 at 5:44 PM, David Blaikie 
>> wrote:
>>
>>>
>>>
>>> On Mon, Oct 26, 2015 at 5:08 AM, Daniel Jasper via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: djasper
 Date: Mon Oct 26 07:08:47 2015
 New Revision: 251284

 URL: http://llvm.org/viewvc/llvm-project?rev=251284=rev
 Log:
 clang-format: Fix false positive in cast detection.

 Before (with spaces in parentheses):
   void inFunction() { std::function fct; }

 After:
   void inFunction() { std::function fct; }

>>>
>>> I take it the typo in ^ between the "(" and the "int" is just a typo in
>>> the commit message, not reflected in the actual behavior? (judging by the
>>> test that seems to be the case)
>>>
>>>

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

 Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=251284=251283=251284=diff

 ==
 --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
 +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Oct 26 07:08:47 2015
 @@ -1086,7 +1086,8 @@ private:
  Tok.Previous->isOneOf(TT_PointerOrReference,
 TT_TemplateCloser) ||
  Tok.Previous->isSimpleTypeSpecifier();
  bool ParensCouldEndDecl =
 -Tok.Next && Tok.Next->isOneOf(tok::equal, tok::semi,
 tok::l_brace);
 +Tok.Next &&
 +Tok.Next->isOneOf(tok::equal, tok::semi, tok::l_brace,
 tok::greater);
  bool IsSizeOfOrAlignOf =
  LeftOfParens && LeftOfParens->isOneOf(tok::kw_sizeof,
 tok::kw_alignof);
  if (ParensAreType && !ParensCouldEndDecl && !IsSizeOfOrAlignOf &&

 Modified: cfe/trunk/unittests/Format/FormatTest.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=251284=251283=251284=diff

 ==
 --- cfe/trunk/unittests/Format/FormatTest.cpp (original)
 +++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Oct 26 07:08:47 2015
 @@ -8398,6 +8398,8 @@ TEST_F(FormatTest, ConfigurableSpacesInP
verifyFormat("call( x, y, z );", Spaces);
verifyFormat("call();", Spaces);
verifyFormat("std::function callback;", Spaces);
 +  verifyFormat("void inFunction() { std::function
 fct; }",
 +   Spaces);
verifyFormat("while ( (bool)1 )\n"
 "  continue;",
 Spaces);
 @@ -10633,6 +10635,9 @@ TEST_F(FormatTest, SpacesInAngles) {
verifyFormat("f< int, float >();", Spaces);
verifyFormat("template <> g() {}", Spaces);
verifyFormat("template < std::vector< int > > f() {}", Spaces);
 +  verifyFormat("std::function< void(int, int) > fct;", Spaces);
 +  verifyFormat("void inFunction() { std::function< void(int, int) >
 fct; }",
 +   Spaces);

Spaces.Standard = FormatStyle::LS_Cpp03;
Spaces.SpacesInAngles = 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: r251284 - clang-format: Fix false positive in cast detection.

2015-10-26 Thread David Blaikie via cfe-commits
On Mon, Oct 26, 2015 at 9:21 PM, Daniel Jasper  wrote:

> I mixed up before and after. Other than that, I don't see a typo.
>

It looks like the test case "+  verifyFormat("std::function< void(int, int)
> fct;", Spaces);" ensures no spaces between the parameters and the () in
the function type ("void(int, int)") but the commit message says "void(
int, int )" -> "void( int, int)", neither of which is what the test case
tests, right?


>
> On Mon, Oct 26, 2015 at 5:44 PM, David Blaikie  wrote:
>
>>
>>
>> On Mon, Oct 26, 2015 at 5:08 AM, Daniel Jasper via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: djasper
>>> Date: Mon Oct 26 07:08:47 2015
>>> New Revision: 251284
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=251284=rev
>>> Log:
>>> clang-format: Fix false positive in cast detection.
>>>
>>> Before (with spaces in parentheses):
>>>   void inFunction() { std::function fct; }
>>>
>>> After:
>>>   void inFunction() { std::function fct; }
>>>
>>
>> I take it the typo in ^ between the "(" and the "int" is just a typo in
>> the commit message, not reflected in the actual behavior? (judging by the
>> test that seems to be the case)
>>
>>
>>>
>>> Modified:
>>> cfe/trunk/lib/Format/TokenAnnotator.cpp
>>> cfe/trunk/unittests/Format/FormatTest.cpp
>>>
>>> Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=251284=251283=251284=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
>>> +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Oct 26 07:08:47 2015
>>> @@ -1086,7 +1086,8 @@ private:
>>>  Tok.Previous->isOneOf(TT_PointerOrReference, TT_TemplateCloser)
>>> ||
>>>  Tok.Previous->isSimpleTypeSpecifier();
>>>  bool ParensCouldEndDecl =
>>> -Tok.Next && Tok.Next->isOneOf(tok::equal, tok::semi,
>>> tok::l_brace);
>>> +Tok.Next &&
>>> +Tok.Next->isOneOf(tok::equal, tok::semi, tok::l_brace,
>>> tok::greater);
>>>  bool IsSizeOfOrAlignOf =
>>>  LeftOfParens && LeftOfParens->isOneOf(tok::kw_sizeof,
>>> tok::kw_alignof);
>>>  if (ParensAreType && !ParensCouldEndDecl && !IsSizeOfOrAlignOf &&
>>>
>>> Modified: cfe/trunk/unittests/Format/FormatTest.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=251284=251283=251284=diff
>>>
>>> ==
>>> --- cfe/trunk/unittests/Format/FormatTest.cpp (original)
>>> +++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Oct 26 07:08:47 2015
>>> @@ -8398,6 +8398,8 @@ TEST_F(FormatTest, ConfigurableSpacesInP
>>>verifyFormat("call( x, y, z );", Spaces);
>>>verifyFormat("call();", Spaces);
>>>verifyFormat("std::function callback;", Spaces);
>>> +  verifyFormat("void inFunction() { std::function
>>> fct; }",
>>> +   Spaces);
>>>verifyFormat("while ( (bool)1 )\n"
>>> "  continue;",
>>> Spaces);
>>> @@ -10633,6 +10635,9 @@ TEST_F(FormatTest, SpacesInAngles) {
>>>verifyFormat("f< int, float >();", Spaces);
>>>verifyFormat("template <> g() {}", Spaces);
>>>verifyFormat("template < std::vector< int > > f() {}", Spaces);
>>> +  verifyFormat("std::function< void(int, int) > fct;", Spaces);
>>> +  verifyFormat("void inFunction() { std::function< void(int, int) >
>>> fct; }",
>>> +   Spaces);
>>>
>>>Spaces.Standard = FormatStyle::LS_Cpp03;
>>>Spaces.SpacesInAngles = 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] D12906: [RFC] Bug identification("issue_hash") change for CmpRuns.py

2015-10-26 Thread Gyorgy Orban via cfe-commits
o.gyorgy added a comment.

Hi,

You are right the diff is is based on the hash. We already tried to
use an earlier hash generator (before the patch was introduced), which
generates a slightly different plist, that is why the current version
does not work with the patch.
We will fix CodeChecker to use new hash tag introduced in the final
patch (we did not change it so far because we didn't know what will be
the accepted naming convention and plist format).

We use LD_PRELOAD technique the log all the compiler calls, so no CC
or CXX environment variable orverride is necessary.
With the 'export CODECHECKER_VERBOSE=debug' enviromnet variable you
can see the analyzer commands.

Br,
Gyorgy


http://reviews.llvm.org/D12906



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


Porting Clang to a new architecture

2015-10-26 Thread Ariel Arelovich via cfe-commits
Hi:

Where I'm working I've been asked to look into developing a C (by this I
mean C89 C standard) compiler a new processor architecture being created
inhouse.

On looking at the options and brushing up on compiler theory, I came up
with Flex/Bison, Writing the compiler from scratch or use Clang. I liked
this option better because parsing and and analyzing c code to genereate
somthing intermediate, and do this from scratch, seemed like reinventing
the wheel (an incredibly complex wheel, at that).

I've figured that if Clang, works with the standard compiler flow (that
I've seen everywhere), it takes a C program and transforms it until it gets
a intermediate language (which is machine independant). The Dragon Book,
even calls this the output of the compiler Front End. From what I've read
from the documentation This is what Clang is: a compiler front end. LLVM
does optimization and translation to opcodes of known architectures. Is
this correct? Or am I getting this wrong?

So, my question is: Would it be possible to use Clang in such a way that it
takes a C program and generates an intermediate language so that I can work
directly on that language to generate opcodes based on the architecture
that we are currently developing?

Thank you, for any answers.

PD: I know my question might be very hard to answer as it is not very
specific. All I'm asking for, here, is a simple: "It could be done, start
reading about this and that" or "It will be next to impossible, just try
something else" (with a little explanation as to why, if that were
possible, please).
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r251289 - [analyzer] Fixed a rare crash when analyzing lambda functions.

2015-10-26 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Mon Oct 26 08:32:26 2015
New Revision: 251289

URL: http://llvm.org/viewvc/llvm-project?rev=251289=rev
Log:
[analyzer] Fixed a rare crash when analyzing lambda functions.

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp?rev=251289=251288=251289=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp Mon Oct 26 08:32:26 2015
@@ -1022,7 +1022,7 @@ MemRegionManager::getCXXThisRegion(QualT
   // 'this' refers to a this to the enclosing scope, there is no right region 
to
   // return.
   while (!LC->inTopFrame() &&
- PT != D->getThisType(getContext())->getAs()) {
+ (!D || PT != D->getThisType(getContext())->getAs())) {
 LC = LC->getParent();
 D = dyn_cast(LC->getDecl());
   }


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


Re: Getting fully qualified names of random qualtypes

2015-10-26 Thread Benjamin Kramer via cfe-commits
Some high level style comments:

1. Please convert the file to LLVM style for the things that
clang-format doesn't change. In particular PascalCase for all
variables and cameCase for all function names.
2. We don't do author attribution in file comments, sorry.
3. Try to avoid commented out/#if 0'd code.
4. I'd really prefer to review this on reviews.llvm.org, makes things easier.

On the functional side:
1. Why is std::vector and friends handled in a special case, don't we
want this for all default arguments?
2. Can the desugaring code be simplified somehow? it feels extremely
repetitive and the corresponding code in Type.cpp looks much simpler?
Where is the additional complexity coming from?

- Ben


On Sat, Oct 24, 2015 at 12:29 AM, Sterling Augustine via cfe-commits
 wrote:
> As requested on cfe-dev, enclosed is a patch (that needs some
> style-related work) to calculate the complete fully qualified name of
> arbitrary Qualtypes, including recursively expanding template
> parameters and subtypes.
>
> Seems to me like it follows most of the conventions described here:
>
> http://llvm.org/docs/CodingStandards.html
>
> but I'm told it needs more work. Happy to oblige.
>
> ___
> 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


r251284 - clang-format: Fix false positive in cast detection.

2015-10-26 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Oct 26 07:08:47 2015
New Revision: 251284

URL: http://llvm.org/viewvc/llvm-project?rev=251284=rev
Log:
clang-format: Fix false positive in cast detection.

Before (with spaces in parentheses):
  void inFunction() { std::function fct; }

After:
  void inFunction() { std::function fct; }

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=251284=251283=251284=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Oct 26 07:08:47 2015
@@ -1086,7 +1086,8 @@ private:
 Tok.Previous->isOneOf(TT_PointerOrReference, TT_TemplateCloser) ||
 Tok.Previous->isSimpleTypeSpecifier();
 bool ParensCouldEndDecl =
-Tok.Next && Tok.Next->isOneOf(tok::equal, tok::semi, tok::l_brace);
+Tok.Next &&
+Tok.Next->isOneOf(tok::equal, tok::semi, tok::l_brace, tok::greater);
 bool IsSizeOfOrAlignOf =
 LeftOfParens && LeftOfParens->isOneOf(tok::kw_sizeof, tok::kw_alignof);
 if (ParensAreType && !ParensCouldEndDecl && !IsSizeOfOrAlignOf &&

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=251284=251283=251284=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Oct 26 07:08:47 2015
@@ -8398,6 +8398,8 @@ TEST_F(FormatTest, ConfigurableSpacesInP
   verifyFormat("call( x, y, z );", Spaces);
   verifyFormat("call();", Spaces);
   verifyFormat("std::function callback;", Spaces);
+  verifyFormat("void inFunction() { std::function fct; }",
+   Spaces);
   verifyFormat("while ( (bool)1 )\n"
"  continue;",
Spaces);
@@ -10633,6 +10635,9 @@ TEST_F(FormatTest, SpacesInAngles) {
   verifyFormat("f< int, float >();", Spaces);
   verifyFormat("template <> g() {}", Spaces);
   verifyFormat("template < std::vector< int > > f() {}", Spaces);
+  verifyFormat("std::function< void(int, int) > fct;", Spaces);
+  verifyFormat("void inFunction() { std::function< void(int, int) > fct; }",
+   Spaces);
 
   Spaces.Standard = FormatStyle::LS_Cpp03;
   Spaces.SpacesInAngles = true;


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


Re: Porting Clang to a new architecture

2015-10-26 Thread Ariel Arelovich via cfe-commits
Great.

So this is what I wanted to know. I think understand what you are saying.
You are saying that most of the work that I would need to do from the AST
(I'm assuming that this stands from Abstract Syntax Tree) is allready being
done by LLVM and I should look to modify for a my new arquitecture. Right?

If I take the AST and process it myself to generate the opcodes, I'm
essentially writing LLVM just less efficient (no optimizations) and
specific for the new architecure, right?



On Mon, Oct 26, 2015 at 12:32 PM, Saleem Abdulrasool 
wrote:

> On Monday, October 26, 2015, Ariel Arelovich via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Hi:
>>
>> Where I'm working I've been asked to look into developing a C (by this I
>> mean C89 C standard) compiler a new processor architecture being created
>> inhouse.
>>
>> On looking at the options and brushing up on compiler theory, I came up
>> with Flex/Bison, Writing the compiler from scratch or use Clang. I liked
>> this option better because parsing and and analyzing c code to genereate
>> somthing intermediate, and do this from scratch, seemed like reinventing
>> the wheel (an incredibly complex wheel, at that).
>>
>> I've figured that if Clang, works with the standard compiler flow (that
>> I've seen everywhere), it takes a C program and transforms it until it gets
>> a intermediate language (which is machine independant). The Dragon Book,
>> even calls this the output of the compiler Front End. From what I've read
>> from the documentation This is what Clang is: a compiler front end. LLVM
>> does optimization and translation to opcodes of known architectures. Is
>> this correct? Or am I getting this wrong?
>>
>
> Correct.  clang is just the front end for C-like languages.  It will parse
> and analyze the code (generating the AST).  The IR it generates is the LLVM
> IR.
>
> So, my question is: Would it be possible to use Clang in such a way that
>> it takes a C program and generates an intermediate language so that I can
>> work directly on that language to generate opcodes based on the
>> architecture that we are currently developing?
>>
>
> Yes.  This is how clang already works.  It sounds like you should be
> looking at LLVM, not clang since you are trying to support a new
> architecture, not a language feature.
>
>
>>
>> Thank you, for any answers.
>>
>> PD: I know my question might be very hard to answer as it is not very
>> specific. All I'm asking for, here, is a simple: "It could be done, start
>> reading about this and that" or "It will be next to impossible, just try
>> something else" (with a little explanation as to why, if that were
>> possible, please).
>>
>
>
> --
> Saleem Abdulrasool
> compnerd (at) compnerd (dot) org
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14030: Use linker option to reference profile runtime hook (Linux)

2015-10-26 Thread Vedant Kumar via cfe-commits
vsk added a comment.

This looks good to me. Does this mean we will get rid of 
`getInstrProfRuntimeHookVarUseFuncName`?


http://reviews.llvm.org/D14030



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


Re: [PATCH] D14030: Use linker option to reference profile runtime hook (Linux)

2015-10-26 Thread Xinliang David Li via cfe-commits
On Mon, Oct 26, 2015 at 8:44 AM, Vedant Kumar  wrote:

> vsk added a comment.
>
> This looks good to me. Does this mean we will get rid of
> `getInstrProfRuntimeHookVarUseFuncName`?
>

not yet -- note that this is only enabled for Linux toolchain only for
now.  If it works for all platforms, we can get rid of the hook use
function all together.

thanks,

David

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


Re: [PATCH] D14014: Checker of proper vfork usage

2015-10-26 Thread Yury Gribov via cfe-commits
ygribov marked 43 inline comments as done.
ygribov added a comment.

http://reviews.llvm.org/D14014



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


Re: [PATCH] D13802: [OPENMP] Make -fopenmp to turn on OpenMP support by default.

2015-10-26 Thread Hans Wennborg via cfe-commits
hans added a comment.

The release script change looks good to me. Better than good actually; it's a 
great improvement :-)


http://reviews.llvm.org/D13802



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


r251313 - [analyzer] Added a missing test case for r251289.

2015-10-26 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Mon Oct 26 12:42:14 2015
New Revision: 251313

URL: http://llvm.org/viewvc/llvm-project?rev=251313=rev
Log:
[analyzer] Added a missing test case for r251289.

Modified:
cfe/trunk/test/Analysis/lambdas.cpp

Modified: cfe/trunk/test/Analysis/lambdas.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/lambdas.cpp?rev=251313=251312=251313=diff
==
--- cfe/trunk/test/Analysis/lambdas.cpp (original)
+++ cfe/trunk/test/Analysis/lambdas.cpp Mon Oct 26 12:42:14 2015
@@ -176,6 +176,19 @@ void inlineDefensiveChecks() {
   (void)p;
 }
 
+
+template
+void callLambda(T t) {
+  t();
+}
+
+struct DontCrash {
+  int x;
+  void f() {
+callLambda([&](){ ++x; });
+  }
+};
+
 // CHECK: [B2 (ENTRY)]
 // CHECK:   Succs (1): B1
 // CHECK: [B1]


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


Re: r251289 - [analyzer] Fixed a rare crash when analyzing lambda functions.

2015-10-26 Thread Gábor Horváth via cfe-commits
Added missing testcase in r251313.

On 26 October 2015 at 17:45, David Blaikie  wrote:

>
>
> On Mon, Oct 26, 2015 at 6:32 AM, Gabor Horvath via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: xazax
>> Date: Mon Oct 26 08:32:26 2015
>> New Revision: 251289
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=251289=rev
>> Log:
>> [analyzer] Fixed a rare crash when analyzing lambda functions.
>>
>
> Test case?
>
>
>>
>> Modified:
>> cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
>>
>> Modified: cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp?rev=251289=251288=251289=diff
>>
>> ==
>> --- cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp (original)
>> +++ cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp Mon Oct 26 08:32:26
>> 2015
>> @@ -1022,7 +1022,7 @@ MemRegionManager::getCXXThisRegion(QualT
>>// 'this' refers to a this to the enclosing scope, there is no right
>> region to
>>// return.
>>while (!LC->inTopFrame() &&
>> - PT != D->getThisType(getContext())->getAs()) {
>> + (!D || PT !=
>> D->getThisType(getContext())->getAs())) {
>>  LC = LC->getParent();
>>  D = dyn_cast(LC->getDecl());
>>}
>>
>>
>> ___
>> 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] D12358: [Analyzer] Widening loops which do not exit

2015-10-26 Thread Sean Eveson via cfe-commits
seaneveson marked an inline comment as done.
seaneveson added a comment.

Hi Devin,

Sorry it also took me so long to get back to you.



Comment at: include/clang/StaticAnalyzer/Core/AnalyzerOptions.h:266
@@ +265,3 @@
+  /// \sa shouldWidenLoops
+  bool WidenLoops;
+

dcoughlin wrote:
> Is this field used?
No. Thanks I'll fix that.


Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:1407
@@ +1406,3 @@
+const CFGBlock *Following = getBlockAfterLoop(L.getDst());
+if (Following && nodeBuilder.getContext().Eng.blockWasVisited(Following))
+  return;

dcoughlin wrote:
> What is the purpose of checking whether the block has already been visited by 
> some other path?
> 
> If I understand correctly, this will stop the analyzer from widening before 
> the "last" iteration through the loop and so will result in a sink after that 
> iteration. What this means is that we will never explore the code beyond the 
> loop in the widened state -- but isn't this the whole point of the widening?
> 
> So, for example, in your `variable_bound_exiting_loops_not_widened()` test, 
> don't we want the clang_analyzer_eval() statement after the loop to be 
> symbolically executed on 4 separate paths? That is, once when i is 0, once 
> when i is 1, once when i is 2 and once when i is $conj_i$ + 1 where $conj_i$ 
> is the value conjured for i when widening.
> 
> Also, in general, analysis of one path should not depend at all on whether 
> another path has been explored. This is because we want the analyzer to be 
> free choose different strategies about path exploration (e.g., BFS vs. DFS, 
> prioritizing some paths over others, etc.) without changing the issues 
> reported on along any given path. For this reason, I don't think we 
> necessarily want to track and expose `blockWasVisited()` on CoreEngine or use 
> this to determine when to permit a sink.
> 
> 
I was trying to avoid doing unnecessary invalidation, where the variable bound 
loop had already exited. I suppose this won’t be a concern when the 
invalidation is improved. If everyone is happy for loops that have already 
exited to be widened then I will remove the related changes.


Comment at: lib/StaticAnalyzer/Core/LoopWidening.cpp:98
@@ +97,3 @@
+  RegionAndSymbolInvalidationTraits ITraits;
+  for (int RegionIndex = 0; RegionIndex < NumRegions; ++ RegionIndex) {
+ITraits.setTrait(Regions[RegionIndex],

dcoughlin wrote:
> I get a warning here about comparing a signed int (RegionIndex) to an 
> unsigned (NumRegions).
> 
> I think you can avoid this and simplify things by using a range-based for 
> loop:
> ```
>   const MemRegion *Regions[] = {
>   ...
>   };
>   RegionAndSymbolInvalidationTraits ITraits;
>   for (auto *Region : Regions) {
> ...
>   }
> ```
Will do. Thanks.


http://reviews.llvm.org/D12358



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


Re: r251284 - clang-format: Fix false positive in cast detection.

2015-10-26 Thread David Blaikie via cfe-commits
On Mon, Oct 26, 2015 at 5:08 AM, Daniel Jasper via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: djasper
> Date: Mon Oct 26 07:08:47 2015
> New Revision: 251284
>
> URL: http://llvm.org/viewvc/llvm-project?rev=251284=rev
> Log:
> clang-format: Fix false positive in cast detection.
>
> Before (with spaces in parentheses):
>   void inFunction() { std::function fct; }
>
> After:
>   void inFunction() { std::function fct; }
>

I take it the typo in ^ between the "(" and the "int" is just a typo in the
commit message, not reflected in the actual behavior? (judging by the test
that seems to be the case)


>
> Modified:
> cfe/trunk/lib/Format/TokenAnnotator.cpp
> cfe/trunk/unittests/Format/FormatTest.cpp
>
> Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=251284=251283=251284=diff
>
> ==
> --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
> +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Oct 26 07:08:47 2015
> @@ -1086,7 +1086,8 @@ private:
>  Tok.Previous->isOneOf(TT_PointerOrReference, TT_TemplateCloser) ||
>  Tok.Previous->isSimpleTypeSpecifier();
>  bool ParensCouldEndDecl =
> -Tok.Next && Tok.Next->isOneOf(tok::equal, tok::semi,
> tok::l_brace);
> +Tok.Next &&
> +Tok.Next->isOneOf(tok::equal, tok::semi, tok::l_brace,
> tok::greater);
>  bool IsSizeOfOrAlignOf =
>  LeftOfParens && LeftOfParens->isOneOf(tok::kw_sizeof,
> tok::kw_alignof);
>  if (ParensAreType && !ParensCouldEndDecl && !IsSizeOfOrAlignOf &&
>
> Modified: cfe/trunk/unittests/Format/FormatTest.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=251284=251283=251284=diff
>
> ==
> --- cfe/trunk/unittests/Format/FormatTest.cpp (original)
> +++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Oct 26 07:08:47 2015
> @@ -8398,6 +8398,8 @@ TEST_F(FormatTest, ConfigurableSpacesInP
>verifyFormat("call( x, y, z );", Spaces);
>verifyFormat("call();", Spaces);
>verifyFormat("std::function callback;", Spaces);
> +  verifyFormat("void inFunction() { std::function fct;
> }",
> +   Spaces);
>verifyFormat("while ( (bool)1 )\n"
> "  continue;",
> Spaces);
> @@ -10633,6 +10635,9 @@ TEST_F(FormatTest, SpacesInAngles) {
>verifyFormat("f< int, float >();", Spaces);
>verifyFormat("template <> g() {}", Spaces);
>verifyFormat("template < std::vector< int > > f() {}", Spaces);
> +  verifyFormat("std::function< void(int, int) > fct;", Spaces);
> +  verifyFormat("void inFunction() { std::function< void(int, int) > fct;
> }",
> +   Spaces);
>
>Spaces.Standard = FormatStyle::LS_Cpp03;
>Spaces.SpacesInAngles = 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: r251289 - [analyzer] Fixed a rare crash when analyzing lambda functions.

2015-10-26 Thread David Blaikie via cfe-commits
On Mon, Oct 26, 2015 at 6:32 AM, Gabor Horvath via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: xazax
> Date: Mon Oct 26 08:32:26 2015
> New Revision: 251289
>
> URL: http://llvm.org/viewvc/llvm-project?rev=251289=rev
> Log:
> [analyzer] Fixed a rare crash when analyzing lambda functions.
>

Test case?


>
> Modified:
> cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp?rev=251289=251288=251289=diff
>
> ==
> --- cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp Mon Oct 26 08:32:26
> 2015
> @@ -1022,7 +1022,7 @@ MemRegionManager::getCXXThisRegion(QualT
>// 'this' refers to a this to the enclosing scope, there is no right
> region to
>// return.
>while (!LC->inTopFrame() &&
> - PT != D->getThisType(getContext())->getAs()) {
> + (!D || PT !=
> D->getThisType(getContext())->getAs())) {
>  LC = LC->getParent();
>  D = dyn_cast(LC->getDecl());
>}
>
>
> ___
> 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: r251289 - [analyzer] Fixed a rare crash when analyzing lambda functions.

2015-10-26 Thread Gábor Horváth via cfe-commits
On 26 October 2015 at 17:45, David Blaikie  wrote:

>
>
> On Mon, Oct 26, 2015 at 6:32 AM, Gabor Horvath via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: xazax
>> Date: Mon Oct 26 08:32:26 2015
>> New Revision: 251289
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=251289=rev
>> Log:
>> [analyzer] Fixed a rare crash when analyzing lambda functions.
>>
>
> Test case?
>

I will follow this up with one tomorrow. Sorry for delaying that.


>
>
>>
>> Modified:
>> cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
>>
>> Modified: cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp?rev=251289=251288=251289=diff
>>
>> ==
>> --- cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp (original)
>> +++ cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp Mon Oct 26 08:32:26
>> 2015
>> @@ -1022,7 +1022,7 @@ MemRegionManager::getCXXThisRegion(QualT
>>// 'this' refers to a this to the enclosing scope, there is no right
>> region to
>>// return.
>>while (!LC->inTopFrame() &&
>> - PT != D->getThisType(getContext())->getAs()) {
>> + (!D || PT !=
>> D->getThisType(getContext())->getAs())) {
>>  LC = LC->getParent();
>>  D = dyn_cast(LC->getDecl());
>>}
>>
>>
>> ___
>> 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


r251312 - [analyzer] ccc-analyzer: Fix -isystem value passing.

2015-10-26 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Mon Oct 26 12:19:51 2015
New Revision: 251312

URL: http://llvm.org/viewvc/llvm-project?rev=251312=rev
Log:
[analyzer] ccc-analyzer: Fix -isystem value passing.

The regex for -isystem matching is broken. -[D,I,Usystem] matches "-D", "-,",
"-I", "-U", "-s" "-y", etc. Besides that, "-isystem /foo" gets interpreted as
"-i" with a non-empty value "system" and thus the next "/foo" argument is not
read. This patch corrects the regex.

This fixes PR13237 .

A patch by Peter Wu!

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

Modified:
cfe/trunk/tools/scan-build/ccc-analyzer

Modified: cfe/trunk/tools/scan-build/ccc-analyzer
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build/ccc-analyzer?rev=251312=251311=251312=diff
==
--- cfe/trunk/tools/scan-build/ccc-analyzer (original)
+++ cfe/trunk/tools/scan-build/ccc-analyzer Mon Oct 26 12:19:51 2015
@@ -586,7 +586,7 @@ foreach (my $i = 0; $i < scalar(@ARGV);
   }
 
   # Compile mode flags.
-  if ($Arg =~ /^-[D,I,U,isystem](.*)$/) {
+  if ($Arg =~ /^-(?:[DIU]|isystem)(.*)$/) {
 my $Tmp = $Arg;
 if ($1 eq '') {
   # FIXME: Check if we are going off the end.


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


Re: [PATCH] D13800: ccc-analyzer: Fix -isystem value passing

2015-10-26 Thread Devin Coughlin via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL251312: [analyzer] ccc-analyzer: Fix -isystem value passing. 
(authored by dcoughlin).

Changed prior to commit:
  http://reviews.llvm.org/D13800?vs=37567=38433#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13800

Files:
  cfe/trunk/tools/scan-build/ccc-analyzer

Index: cfe/trunk/tools/scan-build/ccc-analyzer
===
--- cfe/trunk/tools/scan-build/ccc-analyzer
+++ cfe/trunk/tools/scan-build/ccc-analyzer
@@ -586,7 +586,7 @@
   }
 
   # Compile mode flags.
-  if ($Arg =~ /^-[D,I,U,isystem](.*)$/) {
+  if ($Arg =~ /^-(?:[DIU]|isystem)(.*)$/) {
 my $Tmp = $Arg;
 if ($1 eq '') {
   # FIXME: Check if we are going off the end.


Index: cfe/trunk/tools/scan-build/ccc-analyzer
===
--- cfe/trunk/tools/scan-build/ccc-analyzer
+++ cfe/trunk/tools/scan-build/ccc-analyzer
@@ -586,7 +586,7 @@
   }
 
   # Compile mode flags.
-  if ($Arg =~ /^-[D,I,U,isystem](.*)$/) {
+  if ($Arg =~ /^-(?:[DIU]|isystem)(.*)$/) {
 my $Tmp = $Arg;
 if ($1 eq '') {
   # FIXME: Check if we are going off the end.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13640: [clang-tidy] Add new check cppcoreguidelines-pro-bounds-array-to-pointer-decay

2015-10-26 Thread Samuel Benzaquen via cfe-commits
sbenza accepted this revision.
sbenza added a comment.
This revision is now accepted and ready to land.

Just one formatting comment.



Comment at: 
clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp:52
@@ +51,3 @@
+
+  diag(MatchedCast->getExprLoc(), "do not implicitly decay an array into a 
pointer; consider using gsl::array_view or an explicit cast instead");
+}

reflow to 80 cols


http://reviews.llvm.org/D13640



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


Re: [PATCH] D13731: [RFC][Analyzer] Supporting function attributes in .model files.

2015-10-26 Thread pierre gousseau via cfe-commits
pgousseau updated this revision to Diff 38438.
pgousseau added a comment.

Following Anna's review:

Remove unnecessary AST walk over declarations by reusing already captured 
declarations.
Add handling of merge conflicts using Sema merge methods.
Add condition at the end of ModelInjector::onBodySynthesis to prevent 
unnecessary model file parsing.
Fix 80 col in regression tests.
Add regression tests to exercise merge conflicts.

The const qualifier on model's declarations has to be removed as Sema merge 
methods take non const parameters.


http://reviews.llvm.org/D13731

Files:
  include/clang/Analysis/AnalysisContext.h
  include/clang/Analysis/CodeInjector.h
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  include/clang/StaticAnalyzer/Frontend/FrontendActions.h
  include/clang/StaticAnalyzer/Frontend/ModelConsumer.h
  lib/Analysis/AnalysisDeclContext.cpp
  lib/Analysis/BodyFarm.cpp
  lib/Analysis/BodyFarm.h
  lib/StaticAnalyzer/Core/AnalysisManager.cpp
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  lib/StaticAnalyzer/Frontend/FrontendActions.cpp
  lib/StaticAnalyzer/Frontend/ModelConsumer.cpp
  lib/StaticAnalyzer/Frontend/ModelInjector.cpp
  lib/StaticAnalyzer/Frontend/ModelInjector.h
  test/Analysis/Inputs/Models/modelFileHasAttributes.model
  test/Analysis/Inputs/Models/modelFileHasConflicts.model
  test/Analysis/analyzer-config.c
  test/Analysis/analyzer-config.cpp
  test/Analysis/model-attributes.cpp

Index: test/Analysis/model-attributes.cpp
===
--- /dev/null
+++ test/Analysis/model-attributes.cpp
@@ -0,0 +1,49 @@
+// This is testing the 'faux-attributes' analyzer option.
+// The declaration of 'modelFileHasAttributes' found in
+// modelFileHasAttributes.model has 'nonnull' attributes on the 2nd and 3rd
+// parameter, and a '_Nonnull' attribute on the 4th parameter.
+// The declaration of 'modelFileHasConflicts' has a visibility 'protected'
+// attribute and a '_Nullable' parameter attribute.
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-unknown-unknown -analyze -analyzer-checker=core,nullability -analyzer-config faux-attributes=true,model-path=%S/Inputs/Models %s -verify
+
+int modelFileHasAttributes(int *p0, int *p1, int *p2, int *p3);
+void modelFileHasConflicts(int *_Nonnull p) __attribute__((visibility("hidden")));
+// expected-warning@-1 {{nullability specifier '_Nonnull' conflicts with existing specifier '_Nullable'}}
+// expected-note@-2 {{previous attribute is here}}
+// expected-note@-3 {{previous declaration is here}}
+
+int f0(int *x, int *y, int *z) {
+  int *p = 0;
+  modelFileHasAttributes(p, x, y, z); // no-warning
+  return 0;
+}
+
+int f1(int *x, int *y, int *z) {
+  int *p = 0;
+  modelFileHasAttributes(x, p, y, z);
+  // expected-warning@-1{{Null pointer passed as an argument to a 'nonnull' parameter}}
+  return 0;
+}
+
+int f2(int *x, int *y, int *z) {
+  int *p = 0;
+  modelFileHasAttributes(x, y, p, z);
+  // expected-warning@-1{{Null pointer passed as an argument to a 'nonnull' parameter}}
+  return 0;
+}
+
+int f2a(int *x, int *y, int *z) {
+  int *p = 0;
+  modelFileHasAttributes(x, y, z, p);
+  // expected-warning@-1{{Null passed to a callee that requires a non-null argument}}
+  return 0;
+}
+
+int f3() {
+  modelFileHasConflicts(0);
+  // expected-warning@-1 {{null passed to a callee that requires a non-null argument}}
+  // expected-error@./Inputs/Models/modelFileHasConflicts.model:2 {{visibility does not match previous declaration}}
+  // expected-warning@./Inputs/Models/modelFileHasConflicts.model:1 {{nullability specifier '_Nullable' conflicts with existing specifier '_Nonnull'}}
+  // expected-note@./Inputs/Models/modelFileHasConflicts.model:1 {{previous declaration is here}}
+  return 0;
+}
Index: test/Analysis/analyzer-config.cpp
===
--- test/Analysis/analyzer-config.cpp
+++ test/Analysis/analyzer-config.cpp
@@ -24,6 +24,7 @@
 // CHECK-NEXT: c++-template-inlining = true
 // CHECK-NEXT: cfg-conditional-static-initializers = true
 // CHECK-NEXT: cfg-temporary-dtors = false
+// CHECK-NEXT: faux-attributes = false
 // CHECK-NEXT: faux-bodies = true
 // CHECK-NEXT: graph-trim-interval = 1000
 // CHECK-NEXT: inline-lambdas = true
@@ -37,4 +38,4 @@
 // CHECK-NEXT: mode = deep
 // CHECK-NEXT: region-store-small-struct-limit = 2
 // CHECK-NEXT: [stats]
-// CHECK-NEXT: num-entries = 19
+// CHECK-NEXT: num-entries = 20
Index: test/Analysis/analyzer-config.c
===
--- test/Analysis/analyzer-config.c
+++ test/Analysis/analyzer-config.c
@@ -13,6 +13,7 @@
 // CHECK: [config]
 // CHECK-NEXT: cfg-conditional-static-initializers = true
 // CHECK-NEXT: cfg-temporary-dtors = false
+// CHECK-NEXT: faux-attributes = false
 // CHECK-NEXT: faux-bodies = true
 // CHECK-NEXT: graph-trim-interval = 1000
 // CHECK-NEXT: inline-lambdas = true