Re: r257934 - [CMake] Support generation of linker order files using dtrace

2016-01-18 Thread Renato Golin via cfe-commits
It did, thanks!

On 15 January 2016 at 23:28, Chris Bieneman  wrote:
> That should be fixed with r257948.
>
> -Chris
>
>> On Jan 15, 2016, at 3:19 PM, Renato Golin  wrote:
>>
>> On 15 January 2016 at 21:21, Chris Bieneman via cfe-commits
>>  wrote:
>>> Author: cbieneman
>>> Date: Fri Jan 15 15:21:12 2016
>>> New Revision: 257934
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=257934&view=rev
>>> Log:
>>> [CMake] Support generation of linker order files using dtrace
>>>
>>> Summary:
>>> This patch extends the lit-based perf-training tooling supplied for PGO 
>>> data generation to also generate linker order files using dtrace.
>>
>> Hi Chris,
>>
>> This doesn't look good:
>>
>> Script must be run as root, or you must add the following to your
>> sudoers:%%admin ALL=(ALL) NOPASSWD: /usr/sbin/dtrace
>>
>> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-42vma/builds/5234/steps/ninja%20check%201/logs/FAIL%3A%20Clang%20Perf%20Training%3A%3Ahello_world.cpp
>>
>> cheers,
>> --renato
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16178: [analyzer] A quick fix on top of D12901/r257464

2016-01-18 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL258039: [analyzer] Fix an off-by-one in evalIntegralCast() 
(authored by dergachev).

Changed prior to commit:
  http://reviews.llvm.org/D16178?vs=44842&id=45159#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16178

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
  cfe/trunk/test/Analysis/bool-assignment.c

Index: cfe/trunk/test/Analysis/bool-assignment.c
===
--- cfe/trunk/test/Analysis/bool-assignment.c
+++ cfe/trunk/test/Analysis/bool-assignment.c
@@ -42,6 +42,15 @@
 BOOL x = y; // expected-warning {{Assignment of a non-Boolean value}}
 return;
   }
+  if (y > 200 && y < 250) {
+// FIXME: Currently we are loosing this warning due to a SymbolCast in RHS.
+BOOL x = y; // no-warning
+return;
+  }
+  if (y >= 127 && y < 150) {
+BOOL x = y; // expected-warning{{Assignment of a non-Boolean value}}
+return;
+  }
   if (y > 1) {
 BOOL x = y; // expected-warning {{Assignment of a non-Boolean value}}
 return;
Index: cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -451,7 +451,7 @@
   NonLoc FromVal = val.castAs();
   QualType CmpTy = getConditionType();
   NonLoc CompVal =
-  evalBinOpNN(state, BO_LT, FromVal, ToTypeMaxVal, CmpTy).castAs();
+  evalBinOpNN(state, BO_LE, FromVal, ToTypeMaxVal, CmpTy).castAs();
   ProgramStateRef IsNotTruncated, IsTruncated;
   std::tie(IsNotTruncated, IsTruncated) = state->assume(CompVal);
   if (!IsNotTruncated && IsTruncated) {


Index: cfe/trunk/test/Analysis/bool-assignment.c
===
--- cfe/trunk/test/Analysis/bool-assignment.c
+++ cfe/trunk/test/Analysis/bool-assignment.c
@@ -42,6 +42,15 @@
 BOOL x = y; // expected-warning {{Assignment of a non-Boolean value}}
 return;
   }
+  if (y > 200 && y < 250) {
+// FIXME: Currently we are loosing this warning due to a SymbolCast in RHS.
+BOOL x = y; // no-warning
+return;
+  }
+  if (y >= 127 && y < 150) {
+BOOL x = y; // expected-warning{{Assignment of a non-Boolean value}}
+return;
+  }
   if (y > 1) {
 BOOL x = y; // expected-warning {{Assignment of a non-Boolean value}}
 return;
Index: cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -451,7 +451,7 @@
   NonLoc FromVal = val.castAs();
   QualType CmpTy = getConditionType();
   NonLoc CompVal =
-  evalBinOpNN(state, BO_LT, FromVal, ToTypeMaxVal, CmpTy).castAs();
+  evalBinOpNN(state, BO_LE, FromVal, ToTypeMaxVal, CmpTy).castAs();
   ProgramStateRef IsNotTruncated, IsTruncated;
   std::tie(IsNotTruncated, IsTruncated) = state->assume(CompVal);
   if (!IsNotTruncated && IsTruncated) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r258042 - Add forEachArgumentWithParam AST matcher.

2016-01-18 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Mon Jan 18 05:20:09 2016
New Revision: 258042

URL: http://llvm.org/viewvc/llvm-project?rev=258042&view=rev
Log:
Add forEachArgumentWithParam AST matcher.

The new matcher allows users to provide a matcher for both the argument
of a CallExpr/CxxConstructExpr a well as the ParmVarDecl of the
argument.

Patch by Felix Berger.

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

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

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=258042&r1=258041&r2=258042&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Jan 18 05:20:09 2016
@@ -2871,6 +2871,57 @@ AST_MATCHER_P2(FunctionDecl, hasParamete
   *Node.getParamDecl(N), Finder, Builder));
 }
 
+/// \brief Matches all arguments and their respective ParmVarDecl.
+///
+/// Given
+/// \code
+///   void f(int i);
+///   int y;
+///   f(y);
+/// \endcode
+/// callExpr(declRefExpr(to(varDecl(hasName("y",
+/// parmVarDecl(hasType(isInteger(
+///   matches f(y);
+/// with declRefExpr(...)
+///   matching int y
+/// and parmVarDecl(...)
+///   matching int i
+AST_POLYMORPHIC_MATCHER_P2(forEachArgumentWithParam,
+   AST_POLYMORPHIC_SUPPORTED_TYPES(CallExpr,
+   CXXConstructExpr),
+   internal::Matcher, ArgMatcher,
+   internal::Matcher, ParamMatcher) {
+  BoundNodesTreeBuilder Result;
+  // The first argument of an overloaded member operator is the implicit object
+  // argument of the method which should not be matched against a parameter, so
+  // we skip over it here.
+  BoundNodesTreeBuilder Matches;
+  unsigned ArgIndex = cxxOperatorCallExpr(callee(cxxMethodDecl()))
+  .matches(Node, Finder, &Matches)
+  ? 1
+  : 0;
+  int ParamIndex = 0;
+  bool Matched = false;
+  for (; ArgIndex < Node.getNumArgs(); ++ArgIndex) {
+BoundNodesTreeBuilder ArgMatches(*Builder);
+if (ArgMatcher.matches(*(Node.getArg(ArgIndex)->IgnoreParenCasts()),
+   Finder, &ArgMatches)) {
+  BoundNodesTreeBuilder ParamMatches(ArgMatches);
+  if (expr(anyOf(cxxConstructExpr(hasDeclaration(cxxConstructorDecl(
+ hasParameter(ParamIndex, ParamMatcher,
+ callExpr(callee(functionDecl(
+ hasParameter(ParamIndex, ParamMatcher))
+  .matches(Node, Finder, &ParamMatches)) {
+Result.addMatch(ParamMatches);
+Matched = true;
+  }
+}
+++ParamIndex;
+  }
+  *Builder = std::move(Result);
+  return Matched;
+}
+
 /// \brief Matches any parameter of a function declaration.
 ///
 /// Does not match the 'this' parameter of a method.

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=258042&r1=258041&r2=258042&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Mon Jan 18 05:20:09 2016
@@ -174,6 +174,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(fieldDecl);
   REGISTER_MATCHER(floatLiteral);
   REGISTER_MATCHER(forEach);
+  REGISTER_MATCHER(forEachArgumentWithParam);
   REGISTER_MATCHER(forEachConstructorInitializer);
   REGISTER_MATCHER(forEachDescendant);
   REGISTER_MATCHER(forEachSwitchCase);

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=258042&r1=258041&r2=258042&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Mon Jan 18 05:20:09 2016
@@ -1608,6 +1608,91 @@ TEST(Matcher, AnyArgument) {
   EXPECT_TRUE(notMatches("void x(int, int) { x(1, 2); }", CallArgumentY));
 }
 
+TEST(ForEachArgumentWithParam, ReportsNoFalsePositives) {
+  StatementMatcher ArgumentY =
+  declRefExpr(to(varDecl(hasName("y".bind("arg");
+  DeclarationMatcher IntParam = 
parmVarDecl(hasType(isInteger())).bind("param");
+  StatementMatcher CallExpr =
+  callExpr(forEachArgumentWithParam(ArgumentY, IntParam));
+
+  // IntParam does not match.
+  EXPECT_FALSE(matches("void f(int* i) { int* y; f(y); }", CallExpr));
+  // ArgumentY does not match.
+  EXPECT_FALSE(matches("void f(int i) { int 

Re: [PATCH] D16270: [clang-tidy] Python scripts shebang fixes

2016-01-18 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG. Thanks! Do you need me to submit the patch?


http://reviews.llvm.org/D16270



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


Re: [PATCH] D16179: [clang-tidy] Handle decayed types and other improvements in VirtualNearMiss check.

2016-01-18 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:240
@@ -247,2 +239,3 @@
 unsigned EditDistance =
-BaseMD->getName().edit_distance(DerivedMD->getName());
+StringRef(BaseMD->getNameAsString())
+.edit_distance(DerivedMD->getNameAsString());

xazax.hun wrote:
> alexfh wrote:
> > xazax.hun wrote:
> > > congliu wrote:
> > > > NamedDecl::getName() directly returns a StringRef. Why using 
> > > > "getNameAsString()"? 
> > > Unfortunately getName will cause an assertion fail for methods that has a 
> > > non-identifier name, such as destructors and overloaded operators.
> > Should we maybe exclude operators and destructors from this check? A typo 
> > in destructor name won't compile. Do you have an example of a case where 
> > the check could be useful in detecting a typo in the name of an overloaded 
> > operator?
> > 
> > It would be nice to avoid using the (more expensive) `getNameAsString` 
> > here. 
> Destructors can not be mispelled. Overloaded operators however might be 
> virtual, and the user might forget the qualifier and miss the override. 
> Although that might be a very rare case. Do you think it is worth to exclude 
> that case for performance? Operators might be problematic anyways, the edit 
> distance tend to be low there. 
I'd leave operators alone until we find a realistic example where this check is 
able to detect a problem.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:240
@@ -247,2 +239,3 @@
 unsigned EditDistance =
-BaseMD->getName().edit_distance(DerivedMD->getName());
+StringRef(BaseMD->getNameAsString())
+.edit_distance(DerivedMD->getNameAsString());

alexfh wrote:
> xazax.hun wrote:
> > alexfh wrote:
> > > xazax.hun wrote:
> > > > congliu wrote:
> > > > > NamedDecl::getName() directly returns a StringRef. Why using 
> > > > > "getNameAsString()"? 
> > > > Unfortunately getName will cause an assertion fail for methods that has 
> > > > a non-identifier name, such as destructors and overloaded operators.
> > > Should we maybe exclude operators and destructors from this check? A typo 
> > > in destructor name won't compile. Do you have an example of a case where 
> > > the check could be useful in detecting a typo in the name of an 
> > > overloaded operator?
> > > 
> > > It would be nice to avoid using the (more expensive) `getNameAsString` 
> > > here. 
> > Destructors can not be mispelled. Overloaded operators however might be 
> > virtual, and the user might forget the qualifier and miss the override. 
> > Although that might be a very rare case. Do you think it is worth to 
> > exclude that case for performance? Operators might be problematic anyways, 
> > the edit distance tend to be low there. 
> I'd leave operators alone until we find a realistic example where this check 
> is able to detect a problem.
I'd leave operators alone until we find a realistic example where this check is 
able to detect a problem.


http://reviews.llvm.org/D16179



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


[PATCH] Happy new year 2016 !

2016-01-18 Thread Prayag Verma via cfe-commits
Hi

This updates the copyright year in LICENSE.TXT

Attached the DIFF file with this message
Index: LICENSE.TXT
===
--- LICENSE.TXT (revision 258045)
+++ LICENSE.TXT (working copy)
@@ -4,7 +4,7 @@
 University of Illinois/NCSA
 Open Source License
 
-Copyright (c) 2007-2015 University of Illinois at Urbana-Champaign.
+Copyright (c) 2007-2016 University of Illinois at Urbana-Champaign.
 All rights reserved.
 
 Developed by:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16040: [OpenCL] Refine OpenCLImageAccessAttr to OpenCLAccessAttr

2016-01-18 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

I think some tests for new diagnostics are still missing?



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7676
@@ +7675,3 @@
+def err_opencl_invalid_read_write : Error<
+  "access qualifier read_write can not be used for %0 %select{|before 
CL2.0}1">;
+def err_opencl_multiple_access_qualifiers : Error<

before CL2.0 -> earlier than OpenCL2.0 versions


Comment at: lib/Sema/SemaDeclAttr.cpp:4922
@@ +4921,3 @@
+
+  // OpenCL v2.0 s6.6: read_write can be used for image type The __read_write
+  // (or read_write)qualifier must be used with image object arguments of

could we write it shorter somehow:

read_write can be used for image types to specify that an image object can be 
read and written.


Comment at: lib/Sema/SemaDeclAttr.cpp:5692
@@ +5691,3 @@
+// attr pipe int p;
+// which will process attr for twice, but we do not need to process that 
for
+// twice, so skip this process if it is pipe type

Ah, you mean the attr was already process with element type?

I don't think this comment is clear still.

Could you write something like:
Skip if pipe type as already being processes with an element type.


Comment at: lib/Sema/SemaDeclAttr.cpp:5696
@@ +5695,3 @@
+  if (PDecl->getType().getCanonicalType().getTypePtr()->isPipeType())
+break;
+}

Could you also avoid using break. I think it should be quite easy here.


Comment at: test/SemaOpenCL/invalid-kernel-attrs.cl:31-32
@@ -30,4 +30,4 @@
   int __kernel x; // expected-error {{'__kernel' attribute only applies to 
functions}}
-  read_only int i; // expected-error {{'read_only' attribute only applies to 
parameters}}
-  __write_only int j; // expected-error {{'__write_only' attribute only 
applies to parameters}}
+  read_only image1d_t i; // expected-error {{'read_only' attribute only 
applies to parameters}}
+  __write_only image2d_t j; // expected-error {{'__write_only' attribute only 
applies to parameters}}
 }

LG!


http://reviews.llvm.org/D16040



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


RE: r257827 - [CMake] Set SVN_REVISION if CLANG_APPEND_VC_REV=On

2016-01-18 Thread Daniel Sanders via cfe-commits
Thanks, that did the trick. I've removed the workaround from LLVMLinux.

> -Original Message-
> From: cbiene...@apple.com [mailto:cbiene...@apple.com] On Behalf Of
> Chris Bieneman
> Sent: 15 January 2016 17:55
> To: Daniel Sanders
> Cc: cfe-commits@lists.llvm.org
> Subject: Re: r257827 - [CMake] Set SVN_REVISION if
> CLANG_APPEND_VC_REV=On
> 
> Thanks for the heads up. It looks like that module is was excluded from the
> LLVM install. I’ve changed that in LLVM r257909. That change should resolve
> your build issue. Please let me know if you continue having problems.
> 
> Thanks,
> -Chris
> 
> > On Jan 15, 2016, at 5:18 AM, Daniel Sanders 
> wrote:
> >
> > Hi Chris,
> >
> > This doesn't seem to work when building clang separately from llvm.
> LLVMLinux fails to build clang with:
> > CMake Error at CMakeLists.txt:104 (include):
> >   include could not find load file:
> >
> > VersionFromVCS
> >
> > CMake Error at CMakeLists.txt:222 (add_version_info_from_vcs):
> >   Unknown CMake command "add_version_info_from_vcs".
> > See
> http://buildbot.llvm.linuxfoundation.org/builders/13_malta/builds/383/step
> s/shell_3/logs/stdio for the full log.
> >
> > I've added a patch to llvmlinux to work around the problem for now
> http://git.linuxfoundation.org/?p=llvmlinux.git;a=blob;f=toolchain/clang/pat
> ches/clang/workaround-
> versionfromvcsbug.patch;h=848a096df37b1255575650680a266234f5d4936e;h
> b=e0c4c72c5a008006dc230db748ea69e0d1518daf.
> > Should we make that change to clang or fix it another way?
> >
> >> -Original Message-
> >> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On
> Behalf
> >> Of Chris Bieneman via cfe-commits
> >> Sent: 14 January 2016 22:45
> >> To: cfe-commits@lists.llvm.org
> >> Subject: r257827 - [CMake] Set SVN_REVISION if
> >> CLANG_APPEND_VC_REV=On
> >>
> >> Author: cbieneman
> >> Date: Thu Jan 14 16:45:12 2016
> >> New Revision: 257827
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=257827&view=rev
> >> Log:
> >> [CMake] Set SVN_REVISION if CLANG_APPEND_VC_REV=On
> >>
> >> This matches autoconf's ability to put clang revisions in the clang 
> >> --version
> >> spew.
> >>
> >> Modified:
> >>cfe/trunk/CMakeLists.txt
> >>
> >> Modified: cfe/trunk/CMakeLists.txt
> >> URL: http://llvm.org/viewvc/llvm-
> >>
> project/cfe/trunk/CMakeLists.txt?rev=257827&r1=257826&r2=257827&view
> >> =diff
> >>
> ==
> >> 
> >> --- cfe/trunk/CMakeLists.txt (original)
> >> +++ cfe/trunk/CMakeLists.txt Thu Jan 14 16:45:12 2016
> >> @@ -101,6 +101,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
> >>   include(AddLLVM)
> >>   include(TableGen)
> >>   include(HandleLLVMOptions)
> >> +  include(VersionFromVCS)
> >>
> >>   set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
> >>
> >> @@ -213,6 +214,18 @@ if(CLANG_REPOSITORY_STRING)
> >>   add_definitions(-
> >> DCLANG_REPOSITORY_STRING="${CLANG_REPOSITORY_STRING}")
> >> endif()
> >>
> >> +option(CLANG_APPEND_VC_REV
> >> +  "Append the version control system revision id to clang version spew"
> >> OFF)
> >> +
> >> +if(NOT SVN_REVISION)
> >> +  # This macro will set SVN_REVISION in the parent scope
> >> +  add_version_info_from_vcs(VERSION_VAR)
> >> +endif()
> >> +
> >> +if(SVN_REVISION)
> >> +  add_definitions(-DSVN_REVISION="${SVN_REVISION}")
> >> +endif()
> >> +
> >> set(CLANG_VENDOR_UTI "org.llvm.clang" CACHE STRING
> >>   "Vendor-specific uti.")
> >>
> >>
> >>
> >> ___
> >> 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] D16047: [OpenCL] Add Sema checks for OpenCL 2.0

2016-01-18 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:7255
@@ -7209,3 +7254,3 @@
   return PtrPtrKernelParam;
-return PointeeType.getAddressSpace() == 0 ? PrivatePtrKernelParam
-  : PtrKernelParam;
+// Now generice address space is added, we need to handle like this
+unsigned addrSpace = PointeeType.getAddressSpace();

I think this should be removed?


Comment at: lib/Sema/SemaDecl.cpp:7279
@@ -7228,1 +7278,3 @@
 
+  if (PT->isReserveIDT())
+return InvalidKernelParam;

Is there a test for this?


http://reviews.llvm.org/D16047



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


Re: [PATCH] D15914: [OpenCL] Pipe builtin functions

2016-01-18 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

A few nitpicks here, otherwise it seems we are in a good shape. I hope this 
will hit trunk soon. :)



Comment at: lib/CodeGen/CGBuiltin.cpp:1966
@@ -1965,1 +1965,3 @@
   }
+
+  case Builtin::BIread_pipe:

Can you put a comment with the spec reference here.


Comment at: lib/CodeGen/CGBuiltin.cpp:1974
@@ +1973,3 @@
+// Type of the generic packet parameter.
+llvm::Type *I8PTy = llvm::PointerType::get(llvm::Type::getInt8Ty(Ctxt), 
4U);
+

Please, avoid hard coded constants.

You can use getTargetAddressSpace() method of ASTContext to obtain a generic AS 
number, something like:
unsigned GenericAS = 
getContext().getTargetAddressSpace(LangAS::opencl_generic);
llvm::Type Int8Ty = ...(..., GenericAS);


Comment at: lib/CodeGen/CGBuiltin.cpp:1978
@@ +1977,3 @@
+if (2U == E->getNumArgs()) {
+  // The name is hard-coded for now, since we would like to avoid the
+  // AST rewrite for the infinite user define types.

I don't think this comment is any relevant and can be removed!


Comment at: lib/CodeGen/CGBuiltin.cpp:1983
@@ +1982,3 @@
+  // Re-Creating the function type for this call, since the original type
+  // is variadic, we make them to be generic type.
+  llvm::Type *ArgTys[] = {Arg0->getType(), I8PTy};

the type is not really variadic! May be better to say:

"Creating a generic function type to be able to call with any builtin or user 
defined type."


Comment at: lib/Sema/SemaChecking.cpp:286
@@ +285,3 @@
+  getOpenCLArgAccess(cast(Arg0)->getDecl());
+  // Validates the access modifier is compatible with the call.
+  // From OpenCL C Specification 6.13.16 the access qualifiers for

modifier -> qualifier


Comment at: lib/Sema/SemaChecking.cpp:394
@@ +393,3 @@
+
+  // check the reverse size
+  if (!Call->getArg(1)->getType()->isIntegerType() &&

reverse -> reserve


Comment at: lib/Sema/SemaChecking.cpp:434
@@ +433,3 @@
+// \return True if a semantic error was found, false otherwise.
+static bool SemaBuiltinPipePacketes(Sema &S, CallExpr *Call) {
+  if (checkArgCount(S, Call, 1))

Packetes -> Packets


Comment at: lib/Sema/SemaChecking.cpp:754
@@ +753,3 @@
+  case Builtin::BIwrite_pipe:
+// Since those two functions are declared with var args, therefore we need
+// a semantic check for the argument.

remove "therefore"


Comment at: lib/Sema/SemaChecking.cpp:768
@@ +767,3 @@
+// Since return type of reserve_read/write_pipe built-in function is
+// reserve_id_t, which is not defined in the builtin def, we used int as
+// return type and need to override the return type of these functions

builtin def -> builtin def file


http://reviews.llvm.org/D15914



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


[PATCH] D16295: Change of UserLabelPrefix default value from "_" to ""

2016-01-18 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added reviewers: rafael, rjmccall.
andreybokhanko added subscribers: cfe-commits, rafael.

@rafael proposed (http://reviews.llvm.org/D16138#325739) to change 
UserLablePrefix's default from "_" to "", as latter value happens much more 
often. This patch implements the proposal.

Yours,
Andrey Bokhanko
===
Software Engineer
Intel Compiler Team
Intel

http://reviews.llvm.org/D16295

Files:
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets.cpp

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -102,9 +102,7 @@
 
 public:
   CloudABITargetInfo(const llvm::Triple &Triple)
-  : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-  }
+  : OSTargetInfo(Triple) {}
 };
 
 static void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
@@ -242,6 +240,7 @@
   this->TLSSupported = !Triple.isOSVersionLT(2);
 
 this->MCountName = "\01mcount";
+this->UserLabelPrefix = "_";
   }
 
   std::string isValidSectionSpecifier(StringRef SR) const override {
@@ -284,8 +283,6 @@
 public:
   DragonFlyBSDTargetInfo(const llvm::Triple &Triple)
   : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-
 switch (Triple.getArch()) {
 default:
 case llvm::Triple::x86:
@@ -327,8 +324,6 @@
   }
 public:
   FreeBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-
 switch (Triple.getArch()) {
 default:
 case llvm::Triple::x86:
@@ -368,9 +363,7 @@
   }
 public:
   KFreeBSDTargetInfo(const llvm::Triple &Triple)
-  : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-  }
+  : OSTargetInfo(Triple) {}
 };
 
 // Minix Target
@@ -392,9 +385,7 @@
 DefineStd(Builder, "unix", Opts);
   }
 public:
-  MinixTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-  }
+  MinixTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {}
 };
 
 // Linux target
@@ -467,7 +458,6 @@
   }
 public:
   NetBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->MCountName = "_mcount";
   }
 };
@@ -488,7 +478,6 @@
   }
 public:
   OpenBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->TLSSupported = false;
 
   switch (Triple.getArch()) {
@@ -536,7 +525,6 @@
   }
 public:
   BitrigTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->MCountName = "__mcount";
   }
 };
@@ -554,9 +542,7 @@
 Builder.defineMacro("__ELF__");
   }
 public:
-  PSPTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-  }
+  PSPTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {}
 };
 
 // PS3 PPU Target
@@ -576,7 +562,6 @@
   }
 public:
   PS3PPUTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->LongWidth = this->LongAlign = 32;
 this->PointerWidth = this->PointerAlign = 32;
 this->IntMaxType = TargetInfo::SignedLongLong;
@@ -604,7 +589,6 @@
 
 // On PS4, TLS variable cannot be aligned to more than 32 bytes (256 bits).
 this->MaxTLSAlign = 256;
-this->UserLabelPrefix = "";
 
 switch (Triple.getArch()) {
 default:
@@ -724,7 +708,6 @@
 
 public:
   NaClTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->LongAlign = 32;
 this->LongWidth = 32;
 this->PointerAlign = 32;
@@ -778,7 +761,6 @@
   explicit WebAssemblyOSTargetInfo(const llvm::Triple &Triple)
   : OSTargetInfo(Triple) {
 this->MCountName = "__mcount";
-this->UserLabelPrefix = "";
 this->TheCXXABI.set(TargetCXXABI::WebAssembly);
   }
 };
@@ -816,6 +798,7 @@
 SimdDefaultAlign = 128;
 LongDoubleWidth = LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble;
+UserLabelPrefix = "_";
   }
 
   /// \brief Flags for architecture specific defines.
@@ -1631,6 +1614,7 @@
 NoAsmVariants = true;
 // Set the default GPU to sm20
 GPU = GK_SM20;
+UserLabelPrefix = "_";
   }
   void getTargetDefines(const LangOptions &Opts,
 MacroBuilder &Builder) const override {
@@ -3671,6 +3655,8 @@
 // FIXME: Check that we actually have cmpxchg8b before setting
 // MaxAtomicInlineWidth. (cmpxchg8b is an i586 instruction.)
 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
+
+UserLabelPrefix = "_";
   }
   BuiltinVaListKind getBuiltinVaListKind() const override {
 return TargetInfo::CharPtrBuiltinVaList;
@@ -3882,7 +3868,6 @@
 IntPtrType = SignedLong;
 PtrDiffType = SignedLong;
 ProcessIDType = SignedLong;
-this->UserLabelPrefix = "";
 this->TLSSupported = false;
   }
   void getTargetDefines(const LangOptions &Opts,
@@ -3929,8

Re: [PATCH] D16262: [libc++] Treat trailing backslashes in a regex pattern as invalid.

2016-01-18 Thread Marshall Clow via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

This looks good to me.  A quick search for `\\` in regex didn't find any other 
obvious instances of this anti-pattern.  For the record, the bug is 
https://llvm.org/bugs/show_bug.cgi?id=26175

Can you commit this yourself, or would you rather I did it?


http://reviews.llvm.org/D16262



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


Re: [PATCH] D16295: Change of UserLabelPrefix default value from "_" to ""

2016-01-18 Thread Rafael Ávila de Espíndola via cfe-commits
rafael added a comment.

Thanks for working on this, but many of the changes setting the prefix to "_" 
look wrong.



Comment at: lib/Basic/Targets.cpp:801
@@ -818,2 +800,3 @@
 LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble;
+UserLabelPrefix = "_";
   }

This looks wrong, we produce a "f:" not an "_f:" when targeting 
powerpc-linux-gnu.



Comment at: lib/Basic/Targets.cpp:1617
@@ -1633,2 +1616,3 @@
 GPU = GK_SM20;
+UserLabelPrefix = "_";
   }

This also looks wrong.


Comment at: lib/Basic/Targets.cpp:3659
@@ -3674,1 +3658,3 @@
+
+UserLabelPrefix = "_";
   }

This looks wrong.


Comment at: lib/Basic/Targets.cpp:3991
@@ -4008,1 +3990,3 @@
+
+UserLabelPrefix = "_";
   }

This looks wrong.


Comment at: lib/Basic/Targets.cpp:4530
@@ -4546,1 +4529,3 @@
+
+UserLabelPrefix = "_";
   }

This looks wrong.


Comment at: lib/Basic/Targets.cpp:5308
@@ -5323,1 +5307,3 @@
+
+UserLabelPrefix = "_";
   }

This looks wrong.


Comment at: lib/Basic/Targets.cpp:5834
@@ +5833,3 @@
+  : TargetInfo(Triple), SoftFloat(false) {
+UserLabelPrefix = "_";
+  }

This looks wrong.


Comment at: lib/Basic/Targets.cpp:6136
@@ -6147,2 +6135,3 @@
 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
+UserLabelPrefix = "_";
   }

This looks wrong.


Comment at: lib/Basic/Targets.cpp:6296
@@ -6306,2 +6295,3 @@
 DataLayoutString = "e-m:e-p:16:16-i32:16:32-a:16-n8:16";
+UserLabelPrefix = "_";
   }

This looks wrong.


Comment at: lib/Basic/Targets.cpp:6393
@@ -6402,2 +6392,3 @@
 UseAddrSpaceMapMangling = true;
+UserLabelPrefix = "_";
   }

This looks wrong.


Comment at: lib/Basic/Targets.cpp:6496
@@ -6504,2 +6495,3 @@
 TheCXXABI.set(TargetCXXABI::GenericMIPS);
+UserLabelPrefix = "_";
   }

This looks wrong.


http://reviews.llvm.org/D16295



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


Re: [PATCH] D16007: [libcxxabi] Make test tolerant of uncommon floating literal demanglings

2016-01-18 Thread Ben Craig via cfe-commits
bcraig added a reviewer: mclow.lists.
bcraig added a comment.

ping


http://reviews.llvm.org/D16007



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


Re: [PATCH] D16006: [libcxxabi] Teach cxa_demangle about Hexagon's long double size

2016-01-18 Thread Ben Craig via cfe-commits
bcraig added a reviewer: mclow.lists.
bcraig added a comment.

ping


http://reviews.llvm.org/D16006



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


Re: [PATCH] D15539: [libcxxabi] Reducing stack usage of test

2016-01-18 Thread Ben Craig via cfe-commits
bcraig added a comment.

ping


http://reviews.llvm.org/D15539



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


Re: [PATCH] D16179: [clang-tidy] Handle decayed types and other improvements in VirtualNearMiss check.

2016-01-18 Thread Richard via cfe-commits
LegalizeAdulthood added a subscriber: LegalizeAdulthood.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:54-55
@@ -53,16 +53,4 @@
 
   // Both types must be pointers or references to classes.
-  if (const auto *DerivedPT = DerivedReturnTy->getAs()) {
-if (const auto *BasePT = BaseReturnTy->getAs()) {
-  DTy = DerivedPT->getPointeeType();
-  BTy = BasePT->getPointeeType();
-}
-  } else if (const auto *DerivedRT = DerivedReturnTy->getAs()) {
-if (const auto *BaseRT = BaseReturnTy->getAs()) {
-  DTy = DerivedRT->getPointeeType();
-  BTy = BaseRT->getPointeeType();
-}
-  }
-
-  // The return types aren't either both pointers or references to a class 
type.
-  if (DTy.isNull())
+  if ((!BaseReturnTy->isPointerType() || !DerivedReturnTy->isPointerType()) &&
+  (!BaseReturnTy->isReferenceType() || 
!DerivedReturnTy->isReferenceType()))

alexfh wrote:
> It takes a non-trivial effort to understand the equivalence of the comment 
> and the condition. I think, pulling the negations one level up would make the 
> condition read easier:
> ```
> if (!(BaseReturnTy->isPointerType() && DerivedReturnTy->isPointerType()) &&
> !(BaseReturnTy->isReferenceType() && DerivedReturnTy->isReferenceType()))
>   return;
> ```
> 
> Also, please move the definitions of the variables `BTy`, `DTy`, `BRD`, `DRD` 
> after this `if` and merge them with their initialization. 
IMO, it would be even better would be to extract a predicate function with an 
intention-revealing name.


http://reviews.llvm.org/D16179



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


Re: [PATCH] D16183: Added CheckName field to YAML report

2016-01-18 Thread Ilia Gromov via cfe-commits
Elijah_Th marked 2 inline comments as done.
Elijah_Th added a comment.

What kind of wrapper should it be?
I was thinking of this kind:

  class ExtendedReplacement : public Replacement {
  public:
ExtendedReplacement(StringRef CheckName, Replacement &R);
  
StringRef getCheckName() const { return CheckName; }
std::string CheckName;
  }

but in this case (Replacement.h:141)

  typedef std::set Replacements;

should be changed to

  typedef std::set Replacements;

which means a lot of code will be changed.

Is that an acceptable change? Or you meant another kind of wrapper?


http://reviews.llvm.org/D16183



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


[PATCH] D16262: [libc++] Treat trailing backslashes in a regex pattern as invalid.

2016-01-18 Thread Josh Petrie via cfe-commits
jpetrie created this revision.
jpetrie added a reviewer: mclow.lists.
jpetrie added a subscriber: cfe-commits.

std::regex should throw std::regex_error if constructed with a pattern ending 
in a trailing backslash, since a trailing backlash is not a valid escape 
sequence.

http://reviews.llvm.org/D16262

Files:
  include/regex
  test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp

Index: test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
===
--- test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
+++ test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
@@ -33,6 +33,7 @@
 {
 assert(error_escape_thrown("[\\a]"));
 assert(error_escape_thrown("\\a"));
+assert(error_escape_thrown("\\"));
 
 assert(error_escape_thrown("[\\e]"));
 assert(error_escape_thrown("\\e"));
Index: include/regex
===
--- include/regex
+++ include/regex
@@ -4265,6 +4265,9 @@
 if (__first != __last && *__first == '\\')
 {
 _ForwardIterator __t1 = _VSTD::next(__first);
+if (__t1 == __last)
+__throw_regex_error();
+
 _ForwardIterator __t2 = __parse_decimal_escape(__t1, __last);
 if (__t2 != __t1)
 __first = __t2;


Index: test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
===
--- test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
+++ test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
@@ -33,6 +33,7 @@
 {
 assert(error_escape_thrown("[\\a]"));
 assert(error_escape_thrown("\\a"));
+assert(error_escape_thrown("\\"));
 
 assert(error_escape_thrown("[\\e]"));
 assert(error_escape_thrown("\\e"));
Index: include/regex
===
--- include/regex
+++ include/regex
@@ -4265,6 +4265,9 @@
 if (__first != __last && *__first == '\\')
 {
 _ForwardIterator __t1 = _VSTD::next(__first);
+if (__t1 == __last)
+__throw_regex_error();
+
 _ForwardIterator __t2 = __parse_decimal_escape(__t1, __last);
 if (__t2 != __t1)
 __first = __t2;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16270: [clang-tidy] Python scripts shebang fixes

2016-01-18 Thread Kirill Bobyrev via cfe-commits
omtcyf0 created this revision.
omtcyf0 added reviewers: klimek, alexfh.
omtcyf0 added a subscriber: cfe-commits.

This patch fixes shebang lines in Python script files.

Most Python scripts in LLVM & Clang are using this shebang line.

[[ https://mail.python.org/pipermail/tutor/2007-June/054816.html | Here]] is an 
explanaiton of why such line should be used instead of what is currently in 
these few files.

http://reviews.llvm.org/D16270

Files:
  clang-tidy/tool/clang-tidy-diff.py
  docs/clang-tidy/tools/dump_check_docs.py
  test/clang-tidy/check_clang_tidy.py

Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 #
 #===- check_clang_tidy.py - ClangTidy Test Helper *- python 
-*--===#
 #
Index: docs/clang-tidy/tools/dump_check_docs.py
===
--- docs/clang-tidy/tools/dump_check_docs.py
+++ docs/clang-tidy/tools/dump_check_docs.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 
 r"""
 Create stubs for check documentation files.
Index: clang-tidy/tool/clang-tidy-diff.py
===
--- clang-tidy/tool/clang-tidy-diff.py
+++ clang-tidy/tool/clang-tidy-diff.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 #
 #===- clang-tidy-diff.py - ClangTidy Diff Checker *- python 
-*--===#
 #


Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 #
 #===- check_clang_tidy.py - ClangTidy Test Helper *- python -*--===#
 #
Index: docs/clang-tidy/tools/dump_check_docs.py
===
--- docs/clang-tidy/tools/dump_check_docs.py
+++ docs/clang-tidy/tools/dump_check_docs.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 
 r"""
 Create stubs for check documentation files.
Index: clang-tidy/tool/clang-tidy-diff.py
===
--- clang-tidy/tool/clang-tidy-diff.py
+++ clang-tidy/tool/clang-tidy-diff.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 #
 #===- clang-tidy-diff.py - ClangTidy Diff Checker *- python -*--===#
 #
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15883: Add ARM EHABI-related constants to unwind.h.

2016-01-18 Thread Timon Van Overveldt via cfe-commits
timonvo added a comment.

Logan, how should we proceed here? Can you approve the patch?

I also have no committer rights to the project, so does that mean you (or 
someone else) need to commit it on my behalf?


http://reviews.llvm.org/D15883



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


[PATCH][Modules][PR26179]

2016-01-18 Thread Vassil Vassilev via cfe-commits

Hi,
  Could somebody review the attached patch. It fixes 
https://llvm.org/bugs/show_bug.cgi?id=26179

Many thanks!
Vassil

From 947a163ab4e13c44625085dd51faa656b72de3ac Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Sat, 16 Jan 2016 23:52:40 +0100
Subject: [PATCH] [modules] Teach clang to how to merge variable redecls with
 different types.

We can get decls with different types on the redecl chain. Eg.
template  struct S {
  static T Var[]; // #1
};
template  T S::Var[sizeof(T)]; // #2
Trying to compare #1 and #2 should go through their canonical decls.

Fixes https://llvm.org/bugs/show_bug.cgi?id=26179
---
 lib/Serialization/ASTReaderDecl.cpp  | 17 +++--
 test/Modules/Inputs/PR26179/A.h  |  2 ++
 test/Modules/Inputs/PR26179/B.h  |  1 +
 test/Modules/Inputs/PR26179/basic_string.h   | 12 
 test/Modules/Inputs/PR26179/module.modulemap |  9 +
 test/Modules/pr26179.cpp |  7 +++
 6 files changed, 46 insertions(+), 2 deletions(-)
 create mode 100644 test/Modules/Inputs/PR26179/A.h
 create mode 100644 test/Modules/Inputs/PR26179/B.h
 create mode 100644 test/Modules/Inputs/PR26179/basic_string.h
 create mode 100644 test/Modules/Inputs/PR26179/module.modulemap
 create mode 100644 test/Modules/pr26179.cpp

diff --git a/lib/Serialization/ASTReaderDecl.cpp 
b/lib/Serialization/ASTReaderDecl.cpp
index 5bf95f8..b68b7fe 100644
--- a/lib/Serialization/ASTReaderDecl.cpp
+++ b/lib/Serialization/ASTReaderDecl.cpp
@@ -2595,8 +2595,21 @@ static bool isSameEntity(NamedDecl *X, NamedDecl *Y) {
   // Variables with the same type and linkage match.
   if (VarDecl *VarX = dyn_cast(X)) {
 VarDecl *VarY = cast(Y);
-return (VarX->getLinkageInternal() == VarY->getLinkageInternal()) &&
-  VarX->getASTContext().hasSameType(VarX->getType(), VarY->getType());
+if (VarX->getLinkageInternal() == VarY->getLinkageInternal()) {
+  ASTContext &Context = VarX->getASTContext();
+  if (Context.hasSameType(VarX->getType(), VarY->getType()))
+return true;
+
+  // We can get decls with different types on the redecl chain. Eg.
+  // template  struct S { static T Var[]; }; // #1
+  // template  T S::Var[sizeof(T)]; // #2
+  // Trying to compare #1 and #2 should go through their canonical decls.
+  QualType VarXTy = VarX->getCanonicalDecl()->getType();
+  QualType VarYTy = VarY->getCanonicalDecl()->getType();
+  if (Context.hasSameType(VarXTy, VarYTy))
+return true;
+}
+return false;
   }
 
   // Namespaces with the same name and inlinedness match.
diff --git a/test/Modules/Inputs/PR26179/A.h b/test/Modules/Inputs/PR26179/A.h
new file mode 100644
index 000..c264f4c
--- /dev/null
+++ b/test/Modules/Inputs/PR26179/A.h
@@ -0,0 +1,2 @@
+#include "basic_string.h"
+#include "B.h"
diff --git a/test/Modules/Inputs/PR26179/B.h b/test/Modules/Inputs/PR26179/B.h
new file mode 100644
index 000..46a109e
--- /dev/null
+++ b/test/Modules/Inputs/PR26179/B.h
@@ -0,0 +1 @@
+#include "basic_string.h"
diff --git a/test/Modules/Inputs/PR26179/basic_string.h 
b/test/Modules/Inputs/PR26179/basic_string.h
new file mode 100644
index 000..653ce07
--- /dev/null
+++ b/test/Modules/Inputs/PR26179/basic_string.h
@@ -0,0 +1,12 @@
+#ifndef _GLIBCXX_STRING
+#define _GLIBCXX_STRING 1
+
+template
+struct basic_string {
+  static T _S_empty_rep_storage[];
+};
+
+template
+T basic_string::_S_empty_rep_storage[sizeof(T)];
+
+#endif
diff --git a/test/Modules/Inputs/PR26179/module.modulemap 
b/test/Modules/Inputs/PR26179/module.modulemap
new file mode 100644
index 000..4937418
--- /dev/null
+++ b/test/Modules/Inputs/PR26179/module.modulemap
@@ -0,0 +1,9 @@
+module A {
+  header "A.h"
+  export *
+}
+
+module B {
+  header "B.h"
+  export *
+}
diff --git a/test/Modules/pr26179.cpp b/test/Modules/pr26179.cpp
new file mode 100644
index 000..f25f1ce
--- /dev/null
+++ b/test/Modules/pr26179.cpp
@@ -0,0 +1,7 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -I%S/Inputs/PR26179 -verify %s
+// RUN: %clang_cc1 -fmodules 
-fmodule-map-file=%S/Inputs/PR26179/module.modulemap -fmodules-cache-path=%t 
-I%S/Inputs/PR26179 -verify %s
+
+#include "A.h"
+
+// expected-no-diagnostics
-- 
2.3.8 (Apple Git-58)

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


Re: [PATCH] D16270: [clang-tidy] Python scripts shebang fixes

2016-01-18 Thread Kirill Bobyrev via cfe-commits
omtcyf0 added a comment.

@alexfh, yes, please!

That'll be very nice.


http://reviews.llvm.org/D16270



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


Re: [PATCH] D15373: Fix for bug 25786 - Assertion "Chunk.Kind == DeclaratorChunk::Function" failed with regparm attribute.

2016-01-18 Thread Alexander Makarov via cfe-commits
a.makarov updated this revision to Diff 45179.
a.makarov added a comment.

Oops, forgot to drop svn properties. Done. Sorry for noise.


http://reviews.llvm.org/D15373

Files:
  lib/Sema/SemaType.cpp
  test/CodeGen/pr25786.c
  test/Sema/pr25786.c

Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -5369,6 +5369,7 @@
   struct FunctionTypeUnwrapper {
 enum WrapKind {
   Desugar,
+  Attributed,
   Parens,
   Pointer,
   BlockPointer,
@@ -5401,6 +5402,9 @@
 } else if (isa(Ty)) {
   T = cast(Ty)->getPointeeType();
   Stack.push_back(Reference);
+} else if (isa(Ty)) {
+  T = cast(Ty)->getEquivalentType();
+  Stack.push_back(Attributed);
 } else {
   const Type *DTy = Ty->getUnqualifiedDesugaredType();
   if (Ty == DTy) {
@@ -5449,6 +5453,9 @@
 // information.
 return wrap(C, Old->getUnqualifiedDesugaredType(), I);
 
+  case Attributed:
+return wrap(C, cast(Old)->getEquivalentType(), I);
+
   case Parens: {
 QualType New = wrap(C, cast(Old)->getInnerType(), I);
 return C.getParenType(New);
Index: test/CodeGen/pr25786.c
===
--- test/CodeGen/pr25786.c
+++ test/CodeGen/pr25786.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -triple i686-unknown-linux-gnu -emit-llvm -o - %s | 
FileCheck %s --check-prefix=CHECK-OK
+
+void (__attribute__((regparm(3), stdcall)) *pf) ();
+void (__attribute__((regparm(2), stdcall)) foo)(int a) {
+}
+// CHECK: @pf = common global void (...)* null
+// CHECK: define void @foo(i32 %a)
+
+// CHECK-OK: @pf = common global void (...)* null
+// CHECK-OK: define x86_stdcallcc void @foo(i32 inreg %a)
Index: test/Sema/pr25786.c
===
--- test/Sema/pr25786.c
+++ test/Sema/pr25786.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -DTEST -fsyntax-only 
-verify %s
+// RUN: %clang_cc1 -triple i686-unknown-linux-gnu -fsyntax-only -verify %s
+
+#if TEST
+void (__attribute__((regparm(3), stdcall)) *pf) (); //expected-warning 
{{calling convention 'stdcall' ignored for this target}}
+void (__attribute__((regparm(2), stdcall)) foo)(int a) { //expected-warning 
{{calling convention 'stdcall' ignored for this target}}
+}
+#else
+//expected-no-diagnostics
+void (__attribute__((regparm(3), stdcall)) *pf) ();
+void (__attribute__((regparm(2), stdcall)) foo)(int a) {}
+#endif


Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -5369,6 +5369,7 @@
   struct FunctionTypeUnwrapper {
 enum WrapKind {
   Desugar,
+  Attributed,
   Parens,
   Pointer,
   BlockPointer,
@@ -5401,6 +5402,9 @@
 } else if (isa(Ty)) {
   T = cast(Ty)->getPointeeType();
   Stack.push_back(Reference);
+} else if (isa(Ty)) {
+  T = cast(Ty)->getEquivalentType();
+  Stack.push_back(Attributed);
 } else {
   const Type *DTy = Ty->getUnqualifiedDesugaredType();
   if (Ty == DTy) {
@@ -5449,6 +5453,9 @@
 // information.
 return wrap(C, Old->getUnqualifiedDesugaredType(), I);
 
+  case Attributed:
+return wrap(C, cast(Old)->getEquivalentType(), I);
+
   case Parens: {
 QualType New = wrap(C, cast(Old)->getInnerType(), I);
 return C.getParenType(New);
Index: test/CodeGen/pr25786.c
===
--- test/CodeGen/pr25786.c
+++ test/CodeGen/pr25786.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple i686-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-OK
+
+void (__attribute__((regparm(3), stdcall)) *pf) ();
+void (__attribute__((regparm(2), stdcall)) foo)(int a) {
+}
+// CHECK: @pf = common global void (...)* null
+// CHECK: define void @foo(i32 %a)
+
+// CHECK-OK: @pf = common global void (...)* null
+// CHECK-OK: define x86_stdcallcc void @foo(i32 inreg %a)
Index: test/Sema/pr25786.c
===
--- test/Sema/pr25786.c
+++ test/Sema/pr25786.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -DTEST -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i686-unknown-linux-gnu -fsyntax-only -verify %s
+
+#if TEST
+void (__attribute__((regparm(3), stdcall)) *pf) (); //expected-warning {{calling convention 'stdcall' ignored for this target}}
+void (__attribute__((regparm(2), stdcall)) foo)(int a) { //expected-warning {{calling convention 'stdcall' ignored for this target}}
+}
+#else
+//expected-no-diagnostics
+void (__att

r258039 - [analyzer] Fix an off-by-one in evalIntegralCast()

2016-01-18 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Jan 18 04:17:16 2016
New Revision: 258039

URL: http://llvm.org/viewvc/llvm-project?rev=258039&view=rev
Log:
[analyzer] Fix an off-by-one in evalIntegralCast()

Make sure that we do not add SymbolCast at the very boundary of
the range in which the cast would not certainly happen.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
cfe/trunk/test/Analysis/bool-assignment.c

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp?rev=258039&r1=258038&r2=258039&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp Mon Jan 18 04:17:16 2016
@@ -451,7 +451,7 @@ SVal SValBuilder::evalIntegralCast(Progr
   NonLoc FromVal = val.castAs();
   QualType CmpTy = getConditionType();
   NonLoc CompVal =
-  evalBinOpNN(state, BO_LT, FromVal, ToTypeMaxVal, CmpTy).castAs();
+  evalBinOpNN(state, BO_LE, FromVal, ToTypeMaxVal, CmpTy).castAs();
   ProgramStateRef IsNotTruncated, IsTruncated;
   std::tie(IsNotTruncated, IsTruncated) = state->assume(CompVal);
   if (!IsNotTruncated && IsTruncated) {

Modified: cfe/trunk/test/Analysis/bool-assignment.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/bool-assignment.c?rev=258039&r1=258038&r2=258039&view=diff
==
--- cfe/trunk/test/Analysis/bool-assignment.c (original)
+++ cfe/trunk/test/Analysis/bool-assignment.c Mon Jan 18 04:17:16 2016
@@ -42,6 +42,15 @@ void test_BOOL_initialization(int y) {
 BOOL x = y; // expected-warning {{Assignment of a non-Boolean value}}
 return;
   }
+  if (y > 200 && y < 250) {
+// FIXME: Currently we are loosing this warning due to a SymbolCast in RHS.
+BOOL x = y; // no-warning
+return;
+  }
+  if (y >= 127 && y < 150) {
+BOOL x = y; // expected-warning{{Assignment of a non-Boolean value}}
+return;
+  }
   if (y > 1) {
 BOOL x = y; // expected-warning {{Assignment of a non-Boolean value}}
 return;


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


Re: [PATCH] D15373: Fix for bug 25786 - Assertion "Chunk.Kind == DeclaratorChunk::Function" failed with regparm attribute.

2016-01-18 Thread Alexander Makarov via cfe-commits
a.makarov updated this revision to Diff 45178.
a.makarov added a comment.

I've updated the patch. Now, I've updated the function unwrapping mechanism to 
work properly with AttributedType.
Please, re-review the patch.


http://reviews.llvm.org/D15373

Files:
  lib/Sema/SemaType.cpp
  test/CodeGen/pr25786.c
  test/Sema/pr25786.c

Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -5369,6 +5369,7 @@
   struct FunctionTypeUnwrapper {
 enum WrapKind {
   Desugar,
+  Attributed,
   Parens,
   Pointer,
   BlockPointer,
@@ -5401,6 +5402,9 @@
 } else if (isa(Ty)) {
   T = cast(Ty)->getPointeeType();
   Stack.push_back(Reference);
+} else if (isa(Ty)) {
+  T = cast(Ty)->getEquivalentType();
+  Stack.push_back(Attributed);
 } else {
   const Type *DTy = Ty->getUnqualifiedDesugaredType();
   if (Ty == DTy) {
@@ -5449,6 +5453,9 @@
 // information.
 return wrap(C, Old->getUnqualifiedDesugaredType(), I);
 
+  case Attributed:
+return wrap(C, cast(Old)->getEquivalentType(), I);
+
   case Parens: {
 QualType New = wrap(C, cast(Old)->getInnerType(), I);
 return C.getParenType(New);
Index: test/CodeGen/pr25786.c
===
--- test/CodeGen/pr25786.c
+++ test/CodeGen/pr25786.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -triple i686-unknown-linux-gnu -emit-llvm -o - %s | 
FileCheck %s --check-prefix=CHECK-OK
+
+void (__attribute__((regparm(3), stdcall)) *pf) ();
+void (__attribute__((regparm(2), stdcall)) foo)(int a) {
+}
+// CHECK: @pf = common global void (...)* null
+// CHECK: define void @foo(i32 %a)
+
+// CHECK-OK: @pf = common global void (...)* null
+// CHECK-OK: define x86_stdcallcc void @foo(i32 inreg %a)
Index: test/Sema/pr25786.c
===
--- test/Sema/pr25786.c
+++ test/Sema/pr25786.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -DTEST -fsyntax-only 
-verify %s
+// RUN: %clang_cc1 -triple i686-unknown-linux-gnu -fsyntax-only -verify %s
+
+#if TEST
+void (__attribute__((regparm(3), stdcall)) *pf) (); //expected-warning 
{{calling convention 'stdcall' ignored for this target}}
+void (__attribute__((regparm(2), stdcall)) foo)(int a) { //expected-warning 
{{calling convention 'stdcall' ignored for this target}}
+}
+#else
+//expected-no-diagnostics
+void (__attribute__((regparm(3), stdcall)) *pf) ();
+void (__attribute__((regparm(2), stdcall)) foo)(int a) {}
+#endif


Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -5369,6 +5369,7 @@
   struct FunctionTypeUnwrapper {
 enum WrapKind {
   Desugar,
+  Attributed,
   Parens,
   Pointer,
   BlockPointer,
@@ -5401,6 +5402,9 @@
 } else if (isa(Ty)) {
   T = cast(Ty)->getPointeeType();
   Stack.push_back(Reference);
+} else if (isa(Ty)) {
+  T = cast(Ty)->getEquivalentType();
+  Stack.push_back(Attributed);
 } else {
   const Type *DTy = Ty->getUnqualifiedDesugaredType();
   if (Ty == DTy) {
@@ -5449,6 +5453,9 @@
 // information.
 return wrap(C, Old->getUnqualifiedDesugaredType(), I);
 
+  case Attributed:
+return wrap(C, cast(Old)->getEquivalentType(), I);
+
   case Parens: {
 QualType New = wrap(C, cast(Old)->getInnerType(), I);
 return C.getParenType(New);
Index: test/CodeGen/pr25786.c
===
--- test/CodeGen/pr25786.c
+++ test/CodeGen/pr25786.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple i686-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-OK
+
+void (__attribute__((regparm(3), stdcall)) *pf) ();
+void (__attribute__((regparm(2), stdcall)) foo)(int a) {
+}
+// CHECK: @pf = common global void (...)* null
+// CHECK: define void @foo(i32 %a)
+
+// CHECK-OK: @pf = common global void (...)* null
+// CHECK-OK: define x86_stdcallcc void @foo(i32 inreg %a)
Index: test/Sema/pr25786.c
===
--- test/Sema/pr25786.c
+++ test/Sema/pr25786.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -DTEST -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i686-unknown-linux-gnu -fsyntax-only -verify %s
+
+#if TEST
+void (__attribute__((regparm(3), stdcall)) *pf) (); //expected-warning {{calling convention 'stdcall' ignored for this target}}
+void (__attribute__((regparm(2), stdcall)) foo)(int a) { //expected-warning {{calling convention '

[PATCH] D16298: Improve test coverage of -Wdouble-promotion

2016-01-18 Thread Robert Lougher via cfe-commits
rob.lougher created this revision.
rob.lougher added a reviewer: gbiv.
rob.lougher added a subscriber: cfe-commits.

The -Wdouble-promotion warning was added to clang in r251588 (fixing PR15109).  
The added test, however, only covered a subset of the cases where implicit 
conversion can occur (assignment and function return).  This patch extends the 
coverage to include argument passing and a binary operator (multiply).

The patch also includes coverage for *= and the conditional (ternary) operator. 
 However, warnings are not produced for all the *= cases, and no warnings are 
generated for the conditional operator.  These have been marked as FIXME and I 
will raise bugs for these separately.

Note, I've added George Burgess IV as reviewer as he committed the original 
change and Carl Norum (the author) doesn't seem to be registered.

http://reviews.llvm.org/D16298

Files:
  test/Sema/warn-double-promotion.c

Index: test/Sema/warn-double-promotion.c
===
--- test/Sema/warn-double-promotion.c
+++ test/Sema/warn-double-promotion.c
@@ -24,11 +24,51 @@
   return d;  //expected-warning{{implicit conversion increases floating-point 
precision: 'double' to 'long double'}}
 }
 
-void Convert(float f, double d, long double ld) {
+void Assignment(float f, double d, long double ld) {
   d = f;  //expected-warning{{implicit conversion increases floating-point 
precision: 'float' to 'double'}}
   ld = f; //expected-warning{{implicit conversion increases floating-point 
precision: 'float' to 'long double'}}
   ld = d; //expected-warning{{implicit conversion increases floating-point 
precision: 'double' to 'long double'}}
   f = d;
   f = ld;
   d = ld;
 }
+
+extern void DoubleParameter(double);
+extern void LongDoubleParameter(long double);
+
+void ArgumentPassing(float f, double d, long double ld) {
+  DoubleParameter(f); // expected-warning{{implicit conversion increases 
floating-point precision: 'float' to 'double'}}
+  LongDoubleParameter(f); // expected-warning{{implicit conversion increases 
floating-point precision: 'float' to 'long double'}}
+  LongDoubleParameter(d); // expected-warning{{implicit conversion increases 
floating-point precision: 'double' to 'long double'}}
+}
+
+void BinaryOperator(float f, double d, long double ld) {
+  f = f * d; // expected-warning{{implicit conversion increases floating-point 
precision: 'float' to 'double'}}
+  f = d * f; // expected-warning{{implicit conversion increases floating-point 
precision: 'float' to 'double'}}
+  f = f * ld; // expected-warning{{implicit conversion increases 
floating-point precision: 'float' to 'long double'}}
+  f = ld * f; // expected-warning{{implicit conversion increases 
floating-point precision: 'float' to 'long double'}}
+  d = d * ld; // expected-warning{{implicit conversion increases 
floating-point precision: 'double' to 'long double'}}
+  d = ld * d; // expected-warning{{implicit conversion increases 
floating-point precision: 'double' to 'long double'}}
+}
+
+void MultiplicationAssignment(float f, double d, long double ld) {
+  d *= f; // expected-warning{{implicit conversion increases floating-point 
precision: 'float' to 'double'}}
+  ld *= f; // expected-warning{{implicit conversion increases floating-point 
precision: 'float' to 'long double'}}
+  ld *= d; // expected-warning{{implicit conversion increases floating-point 
precision: 'double' to 'long double'}}
+
+  // FIXME: These cases should produce warnings as above.
+  f *= d;
+  f *= ld;
+  d *= ld;
+}
+
+// FIXME: As with a binary operator, the operands to the conditional operator 
are
+// converted to a common type and should produce a warning.
+void ConditionalOperator(float f, double d, long double ld, int i) {
+  f = i ? f : d;
+  f = i ? d : f;
+  f = i ? f : ld;
+  f = i ? ld : f;
+  d = i ? d : ld;
+  d = i ? ld : d;
+}


Index: test/Sema/warn-double-promotion.c
===
--- test/Sema/warn-double-promotion.c
+++ test/Sema/warn-double-promotion.c
@@ -24,11 +24,51 @@
   return d;  //expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}}
 }
 
-void Convert(float f, double d, long double ld) {
+void Assignment(float f, double d, long double ld) {
   d = f;  //expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
   ld = f; //expected-warning{{implicit conversion increases floating-point precision: 'float' to 'long double'}}
   ld = d; //expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}}
   f = d;
   f = ld;
   d = ld;
 }
+
+extern void DoubleParameter(double);
+extern void LongDoubleParameter(long double);
+
+void ArgumentPassing(float f, double d, long double ld) {
+  DoubleParameter(f); // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
+  LongDoubleParameter(f); 

r258061 - [analyzer] Nullability: Look through implicit casts when suppressing warnings on return.

2016-01-18 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Mon Jan 18 12:53:33 2016
New Revision: 258061

URL: http://llvm.org/viewvc/llvm-project?rev=258061&view=rev
Log:
[analyzer] Nullability: Look through implicit casts when suppressing warnings 
on return.

In r256567 I changed the nullability checker to suppress warnings about 
returning a null
value from a function/method with a non-null return type when the type of the 
returned
expression is itself nonnull. This enables the programmer to silence 
nullability warnings
by casting to _Nonnull:

  return (SomeObject * _Nonnull)nil;

Unfortunately, under ObjC automated reference counting, Sema adds implicit 
casts to
_Nonnull to return expressions of nullable or unspecified types in functions 
with
non-null function/method return types. With r256567, these casts cause all 
nullability
warnings for returns of reference-counted types to be suppressed under ARC, 
leading to
false negatives.

This commit updates the nullability checker to look through implicit casts 
before
determining the type of the returned expression. It also updates the tests to 
turn on
ARC for the nullability_nullonly.mm testfile and adds a new testfile to test 
when ARC
is turned off.

rdar://problem/24200117

Added:
cfe/trunk/test/Analysis/nullability-no-arc.mm
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
cfe/trunk/test/Analysis/nullability.mm
cfe/trunk/test/Analysis/nullability_nullonly.mm

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp?rev=258061&r1=258060&r2=258061&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp Mon Jan 18 
12:53:33 2016
@@ -456,6 +456,20 @@ void NullabilityChecker::checkEvent(Impl
   }
 }
 
+/// Find the outermost subexpression of E that is not an implicit cast.
+/// This looks through the implicit casts to _Nonnull that ARC adds to
+/// return expressions of ObjC types when the return type of the function or
+/// method is non-null but the express is not.
+static const Expr *lookThroughImplicitCasts(const Expr *E) {
+  assert(E);
+
+  while (auto *ICE = dyn_cast(E)) {
+E = ICE->getSubExpr();
+  }
+
+  return E;
+}
+
 /// This method check when nullable pointer or null value is returned from a
 /// function that has nonnull return type.
 ///
@@ -501,7 +515,7 @@ void NullabilityChecker::checkPreStmt(co
   // function with a _Nonnull return type:
   //return (NSString * _Nonnull)0;
   Nullability RetExprTypeLevelNullability =
-getNullabilityAnnotation(RetExpr->getType());
+getNullabilityAnnotation(lookThroughImplicitCasts(RetExpr)->getType());
 
   if (Filter.CheckNullReturnedFromNonnull &&
   Nullness == NullConstraint::IsNull &&

Added: cfe/trunk/test/Analysis/nullability-no-arc.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/nullability-no-arc.mm?rev=258061&view=auto
==
--- cfe/trunk/test/Analysis/nullability-no-arc.mm (added)
+++ cfe/trunk/test/Analysis/nullability-no-arc.mm Mon Jan 18 12:53:33 2016
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,nullability -verify %s
+
+#define nil 0
+
+@protocol NSObject
++ (id)alloc;
+- (id)init;
+@end
+
+__attribute__((objc_root_class))
+@interface
+NSObject
+@end
+
+@interface TestObject : NSObject
+@end
+
+TestObject * _Nonnull returnsNilObjCInstanceIndirectly() {
+  TestObject *local = 0;
+  return local; // expected-warning {{Null is returned from a function that is 
expected to return a non-null value}}
+}
+
+TestObject * _Nonnull returnsNilObjCInstanceIndirectlyWithSupressingCast() {
+  TestObject *local = 0;
+  return (TestObject * _Nonnull)local; // no-warning
+}
+
+TestObject * _Nonnull returnsNilObjCInstanceDirectly() {
+  // The first warning is from Sema. The second is from the static analyzer.
+  return nil; // expected-warning {{null returned from function that requires 
a non-null return value}}
+  // expected-warning@-1 {{Null is returned from a function that 
is expected to return a non-null value}}
+}
+
+TestObject * _Nonnull returnsNilObjCInstanceDirectlyWithSuppressingCast() {
+  return (TestObject * _Nonnull)nil; // no-warning
+}
+
+void testObjCNonARCNoInitialization(TestObject * _Nonnull p) {
+  TestObject * _Nonnull implicitlyZeroInitialized; // no-warning
+  implicitlyZeroInitialized = p;
+}
+
+void testObjCNonARCExplicitZeroInitialization() {
+  TestObject * _Nonnull explicitlyZeroInitialized = nil; // expected-warning 
{{Null is assigned to a pointer which is expected to have non-null value}}
+}

Modified: cfe/trunk/test/Analysis/nullability.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/nullability.mm?rev=

Re: [PATCH] D15883: Add ARM EHABI-related constants to unwind.h.

2016-01-18 Thread Joerg Sonnenberger via cfe-commits
On Tue, Jan 05, 2016 at 05:27:34AM +, Timon Van Overveldt via cfe-commits 
wrote:
> Adds a number of constants, defined in the ARM EHABI spec, to the Clang
> lib/Headers/unwind.h header. This is prerequisite for landing
> http://reviews.llvm.org/D15781, as previously discussed there.

IMO they should be defined *only* for EHABI.

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


Fwd: Re: [PATCH][Modules][PR26179]

2016-01-18 Thread Richard Smith via cfe-commits
+  // the when comparing #1 and #2 we should go through their elements
types.

Typo "the when"

+  QualType VarXTy = VarX->getType();
+  QualType VarYTy = VarY->getType();
+  if (VarXTy->isIncompleteArrayType() ||
VarYTy->isIncompleteArrayType())
+return C.hasSameType(C.getAsArrayType(VarXTy)->getElementType(),
+ C.getAsArrayType(VarYTy)->getElementType());

This will crash when one type is an incomplete array type and the other is
not an array type.

-- Forwarded message --
From: "Richard Smith" 
Date: Jan 18, 2016 11:38 AM
Subject: Re: [PATCH][Modules][PR26179]
To: "Vassil Vassilev" 
Cc: "Douglas Gregor" , "cfe commits" <
cfe-comm...@cs.uiuc.edu>

> Please also add a test case that your old patch would have failed on,
such as:
>
> m1.h:
> extern int a[];
>
> m2.h:
> extern int a[5];
>
> x.cc:
> #include "m1.h"
> #include "m2.h"
> int *p = a;
>
> On Jan 18, 2016 9:28 AM, "Vassil Vassilev"  wrote:
>>
>> On 17/01/16 06:34, Douglas Gregor wrote:

 On Jan 16, 2016, at 3:41 PM, Vassil Vassilev  wrote:

 Hi,
   Could somebody review the attached patch. It fixes
https://llvm.org/bugs/show_bug.cgi?id=26179
 Many thanks!
 Vassil
 <0001-modules-Teach-clang-to-how-to-merge-variable-redecls.patch>
>>>
>>>
>>> +  // We can get decls with different types on the redecl chain. Eg.
>>> +  // template  struct S { static T Var[]; }; // #1
>>> +  // template  T S::Var[sizeof(T)]; // #2
>>> +  // Trying to compare #1 and #2 should go through their canonical
decls.
>>> +  QualType VarXTy = VarX->getCanonicalDecl()->getType();
>>> +  QualType VarYTy = VarY->getCanonicalDecl()->getType();
>>> +  if (Context.hasSameType(VarXTy, VarYTy))
>>> +return true;
>>>
>>> Completing an incomplete array is (I think) the only case in which this
can happen. How about checking for that case specifically (i.e., it’s okay
to have one be an incomplete array and the other to be any other kind of
array with the same element type), rather than a blanket check on the
canonical declaration types?
>>>
>>> - Doug
>>>
>> Thanks for the comments. Patch v2 attached.
>> -- Vassil
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r257827 - [CMake] Set SVN_REVISION if CLANG_APPEND_VC_REV=On

2016-01-18 Thread Craig Topper via cfe-commits
CLANG_APPEND_VC_REV doesn't appear to be checked anywhere. Were the two ifs
supposed to check it instead of SVN_VERSION? The way it is now if the first
if body executes, the second if does too since add_version_info_from_vcs
sets SVN_VERSION and thus satisfies the second if.

On Mon, Jan 18, 2016 at 6:06 AM, Daniel Sanders via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Thanks, that did the trick. I've removed the workaround from LLVMLinux.
>
> > -Original Message-
> > From: cbiene...@apple.com [mailto:cbiene...@apple.com] On Behalf Of
> > Chris Bieneman
> > Sent: 15 January 2016 17:55
> > To: Daniel Sanders
> > Cc: cfe-commits@lists.llvm.org
> > Subject: Re: r257827 - [CMake] Set SVN_REVISION if
> > CLANG_APPEND_VC_REV=On
> >
> > Thanks for the heads up. It looks like that module is was excluded from
> the
> > LLVM install. I’ve changed that in LLVM r257909. That change should
> resolve
> > your build issue. Please let me know if you continue having problems.
> >
> > Thanks,
> > -Chris
> >
> > > On Jan 15, 2016, at 5:18 AM, Daniel Sanders  >
> > wrote:
> > >
> > > Hi Chris,
> > >
> > > This doesn't seem to work when building clang separately from llvm.
> > LLVMLinux fails to build clang with:
> > > CMake Error at CMakeLists.txt:104 (include):
> > >   include could not find load file:
> > >
> > > VersionFromVCS
> > >
> > > CMake Error at CMakeLists.txt:222 (add_version_info_from_vcs):
> > >   Unknown CMake command "add_version_info_from_vcs".
> > > See
> >
> http://buildbot.llvm.linuxfoundation.org/builders/13_malta/builds/383/step
> > s/shell_3/logs/stdio for the full log.
> > >
> > > I've added a patch to llvmlinux to work around the problem for now
> >
> http://git.linuxfoundation.org/?p=llvmlinux.git;a=blob;f=toolchain/clang/pat
> > ches/clang/workaround-
> > versionfromvcsbug.patch;h=848a096df37b1255575650680a266234f5d4936e;h
> > b=e0c4c72c5a008006dc230db748ea69e0d1518daf.
> > > Should we make that change to clang or fix it another way?
> > >
> > >> -Original Message-
> > >> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On
> > Behalf
> > >> Of Chris Bieneman via cfe-commits
> > >> Sent: 14 January 2016 22:45
> > >> To: cfe-commits@lists.llvm.org
> > >> Subject: r257827 - [CMake] Set SVN_REVISION if
> > >> CLANG_APPEND_VC_REV=On
> > >>
> > >> Author: cbieneman
> > >> Date: Thu Jan 14 16:45:12 2016
> > >> New Revision: 257827
> > >>
> > >> URL: http://llvm.org/viewvc/llvm-project?rev=257827&view=rev
> > >> Log:
> > >> [CMake] Set SVN_REVISION if CLANG_APPEND_VC_REV=On
> > >>
> > >> This matches autoconf's ability to put clang revisions in the clang
> --version
> > >> spew.
> > >>
> > >> Modified:
> > >>cfe/trunk/CMakeLists.txt
> > >>
> > >> Modified: cfe/trunk/CMakeLists.txt
> > >> URL: http://llvm.org/viewvc/llvm-
> > >>
> > project/cfe/trunk/CMakeLists.txt?rev=257827&r1=257826&r2=257827&view
> > >> =diff
> > >>
> > ==
> > >> 
> > >> --- cfe/trunk/CMakeLists.txt (original)
> > >> +++ cfe/trunk/CMakeLists.txt Thu Jan 14 16:45:12 2016
> > >> @@ -101,6 +101,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
> > >>   include(AddLLVM)
> > >>   include(TableGen)
> > >>   include(HandleLLVMOptions)
> > >> +  include(VersionFromVCS)
> > >>
> > >>   set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
> > >>
> > >> @@ -213,6 +214,18 @@ if(CLANG_REPOSITORY_STRING)
> > >>   add_definitions(-
> > >> DCLANG_REPOSITORY_STRING="${CLANG_REPOSITORY_STRING}")
> > >> endif()
> > >>
> > >> +option(CLANG_APPEND_VC_REV
> > >> +  "Append the version control system revision id to clang version
> spew"
> > >> OFF)
> > >> +
> > >> +if(NOT SVN_REVISION)
> > >> +  # This macro will set SVN_REVISION in the parent scope
> > >> +  add_version_info_from_vcs(VERSION_VAR)
> > >> +endif()
> > >> +
> > >> +if(SVN_REVISION)
> > >> +  add_definitions(-DSVN_REVISION="${SVN_REVISION}")
> > >> +endif()
> > >> +
> > >> set(CLANG_VENDOR_UTI "org.llvm.clang" CACHE STRING
> > >>   "Vendor-specific uti.")
> > >>
> > >>
> > >>
> > >> ___
> > >> 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
>



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


r258066 - [TableGen] Merge the SuperClass Record and SMRange vector a single vector. This removes the state needed to manage the extract vector. NFC

2016-01-18 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon Jan 18 13:52:54 2016
New Revision: 258066

URL: http://llvm.org/viewvc/llvm-project?rev=258066&view=rev
Log:
[TableGen] Merge the SuperClass Record and SMRange vector a single vector. This 
removes the state needed to manage the extract vector. NFC

Modified:
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
cfe/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp
cfe/trunk/utils/TableGen/NeonEmitter.cpp

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=258066&r1=258065&r2=258066&view=diff
==
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Mon Jan 18 13:52:54 2016
@@ -1072,9 +1072,9 @@ createArgument(const Record &Arg, String
 
   if (!Ptr) {
 // Search in reverse order so that the most-derived type is handled first.
-ArrayRef Bases = Search->getSuperClasses();
-for (const auto *Base : llvm::make_range(Bases.rbegin(), Bases.rend())) {
-  if ((Ptr = createArgument(Arg, Attr, Base)))
+ArrayRef> Bases = Search->getSuperClasses();
+for (const auto &Base : llvm::make_range(Bases.rbegin(), Bases.rend())) {
+  if ((Ptr = createArgument(Arg, Attr, Base.first)))
 break;
 }
   }
@@ -1381,7 +1381,7 @@ static void emitClangAttrTypeArgList(Rec
 if (Args.empty())
   continue;
 
-if (Args[0]->getSuperClasses().back()->getName() != "TypeArgument")
+if (Args[0]->getSuperClasses().back().first->getName() != "TypeArgument")
   continue;
 
 // All these spellings take a single type argument.
@@ -1419,7 +1419,7 @@ static void emitClangAttrArgContextList(
 
 static bool isIdentifierArgument(Record *Arg) {
   return !Arg->getSuperClasses().empty() &&
-llvm::StringSwitch(Arg->getSuperClasses().back()->getName())
+llvm::StringSwitch(Arg->getSuperClasses().back().first->getName())
 .Case("IdentifierArgument", true)
 .Case("EnumArgument", true)
 .Case("VariadicEnumArgument", true)
@@ -1476,13 +1476,13 @@ void EmitClangAttrClass(RecordKeeper &Re
 if (!R.getValueAsBit("ASTNode"))
   continue;
 
-ArrayRef Supers = R.getSuperClasses();
+ArrayRef> Supers = R.getSuperClasses();
 assert(!Supers.empty() && "Forgot to specify a superclass for the attr");
 std::string SuperName;
-for (const auto *Super : llvm::make_range(Supers.rbegin(), Supers.rend())) 
{
-  const Record &R = *Super;
-  if (R.getName() != "TargetSpecificAttr" && SuperName.empty())
-SuperName = R.getName();
+for (const auto &Super : llvm::make_range(Supers.rbegin(), Supers.rend())) 
{
+  const Record *R = Super.first;
+  if (R->getName() != "TargetSpecificAttr" && SuperName.empty())
+SuperName = R->getName();
 }
 
 OS << "class " << R.getName() << "Attr : public " << SuperName << " {\n";

Modified: cfe/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp?rev=258066&r1=258065&r2=258066&view=diff
==
--- cfe/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp Mon Jan 18 13:52:54 
2016
@@ -152,13 +152,12 @@ static bool beforeThanCompareGroups(cons
 }
 
 static SMRange findSuperClassRange(const Record *R, StringRef SuperName) {
-  ArrayRef Supers = R->getSuperClasses();
-
-  for (size_t i = 0, e = Supers.size(); i < e; ++i)
-if (Supers[i]->getName() == SuperName)
-  return R->getSuperClassRanges()[i];
-
-  return SMRange();
+  ArrayRef> Supers = R->getSuperClasses();
+  auto I = std::find_if(Supers.begin(), Supers.end(),
+[&](const std::pair &SuperPair) {
+  return SuperPair.first->getName() == SuperName;
+});
+  return (I != Supers.end()) ? I->second : SMRange();
 }
 
 /// \brief Invert the 1-[0/1] mapping of diags to group into a one to many

Modified: cfe/trunk/utils/TableGen/NeonEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/NeonEmitter.cpp?rev=258066&r1=258065&r2=258066&view=diff
==
--- cfe/trunk/utils/TableGen/NeonEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/NeonEmitter.cpp Mon Jan 18 13:52:54 2016
@@ -1926,7 +1926,7 @@ void NeonEmitter::createIntrinsic(Record
 
   ClassKind CK = ClassNone;
   if (R->getSuperClasses().size() >= 2)
-CK = ClassMap[R->getSuperClasses()[1]];
+CK = ClassMap[R->getSuperClasses()[1].first];
 
   std::vector> NewTypeSpecs;
   for (auto TS : TypeSpecs) {


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

Re: [PATCH][Modules][PR26179]

2016-01-18 Thread Vassil Vassilev via cfe-commits
Attaching v3 of the patch. Added your case to the current test and fixed 
my silly non-array mistake.

-- Vassil
On 18/01/16 20:38, Richard Smith wrote:


Please also add a test case that your old patch would have failed on, 
such as:


m1.h:
extern int a[];

m2.h:
extern int a[5];

x.cc:
#include "m1.h"
#include "m2.h"
int *p = a;

On Jan 18, 2016 9:28 AM, "Vassil Vassilev" > wrote:


On 17/01/16 06:34, Douglas Gregor wrote:

On Jan 16, 2016, at 3:41 PM, Vassil Vassilev
mailto:vvasi...@cern.ch>> wrote:

Hi,
  Could somebody review the attached patch. It fixes
https://llvm.org/bugs/show_bug.cgi?id=26179
Many thanks!
Vassil
<0001-modules-Teach-clang-to-how-to-merge-variable-redecls.patch>


+  // We can get decls with different types on the redecl
chain. Eg.
+  // template  struct S { static T Var[]; };
// #1
+  // template  T S::Var[sizeof(T)]; // #2
+  // Trying to compare #1 and #2 should go through their
canonical decls.
+  QualType VarXTy = VarX->getCanonicalDecl()->getType();
+  QualType VarYTy = VarY->getCanonicalDecl()->getType();
+  if (Context.hasSameType(VarXTy, VarYTy))
+return true;

Completing an incomplete array is (I think) the only case in
which this can happen. How about checking for that case
specifically (i.e., it’s okay to have one be an incomplete
array and the other to be any other kind of array with the
same element type), rather than a blanket check on the
canonical declaration types?

- Doug

Thanks for the comments. Patch v2 attached.
-- Vassil



From d90d111c53eee39c5c74d2e59b607e421c176348 Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Sat, 16 Jan 2016 23:52:40 +0100
Subject: [PATCH] [modules] Teach clang to how to merge variables with
 incomplete array types.

We can get decls with different types on the redecl chain. Eg.
template  struct S {
  static T Var[]; // #1
};
template  T S::Var[sizeof(T)]; // #2
Trying to compare #1 and #2 should go through their canonical decls.

Fixes https://llvm.org/bugs/show_bug.cgi?id=26179
---
 lib/Serialization/ASTReaderDecl.cpp  | 20 ++--
 test/Modules/Inputs/PR26179/A.h  |  4 
 test/Modules/Inputs/PR26179/B.h  |  2 ++
 test/Modules/Inputs/PR26179/basic_string.h   | 14 ++
 test/Modules/Inputs/PR26179/module.modulemap |  9 +
 test/Modules/pr26179.cpp |  7 +++
 6 files changed, 54 insertions(+), 2 deletions(-)
 create mode 100644 test/Modules/Inputs/PR26179/A.h
 create mode 100644 test/Modules/Inputs/PR26179/B.h
 create mode 100644 test/Modules/Inputs/PR26179/basic_string.h
 create mode 100644 test/Modules/Inputs/PR26179/module.modulemap
 create mode 100644 test/Modules/pr26179.cpp

diff --git a/lib/Serialization/ASTReaderDecl.cpp 
b/lib/Serialization/ASTReaderDecl.cpp
index 5bf95f8..9bcd9a0 100644
--- a/lib/Serialization/ASTReaderDecl.cpp
+++ b/lib/Serialization/ASTReaderDecl.cpp
@@ -2595,8 +2595,24 @@ static bool isSameEntity(NamedDecl *X, NamedDecl *Y) {
   // Variables with the same type and linkage match.
   if (VarDecl *VarX = dyn_cast(X)) {
 VarDecl *VarY = cast(Y);
-return (VarX->getLinkageInternal() == VarY->getLinkageInternal()) &&
-  VarX->getASTContext().hasSameType(VarX->getType(), VarY->getType());
+if (VarX->getLinkageInternal() == VarY->getLinkageInternal()) {
+  ASTContext &C = VarX->getASTContext();
+  if (C.hasSameType(VarX->getType(), VarY->getType()))
+return true;
+
+  // We can get decls with different types on the redecl chain. Eg.
+  // template  struct S { static T Var[]; }; // #1
+  // template  T S::Var[sizeof(T)]; // #2
+  // Only? happens when completing an incomplete array type. In this case
+  // when comparing #1 and #2 we should go through their elements types.
+  const ArrayType *VarXTy = C.getAsArrayType(VarX->getType());
+  const ArrayType *VarYTy = C.getAsArrayType(VarY->getType());
+  if (!VarXTy || !VarYTy)
+return false;
+  if (VarXTy->isIncompleteArrayType() || VarYTy->isIncompleteArrayType())
+return C.hasSameType(VarXTy->getElementType(), 
VarYTy->getElementType());
+}
+return false;
   }
 
   // Namespaces with the same name and inlinedness match.
diff --git a/test/Modules/Inputs/PR26179/A.h b/test/Modules/Inputs/PR26179/A.h
new file mode 100644
index 000..ce95faf
--- /dev/null
+++ b/test/Modules/Inputs/PR26179/A.h
@@ -0,0 +1,4 @@
+#include "basic_string.h"
+#include "B.h"
+
+int *p = a;
diff --git a/test/Modules/Inputs/PR26179/B.h b/test/Modules/Inputs/PR26179/B.h
new file mode 100644
index 000..eb8d1c2
--- /dev/null
+++ b/test/Modules/Inputs/PR26179/B.h
@@ -0,0 +1,2 @@
+#include "bas

r258070 - Augments r258042; changes the AST matcher tests to use matchesNot and EXPECT_TRUE instead of EXPECT_FALSE. Adds a matcher test to ensure that static member functions are properly handled. Ge

2016-01-18 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Jan 18 14:28:57 2016
New Revision: 258070

URL: http://llvm.org/viewvc/llvm-project?rev=258070&view=rev
Log:
Augments r258042; changes the AST matcher tests to use matchesNot and 
EXPECT_TRUE instead of EXPECT_FALSE. Adds a matcher test to ensure that static 
member functions are properly handled. Generates the documentation from the 
matcher.

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=258070&r1=258069&r2=258070&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Mon Jan 18 14:28:57 2016
@@ -3292,6 +3292,23 @@ Usable as: MatcherCXXConstructExpr>forEachArgumentWithParamMatcherExpr> 
ArgMatcher, MatcherParmVarDecl>
 ParamMatcher
+Matches 
all arguments and their respective ParmVarDecl.
+
+Given
+  void f(int i);
+  int y;
+  f(y);
+callExpr(declRefExpr(to(varDecl(hasName("y",
+parmVarDecl(hasType(isInteger(
+  matches f(y);
+with declRefExpr(...)
+  matching int y
+and parmVarDecl(...)
+  matching int i
+
+
+
 MatcherCXXConstructExpr>hasAnyArgumentMatcherExpr> 
InnerMatcher
 Matches any argument 
of a call expression or a constructor call
 expression.
@@ -3546,6 +3563,23 @@ implemented in terms of implicit casts.
 
 
 
+MatcherCallExpr>forEachArgumentWithParamMatcherExpr> 
ArgMatcher, MatcherParmVarDecl>
 ParamMatcher
+Matches 
all arguments and their respective ParmVarDecl.
+
+Given
+  void f(int i);
+  int y;
+  f(y);
+callExpr(declRefExpr(to(varDecl(hasName("y",
+parmVarDecl(hasType(isInteger(
+  matches f(y);
+with declRefExpr(...)
+  matching int y
+and parmVarDecl(...)
+  matching int i
+
+
+
 MatcherCallExpr>hasAnyArgumentMatcherExpr> 
InnerMatcher
 Matches any argument 
of a call expression or a constructor call
 expression.

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=258070&r1=258069&r2=258070&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Mon Jan 18 14:28:57 2016
@@ -1616,9 +1616,9 @@ TEST(ForEachArgumentWithParam, ReportsNo
   callExpr(forEachArgumentWithParam(ArgumentY, IntParam));
 
   // IntParam does not match.
-  EXPECT_FALSE(matches("void f(int* i) { int* y; f(y); }", CallExpr));
+  EXPECT_TRUE(notMatches("void f(int* i) { int* y; f(y); }", CallExpr));
   // ArgumentY does not match.
-  EXPECT_FALSE(matches("void f(int i) { int x; f(x); }", CallExpr));
+  EXPECT_TRUE(notMatches("void f(int i) { int x; f(x); }", CallExpr));
 }
 
 TEST(ForEachArgumentWithParam, MatchesCXXMemberCallExpr) {
@@ -1636,6 +1636,18 @@ TEST(ForEachArgumentWithParam, MatchesCX
   "  S1[y];"
   "}",
   CallExpr, new VerifyIdIsBoundTo("param", 1)));
+
+  StatementMatcher CallExpr2 =
+  callExpr(forEachArgumentWithParam(ArgumentY, IntParam));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "struct S {"
+  "  static void g(int i);"
+  "};"
+  "void f() {"
+  "  int y = 1;"
+  "  S::g(y);"
+  "}",
+  CallExpr2, new VerifyIdIsBoundTo("param", 1)));
 }
 
 TEST(ForEachArgumentWithParam, MatchesCallExpr) {


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


Re: [PATCH][Modules][PR26179]

2016-01-18 Thread Richard Smith via cfe-commits
LGTM
On Jan 18, 2016 12:06 PM, "Vassil Vassilev"  wrote:

> Attaching v3 of the patch. Added your case to the current test and fixed
> my silly non-array mistake.
> -- Vassil
> On 18/01/16 20:38, Richard Smith wrote:
>
> Please also add a test case that your old patch would have failed on, such
> as:
>
> m1.h:
> extern int a[];
>
> m2.h:
> extern int a[5];
>
> x.cc:
> #include "m1.h"
> #include "m2.h"
> int *p = a;
> On Jan 18, 2016 9:28 AM, "Vassil Vassilev"  wrote:
>
>> On 17/01/16 06:34, Douglas Gregor wrote:
>>
>>> On Jan 16, 2016, at 3:41 PM, Vassil Vassilev  wrote:

 Hi,
   Could somebody review the attached patch. It fixes
 https://llvm.org/bugs/show_bug.cgi?id=26179
 Many thanks!
 Vassil
 <0001-modules-Teach-clang-to-how-to-merge-variable-redecls.patch>

>>>
>>> +  // We can get decls with different types on the redecl chain. Eg.
>>> +  // template  struct S { static T Var[]; }; // #1
>>> +  // template  T S::Var[sizeof(T)]; // #2
>>> +  // Trying to compare #1 and #2 should go through their canonical
>>> decls.
>>> +  QualType VarXTy = VarX->getCanonicalDecl()->getType();
>>> +  QualType VarYTy = VarY->getCanonicalDecl()->getType();
>>> +  if (Context.hasSameType(VarXTy, VarYTy))
>>> +return true;
>>>
>>> Completing an incomplete array is (I think) the only case in which this
>>> can happen. How about checking for that case specifically (i.e., it’s okay
>>> to have one be an incomplete array and the other to be any other kind of
>>> array with the same element type), rather than a blanket check on the
>>> canonical declaration types?
>>>
>>> - Doug
>>>
>>> Thanks for the comments. Patch v2 attached.
>> -- Vassil
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16301: Allow mode attribute for member variables again

2016-01-18 Thread Stephan Bergmann via cfe-commits
sberg created this revision.
sberg added reviewers: ABataev, aaron.ballman.
sberg added a subscriber: cfe-commits.

...after r257868 "PR26111: segmentation fault with __attribute__((mode(QI))) on 
function declaration" (presumably accidentally) restricted it to variables and 
typedefs, excluding member variables (aka fields).  That broke building 
LibreOffice, which, in bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx, 
contains a "typedef-unwound" copy of struct _Unwind_Except from GCC's 
libgcc/unwind-generic.h.

http://reviews.llvm.org/D16301

Files:
  include/clang/Basic/Attr.td
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/attr-mode.c

Index: test/Sema/attr-mode.c
===
--- test/Sema/attr-mode.c
+++ test/Sema/attr-mode.c
@@ -76,3 +76,7 @@
 #else
 #error Unknown test architecture.
 #endif
+
+struct S {
+  int n __attribute((mode(HI)));
+};
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3392,7 +3392,7 @@
   if (TypedefNameDecl *TD = dyn_cast(D))
 OldTy = TD->getUnderlyingType();
   else
-OldTy = cast(D)->getType();
+OldTy = cast(D)->getType();
 
   // Base type can also be a vector type (see PR17453).
   // Distinguish between base type and base element type.
@@ -3465,7 +3465,7 @@
   if (TypedefNameDecl *TD = dyn_cast(D))
 TD->setModedTypeSourceInfo(TD->getTypeSourceInfo(), NewTy);
   else
-cast(D)->setType(NewTy);
+cast(D)->setType(NewTy);
 
   D->addAttr(::new (S.Context)
  ModeAttr(Attr.getRange(), S.Context, Name,
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -887,7 +887,7 @@
 
 def Mode : Attr {
   let Spellings = [GCC<"mode">];
-  let Subjects = SubjectList<[Var, TypedefName], ErrorDiag,
+  let Subjects = SubjectList<[Var, TypedefName, Field], ErrorDiag,
  "ExpectedVariableOrTypedef">;
   let Args = [IdentifierArgument<"Mode">];
   let Documentation = [Undocumented];


Index: test/Sema/attr-mode.c
===
--- test/Sema/attr-mode.c
+++ test/Sema/attr-mode.c
@@ -76,3 +76,7 @@
 #else
 #error Unknown test architecture.
 #endif
+
+struct S {
+  int n __attribute((mode(HI)));
+};
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3392,7 +3392,7 @@
   if (TypedefNameDecl *TD = dyn_cast(D))
 OldTy = TD->getUnderlyingType();
   else
-OldTy = cast(D)->getType();
+OldTy = cast(D)->getType();
 
   // Base type can also be a vector type (see PR17453).
   // Distinguish between base type and base element type.
@@ -3465,7 +3465,7 @@
   if (TypedefNameDecl *TD = dyn_cast(D))
 TD->setModedTypeSourceInfo(TD->getTypeSourceInfo(), NewTy);
   else
-cast(D)->setType(NewTy);
+cast(D)->setType(NewTy);
 
   D->addAttr(::new (S.Context)
  ModeAttr(Attr.getRange(), S.Context, Name,
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -887,7 +887,7 @@
 
 def Mode : Attr {
   let Spellings = [GCC<"mode">];
-  let Subjects = SubjectList<[Var, TypedefName], ErrorDiag,
+  let Subjects = SubjectList<[Var, TypedefName, Field], ErrorDiag,
  "ExpectedVariableOrTypedef">;
   let Args = [IdentifierArgument<"Mode">];
   let Documentation = [Undocumented];
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r258072 - Add an AST matcher for checking whether a function is defaulted.

2016-01-18 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Jan 18 14:37:44 2016
New Revision: 258072

URL: http://llvm.org/viewvc/llvm-project?rev=258072&view=rev
Log:
Add an AST matcher for checking whether a function is defaulted.

Patch by Jonathan Coe.

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=258072&r1=258071&r2=258072&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Mon Jan 18 14:37:44 2016
@@ -2184,6 +2184,17 @@ Usable as: MatcherFunctionDecl>isDefaulted
+Matches defaulted 
function declarations.
+
+Given:
+  class A { ~A(); };
+  class B { ~B() = default; };
+functionDecl(isDefaulted())
+  matches the declaration of ~B, but not ~A.
+
+
+
 MatcherFunctionDecl>isDeleted
 Matches deleted function 
declarations.
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=258072&r1=258071&r2=258072&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Jan 18 14:37:44 2016
@@ -2993,6 +2993,19 @@ AST_MATCHER(FunctionDecl, isDeleted) {
   return Node.isDeleted();
 }
 
+/// \brief Matches defaulted function declarations.
+///
+/// Given:
+/// \code
+///   class A { ~A(); };
+///   class B { ~B() = default; };
+/// \endcode
+/// functionDecl(isDefaulted())
+///   matches the declaration of ~B, but not ~A.
+AST_MATCHER(FunctionDecl, isDefaulted) {
+  return Node.isDefaulted();
+}
+
 /// \brief Matches functions that have a non-throwing exception specification.
 ///
 /// Given:

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=258072&r1=258071&r2=258072&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Mon Jan 18 14:37:44 2016
@@ -270,6 +270,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(isConstQualified);
   REGISTER_MATCHER(isCopyConstructor);
   REGISTER_MATCHER(isDefaultConstructor);
+  REGISTER_MATCHER(isDefaulted);
   REGISTER_MATCHER(isDefinition);
   REGISTER_MATCHER(isDeleted);
   REGISTER_MATCHER(isExceptionVariable);

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=258072&r1=258071&r2=258072&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Mon Jan 18 14:37:44 2016
@@ -1814,6 +1814,13 @@ TEST(IsExternC, MatchesExternCFunctionDe
   EXPECT_TRUE(notMatches("void f() {}", functionDecl(isExternC(;
 }
 
+TEST(IsDefaulted, MatchesDefaultedFunctionDeclarations) {
+  EXPECT_TRUE(
+  notMatches("class A { ~A(); };", functionDecl(hasName("A"), 
isDefaulted(;
+  EXPECT_TRUE(matches("class B { ~B() = default; };",
+  functionDecl(hasName("B"), isDefaulted(;
+}
+
 TEST(IsDeleted, MatchesDeletedFunctionDeclarations) {
   EXPECT_TRUE(
   notMatches("void Func();", functionDecl(hasName("Func"), isDeleted(;


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


r258077 - The destructor name should be matched to ~Foo instead of Foo.

2016-01-18 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Jan 18 14:47:02 2016
New Revision: 258077

URL: http://llvm.org/viewvc/llvm-project?rev=258077&view=rev
Log:
The destructor name should be matched to ~Foo instead of Foo.

Modified:
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=258077&r1=258076&r2=258077&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Mon Jan 18 14:47:02 2016
@@ -1815,10 +1815,10 @@ TEST(IsExternC, MatchesExternCFunctionDe
 }
 
 TEST(IsDefaulted, MatchesDefaultedFunctionDeclarations) {
-  EXPECT_TRUE(
-  notMatches("class A { ~A(); };", functionDecl(hasName("A"), 
isDefaulted(;
+  EXPECT_TRUE(notMatches("class A { ~A(); };",
+ functionDecl(hasName("~A"), isDefaulted(;
   EXPECT_TRUE(matches("class B { ~B() = default; };",
-  functionDecl(hasName("B"), isDefaulted(;
+  functionDecl(hasName("~B"), isDefaulted(;
 }
 
 TEST(IsDeleted, MatchesDeletedFunctionDeclarations) {


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


Re: [PATCH][Modules][PR26179]

2016-01-18 Thread Vassil Vassilev via cfe-commits

Thanks! Could you check it in?
-- Vassil
On 18/01/16 21:38, Richard Smith via cfe-commits wrote:


LGTM

On Jan 18, 2016 12:06 PM, "Vassil Vassilev" > wrote:


Attaching v3 of the patch. Added your case to the current test and
fixed my silly non-array mistake.
-- Vassil
On 18/01/16 20:38, Richard Smith wrote:


Please also add a test case that your old patch would have failed
on, such as:

m1.h:
extern int a[];

m2.h:
extern int a[5];

x.cc:
#include "m1.h"
#include "m2.h"
int *p = a;

On Jan 18, 2016 9:28 AM, "Vassil Vassilev" mailto:vvasi...@cern.ch>> wrote:

On 17/01/16 06:34, Douglas Gregor wrote:

On Jan 16, 2016, at 3:41 PM, Vassil Vassilev
mailto:vvasi...@cern.ch>> wrote:

Hi,
  Could somebody review the attached patch. It fixes
https://llvm.org/bugs/show_bug.cgi?id=26179
Many thanks!
Vassil

<0001-modules-Teach-clang-to-how-to-merge-variable-redecls.patch>


+  // We can get decls with different types on the
redecl chain. Eg.
+  // template  struct S { static T
Var[]; }; // #1
+  // template  T S::Var[sizeof(T)]; // #2
+  // Trying to compare #1 and #2 should go through
their canonical decls.
+  QualType VarXTy = VarX->getCanonicalDecl()->getType();
+  QualType VarYTy = VarY->getCanonicalDecl()->getType();
+  if (Context.hasSameType(VarXTy, VarYTy))
+return true;

Completing an incomplete array is (I think) the only case
in which this can happen. How about checking for that
case specifically (i.e., it’s okay to have one be an
incomplete array and the other to be any other kind of
array with the same element type), rather than a blanket
check on the canonical declaration types?

- Doug

Thanks for the comments. Patch v2 attached.
-- Vassil





___
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] D16248: [Clang-tidy] rename misc-inefficient-algorithm to performance-inefficient-algorithm

2016-01-18 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko updated the summary for this revision.
Eugene.Zelenko removed rL LLVM as the repository for this revision.
Eugene.Zelenko updated this revision to Diff 45209.
Eugene.Zelenko added a comment.

Add redirect documentation for old check name.


http://reviews.llvm.org/D16248

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/InefficientAlgorithmCheck.cpp
  clang-tidy/misc/InefficientAlgorithmCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/performance/CMakeLists.txt
  clang-tidy/performance/InefficientAlgorithmCheck.cpp
  clang-tidy/performance/InefficientAlgorithmCheck.h
  clang-tidy/performance/PerformanceTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-inefficient-algorithm.rst
  docs/clang-tidy/checks/performance-inefficient-algorithm.rst
  test/clang-tidy/misc-inefficient-algorithm.cpp
  test/clang-tidy/performance-inefficient-algorithm.cpp

Index: clang-tidy/performance/InefficientAlgorithmCheck.h
===
--- clang-tidy/performance/InefficientAlgorithmCheck.h
+++ clang-tidy/performance/InefficientAlgorithmCheck.h
@@ -7,14 +7,14 @@
 //
 //===--===//
 
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_INEFFICIENTALGORITHMCHECK_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_INEFFICIENTALGORITHMCHECK_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_INEFFICIENTALGORITHMCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_INEFFICIENTALGORITHMCHECK_H
 
 #include "../ClangTidy.h"
 
 namespace clang {
 namespace tidy {
-namespace misc {
+namespace performance {
 
 /// Warns on inefficient use of STL algorithms on associative containers.
 ///
@@ -29,8 +29,8 @@
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 };
 
-} // namespace misc
+} // namespace performance
 } // namespace tidy
 } // namespace clang
 
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_INEFFICIENTALGORITHMCHECK_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_INEFFICIENTALGORITHMCHECK_H
Index: clang-tidy/performance/CMakeLists.txt
===
--- clang-tidy/performance/CMakeLists.txt
+++ clang-tidy/performance/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyPerformanceModule
+  InefficientAlgorithmCheck.cpp
   PerformanceTidyModule.cpp
   UnnecessaryCopyInitialization.cpp
 
Index: clang-tidy/performance/InefficientAlgorithmCheck.cpp
===
--- clang-tidy/performance/InefficientAlgorithmCheck.cpp
+++ clang-tidy/performance/InefficientAlgorithmCheck.cpp
@@ -16,7 +16,7 @@
 
 namespace clang {
 namespace tidy {
-namespace misc {
+namespace performance {
 
 static bool areTypesCompatible(QualType Left, QualType Right) {
   if (const auto *LeftRefType = Left->getAs())
@@ -153,6 +153,6 @@
   << Hint;
 }
 
-} // namespace misc
+} // namespace performance
 } // namespace tidy
 } // namespace clang
Index: clang-tidy/performance/PerformanceTidyModule.cpp
===
--- clang-tidy/performance/PerformanceTidyModule.cpp
+++ clang-tidy/performance/PerformanceTidyModule.cpp
@@ -10,7 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
-
+#include "InefficientAlgorithmCheck.h"
 #include "UnnecessaryCopyInitialization.h"
 
 namespace clang {
@@ -20,6 +20,8 @@
 class PerformanceModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"performance-inefficient-algorithm");
 CheckFactories.registerCheck(
 "performance-unnecessary-copy-initialization");
   }
Index: clang-tidy/misc/InefficientAlgorithmCheck.h
===
--- clang-tidy/misc/InefficientAlgorithmCheck.h
+++ clang-tidy/misc/InefficientAlgorithmCheck.h
@@ -1,36 +0,0 @@
-//===--- InefficientAlgorithmCheck.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_MISC_INEFFICIENTALGORITHMCHECK_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_INEFFICIENTALGORITHMCHECK_H
-
-#include "../ClangTidy.h"
-
-namespace clang {
-namespace tidy {
-namespace misc {
-
-/// Warns on inefficient use of STL algorithms on associative containers.
-///
-/// Associative containers implements some of the algorithms as methods which
-/// should be preferred to the algorithms in the algorithm header. The methods
-/// can take advanatage of t

r258097 - fix formatting; NFC

2016-01-18 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Mon Jan 18 16:15:33 2016
New Revision: 258097

URL: http://llvm.org/viewvc/llvm-project?rev=258097&view=rev
Log:
fix formatting; NFC

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

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=258097&r1=258096&r2=258097&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Mon Jan 18 16:15:33 2016
@@ -3046,8 +3046,7 @@ CodeGenFunction::EmitRuntimeCall(llvm::V
   return EmitRuntimeCall(callee, None, name);
 }
 
-/// Emits a simple call (never an invoke) to the given runtime
-/// function.
+/// Emits a simple call (never an invoke) to the given runtime function.
 llvm::CallInst *
 CodeGenFunction::EmitRuntimeCall(llvm::Value *callee,
  ArrayRef args,
@@ -3060,10 +3059,10 @@ CodeGenFunction::EmitRuntimeCall(llvm::V
 // Calls which may throw must have operand bundles indicating which funclet
 // they are nested within.
 static void
-getBundlesForFunclet(llvm::Value *Callee,
- llvm::Instruction *CurrentFuncletPad,
+getBundlesForFunclet(llvm::Value *Callee, llvm::Instruction *CurrentFuncletPad,
  SmallVectorImpl &BundleList) {
-  // There is no need for a funclet operand bundle if we aren't inside a 
funclet.
+  // There is no need for a funclet operand bundle if we aren't inside a
+  // funclet.
   if (!CurrentFuncletPad)
 return;
 
@@ -3098,8 +3097,7 @@ void CodeGenFunction::EmitNoreturnRuntim
   }
 }
 
-/// Emits a call or invoke instruction to the given nullary runtime
-/// function.
+/// Emits a call or invoke instruction to the given nullary runtime function.
 llvm::CallSite
 CodeGenFunction::EmitRuntimeCallOrInvoke(llvm::Value *callee,
  const Twine &name) {


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


Re: [PATCH] D16286: [clang-tidy] Readability check for redundant parenthesis in return expression.

2016-01-18 Thread Richard via cfe-commits
LegalizeAdulthood added inline comments.


Comment at: clang-tidy/readability/ReturnWithRedundantParensCheck.cpp:41-44
@@ +40,6 @@
+
+  // Complex expression can be surrounded by parenthesis for readability
+  if (isComplexExpression(ParenExpression->getSubExpr())) {
+return;
+  }
+

adek05 wrote:
> LegalizeAdulthood wrote:
> > Rather than using an ad-hoc heuristic, I'd rather the check just do it.
> > 
> > If we must have an ad-hoc heuristic, then we should have a configuration 
> > parameter that configures the metric `ChildrenCountThreshold`, where some 
> > value like `0` means "always do it" and this value should be the default 
> > value for this parameter.
> > 
> > If your return expression is so huge that you think you need extra 
> > parentheses to clarify something, then the problem isn't made any worse by 
> > removing the outer-most set of parentheses.  The real problem of 
> > readability is your huge expression.  Extracting subexpressions into a 
> > variable with an intention-revealing name is a better approach to 
> > readability.  This is beyond the scope of this check.
> So you prefer moving this logic into `check` function? I separated that for 
> the sake of readability. I do not mean that this is what we need. But for 
> example we could expand the `isComplexExpression` to allow for `return 
> (!*foo);` to be in parens (deep expression tree). I agree, that configuration 
> param makes sense in such case. Which way would you prefer it?
I don't see `return (!*foo);` as any clearer than `return !*foo;`.  It's the 
`!*` that is the source of the complexity and adding parens just makes it look 
even more complicated, so I would rather that clang-tidy just remove the 
parentheses always.

In this case, I would "do the simplest thing that could possibly work" and 
always remove the parentheses.

Specifically, in this changeset I'm proposing that the function 
`isComplexExpression` be removed and the `if` statement on lines 41-44 also be 
removed and that the check simply always removes the parentheses.


Comment at: clang-tidy/readability/ReturnWithRedundantParensCheck.cpp:50
@@ +49,3 @@
+  << FixItHint::CreateReplacement(LParenLoc, "");
+  diag(RParenLoc, "redundant ')' for expression in return statement")
+  << FixItHint::CreateReplacement(RParenLoc, "");

adek05 wrote:
> omtcyf0 wrote:
> > Both warnings correspond to the same issue. Therefore I'd suggest creating 
> > one warning only.
> I'll try to merge them.
What I would do is replace this with a single diagnostic:

```
diag(LParenLoc, "redundant parentheses for expression in return statement")
  << FixItHint::CreateReplacement(LParenLoc, "")
  << FixitHint::CreateReplacement(RParenLoc, "");
```

Also, I think the `FixitHint` stuff has a way of expressing a deletion directly 
instead of replace some text with empty string.


Comment at: test/clang-tidy/readability-return-with-redundant-parens.cpp:24
@@ +23,2 @@
+  return (1 + 2);
+}

Eugene.Zelenko wrote:
> adek05 wrote:
> > LegalizeAdulthood wrote:
> > > I don't know if it makes a difference, but I added a test case for:
> > > 
> > > ```
> > > return(1);
> > > ```
> > > 
> > > as well.  In that case we need to remove the parens but add a space 
> > > between the `return` and it's expression.
> > Yeah... that's an odd case. Ideally I would defer to clang-format here 
> > which could first add space between `return` and `(1)`, but since it is 
> > easy enough I could just always do `s/)/ /` since clang-format is expected 
> > to be run after clang-tidy anyway. Good catch!
> I encountered such statements in my work code base. Unfortunately I could not 
> use Clang-format, since we standardized on Artistic Style, and its default 
> didn't fix excessive spacing :-(
In general, I wouldn't want to rely on `clang-format` to pretty up the input to 
`clang-tidy` for exactly the reasons that there are many code bases where it is 
unacceptable to run `clang-format` on the code base.  At least not until 
`clang-format` subsumes all the functionality of other existing formatters (and 
it is far from that currently).

IMO, `clang-tidy` should be agnostic as to input formatting for what it can 
handle.


Repository:
  rL LLVM

http://reviews.llvm.org/D16286



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


[clang-tools-extra] r258098 - [clang-tidy] Fixed wording ("clang-tidy check", not "clang-tidy checker")

2016-01-18 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon Jan 18 16:51:09 2016
New Revision: 258098

URL: http://llvm.org/viewvc/llvm-project?rev=258098&view=rev
Log:
[clang-tidy] Fixed wording ("clang-tidy check", not "clang-tidy checker")

Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl03-c.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl54-cpp.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl59-cpp.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err61-cpp.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-fio38-c.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-oop11-cpp.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-namespaces.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-constructor-init.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-new-delete-overloads.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-non-copyable-objects.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-static-assert.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl03-c.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl03-c.rst?rev=258098&r1=258097&r2=258098&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl03-c.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl03-c.rst Mon Jan 18 
16:51:09 2016
@@ -5,5 +5,5 @@
 cert-dcl03-c
 
 
-The cert-dcl03-c checker is an alias, please see
+The cert-dcl03-c check is an alias, please see
 `misc-static-assert `_ for more information.

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl54-cpp.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl54-cpp.rst?rev=258098&r1=258097&r2=258098&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl54-cpp.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl54-cpp.rst Mon Jan 
18 16:51:09 2016
@@ -5,6 +5,6 @@
 cert-dcl54-cpp
 ==
 
-The cert-dcl54-cpp checker is an alias, please see
+The cert-dcl54-cpp check is an alias, please see
 `misc-new-delete-overloads `_ for more
 information.

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl59-cpp.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl59-cpp.rst?rev=258098&r1=258097&r2=258098&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl59-cpp.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl59-cpp.rst Mon Jan 
18 16:51:09 2016
@@ -5,5 +5,5 @@
 cert-dcl59-cpp
 ==
 
-The cert-dcl59-cpp checker is an alias, please see
+The cert-dcl59-cpp check is an alias, please see
 `google-build-namespaces `_ for more information.

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err61-cpp.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err61-cpp.rst?rev=258098&r1=258097&r2=258098&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err61-cpp.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err61-cpp.rst Mon Jan 
18 16:51:09 2016
@@ -5,6 +5,6 @@
 cert-err61-cpp
 ==
 
-The cert-err61-cpp checker is an alias, please see
+The cert-err61-cpp check is an alias, please see
 `misc-throw-by-value-catch-by-reference 
`_
 for more information.

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/cert-fio38-c.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cert-fio38-c.rst?rev=258098&r1=258097&r2=258098&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-fio38-c.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/cert-fio38-c.rst Mon Jan 18 
16:51:09 2016
@@ -5,6 +5,6 @@
 cert-fio38-c
 
 
-The cert-fio38-c checker is an alias, please see
+The cert-fio38-c check is an alias, please see
 `misc-non-copyable-objects `_ for more
 information.

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/cert-oop11-cpp.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cert-oop11-cpp.rst?rev=258098&r1=258097&r2=258098&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-oop11-cpp.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/cert-oop11-cpp.rst Mon 

Re: [clang-tools-extra] r258098 - [clang-tidy] Fixed wording ("clang-tidy check", not "clang-tidy checker")

2016-01-18 Thread Aaron Ballman via cfe-commits
On Mon, Jan 18, 2016 at 5:51 PM, Alexander Kornienko via cfe-commits
 wrote:
> Author: alexfh
> Date: Mon Jan 18 16:51:09 2016
> New Revision: 258098
>
> URL: http://llvm.org/viewvc/llvm-project?rev=258098&view=rev
> Log:
> [clang-tidy] Fixed wording ("clang-tidy check", not "clang-tidy checker")

Sorry about that -- community terminology can be hard to keep straight
sometimes. ;-)

~Aaron

>
> Modified:
> clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl03-c.rst
> clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl54-cpp.rst
> clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl59-cpp.rst
> clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err61-cpp.rst
> clang-tools-extra/trunk/docs/clang-tidy/checks/cert-fio38-c.rst
> clang-tools-extra/trunk/docs/clang-tidy/checks/cert-oop11-cpp.rst
> clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-namespaces.rst
> 
> clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-constructor-init.rst
> 
> clang-tools-extra/trunk/docs/clang-tidy/checks/misc-new-delete-overloads.rst
> 
> clang-tools-extra/trunk/docs/clang-tidy/checks/misc-non-copyable-objects.rst
> clang-tools-extra/trunk/docs/clang-tidy/checks/misc-static-assert.rst
> 
> clang-tools-extra/trunk/docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst
>
> Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl03-c.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl03-c.rst?rev=258098&r1=258097&r2=258098&view=diff
> ==
> --- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl03-c.rst (original)
> +++ clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl03-c.rst Mon Jan 
> 18 16:51:09 2016
> @@ -5,5 +5,5 @@
>  cert-dcl03-c
>  
>
> -The cert-dcl03-c checker is an alias, please see
> +The cert-dcl03-c check is an alias, please see
>  `misc-static-assert `_ for more information.
>
> Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl54-cpp.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl54-cpp.rst?rev=258098&r1=258097&r2=258098&view=diff
> ==
> --- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl54-cpp.rst 
> (original)
> +++ clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl54-cpp.rst Mon Jan 
> 18 16:51:09 2016
> @@ -5,6 +5,6 @@
>  cert-dcl54-cpp
>  ==
>
> -The cert-dcl54-cpp checker is an alias, please see
> +The cert-dcl54-cpp check is an alias, please see
>  `misc-new-delete-overloads `_ for more
>  information.
>
> Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl59-cpp.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl59-cpp.rst?rev=258098&r1=258097&r2=258098&view=diff
> ==
> --- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl59-cpp.rst 
> (original)
> +++ clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl59-cpp.rst Mon Jan 
> 18 16:51:09 2016
> @@ -5,5 +5,5 @@
>  cert-dcl59-cpp
>  ==
>
> -The cert-dcl59-cpp checker is an alias, please see
> +The cert-dcl59-cpp check is an alias, please see
>  `google-build-namespaces `_ for more 
> information.
>
> Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err61-cpp.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err61-cpp.rst?rev=258098&r1=258097&r2=258098&view=diff
> ==
> --- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err61-cpp.rst 
> (original)
> +++ clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err61-cpp.rst Mon Jan 
> 18 16:51:09 2016
> @@ -5,6 +5,6 @@
>  cert-err61-cpp
>  ==
>
> -The cert-err61-cpp checker is an alias, please see
> +The cert-err61-cpp check is an alias, please see
>  `misc-throw-by-value-catch-by-reference 
> `_
>  for more information.
>
> Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/cert-fio38-c.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cert-fio38-c.rst?rev=258098&r1=258097&r2=258098&view=diff
> ==
> --- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-fio38-c.rst (original)
> +++ clang-tools-extra/trunk/docs/clang-tidy/checks/cert-fio38-c.rst Mon Jan 
> 18 16:51:09 2016
> @@ -5,6 +5,6 @@
>  cert-fio38-c
>  
>
> -The cert-fio38-c checker is an alias, please see
> +The cert-fio38-c check is an alias, please see
>  `misc-non-copyable-objects `_ for more
>  information.
>
> Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/cert-oop11-cpp.rst
> 

Re: [libcxx] [PATCH] unordered_map: Avoid unnecessary mallocs when no insert occurs

2016-01-18 Thread Duncan P. N. Exon Smith via cfe-commits
ping

> On 2016-Jan-11, at 16:23, Duncan P. N. Exon Smith  
> wrote:
> 
> ping
> 
>> On 2016-Jan-04, at 12:37, Duncan P. N. Exon Smith  
>> wrote:
>> 
>> ping
>> 
>>> On 2015-Dec-17, at 13:56, Duncan P. N. Exon Smith  
>>> wrote:
>>> 
>>> 
 On 2015-Dec-16, at 14:42, Duncan P. N. Exon Smith  
 wrote:
 
 This is a follow-up to r239666: "Fix PR12999 - unordered_set::insert
 calls operator new when no insert occurs".  That fix didn't apply to
 `unordered_map` because unordered_map::value_type gets packed inside:
 --
 union __value_type {
 pair __nc;   // Only C++11 or higher.
 pair __cc; // Always.
 // Constructors...
 };
 --
 and the underlying __hash_table only knows about __value_type.
>>> 
>>> Sorry for the quick ping, but I realized this morning that my approach
>>> was still leaving mallocs on the table.
>>> 
>>> I've attached a new patch that handles more cases.
>>> 
>>> This patch should avoid unnecessary mallocs whenever the caller passes
>>> in a pair such that T is trivially convertible to key_type.
>>> 
>>> Since __hash_table's value_type is really *never* a pair (for
>>> unordered_map, it's a union of two pairs) the static dispatch is all in
>>> unordered_map.  It's doing this:
>>> - If the argument isn't a pair<>, alloc.
>>> - If argument.first can be referenced as const key_type&, don't alloc.
>>> - If argument.first can be trivially converted to key_type, don't
>>>  alloc.
>>> - Else alloc.
>>> 
>>> In the pre-C++11 world the caller has already converted to
>>> unordered_map::value_type.  We can always avoid the alloc.
>>> 
>>> To support all of this:
>>> - In C++03, __unordered_map_equal and __unordered_map_hasher need to
>>>  handle unordered_map::value_type.
>>> - In C++03, __hash_table::__insert_unique_value() now takes its
>>>  argument by template.
>>> - In C++11, __hash_table::__insert_unique_value() is now a one-liner
>>>  that forwards to __insert_unique_key_value() for the real work.
>>> - The versions of __hash_table::__construct_node() that take a
>>>  pre-computed hash have been renamed to __construct_node_hash(), and
>>>  these versions use perfect forwarding.
>>> 
>>> Most of the following still apply:
>>> 
 This is one of my first patches for libc++, and I'm not sure of a few
 things:
 - Did I successfully match the coding style?  (I'm kind of lost
 without clang-format TBH.)
 - Should I separate the change to __construct_node_hash() into a
 separate prep commit?  (I would if this were LLVM, but I'm not sure
 if the common practice is different for libc++.)
 - Most of the overloads I added to __unordered_map_hasher and
 __unordered_map_equal aren't actually used by
 __hash_table::__insert_unique_value().  Should I omit the unused
 ones?  (Again, for LLVM I would have omitted them.)
>>> 
>>> (For the updated patch, I went with the LLVM approach of only adding
>>> the used API.  It seems more appropriate in this case.)
>>> 
 After this I'll fix the same performance issue in std::map (and I
 assume std::set?).
>> 
>> <0001-unordered_map-Avoid-unnecessary-mallocs-when-no-i-v2.patch>
> 

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


[PATCH] D16307: [CUDA] Handle -O options (more) correctly.

2016-01-18 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added subscribers: jhen, echristo, cfe-commits.

Previously we'd crash the driver if you passed -O0.  Now we try to
handle all of clang's various optimization flags in a sane way.

http://reviews.llvm.org/D16307

Files:
  lib/Driver/Tools.cpp
  test/Driver/cuda-external-tools.cu

Index: test/Driver/cuda-external-tools.cu
===
--- test/Driver/cuda-external-tools.cu
+++ test/Driver/cuda-external-tools.cu
@@ -4,14 +4,31 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
 
-// Regular compile with -O2.
+// Regular compiles with -O{0,1,2,3,4,fast}.  -O4 and -Ofast map to ptxas O3.
+// RUN: %clang -### -target x86_64-linux-gnu -O0 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT0 
%s
+// RUN: %clang -### -target x86_64-linux-gnu -O1 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT1 
%s
 // RUN: %clang -### -target x86_64-linux-gnu -O2 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT2 
%s
+// RUN: %clang -### -target x86_64-linux-gnu -O3 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT3 
%s
+// RUN: %clang -### -target x86_64-linux-gnu -O4 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT3 
%s
+// RUN: %clang -### -target x86_64-linux-gnu -Ofast -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT3 
%s
 
 // Regular compile without -O.  This should result in us passing -O0 to ptxas.
 // RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT0 
%s
 
+// Regular compiles with -Os and -Oz.  For lack of a better option, we map
+// these to ptxas -O3.
+// RUN: %clang -### -target x86_64-linux-gnu -Os -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT3 
%s
+// RUN: %clang -### -target x86_64-linux-gnu -Oz -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT3 
%s
+
 // Regular compile targeting sm_35.
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM35 %s
@@ -42,7 +59,9 @@
 // ARCH64: "-m64"
 // ARCH32: "-m32"
 // OPT0: "-O0"
+// OPT1: "-O1"
 // OPT2: "-O2"
+// OPT3: "-O3"
 // SM20: "--gpu-name" "sm_20"
 // SM35: "--gpu-name" "sm_35"
 // SM20: "--output-file" "[[CUBINFILE:[^"]*]]"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -10645,10 +10645,34 @@
   ArgStringList CmdArgs;
   CmdArgs.push_back(TC.getTriple().isArch64Bit() ? "-m64" : "-m32");
 
-  // Clang's default optimization level is -O0, but ptxas's default is -O3.
-  CmdArgs.push_back(Args.MakeArgString(
-  llvm::Twine("-O") +
-  Args.getLastArgValue(options::OPT_O_Group, "0").data()));
+  // Map the -O we received to -O{0,1,2,3}.
+  //
+  // TODO: Perhaps we should map host -O2 to ptxas -O3. -O3 is ptxas's default,
+  // so it may correspond more closely to the spirit of clang -O2.
+  if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
+// -O3 seems like the least-bad option when -Osomething is specified to
+// clang but it isn't handled above.
+StringRef OOpt = "3";
+if (A->getOption().matches(options::OPT_O4) ||
+A->getOption().matches(options::OPT_Ofast))
+  OOpt = "3";
+else if (A->getOption().matches(options::OPT_O0))
+  OOpt = "0";
+else if (A->getOption().matches(options::OPT_O)) {
+  // -Os, -Oz, and -O(anything else) map to -O3, for lack of better 
options.
+  OOpt = llvm::StringSwitch(A->getValue())
+ .Case("1", "1")
+ .Case("2", "2")
+ .Case("s", "3")
+ .Case("z", "3")
+ .Default("3");
+}
+CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-O") + OOpt));
+  } else {
+// If no -O was passed, pass -O0 to ptxas -- no opt flag should correspond
+// to no optimizations, but ptxas's default is -O3.
+CmdArgs.push_back("-O0");
+  }
 
   // Don't bother passing -g to ptxas: It's enabled by default at -O0, and
   // not supported at other optimization levels.


Index: test/Driver/cuda-external-tools.cu
===
--- test/Driver/cuda-external-tools.cu
+++ test/Driver/cuda-external-tools.cu
@@ -4,14 +4,31 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
 
-// Regular compile with -O2.
+// Regular compiles with -O{0,1,2,3,4,fast}.  -O4 and -Ofast map to ptxas O3.
+// RUN: %clang -### -target x86_64-linux-gnu -O0 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix S

Re: [PATCH] D16307: [CUDA] Handle -O options (more) correctly.

2016-01-18 Thread Eric Christopher via cfe-commits
At a quick glance Os and Oz should probably map to O2.

On Mon, Jan 18, 2016, 4:19 PM Justin Lebar  wrote:

> jlebar created this revision.
> jlebar added a reviewer: tra.
> jlebar added subscribers: jhen, echristo, cfe-commits.
>
> Previously we'd crash the driver if you passed -O0.  Now we try to
> handle all of clang's various optimization flags in a sane way.
>
> http://reviews.llvm.org/D16307
>
> Files:
>   lib/Driver/Tools.cpp
>   test/Driver/cuda-external-tools.cu
>
> Index: test/Driver/cuda-external-tools.cu
> ===
> --- test/Driver/cuda-external-tools.cu
> +++ test/Driver/cuda-external-tools.cu
> @@ -4,14 +4,31 @@
>  // REQUIRES: x86-registered-target
>  // REQUIRES: nvptx-registered-target
>
> -// Regular compile with -O2.
> +// Regular compiles with -O{0,1,2,3,4,fast}.  -O4 and -Ofast map to ptxas
> O3.
> +// RUN: %clang -### -target x86_64-linux-gnu -O0 -c %s 2>&1 \
> +// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix
> OPT0 %s
> +// RUN: %clang -### -target x86_64-linux-gnu -O1 -c %s 2>&1 \
> +// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix
> OPT1 %s
>  // RUN: %clang -### -target x86_64-linux-gnu -O2 -c %s 2>&1 \
>  // RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix
> OPT2 %s
> +// RUN: %clang -### -target x86_64-linux-gnu -O3 -c %s 2>&1 \
> +// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix
> OPT3 %s
> +// RUN: %clang -### -target x86_64-linux-gnu -O4 -c %s 2>&1 \
> +// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix
> OPT3 %s
> +// RUN: %clang -### -target x86_64-linux-gnu -Ofast -c %s 2>&1 \
> +// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix
> OPT3 %s
>
>  // Regular compile without -O.  This should result in us passing -O0 to
> ptxas.
>  // RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
>  // RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix
> OPT0 %s
>
> +// Regular compiles with -Os and -Oz.  For lack of a better option, we map
> +// these to ptxas -O3.
> +// RUN: %clang -### -target x86_64-linux-gnu -Os -c %s 2>&1 \
> +// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix
> OPT3 %s
> +// RUN: %clang -### -target x86_64-linux-gnu -Oz -c %s 2>&1 \
> +// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix
> OPT3 %s
> +
>  // Regular compile targeting sm_35.
>  // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s
> 2>&1 \
>  // RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM35 %s
> @@ -42,7 +59,9 @@
>  // ARCH64: "-m64"
>  // ARCH32: "-m32"
>  // OPT0: "-O0"
> +// OPT1: "-O1"
>  // OPT2: "-O2"
> +// OPT3: "-O3"
>  // SM20: "--gpu-name" "sm_20"
>  // SM35: "--gpu-name" "sm_35"
>  // SM20: "--output-file" "[[CUBINFILE:[^"]*]]"
> Index: lib/Driver/Tools.cpp
> ===
> --- lib/Driver/Tools.cpp
> +++ lib/Driver/Tools.cpp
> @@ -10645,10 +10645,34 @@
>ArgStringList CmdArgs;
>CmdArgs.push_back(TC.getTriple().isArch64Bit() ? "-m64" : "-m32");
>
> -  // Clang's default optimization level is -O0, but ptxas's default is
> -O3.
> -  CmdArgs.push_back(Args.MakeArgString(
> -  llvm::Twine("-O") +
> -  Args.getLastArgValue(options::OPT_O_Group, "0").data()));
> +  // Map the -O we received to -O{0,1,2,3}.
> +  //
> +  // TODO: Perhaps we should map host -O2 to ptxas -O3. -O3 is ptxas's
> default,
> +  // so it may correspond more closely to the spirit of clang -O2.
> +  if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
> +// -O3 seems like the least-bad option when -Osomething is specified
> to
> +// clang but it isn't handled above.
> +StringRef OOpt = "3";
> +if (A->getOption().matches(options::OPT_O4) ||
> +A->getOption().matches(options::OPT_Ofast))
> +  OOpt = "3";
> +else if (A->getOption().matches(options::OPT_O0))
> +  OOpt = "0";
> +else if (A->getOption().matches(options::OPT_O)) {
> +  // -Os, -Oz, and -O(anything else) map to -O3, for lack of better
> options.
> +  OOpt = llvm::StringSwitch(A->getValue())
> + .Case("1", "1")
> + .Case("2", "2")
> + .Case("s", "3")
> + .Case("z", "3")
> + .Default("3");
> +}
> +CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-O") + OOpt));
> +  } else {
> +// If no -O was passed, pass -O0 to ptxas -- no opt flag should
> correspond
> +// to no optimizations, but ptxas's default is -O3.
> +CmdArgs.push_back("-O0");
> +  }
>
>// Don't bother passing -g to ptxas: It's enabled by default at -O0, and
>// not supported at other optimization levels.
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r258106 - Fix local variable name /NFC

2016-01-18 Thread Xinliang David Li via cfe-commits
Author: davidxl
Date: Mon Jan 18 18:49:06 2016
New Revision: 258106

URL: http://llvm.org/viewvc/llvm-project?rev=258106&view=rev
Log:
Fix local variable name /NFC

Modified:
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
cfe/trunk/lib/CodeGen/CoverageMappingGen.h

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=258106&r1=258105&r2=258106&view=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Mon Jan 18 18:49:06 2016
@@ -911,7 +911,7 @@ static void dump(llvm::raw_ostream &OS,
 
 void CoverageMappingModuleGen::addFunctionMappingRecord(
 llvm::GlobalVariable *NamePtr, StringRef NameValue, uint64_t FuncHash,
-const std::string &CoverageMapping, bool isUsed) {
+const std::string &CoverageMapping, bool IsUsed) {
   llvm::LLVMContext &Ctx = CGM.getLLVMContext();
   if (!FunctionRecordTy) {
 #define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Init) LLVMType,
@@ -929,7 +929,7 @@ void CoverageMappingModuleGen::addFuncti
   };
   FunctionRecords.push_back(llvm::ConstantStruct::get(
   FunctionRecordTy, makeArrayRef(FunctionRecordVals)));
-  if (!isUsed)
+  if (!IsUsed)
 FunctionNames.push_back(
 llvm::ConstantExpr::getBitCast(NamePtr, 
llvm::Type::getInt8PtrTy(Ctx)));
   CoverageMappings += CoverageMapping;

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.h?rev=258106&r1=258105&r2=258106&view=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.h (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.h Mon Jan 18 18:49:06 2016
@@ -72,7 +72,7 @@ public:
 StringRef FunctionNameValue,
 uint64_t FunctionHash,
 const std::string &CoverageMapping,
-bool isUsed = true);
+bool IsUsed = true);
 
   /// \brief Emit the coverage mapping data for a translation unit.
   void emit();


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


[libcxx] r258107 - Fix PR#26175. Thanks to Josh Petrie for the report and the patch. Reviewed as http://reviews.llvm.org/D16262

2016-01-18 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Jan 18 18:50:37 2016
New Revision: 258107

URL: http://llvm.org/viewvc/llvm-project?rev=258107&view=rev
Log:
Fix PR#26175. Thanks to Josh Petrie for the report and the patch. Reviewed as 
http://reviews.llvm.org/D16262

Modified:
libcxx/trunk/include/regex
libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp

Modified: libcxx/trunk/include/regex
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/regex?rev=258107&r1=258106&r2=258107&view=diff
==
--- libcxx/trunk/include/regex (original)
+++ libcxx/trunk/include/regex Mon Jan 18 18:50:37 2016
@@ -4265,6 +4265,9 @@ basic_regex<_CharT, _Traits>::__parse_at
 if (__first != __last && *__first == '\\')
 {
 _ForwardIterator __t1 = _VSTD::next(__first);
+if (__t1 == __last)
+__throw_regex_error();
+
 _ForwardIterator __t2 = __parse_decimal_escape(__t1, __last);
 if (__t2 != __t1)
 __first = __t2;

Modified: 
libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp?rev=258107&r1=258106&r2=258107&view=diff
==
--- libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp 
(original)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp 
Mon Jan 18 18:50:37 2016
@@ -33,6 +33,7 @@ int main()
 {
 assert(error_escape_thrown("[\\a]"));
 assert(error_escape_thrown("\\a"));
+assert(error_escape_thrown("\\"));
 
 assert(error_escape_thrown("[\\e]"));
 assert(error_escape_thrown("\\e"));


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


Re: [PATCH] D15853: [PGO]: Simplify coverage data lowering code

2016-01-18 Thread David Li via cfe-commits
davidxl added a comment.

I missed the review comments earlier.

The local var name is fixed. The getCoverageNamesVarName API name will be fixed 
later.

Regarding to your question:  the patch does not not change the behavior of the 
name handling. For all used functions, their names are handled in regular 
lowering procedure (getOrCreateRegionCounter) so their names will be skipped by 
lowerCoverageData actually.


http://reviews.llvm.org/D15853



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


Re: [clang-tools-extra] r258098 - [clang-tidy] Fixed wording ("clang-tidy check", not "clang-tidy checker")

2016-01-18 Thread Alexander Kornienko via cfe-commits
No worries, I reviewed at least some of these changes and haven't found the
issues, but was later pointed to them by a community member ;)

On Mon, Jan 18, 2016 at 11:58 PM, Aaron Ballman 
wrote:

> On Mon, Jan 18, 2016 at 5:51 PM, Alexander Kornienko via cfe-commits
>  wrote:
> > Author: alexfh
> > Date: Mon Jan 18 16:51:09 2016
> > New Revision: 258098
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=258098&view=rev
> > Log:
> > [clang-tidy] Fixed wording ("clang-tidy check", not "clang-tidy checker")
>
> Sorry about that -- community terminology can be hard to keep straight
> sometimes. ;-)
>
> ~Aaron
>
> >
> > Modified:
> > clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl03-c.rst
> > clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl54-cpp.rst
> > clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl59-cpp.rst
> > clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err61-cpp.rst
> > clang-tools-extra/trunk/docs/clang-tidy/checks/cert-fio38-c.rst
> > clang-tools-extra/trunk/docs/clang-tidy/checks/cert-oop11-cpp.rst
> >
>  clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-namespaces.rst
> >
>  clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-constructor-init.rst
> >
>  clang-tools-extra/trunk/docs/clang-tidy/checks/misc-new-delete-overloads.rst
> >
>  clang-tools-extra/trunk/docs/clang-tidy/checks/misc-non-copyable-objects.rst
> > clang-tools-extra/trunk/docs/clang-tidy/checks/misc-static-assert.rst
> >
>  
> clang-tools-extra/trunk/docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst
> >
> > Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl03-c.rst
> > URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl03-c.rst?rev=258098&r1=258097&r2=258098&view=diff
> >
> ==
> > --- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl03-c.rst
> (original)
> > +++ clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl03-c.rst Mon
> Jan 18 16:51:09 2016
> > @@ -5,5 +5,5 @@
> >  cert-dcl03-c
> >  
> >
> > -The cert-dcl03-c checker is an alias, please see
> > +The cert-dcl03-c check is an alias, please see
> >  `misc-static-assert `_ for more information.
> >
> > Modified:
> clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl54-cpp.rst
> > URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl54-cpp.rst?rev=258098&r1=258097&r2=258098&view=diff
> >
> ==
> > --- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl54-cpp.rst
> (original)
> > +++ clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl54-cpp.rst
> Mon Jan 18 16:51:09 2016
> > @@ -5,6 +5,6 @@
> >  cert-dcl54-cpp
> >  ==
> >
> > -The cert-dcl54-cpp checker is an alias, please see
> > +The cert-dcl54-cpp check is an alias, please see
> >  `misc-new-delete-overloads `_ for more
> >  information.
> >
> > Modified:
> clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl59-cpp.rst
> > URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl59-cpp.rst?rev=258098&r1=258097&r2=258098&view=diff
> >
> ==
> > --- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl59-cpp.rst
> (original)
> > +++ clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl59-cpp.rst
> Mon Jan 18 16:51:09 2016
> > @@ -5,5 +5,5 @@
> >  cert-dcl59-cpp
> >  ==
> >
> > -The cert-dcl59-cpp checker is an alias, please see
> > +The cert-dcl59-cpp check is an alias, please see
> >  `google-build-namespaces `_ for more
> information.
> >
> > Modified:
> clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err61-cpp.rst
> > URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err61-cpp.rst?rev=258098&r1=258097&r2=258098&view=diff
> >
> ==
> > --- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err61-cpp.rst
> (original)
> > +++ clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err61-cpp.rst
> Mon Jan 18 16:51:09 2016
> > @@ -5,6 +5,6 @@
> >  cert-err61-cpp
> >  ==
> >
> > -The cert-err61-cpp checker is an alias, please see
> > +The cert-err61-cpp check is an alias, please see
> >  `misc-throw-by-value-catch-by-reference
> `_
> >  for more information.
> >
> > Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/cert-fio38-c.rst
> > URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cert-fio38-c.rst?rev=258098&r1=258097&r2=258098&view=diff
> >
> ==
> > --- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-fio38-c.rst
> (original)
> > +++ clang-tools-extra/trun

Re: r226298 - [AVX512] Add intrinsics for masked aligned FP loads and stores

2016-01-18 Thread Hal Finkel via cfe-commits
- Original Message -
> From: "Adam Nemet" 
> To: cfe-comm...@cs.uiuc.edu
> Sent: Friday, January 16, 2015 12:51:50 PM
> Subject: r226298 - [AVX512] Add intrinsics for masked aligned FP loads and
> stores
> 
> Author: anemet
> Date: Fri Jan 16 12:51:50 2015
> New Revision: 226298
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=226298&view=rev
> Log:
> [AVX512] Add intrinsics for masked aligned FP loads and stores
> 
> Part of 
> 
> Modified:
> cfe/trunk/include/clang/Basic/BuiltinsX86.def
> cfe/trunk/lib/Headers/avx512fintrin.h
> cfe/trunk/test/CodeGen/avx512f-builtins.c
> 
> Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=226298&r1=226297&r2=226298&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
> +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Fri Jan 16 12:51:50
> 2015
> @@ -897,11 +897,15 @@ BUILTIN(__builtin_ia32_pbroadcastq512_me
>  BUILTIN(__builtin_ia32_loaddqusi512_mask, "V16ivC*V16iUs", "")
>  BUILTIN(__builtin_ia32_loaddqudi512_mask, "V8LLivC*V8LLiUc", "")
>  BUILTIN(__builtin_ia32_loadups512_mask, "V16fvC*V16fUs", "")
> +BUILTIN(__builtin_ia32_loadaps512_mask, "V16fvC*V16fUs", "")
>  BUILTIN(__builtin_ia32_loadupd512_mask, "V8dvC*V8dUc", "")
> +BUILTIN(__builtin_ia32_loadapd512_mask, "V8dvC*V8dUc", "")
>  BUILTIN(__builtin_ia32_storedqudi512_mask, "vv*V8LLiUc", "")
>  BUILTIN(__builtin_ia32_storedqusi512_mask, "vv*V16iUs", "")
>  BUILTIN(__builtin_ia32_storeupd512_mask, "vv*V8dUc", "")
> +BUILTIN(__builtin_ia32_storeapd512_mask, "vv*V8dUc", "")
>  BUILTIN(__builtin_ia32_storeups512_mask, "vv*V16fUs", "")
> +BUILTIN(__builtin_ia32_storeaps512_mask, "vv*V16fUs", "")
>  BUILTIN(__builtin_ia32_vpermt2vard512_mask, "V16iV16iV16iV16iUs",
>  "")
>  BUILTIN(__builtin_ia32_vpermt2varq512_mask,
>  "V8LLiV8LLiV8LLiV8LLiUc", "")
>  BUILTIN(__builtin_ia32_vpermt2varps512_mask, "V16fV16iV16fV16fUs",
>  "")
> 
> Modified: cfe/trunk/lib/Headers/avx512fintrin.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=226298&r1=226297&r2=226298&view=diff
> ==
> --- cfe/trunk/lib/Headers/avx512fintrin.h (original)
> +++ cfe/trunk/lib/Headers/avx512fintrin.h Fri Jan 16 12:51:50 2015
> @@ -928,6 +928,24 @@ _mm512_maskz_loadu_pd(__mmask8 __U, void
> (__mmask8) __U);
>  }
>  
> +static __inline __m512 __attribute__ ((__always_inline__,
> __nodebug__))
> +_mm512_maskz_load_ps(__mmask16 __U, void const *__P)
> +{
> +  return (__m512) __builtin_ia32_loadaps512_mask ((const __v16sf
> *)__P,
> +  (__v16sf)
> +  _mm512_setzero_ps
> (),
> +  (__mmask16) __U);
> +}
> +
> +static __inline __m512d __attribute__ ((__always_inline__,
> __nodebug__))
> +_mm512_maskz_load_pd(__mmask8 __U, void const *__P)
> +{
> +  return (__m512d) __builtin_ia32_loadapd512_mask ((const __v8df
> *)__P,
> +   (__v8df)
> +   _mm512_setzero_pd
> (),
> +   (__mmask8) __U);
> +}
> +
>  static __inline __m512d __attribute__((__always_inline__,
>  __nodebug__))
>  _mm512_loadu_pd(double const *__p)
>  {
> @@ -946,6 +964,24 @@ _mm512_loadu_ps(float const *__p)
>return ((struct __loadu_ps*)__p)->__v;
>  }
>  
> +static __inline __m512 __attribute__((__always_inline__,
> __nodebug__))
> +_mm512_load_ps(double const *__p)
> +{
> +  return (__m512) __builtin_ia32_loadaps512_mask ((const __v16sf
> *)__p,
> +  (__v16sf)
> +  _mm512_setzero_ps
> (),
> +  (__mmask16) -1);
> +}
> +
> +static __inline __m512d __attribute__((__always_inline__,
> __nodebug__))
> +_mm512_load_pd(float const *__p)

Shouldn't this one take a 'double const *' and the one above take a 'float 
const *'?

 -Hal

> +{
> +  return (__m512d) __builtin_ia32_loadapd512_mask ((const __v8df
> *)__p,
> +   (__v8df)
> +   _mm512_setzero_pd
> (),
> +   (__mmask8) -1);
> +}
> +
>  /* SIMD store ops */
>  
>  static __inline void __attribute__ ((__always_inline__,
>  __nodebug__))
> @@ -988,9 +1024,9 @@ _mm512_storeu_ps(void *__P, __m512 __A)
>  }
>  
>  static __inline void __attribute__ ((__always_inline__,
>  __nodebug__))
> -_mm512_store_ps(void *__P, __m512 __A)
> +_mm512_mask_store_pd(void *__P, __mmask8 __U, __m512d __A)
>  {
> -  *(__m512*

Re: [PATCH] D16307: [CUDA] Handle -O options (more) correctly.

2016-01-18 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 45222.
jlebar added a comment.

Map -Os, -Oz to -O2, rather than -O3.


http://reviews.llvm.org/D16307

Files:
  lib/Driver/Tools.cpp
  test/Driver/cuda-external-tools.cu

Index: test/Driver/cuda-external-tools.cu
===
--- test/Driver/cuda-external-tools.cu
+++ test/Driver/cuda-external-tools.cu
@@ -4,14 +4,31 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
 
-// Regular compile with -O2.
+// Regular compiles with -O{0,1,2,3,4,fast}.  -O4 and -Ofast map to ptxas O3.
+// RUN: %clang -### -target x86_64-linux-gnu -O0 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT0 
%s
+// RUN: %clang -### -target x86_64-linux-gnu -O1 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT1 
%s
 // RUN: %clang -### -target x86_64-linux-gnu -O2 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT2 
%s
+// RUN: %clang -### -target x86_64-linux-gnu -O3 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT3 
%s
+// RUN: %clang -### -target x86_64-linux-gnu -O4 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT3 
%s
+// RUN: %clang -### -target x86_64-linux-gnu -Ofast -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT3 
%s
 
 // Regular compile without -O.  This should result in us passing -O0 to ptxas.
 // RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT0 
%s
 
+// Regular compiles with -Os and -Oz.  For lack of a better option, we map
+// these to ptxas -O3.
+// RUN: %clang -### -target x86_64-linux-gnu -Os -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT2 
%s
+// RUN: %clang -### -target x86_64-linux-gnu -Oz -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT2 
%s
+
 // Regular compile targeting sm_35.
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM35 %s
@@ -42,7 +59,9 @@
 // ARCH64: "-m64"
 // ARCH32: "-m32"
 // OPT0: "-O0"
+// OPT1: "-O1"
 // OPT2: "-O2"
+// OPT3: "-O3"
 // SM20: "--gpu-name" "sm_20"
 // SM35: "--gpu-name" "sm_35"
 // SM20: "--output-file" "[[CUBINFILE:[^"]*]]"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -10645,10 +10645,35 @@
   ArgStringList CmdArgs;
   CmdArgs.push_back(TC.getTriple().isArch64Bit() ? "-m64" : "-m32");
 
-  // Clang's default optimization level is -O0, but ptxas's default is -O3.
-  CmdArgs.push_back(Args.MakeArgString(
-  llvm::Twine("-O") +
-  Args.getLastArgValue(options::OPT_O_Group, "0").data()));
+  // Map the -O we received to -O{0,1,2,3}.
+  //
+  // TODO: Perhaps we should map host -O2 to ptxas -O3. -O3 is ptxas's default,
+  // so it may correspond more closely to the spirit of clang -O2.
+  if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
+// -O3 seems like the least-bad option when -Osomething is specified to
+// clang but it isn't handled above.
+StringRef OOpt = "3";
+if (A->getOption().matches(options::OPT_O4) ||
+A->getOption().matches(options::OPT_Ofast))
+  OOpt = "3";
+else if (A->getOption().matches(options::OPT_O0))
+  OOpt = "0";
+else if (A->getOption().matches(options::OPT_O)) {
+  // -Os, -Oz, and -O(anything else) map to -O3, for lack of better 
options.
+  OOpt = llvm::StringSwitch(A->getValue())
+ .Case("1", "1")
+ .Case("2", "2")
+ .Case("3", "3")
+ .Case("s", "2")
+ .Case("z", "2")
+ .Default("2");
+}
+CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-O") + OOpt));
+  } else {
+// If no -O was passed, pass -O0 to ptxas -- no opt flag should correspond
+// to no optimizations, but ptxas's default is -O3.
+CmdArgs.push_back("-O0");
+  }
 
   // Don't bother passing -g to ptxas: It's enabled by default at -O0, and
   // not supported at other optimization levels.


Index: test/Driver/cuda-external-tools.cu
===
--- test/Driver/cuda-external-tools.cu
+++ test/Driver/cuda-external-tools.cu
@@ -4,14 +4,31 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
 
-// Regular compile with -O2.
+// Regular compiles with -O{0,1,2,3,4,fast}.  -O4 and -Ofast map to ptxas O3.
+// RUN: %clang -### -target x86_64-linux-gnu -O0 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT0 %s
+// RUN: %clang -### -target x86_64-linux-gnu -O1 -c %s 2>&1 \
+// RUN: | FileC

Re: [PATCH] D16307: [CUDA] Handle -O options (more) correctly.

2016-01-18 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 45223.
jlebar added a comment.

Update comment


http://reviews.llvm.org/D16307

Files:
  lib/Driver/Tools.cpp
  test/Driver/cuda-external-tools.cu

Index: test/Driver/cuda-external-tools.cu
===
--- test/Driver/cuda-external-tools.cu
+++ test/Driver/cuda-external-tools.cu
@@ -4,14 +4,31 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
 
-// Regular compile with -O2.
+// Regular compiles with -O{0,1,2,3,4,fast}.  -O4 and -Ofast map to ptxas O3.
+// RUN: %clang -### -target x86_64-linux-gnu -O0 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT0 
%s
+// RUN: %clang -### -target x86_64-linux-gnu -O1 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT1 
%s
 // RUN: %clang -### -target x86_64-linux-gnu -O2 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT2 
%s
+// RUN: %clang -### -target x86_64-linux-gnu -O3 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT3 
%s
+// RUN: %clang -### -target x86_64-linux-gnu -O4 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT3 
%s
+// RUN: %clang -### -target x86_64-linux-gnu -Ofast -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT3 
%s
 
 // Regular compile without -O.  This should result in us passing -O0 to ptxas.
 // RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT0 
%s
 
+// Regular compiles with -Os and -Oz.  For lack of a better option, we map
+// these to ptxas -O3.
+// RUN: %clang -### -target x86_64-linux-gnu -Os -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT2 
%s
+// RUN: %clang -### -target x86_64-linux-gnu -Oz -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT2 
%s
+
 // Regular compile targeting sm_35.
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM35 %s
@@ -42,7 +59,9 @@
 // ARCH64: "-m64"
 // ARCH32: "-m32"
 // OPT0: "-O0"
+// OPT1: "-O1"
 // OPT2: "-O2"
+// OPT3: "-O3"
 // SM20: "--gpu-name" "sm_20"
 // SM35: "--gpu-name" "sm_35"
 // SM20: "--output-file" "[[CUBINFILE:[^"]*]]"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -10645,10 +10645,35 @@
   ArgStringList CmdArgs;
   CmdArgs.push_back(TC.getTriple().isArch64Bit() ? "-m64" : "-m32");
 
-  // Clang's default optimization level is -O0, but ptxas's default is -O3.
-  CmdArgs.push_back(Args.MakeArgString(
-  llvm::Twine("-O") +
-  Args.getLastArgValue(options::OPT_O_Group, "0").data()));
+  // Map the -O we received to -O{0,1,2,3}.
+  //
+  // TODO: Perhaps we should map host -O2 to ptxas -O3. -O3 is ptxas's default,
+  // so it may correspond more closely to the spirit of clang -O2.
+  if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
+// -O3 seems like the least-bad option when -Osomething is specified to
+// clang but it isn't handled above.
+StringRef OOpt = "3";
+if (A->getOption().matches(options::OPT_O4) ||
+A->getOption().matches(options::OPT_Ofast))
+  OOpt = "3";
+else if (A->getOption().matches(options::OPT_O0))
+  OOpt = "0";
+else if (A->getOption().matches(options::OPT_O)) {
+  // -Os, -Oz, and -O(anything else) map to -O2, for lack of better 
options.
+  OOpt = llvm::StringSwitch(A->getValue())
+ .Case("1", "1")
+ .Case("2", "2")
+ .Case("3", "3")
+ .Case("s", "2")
+ .Case("z", "2")
+ .Default("2");
+}
+CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-O") + OOpt));
+  } else {
+// If no -O was passed, pass -O0 to ptxas -- no opt flag should correspond
+// to no optimizations, but ptxas's default is -O3.
+CmdArgs.push_back("-O0");
+  }
 
   // Don't bother passing -g to ptxas: It's enabled by default at -O0, and
   // not supported at other optimization levels.


Index: test/Driver/cuda-external-tools.cu
===
--- test/Driver/cuda-external-tools.cu
+++ test/Driver/cuda-external-tools.cu
@@ -4,14 +4,31 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
 
-// Regular compile with -O2.
+// Regular compiles with -O{0,1,2,3,4,fast}.  -O4 and -Ofast map to ptxas O3.
+// RUN: %clang -### -target x86_64-linux-gnu -O0 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT0 %s
+// RUN: %clang -### -target x86_64-linux-gnu -O1 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH

Re: [PATCH] D16264: For FreeBSD, use _p variants of libraries for linking C++ programs

2016-01-18 Thread David Sanderson via cfe-commits
dws added a comment.

I will try this out on a system running FreeBSD HEAD (as of r294306) and see 
how it does.


http://reviews.llvm.org/D16264



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


Re: r226298 - [AVX512] Add intrinsics for masked aligned FP loads and stores

2016-01-18 Thread Adam Nemet via cfe-commits

> On Jan 18, 2016, at 5:28 PM, Hal Finkel  wrote:
> 
> - Original Message -
>> From: "Adam Nemet" 
>> To: cfe-comm...@cs.uiuc.edu
>> Sent: Friday, January 16, 2015 12:51:50 PM
>> Subject: r226298 - [AVX512] Add intrinsics for masked aligned FP loads and   
>> stores
>> 
>> Author: anemet
>> Date: Fri Jan 16 12:51:50 2015
>> New Revision: 226298
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=226298&view=rev
>> Log:
>> [AVX512] Add intrinsics for masked aligned FP loads and stores
>> 
>> Part of 
>> 
>> Modified:
>>cfe/trunk/include/clang/Basic/BuiltinsX86.def
>>cfe/trunk/lib/Headers/avx512fintrin.h
>>cfe/trunk/test/CodeGen/avx512f-builtins.c
>> 
>> Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=226298&r1=226297&r2=226298&view=diff
>> ==
>> --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
>> +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Fri Jan 16 12:51:50
>> 2015
>> @@ -897,11 +897,15 @@ BUILTIN(__builtin_ia32_pbroadcastq512_me
>> BUILTIN(__builtin_ia32_loaddqusi512_mask, "V16ivC*V16iUs", "")
>> BUILTIN(__builtin_ia32_loaddqudi512_mask, "V8LLivC*V8LLiUc", "")
>> BUILTIN(__builtin_ia32_loadups512_mask, "V16fvC*V16fUs", "")
>> +BUILTIN(__builtin_ia32_loadaps512_mask, "V16fvC*V16fUs", "")
>> BUILTIN(__builtin_ia32_loadupd512_mask, "V8dvC*V8dUc", "")
>> +BUILTIN(__builtin_ia32_loadapd512_mask, "V8dvC*V8dUc", "")
>> BUILTIN(__builtin_ia32_storedqudi512_mask, "vv*V8LLiUc", "")
>> BUILTIN(__builtin_ia32_storedqusi512_mask, "vv*V16iUs", "")
>> BUILTIN(__builtin_ia32_storeupd512_mask, "vv*V8dUc", "")
>> +BUILTIN(__builtin_ia32_storeapd512_mask, "vv*V8dUc", "")
>> BUILTIN(__builtin_ia32_storeups512_mask, "vv*V16fUs", "")
>> +BUILTIN(__builtin_ia32_storeaps512_mask, "vv*V16fUs", "")
>> BUILTIN(__builtin_ia32_vpermt2vard512_mask, "V16iV16iV16iV16iUs",
>> "")
>> BUILTIN(__builtin_ia32_vpermt2varq512_mask,
>> "V8LLiV8LLiV8LLiV8LLiUc", "")
>> BUILTIN(__builtin_ia32_vpermt2varps512_mask, "V16fV16iV16fV16fUs",
>> "")
>> 
>> Modified: cfe/trunk/lib/Headers/avx512fintrin.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=226298&r1=226297&r2=226298&view=diff
>> ==
>> --- cfe/trunk/lib/Headers/avx512fintrin.h (original)
>> +++ cfe/trunk/lib/Headers/avx512fintrin.h Fri Jan 16 12:51:50 2015
>> @@ -928,6 +928,24 @@ _mm512_maskz_loadu_pd(__mmask8 __U, void
>>(__mmask8) __U);
>> }
>> 
>> +static __inline __m512 __attribute__ ((__always_inline__,
>> __nodebug__))
>> +_mm512_maskz_load_ps(__mmask16 __U, void const *__P)
>> +{
>> +  return (__m512) __builtin_ia32_loadaps512_mask ((const __v16sf
>> *)__P,
>> +  (__v16sf)
>> +  _mm512_setzero_ps
>> (),
>> +  (__mmask16) __U);
>> +}
>> +
>> +static __inline __m512d __attribute__ ((__always_inline__,
>> __nodebug__))
>> +_mm512_maskz_load_pd(__mmask8 __U, void const *__P)
>> +{
>> +  return (__m512d) __builtin_ia32_loadapd512_mask ((const __v8df
>> *)__P,
>> +   (__v8df)
>> +   _mm512_setzero_pd
>> (),
>> +   (__mmask8) __U);
>> +}
>> +
>> static __inline __m512d __attribute__((__always_inline__,
>> __nodebug__))
>> _mm512_loadu_pd(double const *__p)
>> {
>> @@ -946,6 +964,24 @@ _mm512_loadu_ps(float const *__p)
>>   return ((struct __loadu_ps*)__p)->__v;
>> }
>> 
>> +static __inline __m512 __attribute__((__always_inline__,
>> __nodebug__))
>> +_mm512_load_ps(double const *__p)
>> +{
>> +  return (__m512) __builtin_ia32_loadaps512_mask ((const __v16sf
>> *)__p,
>> +  (__v16sf)
>> +  _mm512_setzero_ps
>> (),
>> +  (__mmask16) -1);
>> +}
>> +
>> +static __inline __m512d __attribute__((__always_inline__,
>> __nodebug__))
>> +_mm512_load_pd(float const *__p)
> 
> Shouldn't this one take a 'double const *' and the one above take a 'float 
> const *’?

You’re right.  Fixing it.

Thanks,
Adam

> 
> -Hal
> 
>> +{
>> +  return (__m512d) __builtin_ia32_loadapd512_mask ((const __v8df
>> *)__p,
>> +   (__v8df)
>> +   _mm512_setzero_pd
>> (),
>> +   (__mmask8) -1);
>> +}
>> +
>> /* SIMD store ops */
>> 
>> static __inline void __attribute__ ((__always_inline__,
>> __nodebug__))
>> @@ -988,9 +1024,9 @@ _mm512_storeu_ps(void *__P, __m512 __A)
>> }
>> 
>> 

r258108 - [AVX512] Fix typo in r226298

2016-01-18 Thread Adam Nemet via cfe-commits
Author: anemet
Date: Mon Jan 18 20:02:25 2016
New Revision: 258108

URL: http://llvm.org/viewvc/llvm-project?rev=258108&view=rev
Log:
[AVX512] Fix typo in r226298

Hal noticed that the double/float got mixed up on the parameters for
these.

Modified:
cfe/trunk/lib/Headers/avx512fintrin.h

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=258108&r1=258107&r2=258108&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Mon Jan 18 20:02:25 2016
@@ -2648,7 +2648,7 @@ _mm512_loadu_ps(float const *__p)
 }
 
 static __inline __m512 __DEFAULT_FN_ATTRS
-_mm512_load_ps(double const *__p)
+_mm512_load_ps(float const *__p)
 {
   return (__m512) __builtin_ia32_loadaps512_mask ((const __v16sf *)__p,
   (__v16sf)
@@ -2657,7 +2657,7 @@ _mm512_load_ps(double const *__p)
 }
 
 static __inline __m512d __DEFAULT_FN_ATTRS
-_mm512_load_pd(float const *__p)
+_mm512_load_pd(double const *__p)
 {
   return (__m512d) __builtin_ia32_loadapd512_mask ((const __v8df *)__p,
(__v8df)


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


Re: r226298 - [AVX512] Add intrinsics for masked aligned FP loads and stores

2016-01-18 Thread Adam Nemet via cfe-commits

> On Jan 18, 2016, at 6:00 PM, Adam Nemet  wrote:
> 
> 
>> On Jan 18, 2016, at 5:28 PM, Hal Finkel  wrote:
>> 
>> - Original Message -
>>> From: "Adam Nemet" 
>>> To: cfe-comm...@cs.uiuc.edu
>>> Sent: Friday, January 16, 2015 12:51:50 PM
>>> Subject: r226298 - [AVX512] Add intrinsics for masked aligned FP loads and  
>>> stores
>>> 
>>> Author: anemet
>>> Date: Fri Jan 16 12:51:50 2015
>>> New Revision: 226298
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=226298&view=rev
>>> Log:
>>> [AVX512] Add intrinsics for masked aligned FP loads and stores
>>> 
>>> Part of 
>>> 
>>> Modified:
>>>   cfe/trunk/include/clang/Basic/BuiltinsX86.def
>>>   cfe/trunk/lib/Headers/avx512fintrin.h
>>>   cfe/trunk/test/CodeGen/avx512f-builtins.c
>>> 
>>> Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=226298&r1=226297&r2=226298&view=diff
>>> ==
>>> --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
>>> +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Fri Jan 16 12:51:50
>>> 2015
>>> @@ -897,11 +897,15 @@ BUILTIN(__builtin_ia32_pbroadcastq512_me
>>> BUILTIN(__builtin_ia32_loaddqusi512_mask, "V16ivC*V16iUs", "")
>>> BUILTIN(__builtin_ia32_loaddqudi512_mask, "V8LLivC*V8LLiUc", "")
>>> BUILTIN(__builtin_ia32_loadups512_mask, "V16fvC*V16fUs", "")
>>> +BUILTIN(__builtin_ia32_loadaps512_mask, "V16fvC*V16fUs", "")
>>> BUILTIN(__builtin_ia32_loadupd512_mask, "V8dvC*V8dUc", "")
>>> +BUILTIN(__builtin_ia32_loadapd512_mask, "V8dvC*V8dUc", "")
>>> BUILTIN(__builtin_ia32_storedqudi512_mask, "vv*V8LLiUc", "")
>>> BUILTIN(__builtin_ia32_storedqusi512_mask, "vv*V16iUs", "")
>>> BUILTIN(__builtin_ia32_storeupd512_mask, "vv*V8dUc", "")
>>> +BUILTIN(__builtin_ia32_storeapd512_mask, "vv*V8dUc", "")
>>> BUILTIN(__builtin_ia32_storeups512_mask, "vv*V16fUs", "")
>>> +BUILTIN(__builtin_ia32_storeaps512_mask, "vv*V16fUs", "")
>>> BUILTIN(__builtin_ia32_vpermt2vard512_mask, "V16iV16iV16iV16iUs",
>>> "")
>>> BUILTIN(__builtin_ia32_vpermt2varq512_mask,
>>> "V8LLiV8LLiV8LLiV8LLiUc", "")
>>> BUILTIN(__builtin_ia32_vpermt2varps512_mask, "V16fV16iV16fV16fUs",
>>> "")
>>> 
>>> Modified: cfe/trunk/lib/Headers/avx512fintrin.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=226298&r1=226297&r2=226298&view=diff
>>> ==
>>> --- cfe/trunk/lib/Headers/avx512fintrin.h (original)
>>> +++ cfe/trunk/lib/Headers/avx512fintrin.h Fri Jan 16 12:51:50 2015
>>> @@ -928,6 +928,24 @@ _mm512_maskz_loadu_pd(__mmask8 __U, void
>>>   (__mmask8) __U);
>>> }
>>> 
>>> +static __inline __m512 __attribute__ ((__always_inline__,
>>> __nodebug__))
>>> +_mm512_maskz_load_ps(__mmask16 __U, void const *__P)
>>> +{
>>> +  return (__m512) __builtin_ia32_loadaps512_mask ((const __v16sf
>>> *)__P,
>>> +  (__v16sf)
>>> +  _mm512_setzero_ps
>>> (),
>>> +  (__mmask16) __U);
>>> +}
>>> +
>>> +static __inline __m512d __attribute__ ((__always_inline__,
>>> __nodebug__))
>>> +_mm512_maskz_load_pd(__mmask8 __U, void const *__P)
>>> +{
>>> +  return (__m512d) __builtin_ia32_loadapd512_mask ((const __v8df
>>> *)__P,
>>> +   (__v8df)
>>> +   _mm512_setzero_pd
>>> (),
>>> +   (__mmask8) __U);
>>> +}
>>> +
>>> static __inline __m512d __attribute__((__always_inline__,
>>> __nodebug__))
>>> _mm512_loadu_pd(double const *__p)
>>> {
>>> @@ -946,6 +964,24 @@ _mm512_loadu_ps(float const *__p)
>>>  return ((struct __loadu_ps*)__p)->__v;
>>> }
>>> 
>>> +static __inline __m512 __attribute__((__always_inline__,
>>> __nodebug__))
>>> +_mm512_load_ps(double const *__p)
>>> +{
>>> +  return (__m512) __builtin_ia32_loadaps512_mask ((const __v16sf
>>> *)__p,
>>> +  (__v16sf)
>>> +  _mm512_setzero_ps
>>> (),
>>> +  (__mmask16) -1);
>>> +}
>>> +
>>> +static __inline __m512d __attribute__((__always_inline__,
>>> __nodebug__))
>>> +_mm512_load_pd(float const *__p)
>> 
>> Shouldn't this one take a 'double const *' and the one above take a 'float 
>> const *’?
> 
> You’re right.  Fixing it.

It’s r258108.

> 
> Thanks,
> Adam
> 
>> 
>> -Hal
>> 
>>> +{
>>> +  return (__m512d) __builtin_ia32_loadapd512_mask ((const __v8df
>>> *)__p,
>>> +   (__v8df)
>>> +   _mm512_setzero_pd
>>> (),
>>> +   (__mmask

Re: [PATCH] D15989: [OpenMP] Parsing + sema for "target enter data" and "target exit data" directives.

2016-01-18 Thread Arpith Jacob via cfe-commits
arpith-jacob updated this revision to Diff 45225.
arpith-jacob added a comment.

HasMapClause() is now static.
Removed comment about 'target exit data'.
Modified: just if(*I != nullptr && (*I)->getClauseKind() == OMPC_map)
Done: Remove parens around 0


http://reviews.llvm.org/D15989

Files:
  include/clang-c/Index.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/StmtOpenMP.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenMPKinds.def
  include/clang/Basic/StmtNodes.td
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/StmtOpenMP.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/OpenMP/nesting_of_regions.cpp
  test/OpenMP/target_enter_data_ast_print.cpp
  test/OpenMP/target_enter_data_device_messages.cpp
  test/OpenMP/target_enter_data_if_messages.cpp
  test/OpenMP/target_enter_data_map_messages.c
  tools/libclang/CIndex.cpp
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -600,6 +600,9 @@
   case Stmt::OMPTargetDataDirectiveClass:
 K = CXCursor_OMPTargetDataDirective;
 break;
+  case Stmt::OMPTargetEnterDataDirectiveClass:
+K = CXCursor_OMPTargetEnterDataDirective;
+break;
   case Stmt::OMPTeamsDirectiveClass:
 K = CXCursor_OMPTeamsDirective;
 break;
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1953,6 +1953,7 @@
   void VisitOMPAtomicDirective(const OMPAtomicDirective *D);
   void VisitOMPTargetDirective(const OMPTargetDirective *D);
   void VisitOMPTargetDataDirective(const OMPTargetDataDirective *D);
+  void VisitOMPTargetEnterDataDirective(const OMPTargetEnterDataDirective *D);
   void VisitOMPTeamsDirective(const OMPTeamsDirective *D);
   void VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *D);
   void VisitOMPTaskLoopSimdDirective(const OMPTaskLoopSimdDirective *D);
@@ -2628,6 +2629,11 @@
   VisitOMPExecutableDirective(D);
 }
 
+void EnqueueVisitor::VisitOMPTargetEnterDataDirective(
+const OMPTargetEnterDataDirective *D) {
+  VisitOMPExecutableDirective(D);
+}
+
 void EnqueueVisitor::VisitOMPTeamsDirective(const OMPTeamsDirective *D) {
   VisitOMPExecutableDirective(D);
 }
@@ -4510,6 +4516,8 @@
 return cxstring::createRef("OMPTargetDirective");
   case CXCursor_OMPTargetDataDirective:
 return cxstring::createRef("OMPTargetDataDirective");
+  case CXCursor_OMPTargetEnterDataDirective:
+return cxstring::createRef("OMPTargetEnterDataDirective");
   case CXCursor_OMPTeamsDirective:
 return cxstring::createRef("OMPTeamsDirective");
   case CXCursor_OMPCancellationPointDirective:
Index: test/OpenMP/target_enter_data_map_messages.c
===
--- /dev/null
+++ test/OpenMP/target_enter_data_map_messages.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+
+int main(int argc, char **argv) {
+
+  int r;
+  #pragma omp target enter data // expected-error {{expected at least one map clause for '#pragma omp target enter data'}}
+
+  #pragma omp target enter data map(tofrom: r) // expected-error {{map type 'tofrom' is not allowed for '#pragma omp target enter data'}}
+
+  #pragma omp target enter data map(always, to: r)
+  #pragma omp target enter data map(always, alloc: r)
+  #pragma omp target enter data map(always, from: r) // expected-error {{map type 'from' is not allowed for '#pragma omp target enter data'}}
+  #pragma omp target enter data map(release: r) // expected-error {{map type 'release' is not allowed for '#pragma omp target enter data'}}
+  #pragma omp target enter data map(delete: r) // expected-error {{map type 'delete' is not allowed for '#pragma omp target enter data'}}
+
+  return 0;
+}
Index: test/OpenMP/target_enter_data_if_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_enter_data_if_messages.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+int main(int argc, char **argv) {
+  int i;
+  #pragma omp target enter data map(to: i) if // expected-error {{expected '(' after 'if'}}
+  #pragma omp target enter data map(to: i) if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to mat

Re: [PATCH] D15989: [OpenMP] Parsing + sema for "target enter data" and "target exit data" directives.

2016-01-18 Thread Arpith Jacob via cfe-commits
arpith-jacob marked 4 inline comments as done.
arpith-jacob added a comment.

http://reviews.llvm.org/D15989



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


Re: [PATCH] D16279: [OpenMP] Parsing + sema for "target exit data" directive.

2016-01-18 Thread Arpith Jacob via cfe-commits
arpith-jacob updated this revision to Diff 45226.
arpith-jacob added a comment.

Addressed comments from similar patch for 'target enter data' directive.

Added comment about 'target exit data'.
Removed parens around 0.


http://reviews.llvm.org/D16279

Files:
  include/clang-c/Index.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/StmtOpenMP.h
  include/clang/Basic/OpenMPKinds.def
  include/clang/Basic/StmtNodes.td
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/StmtOpenMP.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/OpenMP/nesting_of_regions.cpp
  test/OpenMP/target_exit_data_ast_print.cpp
  test/OpenMP/target_exit_data_device_messages.cpp
  test/OpenMP/target_exit_data_if_messages.cpp
  test/OpenMP/target_exit_data_map_messages.c
  tools/libclang/CIndex.cpp
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -603,6 +603,9 @@
   case Stmt::OMPTargetEnterDataDirectiveClass:
 K = CXCursor_OMPTargetEnterDataDirective;
 break;
+  case Stmt::OMPTargetExitDataDirectiveClass:
+K = CXCursor_OMPTargetExitDataDirective;
+break;
   case Stmt::OMPTeamsDirectiveClass:
 K = CXCursor_OMPTeamsDirective;
 break;
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1954,6 +1954,7 @@
   void VisitOMPTargetDirective(const OMPTargetDirective *D);
   void VisitOMPTargetDataDirective(const OMPTargetDataDirective *D);
   void VisitOMPTargetEnterDataDirective(const OMPTargetEnterDataDirective *D);
+  void VisitOMPTargetExitDataDirective(const OMPTargetExitDataDirective *D);
   void VisitOMPTeamsDirective(const OMPTeamsDirective *D);
   void VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *D);
   void VisitOMPTaskLoopSimdDirective(const OMPTaskLoopSimdDirective *D);
@@ -2634,6 +2635,11 @@
   VisitOMPExecutableDirective(D);
 }
 
+void EnqueueVisitor::VisitOMPTargetExitDataDirective(
+const OMPTargetExitDataDirective *D) {
+  VisitOMPExecutableDirective(D);
+}
+
 void EnqueueVisitor::VisitOMPTeamsDirective(const OMPTeamsDirective *D) {
   VisitOMPExecutableDirective(D);
 }
@@ -4518,6 +4524,8 @@
 return cxstring::createRef("OMPTargetDataDirective");
   case CXCursor_OMPTargetEnterDataDirective:
 return cxstring::createRef("OMPTargetEnterDataDirective");
+  case CXCursor_OMPTargetExitDataDirective:
+return cxstring::createRef("OMPTargetExitDataDirective");
   case CXCursor_OMPTeamsDirective:
 return cxstring::createRef("OMPTeamsDirective");
   case CXCursor_OMPCancellationPointDirective:
Index: test/OpenMP/target_exit_data_map_messages.c
===
--- /dev/null
+++ test/OpenMP/target_exit_data_map_messages.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+
+int main(int argc, char **argv) {
+
+  int r;
+  #pragma omp target exit data // expected-error {{expected at least one map clause for '#pragma omp target exit data'}}
+
+  #pragma omp target exit data map(tofrom: r) // expected-error {{map type 'tofrom' is not allowed for '#pragma omp target exit data'}}
+
+  #pragma omp target exit data map(always, from: r)
+  #pragma omp target exit data map(delete: r)
+  #pragma omp target exit data map(release: r)
+  #pragma omp target exit data map(always, alloc: r) // expected-error {{map type 'alloc' is not allowed for '#pragma omp target exit data'}}
+  #pragma omp target exit data map(to: r) // expected-error {{map type 'to' is not allowed for '#pragma omp target exit data'}}
+
+  return 0;
+}
Index: test/OpenMP/target_exit_data_if_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_exit_data_if_messages.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+int main(int argc, char **argv) {
+  int i;
+  #pragma omp target exit data map(from: i) if // expected-error {{expected '(' after 'if'}}
+  #pragma omp target exit data map(from: i) if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp target exit data map(from: i) if () // expected-error {{expected expression}}
+  #pragma omp target exit data map(from: i) if (argc //

Re: [PATCH] D16280: [OpenMP] Detect implicit map type to report unspecified map type for target enter/exit data directives.

2016-01-18 Thread Arpith Jacob via cfe-commits
arpith-jacob updated this revision to Diff 45227.
arpith-jacob added a comment.

Addressed comment:
Do not cast bool to unsigned, use (IsMapTypeImplicit ? 1 : 0) instead.


http://reviews.llvm.org/D16280

Files:
  include/clang/AST/OpenMPClause.h
  include/clang/Sema/Sema.h
  lib/AST/OpenMPClause.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  test/OpenMP/target_enter_data_map_messages.c
  test/OpenMP/target_exit_data_map_messages.c

Index: test/OpenMP/target_exit_data_map_messages.c
===
--- test/OpenMP/target_exit_data_map_messages.c
+++ test/OpenMP/target_exit_data_map_messages.c
@@ -5,6 +5,7 @@
   int r;
   #pragma omp target exit data // expected-error {{expected at least one map clause for '#pragma omp target exit data'}}
 
+  #pragma omp target exit data map(r) // expected-error {{map type must be specified for '#pragma omp target exit data'}}
   #pragma omp target exit data map(tofrom: r) // expected-error {{map type 'tofrom' is not allowed for '#pragma omp target exit data'}}
 
   #pragma omp target exit data map(always, from: r)
Index: test/OpenMP/target_enter_data_map_messages.c
===
--- test/OpenMP/target_enter_data_map_messages.c
+++ test/OpenMP/target_enter_data_map_messages.c
@@ -5,6 +5,7 @@
   int r;
   #pragma omp target enter data // expected-error {{expected at least one map clause for '#pragma omp target enter data'}}
 
+  #pragma omp target enter data map(r) // expected-error {{map type must be specified for '#pragma omp target enter data'}}
   #pragma omp target enter data map(tofrom: r) // expected-error {{map type 'tofrom' is not allowed for '#pragma omp target enter data'}}
 
   #pragma omp target enter data map(always, to: r)
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -1660,10 +1660,11 @@
   /// Subclasses may override this routine to provide different behavior.
   OMPClause *RebuildOMPMapClause(
   OpenMPMapClauseKind MapTypeModifier, OpenMPMapClauseKind MapType,
-  SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef VarList,
-  SourceLocation StartLoc, SourceLocation LParenLoc,
-  SourceLocation EndLoc) {
-return getSema().ActOnOpenMPMapClause(MapTypeModifier, MapType, MapLoc,
+  bool IsMapTypeImplicit, SourceLocation MapLoc, SourceLocation ColonLoc,
+  ArrayRef VarList, SourceLocation StartLoc,
+  SourceLocation LParenLoc, SourceLocation EndLoc) {
+return getSema().ActOnOpenMPMapClause(MapTypeModifier, MapType,
+  IsMapTypeImplicit, MapLoc,
   ColonLoc, VarList,StartLoc,
   LParenLoc, EndLoc);
   }
@@ -7847,9 +7848,9 @@
 Vars.push_back(EVar.get());
   }
   return getDerived().RebuildOMPMapClause(
-  C->getMapTypeModifier(), C->getMapType(), C->getMapLoc(),
-  C->getColonLoc(), Vars, C->getLocStart(), C->getLParenLoc(),
-  C->getLocEnd());
+  C->getMapTypeModifier(), C->getMapType(), C->isImplicitMapType(),
+  C->getMapLoc(), C->getColonLoc(), Vars, C->getLocStart(),
+  C->getLParenLoc(), C->getLocEnd());
 }
 
 template 
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -6503,7 +6503,8 @@
 SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec,
 const DeclarationNameInfo &ReductionId, OpenMPDependClauseKind DepKind,
 OpenMPLinearClauseKind LinKind, OpenMPMapClauseKind MapTypeModifier, 
-OpenMPMapClauseKind MapType, SourceLocation DepLinMapLoc) {
+OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,
+SourceLocation DepLinMapLoc) {
   OMPClause *Res = nullptr;
   switch (Kind) {
   case OMPC_private:
@@ -6544,8 +6545,9 @@
   StartLoc, LParenLoc, EndLoc);
 break;
   case OMPC_map:
-Res = ActOnOpenMPMapClause(MapTypeModifier, MapType, DepLinMapLoc, ColonLoc,
-   VarList, StartLoc, LParenLoc, EndLoc);
+Res = ActOnOpenMPMapClause(MapTypeModifier, MapType, IsMapTypeImplicit,
+   DepLinMapLoc, ColonLoc, VarList, StartLoc,
+   LParenLoc, EndLoc);
 break;
   case OMPC_if:
   case OMPC_final:
@@ -8464,8 +8466,9 @@
 
 OMPClause *Sema::ActOnOpenMPMapClause(
 OpenMPMapClauseKind MapTypeModifier, OpenMPMapClauseKind MapType,
-SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef VarList,
-SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc) {
+bool IsMapTypeImplicit, SourceLocation MapLoc, SourceLocation ColonLoc,
+ArrayRef VarList, SourceLocation StartLoc, SourceLocation LParenLoc,
+SourceLocation EndLoc) {
   SmallVecto

Re: [PATCH] D16280: [OpenMP] Detect implicit map type to report unspecified map type for target enter/exit data directives.

2016-01-18 Thread Arpith Jacob via cfe-commits
arpith-jacob marked 2 inline comments as done.
arpith-jacob added a comment.

http://reviews.llvm.org/D16280



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


r258110 - Fix PR26134: When substituting into default template arguments, keep CurContext unchanged.

2016-01-18 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Mon Jan 18 21:58:55 2016
New Revision: 258110

URL: http://llvm.org/viewvc/llvm-project?rev=258110&view=rev
Log:
Fix PR26134: When substituting into default template arguments, keep CurContext 
unchanged.

Or, do not set Sema's CurContext to the template declaration's when 
substituting into default template arguments of said template declaration.   
If we do push the template declaration context on to Sema, and the template 
declaration is at namespace scope, Sema can get confused and try and do odr 
analysis when substituting into default template arguments, even though the 
substitution could be occurring within a dependent context.
I'm not sure why this was being done, perhaps there was concern that if a 
default template argument referred to a previous template parameter, it might 
not be found during substitution - but all regression tests pass, and I can't 
craft a test that would cause it to fails (if some one does, please inform me, 
and i'll craft a different fix for the PR).


This patch removes a single line of code, but unfortunately adds more than it 
removes, because of the tests.  Some day I still hope to commit a patch that 
removes far more lines than it adds, while leaving clang better for it ;)

Sorry that r253590 ("Change the expression evaluation context from Unevaluated 
to ConstantEvaluated while substituting into non-type template argument 
defaults") caused the PR!





Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaTemplate/default-arguments.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=258110&r1=258109&r2=258110&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Mon Jan 18 21:58:55 2016
@@ -3281,7 +3281,6 @@ SubstDefaultTemplateArgument(Sema &SemaR
   for (unsigned i = 0, e = Param->getDepth(); i != e; ++i)
 TemplateArgLists.addOuterTemplateArguments(None);
 
-  Sema::ContextRAII SavedContext(SemaRef, Template->getDeclContext());
   EnterExpressionEvaluationContext ConstantEvaluated(SemaRef,
  Sema::ConstantEvaluated);
   return SemaRef.SubstExpr(Param->getDefaultArgument(), TemplateArgLists);

Modified: cfe/trunk/test/SemaTemplate/default-arguments.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-arguments.cpp?rev=258110&r1=258109&r2=258110&view=diff
==
--- cfe/trunk/test/SemaTemplate/default-arguments.cpp (original)
+++ cfe/trunk/test/SemaTemplate/default-arguments.cpp Mon Jan 18 21:58:55 2016
@@ -179,3 +179,31 @@ struct C {
   C(T t = ); // expected-error {{expected expression}}
 };
 C obj;
+
+namespace PR26134 {
+// Make sure when substituting default template arguments we do it in the 
current context.
+template
+struct X {};
+
+template struct Y {
+  void f() { X xy; }
+  static const bool value = B;
+};
+
+namespace ns1 {
+template
+struct X {
+  template struct XInner { static const bool value = B; };
+};
+template struct S { static const bool value = B; };
+#if __cplusplus > 199711L
+template struct Y {
+  static constexpr bool f() { return typename X>::template 
XInner<>{}.value; }
+  static_assert(f() == B, "");
+};
+Y y;
+Y y2;
+#endif
+
+} // end ns1
+} // end ns PR26134


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


Re: [PATCH] D16286: [clang-tidy] Readability check for redundant parenthesis in return expression.

2016-01-18 Thread Adrian Zgorzałek via cfe-commits
adek05 updated this revision to Diff 45228.
adek05 added a comment.

@LegalizeAdulthood, @Eugene.Zelenko and @omtcyf0 comments


http://reviews.llvm.org/D16286

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/ReturnWithRedundantParensCheck.cpp
  clang-tidy/readability/ReturnWithRedundantParensCheck.h
  test/clang-tidy/readability-return-with-redundant-parens.cpp

Index: test/clang-tidy/readability-return-with-redundant-parens.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-return-with-redundant-parens.cpp
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy %s readability-return-with-redundant-parens %t
+
+int no_parens() {
+  return 1;
+}
+
+int simple1() {
+  return (1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: redundant parentheses for expression in return statement [readability-return-with-redundant-parens]
+  // CHECK-FIXES: {{^  }}return 1;{{$}}
+}
+
+int complex1() {
+  int a = 0;
+  return (a + a * (a + a));
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: redundant parentheses for expression in return statement [readability-return-with-redundant-parens]
+  // CHECK-FIXES: {{^  }}return a + a * (a + a);{{$}}
+}
+
+int no_space() {
+  return(1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: redundant parentheses for expression in return statement [readability-return-with-redundant-parens]
+  // CHECK-FIXES: {{^  }}return 1;{{$}}
+}
Index: clang-tidy/readability/ReturnWithRedundantParensCheck.h
===
--- /dev/null
+++ clang-tidy/readability/ReturnWithRedundantParensCheck.h
@@ -0,0 +1,38 @@
+//===--- ReturnWithRedundantParensCheck.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_READABILITY_RETURNBRACKETSCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_RETURNBRACKETSCHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+/// Find and remove redundant parenthesis surrounding returned expression.
+///
+/// Examples:
+/// \code
+///   void f() { return (1); } ==> void f() { return 1; }
+/// \endcode
+class ReturnWithRedundantParensCheck : public ClangTidyCheck {
+public:
+  ReturnWithRedundantParensCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace readability
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_RETURNBRACKETSCHECK_H
Index: clang-tidy/readability/ReturnWithRedundantParensCheck.cpp
===
--- /dev/null
+++ clang-tidy/readability/ReturnWithRedundantParensCheck.cpp
@@ -0,0 +1,40 @@
+//===--- ReturnWithRedundantParensCheck.cpp - clang-tidy *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ReturnWithRedundantParensCheck.h"
+
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+void ReturnWithRedundantParensCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(returnStmt(hasDescendant(parenExpr().bind("paren_expr"))),
+ this);
+}
+
+void ReturnWithRedundantParensCheck::check(
+const ast_matchers::MatchFinder::MatchResult &Result) {
+
+  const ParenExpr *ParenExpression =
+  Result.Nodes.getNodeAs("paren_expr");
+
+  const SourceLocation &LParenLoc = ParenExpression->getLParen();
+  const SourceLocation &RParenLoc = ParenExpression->getRParen();
+  diag(LParenLoc, "redundant parentheses for expression in return statement")
+  << FixItHint::CreateRemoval(LParenLoc)
+  << FixItHint::CreateRemoval(RParenLoc);
+}
+
+} // namespace readability
+} // namespace tidy
+} // namespace clang
Index: clang-tidy/readability/ReadabilityTidyModule.cpp
===
--- clang-tidy/readability/ReadabilityTidyModule.cpp
+++ clang-tidy/readability/ReadabilityTidyModule.cpp
@@ -20,6 +20,7 @@
 #include "NamedParameterCheck.h"
 #include "RedundantSmartptrGetCheck.h"
 #include "RedundantStringCStrCheck.h"
+#include "ReturnWithRedundantParensCheck.h"
 #include "SimplifyBooleanExprCheck.h"
 #include "UniqueptrDeleteReleaseCheck.

Re: [PATCH] D15173: [Preprocessor] Fix assertion in AnnotatePreviousCachedTokens

2016-01-18 Thread Richard Smith via cfe-commits
On Jan 7, 2016 7:13 PM, "Bruno Cardoso Lopes" 
wrote:
>
> bruno updated this revision to Diff 44306.
> bruno added a comment.
>
> Hi Richard,
>
> Thanks for the detailed explanation, it now makes sense to me. I updated
the patch with another approach! Let me know if it's the right direction.
>
>
> http://reviews.llvm.org/D15173
>
> Files:
>   include/clang/Lex/Preprocessor.h
>   lib/Lex/PPCaching.cpp
>   lib/Parse/ParseTemplate.cpp
>   test/Parser/objcxx11-protocol-in-template.mm
>
> Index: test/Parser/objcxx11-protocol-in-template.mm
> ===
> --- test/Parser/objcxx11-protocol-in-template.mm
> +++ test/Parser/objcxx11-protocol-in-template.mm
> @@ -8,3 +8,11 @@
>
>  vector> v;
>  vector>> v2;
> +
> +@protocol PA;
> +@protocol PB;
> +
> +@class NSArray;
> +typedef int some_t;
> +
> +id FA(NSArray> *h, some_t group);
> Index: lib/Parse/ParseTemplate.cpp
> ===
> --- lib/Parse/ParseTemplate.cpp
> +++ lib/Parse/ParseTemplate.cpp
> @@ -827,6 +827,7 @@
>}
>
>// Strip the initial '>' from the token.
> +  Token PrevTok = Tok;
>if (RemainingToken == tok::equal && Next.is(tok::equal) &&
>areTokensAdjacent(Tok, Next)) {
>  // Join two adjacent '=' tokens into one, for cases like:
> @@ -843,6 +844,20 @@
>   PP.getSourceManager(),
>   getLangOpts()));
>
> +  // The advance from '>>' to '>' in a ObjectiveC template argument list
needs
> +  // to be properly reflected in the token cache to allow correct
interaction
> +  // between annotation and backtracking.
> +  if (ObjCGenericList && PrevTok.getKind() == tok::greatergreater &&

Why do you only do this in one special case, rather than in the general
case where we split a token?

> +  RemainingToken == tok::greater &&
> +  PrevTok.getLocation().getRawEncoding() <=
> +  PP.getLastCachedTokenLocation().getRawEncoding()) {

A <= check on a source location raw encoding is pretty much meaningless if
you don't know they have the same FileID (and even then, you should ask
SourceManager to compare the locations).

Can you push the "is this a cached token" check down into the preprocessor
instead? (If we're doing token caching, how can it not be?)

> +Token ReplTok = PrevTok;
> +PrevTok.setKind(RemainingToken);
> +PrevTok.setLength(1);
> +SmallVector NewToks = {PrevTok, Tok};
> +PP.ReplaceCachedToken(ReplTok, NewToks);
> +  }
> +
>if (!ConsumeLastToken) {
>  // Since we're not supposed to consume the '>' token, we need to push
>  // this token and revert the current token back to the '>'.
> Index: lib/Lex/PPCaching.cpp
> ===
> --- lib/Lex/PPCaching.cpp
> +++ lib/Lex/PPCaching.cpp
> @@ -116,3 +116,19 @@
>  }
>}
>  }
> +
> +void Preprocessor::ReplaceCachedToken(const Token &Tok,
> +  SmallVectorImpl &NewToks) {

It seems like this could always assume that it's replacing the most recent
token (the one at CachedLexPos-1).

> +  assert(CachedLexPos != 0 && "Expected to have some cached tokens");
> +  for (auto i = CachedLexPos - 1; i != 0; --i) {
> +const Token CurrCachedTok = CachedTokens[i];
> +if (CurrCachedTok.getKind() == Tok.getKind() &&
> +CurrCachedTok.getLocation() == Tok.getLocation()) {
> +  CachedTokens.insert(CachedTokens.begin() + i, NewToks.begin(),
> +  NewToks.end());
> +  CachedTokens.erase(CachedTokens.begin() + i + NewToks.size());
> +  CachedLexPos += NewToks.size() - 1;
> +  return;
> +}
> +  }
> +}
> Index: include/clang/Lex/Preprocessor.h
> ===
> --- include/clang/Lex/Preprocessor.h
> +++ include/clang/Lex/Preprocessor.h
> @@ -1185,6 +1185,12 @@
>  return CachedTokens[CachedLexPos-1].getLastLoc();
>}
>
> +  /// \brief Replace token \p Tok in CachedTokens by the tokens in \p
NewToks.
> +  ///
> +  /// Useful when a token needs to be split in smaller ones and
CachedTokens
> +  /// must to be updated to reflect that.
> +  void ReplaceCachedToken(const Token &Tok, SmallVectorImpl
&NewToks);
> +
>/// \brief Replace the last token with an annotation token.
>///
>/// Like AnnotateCachedTokens(), this routine replaces an
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D8149: Add hasUnderlyingType narrowing matcher for TypedefDecls, functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes

2016-01-18 Thread Richard via cfe-commits
LegalizeAdulthood added a comment.

Is there any reason we can't proceed with the patch as-is and then see if it 
can be refactored into an overload of `hasType`?


http://reviews.llvm.org/D8149



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


[PATCH] D16308: clang-tidy Enhance readability-simplify-boolean-expr check to handle implicit conversions of integral types to bool and member pointers

2016-01-18 Thread Richard via cfe-commits
LegalizeAdulthood created this revision.
LegalizeAdulthood added a reviewer: alexfh.
LegalizeAdulthood added a subscriber: cfe-commits.

Expand the simplify boolean expression check to handle implicit conversion of 
integral types to bool
and improve the handling of implicit conversion of member pointers to bool.

Implicit conversion of member pointers are replaced with explicit comparisons 
to `nullptr`.

Implicit conversions of integral types are replaced with explicit comparisons 
to `0`.

http://reviews.llvm.org/D16308

Files:
  clang-tidy/readability/SimplifyBooleanExprCheck.cpp
  clang-tidy/readability/SimplifyBooleanExprCheck.h
  docs/clang-tidy/checks/readability-simplify-boolean-expr.rst
  test/clang-tidy/readability-simplify-bool-expr.cpp

Index: test/clang-tidy/readability-simplify-bool-expr.cpp
===
--- test/clang-tidy/readability-simplify-bool-expr.cpp
+++ test/clang-tidy/readability-simplify-bool-expr.cpp
@@ -690,7 +690,7 @@
   }
 }
 // CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return
-// CHECK-FIXES: {{^}}  return static_cast(i & 1);{{$}}
+// CHECK-FIXES: {{^}}  return i & 1 != 0;{{$}}
 
 bool negated_if_implicit_bool_expr(int i) {
   if (i - 1) {
@@ -700,7 +700,7 @@
   }
 }
 // CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return
-// CHECK-FIXES: {{^}}  return !static_cast(i - 1);{{$}}
+// CHECK-FIXES: {{^}}  return i - 1 == 0;{{$}}
 
 bool implicit_int(int i) {
   if (i) {
@@ -710,7 +710,7 @@
   }
 }
 // CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return
-// CHECK-FIXES: {{^}}  return static_cast(i);{{$}}
+// CHECK-FIXES: {{^}}  return i != 0;{{$}}
 
 bool explicit_bool(bool b) {
   if (b) {
@@ -757,7 +757,7 @@
   }
 }
 // CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return
-// CHECK-FIXES: {{^}}  return static_cast(~i);{{$}}
+// CHECK-FIXES: {{^}}  return ~i != 0;{{$}}
 
 bool logical_or(bool a, bool b) {
   if (a || b) {
@@ -830,7 +830,7 @@
   bool b = i ? true : false;
 }
 // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: {{.*}} in ternary expression result
-// CHECK-FIXES: bool b = static_cast(i);{{$}}
+// CHECK-FIXES: bool b = i != 0;{{$}}
 
 bool non_null_pointer_condition(int *p1) {
   if (p1) {
@@ -895,3 +895,28 @@
 // CHECK-MESSAGES: :[[@LINE-6]]:12: warning: {{.*}} in conditional return
 // CHECK-FIXES: {{^}}  if (b) {
 // CHECK-FIXES: {{^}}#define SOMETHING_WICKED false
+
+bool integer_not_zero(int i) {
+  if (i) {
+return false;
+  } else {
+return true;
+  }
+}
+// CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return
+// CHECK-FIXES: {{^}}  return i == 0;{{$}}
+
+class A {
+public:
+int m;
+};
+
+bool member_pointer_nullptr(int A::*p) {
+  if (p) {
+return true;
+  } else {
+return false;
+  }
+}
+// CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return
+// CHECK-FIXES: return p != nullptr;{{$}}
Index: docs/clang-tidy/checks/readability-simplify-boolean-expr.rst
===
--- docs/clang-tidy/checks/readability-simplify-boolean-expr.rst
+++ docs/clang-tidy/checks/readability-simplify-boolean-expr.rst
@@ -40,6 +40,8 @@
   5. Implicit casts to ``bool`` are replaced with explicit casts to ``bool``.
   6. Object expressions with ``explicit operator bool`` conversion operators
  are replaced with explicit casts to ``bool``.
+  7. Implicit conversions of integral types to ``bool`` are replaced with
+ explicit comparisons to ``0``.
 
 Examples:
   1. The ternary assignment ``bool b = (i < 0) ? true : false;`` has redundant
@@ -60,11 +62,11 @@
 
  The ternary assignment ``bool b = (i & 1) ? true : false;`` has an
  implicit conversion of ``i & 1`` to ``bool`` and becomes
- ``bool b = static_cast(i & 1);``.
+ ``bool b = i & 1 != 0;``.
 
   5. The conditional return ``if (i & 1) return true; else return false;`` has
  an implicit conversion of an integer quantity ``i & 1`` to ``bool`` and
- becomes ``return static_cast(i & 1);``
+ becomes ``return i & 1 != 0;``
 
   6. Given ``struct X { explicit operator bool(); };``, and an instance ``x`` of
  ``struct X``, the conditional return ``if (x) return true; return false;``
Index: clang-tidy/readability/SimplifyBooleanExprCheck.h
===
--- clang-tidy/readability/SimplifyBooleanExprCheck.h
+++ clang-tidy/readability/SimplifyBooleanExprCheck.h
@@ -52,6 +52,8 @@
 ///   5. Implicit casts to `bool` are replaced with explicit casts to `bool`.
 ///   6. Object expressions with `explicit operator bool` conversion operators
 ///  are replaced with explicit casts to `bool`.
+///   7. Implicit conversions of integral types to `bool` are replaced with
+///  explicit comparisons to `0`.
 ///
 /// Examples:
 ///   1. The ternary assignment `bool b = (i < 0) ? true : false;` has redundant
@@ -72,11 +74,1

[PATCH] D16309: Use getCharWidth() instead of magic number

2016-01-18 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki created this revision.
danielmarjamaki added a subscriber: cfe-commits.

Use getCharWidth() instead of magic number to handle arbitrary char widths.

no change in logical behaviour is intended when getCharWidth() is 8.


http://reviews.llvm.org/D16309

Files:
  lib/Frontend/InitPreprocessor.cpp

Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -644,7 +644,7 @@
 
   // Define type sizing macros based on the target properties.
   assert(TI.getCharWidth() == 8 && "Only support 8-bit char so far");
-  Builder.defineMacro("__CHAR_BIT__", "8");
+  Builder.defineMacro("__CHAR_BIT__", Twine(TI.getCharWidth()));
 
   DefineTypeSize("__SCHAR_MAX__", TargetInfo::SignedChar, TI, Builder);
   DefineTypeSize("__SHRT_MAX__", TargetInfo::SignedShort, TI, Builder);


Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -644,7 +644,7 @@
 
   // Define type sizing macros based on the target properties.
   assert(TI.getCharWidth() == 8 && "Only support 8-bit char so far");
-  Builder.defineMacro("__CHAR_BIT__", "8");
+  Builder.defineMacro("__CHAR_BIT__", Twine(TI.getCharWidth()));
 
   DefineTypeSize("__SCHAR_MAX__", TargetInfo::SignedChar, TI, Builder);
   DefineTypeSize("__SHRT_MAX__", TargetInfo::SignedShort, TI, Builder);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits