Re: [PATCH] D12402: PR24595: clang-cl fails to compile vswriter.h header from Windows SDK 8.1 in 32 bit mode

2015-09-11 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

Reid, thank you for the review!

One last confirmation (see below), and I'll go ahead.

Yours,
Andrey



Comment at: test/CodeGenCXX/ctor-dtor-alias.cpp:170
@@ -169,3 +169,3 @@
   // it has a different calling conversion.
-  // CHECK4: call void @_ZN5test93barD2Ev
+  // CHECK4: call void @_ZN6test103barD2Ev
   bar ptr;

rnk wrote:
> Isn't this still in the test9 namespace? Shouldn't this change be reverted?
Now, after making the change you requested (wrapping checks in "default" part 
of adjustMemberFunctionCC function with !IsCtorOrDtor (SemaType.cpp:5876)) we 
start to call ~foo() here, so the check should be changed to:

  // CHECK4: call void bitcast (void (%"struct.test9::foo"*)* @_ZN5test93fooD2Ev

Please confirm you are OK with this change and I'll go ahead with commit.


http://reviews.llvm.org/D12402



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


Re: [PATCH] D12736: [PATCH] AST traversal from types to decls

2015-09-11 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

LG. This is great, thanks!


http://reviews.llvm.org/D12736



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


r247431 - Revert "Module Debugging: Emit forward declarations for types that are defined in"

2015-09-11 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Sep 11 12:23:03 2015
New Revision: 247431

URL: http://llvm.org/viewvc/llvm-project?rev=247431=rev
Log:
Revert "Module Debugging: Emit forward declarations for types that are defined 
in"

This reverts commit r247369 to facilitate reviewing of the following patch.

Removed:
cfe/trunk/test/Modules/ExtDebugInfo.cpp
cfe/trunk/test/Modules/ExtDebugInfo.m
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=247431=247430=247431=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep 11 12:23:03 2015
@@ -148,9 +148,7 @@ void CGDebugInfo::setLocation(SourceLoca
 }
 
 llvm::DIScope *CGDebugInfo::getDeclContextDescriptor(const Decl *D) {
-  llvm::DIScope *Mod = getParentModuleOrNull(D);
-  return getContextDescriptor(cast(D->getDeclContext()),
-  Mod ? Mod : TheCU);
+  return getContextDescriptor(cast(D->getDeclContext()), TheCU);
 }
 
 llvm::DIScope *CGDebugInfo::getContextDescriptor(const Decl *Context,
@@ -1450,9 +1448,6 @@ void CGDebugInfo::completeRequiredType(c
 if (CXXDecl->isDynamicClass())
   return;
 
-  if (DebugTypeExtRefs && RD->isFromASTFile())
-return;
-
   QualType Ty = CGM.getContext().getRecordType(RD);
   llvm::DIType *T = getTypeOrNull(Ty);
   if (T && T->isForwardDecl())
@@ -1674,9 +1669,9 @@ CGDebugInfo::getOrCreateModuleRef(Extern
   TheCU->getSourceLanguage(), internString(Mod.ModuleName),
   internString(Mod.Path), TheCU->getProducer(), true, StringRef(), 0,
   internString(Mod.ASTFile), llvm::DIBuilder::FullDebug, Mod.Signature);
-  llvm::DIModule *M = DIB.createModule(
-  CU, Mod.ModuleName, ConfigMacros, internString(Mod.Path),
-  internString(CGM.getHeaderSearchOpts().Sysroot));
+  llvm::DIModule *M =
+  DIB.createModule(CU, Mod.ModuleName, ConfigMacros, 
internString(Mod.Path),
+   internString(CGM.getHeaderSearchOpts().Sysroot));
   DIB.finalize();
   ModRef.reset(M);
   return M;
@@ -2086,16 +2081,9 @@ llvm::DIType *CGDebugInfo::getOrCreateTy
   if (auto *T = getTypeOrNull(Ty))
 return T;
 
-  llvm::DIType *Res = nullptr;
-  if (DebugTypeExtRefs)
-// Make a forward declaration of an external type.
-Res = getTypeExtRefOrNull(Ty, Unit);
-
   // Otherwise create the type.
-  if (!Res)
-Res = CreateTypeNode(Ty, Unit);
-
-  void* TyPtr = Ty.getAsOpaquePtr();
+  llvm::DIType *Res = CreateTypeNode(Ty, Unit);
+  void *TyPtr = Ty.getAsOpaquePtr();
 
   // And update the type cache.
   TypeCache[TyPtr].reset(Res);
@@ -2127,123 +2115,6 @@ ObjCInterfaceDecl *CGDebugInfo::getObjCI
   }
 }
 
-llvm::DIModule *CGDebugInfo::getParentModuleOrNull(const Decl *D) {
-  if (!DebugTypeExtRefs || !D || !D->isFromASTFile())
-return nullptr;
-
-  llvm::DIModule *ModuleRef = nullptr;
-  auto *Reader = CGM.getContext().getExternalSource();
-  auto Idx = D->getOwningModuleID();
-  auto Info = Reader->getSourceDescriptor(Idx);
-  if (Info)
-ModuleRef = getOrCreateModuleRef(*Info);
-  return ModuleRef;
-}
-
-llvm::DIType *CGDebugInfo::getTypeExtRefOrNull(QualType Ty, llvm::DIFile *F,
-   bool Anchored) {
-  assert(DebugTypeExtRefs && "module debugging only");
-  Decl *TyDecl = nullptr;
-  StringRef Name;
-  SmallString<256> UID;
-  unsigned Tag = 0;
-
-  // Handle all types that have a declaration.
-  switch (Ty->getTypeClass()) {
-  case Type::Typedef: {
-TyDecl = cast(Ty)->getDecl();
-if (!TyDecl->isFromASTFile())
-  return nullptr;
-
-// A typedef will anchor a type in the module.
-if (auto *TD = dyn_cast(TyDecl)) {
-  // This is a working around the fact that LLVM does not allow
-  // typedefs to be forward declarations.
-  QualType Ty = TD->getUnderlyingType();
-  Ty = UnwrapTypeForDebugInfo(Ty, CGM.getContext());
-  if (auto *AnchoredTy = getTypeExtRefOrNull(Ty, F, /*Anchored=*/true)) {
-TypeCache[Ty.getAsOpaquePtr()].reset(AnchoredTy);
-SourceLocation Loc = TD->getLocation();
-return DBuilder.createTypedef(AnchoredTy, TD->getName(),
-  getOrCreateFile(Loc), getLineNumber(Loc),
-  getDeclContextDescriptor(TD));
-  }
-}
-break;
-  }
-
-  case Type::Record: {
-TyDecl = cast(Ty)->getDecl();
-if (!TyDecl->isFromASTFile())
-  return nullptr;
-
-if (auto *CTSD = dyn_cast(TyDecl))
-  if (!CTSD->isExplicitInstantiationOrSpecialization() && !Anchored)
-// We may not assume that this type made it into the module.
-return nullptr;
-// C++ classes and template instantiations.
-if (auto *RD = dyn_cast(TyDecl)) {
-  if (!RD->getDefinition())
-

Re: [PATCH] D12767: [Static Analyzer] Properly clean up the dynamic type information for dead regions.

2015-09-11 Thread Gábor Horváth via cfe-commits
xazax.hun updated this revision to Diff 34554.
xazax.hun added a comment.

- Addressed the comments.


http://reviews.llvm.org/D12767

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  lib/StaticAnalyzer/Core/CMakeLists.txt
  lib/StaticAnalyzer/Core/CallEvent.cpp
  lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
  lib/StaticAnalyzer/Core/ProgramState.cpp

Index: lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- lib/StaticAnalyzer/Core/ProgramState.cpp
+++ lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -752,36 +752,3 @@
   return Tainted;
 }
 
-/// The GDM component containing the dynamic type info. This is a map from a
-/// symbol to its most likely type.
-REGISTER_TRAIT_WITH_PROGRAMSTATE(DynamicTypeMap,
- CLANG_ENTO_PROGRAMSTATE_MAP(const MemRegion *,
- DynamicTypeInfo))
-
-DynamicTypeInfo ProgramState::getDynamicTypeInfo(const MemRegion *Reg) const {
-  Reg = Reg->StripCasts();
-
-  // Look up the dynamic type in the GDM.
-  const DynamicTypeInfo *GDMType = get(Reg);
-  if (GDMType)
-return *GDMType;
-
-  // Otherwise, fall back to what we know about the region.
-  if (const TypedRegion *TR = dyn_cast(Reg))
-return DynamicTypeInfo(TR->getLocationType(), /*CanBeSubclass=*/false);
-
-  if (const SymbolicRegion *SR = dyn_cast(Reg)) {
-SymbolRef Sym = SR->getSymbol();
-return DynamicTypeInfo(Sym->getType());
-  }
-
-  return DynamicTypeInfo();
-}
-
-ProgramStateRef ProgramState::setDynamicTypeInfo(const MemRegion *Reg,
- DynamicTypeInfo NewTy) const {
-  Reg = Reg->StripCasts();
-  ProgramStateRef NewState = set(Reg, NewTy);
-  assert(NewState);
-  return NewState;
-}
Index: lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
@@ -0,0 +1,51 @@
+//==- DynamicTypeMap.cpp - Dynamic Type Info related APIs --*- C++ -*-//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This file defines APIs that track and query dynamic type information. This
+//  information can be used to devirtualize calls during the symbolic exection
+//  or do type checking.
+//
+//===--===//
+
+#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h"
+
+namespace clang {
+namespace ento {
+
+DynamicTypeInfo getDynamicTypeInfo(ProgramStateRef State,
+   const MemRegion *Reg) {
+  Reg = Reg->StripCasts();
+
+  // Look up the dynamic type in the GDM.
+  const DynamicTypeInfo *GDMType = State->get(Reg);
+  if (GDMType)
+return *GDMType;
+
+  // Otherwise, fall back to what we know about the region.
+  if (const TypedRegion *TR = dyn_cast(Reg))
+return DynamicTypeInfo(TR->getLocationType(), /*CanBeSubclass=*/false);
+
+  if (const SymbolicRegion *SR = dyn_cast(Reg)) {
+SymbolRef Sym = SR->getSymbol();
+return DynamicTypeInfo(Sym->getType());
+  }
+
+  return DynamicTypeInfo();
+}
+
+ProgramStateRef setDynamicTypeInfo(ProgramStateRef State, const MemRegion *Reg,
+   DynamicTypeInfo NewTy) {
+  Reg = Reg->StripCasts();
+  ProgramStateRef NewState = State->set(Reg, NewTy);
+  assert(NewState);
+  return NewState;
+}
+
+} // namespace ento
+} // namespace clang
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -17,6 +17,7 @@
 #include "clang/AST/ParentMap.h"
 #include "clang/Analysis/ProgramPoint.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/raw_ostream.h"
@@ -435,7 +436,7 @@
 return RuntimeDefinition();
 
   // Do we know anything about the type of 'this'?
-  DynamicTypeInfo DynType = getState()->getDynamicTypeInfo(R);
+  DynamicTypeInfo DynType = getDynamicTypeInfo(getState(), R);
   if (!DynType.isValid())
 return RuntimeDefinition();
 
@@ -800,7 +801,7 @@
   if (!Receiver)
 return RuntimeDefinition();
 
-  DynamicTypeInfo DTI = getState()->getDynamicTypeInfo(Receiver);
+  DynamicTypeInfo DTI = getDynamicTypeInfo(getState(), Receiver);
   QualType DynType = DTI.getType();
   CanBeSubClassed = DTI.canBeASubClass();
   

Re: [PATCH] D12652: [Static Analyzer] Lambda support.

2015-09-11 Thread Gábor Horváth via cfe-commits
xazax.hun added inline comments.


Comment at: include/clang/StaticAnalyzer/Core/AnalyzerOptions.h:515-517
@@ -511,1 +514,5 @@
 
+  /// Returns true if lambdas should be inlined. Otherwise a sink node will be
+  /// generated each time a LambdaExpr is visited.
+  bool shouldInlineLambdas();
+

jordan_rose wrote:
> "inline" is kind of a misnomer, since we may not actually inline lambdas. I 
> would have suggested "model lambdas" or "lambda support".
Even when this configuration option is set to false, the body of the lambda is 
analyzed as a top level function. For this reason I think the "lambda support" 
might be a misnomer too. What do you think?


Comment at: lib/StaticAnalyzer/Core/MemRegion.cpp:740-741
@@ -739,3 +739,4 @@
   const DeclContext *DC,
-  const VarDecl *VD) {
+  const VarDecl *VD,
+  MemRegionManager *Mmgr) {
   while (LC) {

jordan_rose wrote:
> Why the extra parameter?
This is just a leftover from code evolution, thank you for spotting this.


http://reviews.llvm.org/D12652



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


Re: [PATCH] D12743: [CodeGen] Teach SimplifyPersonality about the updated LandingPadInst

2015-09-11 Thread Reid Kleckner via cfe-commits
rnk added a comment.

Right, I understand the behavior change, I'm just wondering why it results in 
link failures. There isn't a ton of public info about how ObjC++ EH interacts 
with C++ EH.


Repository:
  rL LLVM

http://reviews.llvm.org/D12743



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


[PATCH] D12807: Display name of identifier tokens in Visual Studio native visualizer

2015-09-11 Thread Mike Spertus via cfe-commits
mspertus created this revision.
mspertus added a subscriber: cfe-commits.

The Token visualizer in clang.natvis makes debugging Clang in Visual Studio 
much easier for keywords (because a given keyword is always the same), but it 
doesn't work very well for identifiers (because they are all different). This 
change has the visualizer display the name of the identifier. I have been using 
this daily, and I find this simple change has lead to a much-improved 
day-to-day experience.

http://reviews.llvm.org/D12807

Files:
  utils/clang.natvis

Index: utils/clang.natvis
===
--- utils/clang.natvis
+++ utils/clang.natvis
@@ -27,7 +27,8 @@
 
   
   
-{(clang::tok::TokenKind)Kind}
+{(clang::tok::TokenKind)Kind}
+{{Identifier 
({*(clang::IdentifierInfo *)(PtrData)})}}
   
   
 [{(clang::DeclSpec::SCS)StorageClassSpec}], 
[{(clang::TypeSpecifierType)TypeSpecType}]


Index: utils/clang.natvis
===
--- utils/clang.natvis
+++ utils/clang.natvis
@@ -27,7 +27,8 @@
 
   
   
-{(clang::tok::TokenKind)Kind}
+{(clang::tok::TokenKind)Kind}
+{{Identifier ({*(clang::IdentifierInfo *)(PtrData)})}}
   
   
 [{(clang::DeclSpec::SCS)StorageClassSpec}], [{(clang::TypeSpecifierType)TypeSpecType}]
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12807: Display name of identifier tokens in Visual Studio native visualizer

2015-09-11 Thread Mike Spertus via cfe-commits
mspertus added a comment.

Thanks, Aaron! Hal mentioned that I might need to ask you to commit on my 
behalf as I don't have commit access as of now.


http://reviews.llvm.org/D12807



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


Re: r247369 - Module Debugging: Emit forward declarations for types that are defined in

2015-09-11 Thread Adrian Prantl via cfe-commits

> On Sep 11, 2015, at 8:27 AM, David Blaikie  wrote:
> 
> 
> 
> On Fri, Sep 11, 2015 at 8:18 AM, Adrian Prantl  > wrote:
> 
>> On Sep 10, 2015, at 6:56 PM, David Blaikie > > wrote:
>> 
>> 
>> 
>> On Thu, Sep 10, 2015 at 6:40 PM, David Blaikie > > wrote:
>> 
>> 
>> On Thu, Sep 10, 2015 at 6:03 PM, Adrian Prantl via cfe-commits 
>> > wrote:
>> Author: adrian
>> Date: Thu Sep 10 20:03:26 2015
>> New Revision: 247369
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=247369=rev 
>> 
>> Log:
>> Module Debugging: Emit forward declarations for types that are defined in
>> clang modules, if -dwarf-ext-refs (DebugTypesExtRefs) is specified.
>> 
>> This change seems to have a lot more code in it than I was expecting... 
>> 
>> I was rather expecting something a lot like the flimit-debug-info support. 
>> Specifically, I would've expected one more conditional added to 
>> CGDebugInfo::shouldOmitDefinition.
>> 
>> Why the extra complexity?
>> 
>> I guess part of it is to be able to omit definitions of things other than 
>> record types - is there much value in that? (especially typedefs - it seems 
>> like a typedef is too small to benefit from a declaration (even if we could 
>> emit one)?)
> 
> The typedef itself is not interesting, but it can be used to anchor template 
> instantiations like std::string. The contract between the debug info in the 
> module and the debug info referencing the module is that all explicit 
> template specializations 
> 
> This I get ^ (though does that case need any special handling, or will the 
> isFromASTFile return true for the location of the explicit specialization 
> declaration/definition?)
>  
> and template instantiations referenced used in a typedef can be expected to 
> exist in the module.
> 
> This I do not get & would imagine it could cause substantial size increase... 
> 
> Might be worth splitting out that change to look at it more carefully. I'd 
> love to see numbers here.
>> Also, we could possibly solve both the problem of "don't emit definitions 
>> for module things when compiling the main source file" and "don't emit 
>> definitions for module things defined in other modules" with the same tool. 
>> If there's a way to say "is this in a foreign AST file" then testing for 
>> that in CGDebugInfo::shouldOmitDefinition would solve both problems, I think 
>> (conditionalized on the appropriate flags, either dwarf-ext-refs or "I'm 
>> building a module here”).
> 
> I believe that this is a good point. Really, getExtRefOrNull is a separate 
> function mostly for evolutionary reasons — it used to do different things 
> like mangling names of ObjC types etc. I will see if I can merge the existing 
> functionality into shouldOmitDefinition().
> 
> From a review perspective it might be easier to revert this & commit a new 
> patch - I haven't reviewed all these changes in detail because they just 
> seemed more complex than necessary, but if you're going to evolve it from 
> here I'll need to dig into the current implementation/be more careful about 
> checking that future changes remove the complexity along with whatever they 
> add.
> 

I just did this in r24743[12].

-- adrian

> - Dave
>  
> 
> -- adrian
> 
>>  
>>  
>> 
>> Added:
>> cfe/trunk/test/Modules/ExtDebugInfo.cpp
>> cfe/trunk/test/Modules/ExtDebugInfo.m
>> Modified:
>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> cfe/trunk/lib/CodeGen/CGDebugInfo.h
>> 
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=247369=247368=247369=diff
>>  
>> 
>> ==
>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Sep 10 20:03:26 2015
>> @@ -148,7 +148,9 @@ void CGDebugInfo::setLocation(SourceLoca
>>  }
>> 
>>  llvm::DIScope *CGDebugInfo::getDeclContextDescriptor(const Decl *D) {
>> -  return getContextDescriptor(cast(D->getDeclContext()), TheCU);
>> +  llvm::DIScope *Mod = getParentModuleOrNull(D);
>> +  return getContextDescriptor(cast(D->getDeclContext()),
>> +  Mod ? Mod : TheCU);
>>  }
>> 
>>  llvm::DIScope *CGDebugInfo::getContextDescriptor(const Decl *Context,
>> @@ -1448,6 +1450,9 @@ void CGDebugInfo::completeRequiredType(c
>>  if (CXXDecl->isDynamicClass())
>>return;
>> 
>> +  if (DebugTypeExtRefs && RD->isFromASTFile())
>> +return;
>> +
>>QualType Ty = CGM.getContext().getRecordType(RD);
>>llvm::DIType *T = getTypeOrNull(Ty);
>>if (T && T->isForwardDecl())

Re: [PATCH] D12652: [Static Analyzer] Lambda support.

2015-09-11 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247426: [Static Analyzer] Lambda support. (authored by 
xazax).

Changed prior to commit:
  http://reviews.llvm.org/D12652?vs=34498=34555#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12652

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
  cfe/trunk/test/Analysis/dead-stores.cpp
  cfe/trunk/test/Analysis/lambda-notes.cpp
  cfe/trunk/test/Analysis/lambdas.cpp
  cfe/trunk/test/Analysis/temporaries.cpp

Index: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -256,6 +256,9 @@
   /// \sa getMaxNodesPerTopLevelFunction
   Optional MaxNodesPerTopLevelFunction;
 
+  /// \sa shouldInlineLambdas
+  Optional InlineLambdas;
+
   /// A helper function that retrieves option for a given full-qualified
   /// checker name.
   /// Options for checkers can be specified via 'analyzer-config' command-line
@@ -509,6 +512,10 @@
   /// This is controlled by the 'max-nodes' config option.
   unsigned getMaxNodesPerTopLevelFunction();
 
+  /// Returns true if lambdas should be inlined. Otherwise a sink node will be
+  /// generated each time a LambdaExpr is visited.
+  bool shouldInlineLambdas();
+
 public:
   AnalyzerOptions() :
 AnalysisStoreOpt(RegionStoreModel),
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
@@ -341,6 +341,10 @@
   void VisitBlockExpr(const BlockExpr *BE, ExplodedNode *Pred, 
   ExplodedNodeSet );
 
+  /// VisitLambdaExpr - Transfer function logic for LambdaExprs.
+  void VisitLambdaExpr(const LambdaExpr *LE, ExplodedNode *Pred, 
+   ExplodedNodeSet );
+
   /// VisitBinaryOperator - Transfer function logic for binary operators.
   void VisitBinaryOperator(const BinaryOperator* B, ExplodedNode *Pred, 
ExplodedNodeSet );
Index: cfe/trunk/test/Analysis/dead-stores.cpp
===
--- cfe/trunk/test/Analysis/dead-stores.cpp
+++ cfe/trunk/test/Analysis/dead-stores.cpp
@@ -174,3 +174,17 @@
   return radar13213575_testit(5) + radar13213575_testit(3);
 }
 
+//===--===//
+// Dead store checking involving lambdas.
+//===--===//
+
+int basicLambda(int i, int j) {
+  i = 5; // no warning
+  j = 6; // no warning
+  [i] { (void)i; }();
+  [] { (void)j; }();
+  i = 2;
+  j = 3;
+  return i + j;
+}
+
Index: cfe/trunk/test/Analysis/lambda-notes.cpp
===
--- cfe/trunk/test/Analysis/lambda-notes.cpp
+++ cfe/trunk/test/Analysis/lambda-notes.cpp
@@ -0,0 +1,204 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -analyze -analyzer-checker=core -analyzer-config inline-lambdas=true -analyzer-output plist -verify %s -o %t
+// RUN: FileCheck --input-file=%t %s
+
+
+// Diagnostic inside a lambda
+
+void diagnosticFromLambda() {
+  int i = 0;
+  [=] {
+int p = 5/i; // expected-warning{{Division by zero}}
+(void)p;
+  }();
+}
+
+// CHECK:  
+// CHECK:   
+// CHECK:path
+// CHECK:
+// CHECK: 
+// CHECK:  kindcontrol
+// CHECK:  edges
+// CHECK:   
+// CHECK:
+// CHECK: start
+// CHECK:  
+// CHECK:   
+// CHECK:line8
+// CHECK:col3
+// CHECK:file0
+// CHECK:   
+// CHECK:   
+// CHECK:line8
+// CHECK:col5
+// CHECK:file0
+// CHECK:   
+// CHECK:  
+// CHECK: end
+// CHECK:  
+// CHECK:   
+// CHECK:line9
+// CHECK:col3
+// CHECK:file0
+// CHECK:   
+// CHECK:   
+// CHECK:line9
+// CHECK:col3
+// CHECK:file0
+// CHECK:   
+// CHECK:  
+// CHECK:
+// CHECK:   
+// CHECK: 
+// CHECK: 
+// CHECK:  kindevent
+// CHECK:  location
+// CHECK:  
+// CHECK:   line9
+// CHECK:   col3
+// CHECK:   file0
+// CHECK:  
+// CHECK:  ranges
+// CHECK:  
+// CHECK:
+// CHECK: 
+// CHECK:  line9
+// CHECK:  

Re: [PATCH] D12743: [CodeGen] Teach SimplifyPersonality about the updated LandingPadInst

2015-09-11 Thread Vedant Kumar via cfe-commits
vsk added a comment.

I think 'optimization' is a bit of a misnomer. There's a comment in this code 
that reads: "Can't do the optimization if it has non-C++ uses", so that's why I 
picked up the word. Without SimplifyPersonality(), some objective c++ code can 
no longer link against c++ libraries.

Consider the following test:
$ echo "#include " "\n" 'void foo() { throw 
std::runtime_error("foo"); }' | clang -x objective-cxx -S -emit-llvm - -o - | 
grep personality

After we moved personality from landingpadinst to functions, the output of the 
test changes (from __gxx_personality to __objc_personality). This commit just 
takes us back to the original behavior.

The original comment, "Otherwise, it has to be a landingpad instruction.", is 
wrong after David's patch.


http://reviews.llvm.org/D12743



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


r247436 - [CMake] Making the bootstrap-clear target always delete the boostrap build directories.

2015-09-11 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Fri Sep 11 12:38:38 2015
New Revision: 247436

URL: http://llvm.org/viewvc/llvm-project?rev=247436=rev
Log:
[CMake] Making the bootstrap-clear target always delete the boostrap build 
directories.

Modified:
cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=247436=247435=247436=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Fri Sep 11 12:38:38 2015
@@ -598,7 +598,6 @@ if (CLANG_ENABLE_BOOTSTRAP)
 COMMAND ${CMAKE_COMMAND} -E make_directory ${BINARY_DIR}
 COMMAND ${CMAKE_COMMAND} -E remove_directory ${STAMP_DIR}
 COMMAND ${CMAKE_COMMAND} -E make_directory ${STAMP_DIR}
-COMMAND ${CMAKE_COMMAND} -E touch 
${CMAKE_CURRENT_BINARY_DIR}/bootstrap-cleared
 COMMENT "Clobberring bootstrap build and stamp directories"
 )
 


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


Re: r247432 - Module Debugging: Emit forward declarations for types that are defined in

2015-09-11 Thread David Blaikie via cfe-commits
On Fri, Sep 11, 2015 at 10:23 AM, Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: adrian
> Date: Fri Sep 11 12:23:08 2015
> New Revision: 247432
>
> URL: http://llvm.org/viewvc/llvm-project?rev=247432=rev
> Log:
> Module Debugging: Emit forward declarations for types that are defined in
> clang modules, if -dwarf-ext-refs (DebugTypesExtRefs) is specified.
>
> This reimplements r247369 in about a third of the amount of code.
> Thanks to David Blaikie pointing this out in post-commit review!
>
> Added:
> cfe/trunk/test/Modules/ExtDebugInfo.cpp
> cfe/trunk/test/Modules/ExtDebugInfo.m
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CGDebugInfo.h
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=247432=247431=247432=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep 11 12:23:08 2015
> @@ -148,7 +148,9 @@ void CGDebugInfo::setLocation(SourceLoca
>  }
>
>  llvm::DIScope *CGDebugInfo::getDeclContextDescriptor(const Decl *D) {
> -  return getContextDescriptor(cast(D->getDeclContext()), TheCU);
> +  llvm::DIScope *Mod = getParentModuleOrNull(D);
> +  return getContextDescriptor(cast(D->getDeclContext()),
> +  Mod ? Mod : TheCU);
>

Might've been nice to separate the module-parenting part of the change,
smaller patches (easier to revert, review, etc), the usual stuff.


>  }
>
>  llvm::DIScope *CGDebugInfo::getContextDescriptor(const Decl *Context,
> @@ -1448,6 +1450,9 @@ void CGDebugInfo::completeRequiredType(c
>  if (CXXDecl->isDynamicClass())
>return;
>
> +  if (DebugTypeExtRefs && RD->isFromASTFile())
> +return;
> +
>QualType Ty = CGM.getContext().getRecordType(RD);
>llvm::DIType *T = getTypeOrNull(Ty);
>if (T && T->isForwardDecl())
> @@ -1478,8 +1483,19 @@ static bool hasExplicitMemberDefinition(
>  }
>
>  static bool shouldOmitDefinition(CodeGenOptions::DebugInfoKind DebugKind,
> + bool DebugTypeExtRefs,
>   const RecordDecl *RD,
>   const LangOptions ) {
> +  // Does the type exist in an imported clang module?
> +  if (DebugTypeExtRefs && RD->isFromASTFile()) {
> +if (auto *CTSD = dyn_cast(RD))
> +  if (CTSD->isExplicitInstantiationOrSpecialization())
> +// We may not assume that this type made it into the module.
>

I guess you mean "we may assume this type made it into the module"? (the
"not" seems erroneous - but perhaps I'm misparsing the sentence?)


> +return true;
>

Does this case ^ actually do anything? (aren't all these instantiations
going to be definitions anyway? so if you removed that code the below would
return true anyway, wouldn't it?)


> +if (RD->getDefinition())
> +  return true;
> +  }
> +
>if (DebugKind > CodeGenOptions::LimitedDebugInfo)
>  return false;
>
> @@ -1513,7 +1529,8 @@ static bool shouldOmitDefinition(CodeGen
>  llvm::DIType *CGDebugInfo::CreateType(const RecordType *Ty) {
>RecordDecl *RD = Ty->getDecl();
>llvm::DIType *T = cast_or_null(getTypeOrNull(QualType(Ty,
> 0)));
> -  if (T || shouldOmitDefinition(DebugKind, RD, CGM.getLangOpts())) {
> +  if (T || shouldOmitDefinition(DebugKind, DebugTypeExtRefs, RD,
> +CGM.getLangOpts())) {
>  if (!T)
>T = getOrCreateRecordFwdDecl(Ty, getDeclContextDescriptor(RD));
>  return T;
> @@ -1616,6 +1633,12 @@ llvm::DIType *CGDebugInfo::CreateType(co
>if (!ID)
>  return nullptr;
>
> +  // Return a forward declaration if this type was imported from a clang
> module.
>

What's this extra code needed for? Isn't this what shouldOmitDefinition
already does? It causes calls to getOrCreateRecordFwdDecl and so we should
never get into the CreateTypeDefinition function for the type.


> +  if (DebugTypeExtRefs && ID->isFromASTFile() && ID->getDefinition())
> +return DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type,
> +  ID->getName(),
> +  getDeclContextDescriptor(ID), Unit,
> 0);
> +
>// Get overall information about the record type for the debug info.
>llvm::DIFile *DefUnit = getOrCreateFile(ID->getLocation());
>unsigned Line = getLineNumber(ID->getLocation());
> @@ -1669,9 +1692,9 @@ CGDebugInfo::getOrCreateModuleRef(Extern
>TheCU->getSourceLanguage(), internString(Mod.ModuleName),
>internString(Mod.Path), TheCU->getProducer(), true, StringRef(), 0,
>internString(Mod.ASTFile), llvm::DIBuilder::FullDebug,
> Mod.Signature);
> -  llvm::DIModule *M =
> -  DIB.createModule(CU, Mod.ModuleName, ConfigMacros,
> internString(Mod.Path),
> -   

Re: [PATCH] D12743: [CodeGen] Teach SimplifyPersonality about the updated LandingPadInst

2015-09-11 Thread Reid Kleckner via cfe-commits
rnk added a subscriber: rnk.
rnk added a comment.

I'm confused. I thought SimplifyPersonalityFunction was an optimization, but 
somehow it caused link failures? Why do you think this was an ABI break?



Comment at: test/CodeGenObjCXX/exception-cxx.mm:8
@@ +7,3 @@
+  throw 0;
+} catch (...) {
+  return;

Don't you want to test the 'catch (int e)' case? That introduces interesting 
uses of the selector that catch-all doesn't have.


http://reviews.llvm.org/D12743



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


r247434 - Update test expectations for LLVM asm printing change

2015-09-11 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Sep 11 12:27:53 2015
New Revision: 247434

URL: http://llvm.org/viewvc/llvm-project?rev=247434=rev
Log:
Update test expectations for LLVM asm printing change

Modified:
cfe/trunk/test/CodeGen/exceptions-seh-new.c

Modified: cfe/trunk/test/CodeGen/exceptions-seh-new.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/exceptions-seh-new.c?rev=247434=247433=247434=diff
==
--- cfe/trunk/test/CodeGen/exceptions-seh-new.c (original)
+++ cfe/trunk/test/CodeGen/exceptions-seh-new.c Fri Sep 11 12:27:53 2015
@@ -30,8 +30,9 @@ int safe_div(int numerator, int denomina
 // CHECK:   to label %{{.*}} unwind label %[[catchpad:[^ ]*]]
 //
 // CHECK: [[catchpad]]
-// X64: %[[padtoken:[^ ]*]] = catchpad [i8* null] to label %[[exceptret:[^ 
]*]] unwind label
-// X86: %[[padtoken:[^ ]*]] = catchpad [i8* bitcast (i32 ()* 
@"\01?filt$0@0@safe_div@@" to i8*)] to label %[[exceptret:[^ ]*]] unwind label
+// X64: %[[padtoken:[^ ]*]] = catchpad [i8* null]
+// X86: %[[padtoken:[^ ]*]] = catchpad [i8* bitcast (i32 ()* 
@"\01?filt$0@0@safe_div@@" to i8*)]
+// CHECK-NEXT:to label %[[exceptret:[^ ]*]] unwind label
 //
 // CHECK: [[exceptret]]
 // CHECK: catchret %[[padtoken]] to label %[[except:[^ ]*]]
@@ -113,7 +114,8 @@ int nested_try(void) {
 // CHECK:   to label %[[cont:[^ ]*]] unwind label %[[cpad_inner:[^ ]*]]
 //
 // CHECK: [[cpad_inner]]
-// CHECK: catchpad [i8* bitcast (i32 ({{.*}})* @"\01?filt$1@0@nested_try@@" to 
i8*)] to label %[[exceptret_inner:[^ ]*]] unwind label %[[cpad_outer:[^ ]*]]
+// CHECK: catchpad [i8* bitcast (i32 ({{.*}})* @"\01?filt$1@0@nested_try@@" to 
i8*)]
+// CHECK-NEXT: to label %[[exceptret_inner:[^ ]*]] unwind label 
%[[cpad_outer:[^ ]*]]
 //
 // CHECK: [[exceptret_inner]]
 // CHECK: catchret {{.*}} to label %[[except_inner:[^ ]*]]
@@ -126,7 +128,8 @@ int nested_try(void) {
 // CHECK: br label %[[outer_try_cont:[^ ]*]]
 //
 // CHECK: [[cpad_outer]]
-// CHECK: catchpad [i8* bitcast (i32 ({{.*}})* @"\01?filt$0@0@nested_try@@" to 
i8*)] to label %[[exceptret_outer:[^ ]*]] unwind label
+// CHECK: catchpad [i8* bitcast (i32 ({{.*}})* @"\01?filt$0@0@nested_try@@" to 
i8*)]
+// CHECK-NEXT: to label %[[exceptret_outer:[^ ]*]] unwind label
 //
 // CHECK: [[exceptret_outer]]
 // CHECK: catchret {{.*}} to label %[[except_outer:[^ ]*]]


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


Re: r247346 - [MS ABI] Make member pointers return true for isIncompleteType

2015-09-11 Thread Hans Wennborg via cfe-commits
This made the Chromium build sad. For example:
http://build.chromium.org/p/chromium.fyi/builders/ClangToTWin/builds/3092/steps/compile/logs/stdio

Reduction:

$ clang -cc1 -triple i686-pc-windows-msvc18.0.0 -w -fms-extensions
-fms-compatibility -fms-compatibility-version=18.0 -std=c++11
-fdelayed-template-parsing a.ii

template 
void JSMethod(char *, char *, int);
class A {
  int printd(int *, const int &, int &, int &);
  int printd_info;
  void printd() { JSMethod("", "", printd_info); }
};


On Thu, Sep 10, 2015 at 2:52 PM, David Majnemer via cfe-commits
 wrote:
> Author: majnemer
> Date: Thu Sep 10 16:52:00 2015
> New Revision: 247346
>
> URL: http://llvm.org/viewvc/llvm-project?rev=247346=rev
> Log:
> [MS ABI] Make member pointers return true for isIncompleteType
>
> The type of a member pointer is incomplete if it has no inheritance
> model.  This lets us reuse more general logic already embedded in clang.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12807: Display name of identifier tokens in Visual Studio native visualizer

2015-09-11 Thread Aaron Ballman via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

I've commit in r247442, thank you for the patch!


http://reviews.llvm.org/D12807



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


r247442 - Extend the Token visualizer used by MSVC to display the identifier text for tok::identifier tokens.

2015-09-11 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Sep 11 13:35:18 2015
New Revision: 247442

URL: http://llvm.org/viewvc/llvm-project?rev=247442=rev
Log:
Extend the Token visualizer used by MSVC to display the identifier text for 
tok::identifier tokens.

Patch by Mike Spertus.

Modified:
cfe/trunk/utils/clang.natvis

Modified: cfe/trunk/utils/clang.natvis
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/clang.natvis?rev=247442=247441=247442=diff
==
--- cfe/trunk/utils/clang.natvis (original)
+++ cfe/trunk/utils/clang.natvis Fri Sep 11 13:35:18 2015
@@ -24,13 +24,14 @@ or create a symbolic link so it updates
   *(clang::IdentifierInfo *)(Ptr  
~PtrMask)
   *(clang::IdentifierInfo *)(Ptr  
~PtrMask)
   (clang::DeclarationNameExtra::ExtraKind)((clang::DeclarationNameExtra
 *)(Ptr  ~PtrMask))-ExtraKindOrNumArgs
-
-  
-  
-{(clang::tok::TokenKind)Kind}
-  
-  
-[{(clang::DeclSpec::SCS)StorageClassSpec}], 
[{(clang::TypeSpecifierType)TypeSpecType}]
+
+  
+  
+{(clang::tok::TokenKind)Kind}
+{{Identifier 
({*(clang::IdentifierInfo *)(PtrData)})}}
+  
+  
+[{(clang::DeclSpec::SCS)StorageClassSpec}], 
[{(clang::TypeSpecifierType)TypeSpecType}]
   
   
 {Name,s}


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


Re: [PATCH] D12743: [CodeGen] Teach SimplifyPersonality about the updated LandingPadInst

2015-09-11 Thread Vedant Kumar via cfe-commits
vsk marked an inline comment as done.
vsk added a comment.

Addressed Reid's comment w.r.t exception object type.


Repository:
  rL LLVM

http://reviews.llvm.org/D12743



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


Re: [PATCH] D12734: Another patch for modernize-loop-convert.

2015-09-11 Thread Angel Garcia via cfe-commits
angelgarcia updated this revision to Diff 34535.
angelgarcia added a comment.

Add examples of 'default' usages.


http://reviews.llvm.org/D12734

Files:
  clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tidy/modernize/LoopConvertCheck.h
  clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tidy/modernize/LoopConvertUtils.h
  test/clang-tidy/Inputs/modernize-loop-convert/structures.h
  test/clang-tidy/modernize-loop-convert-basic.cpp
  test/clang-tidy/modernize-loop-convert-extra.cpp
  test/clang-tidy/modernize-loop-convert-negative.cpp

Index: test/clang-tidy/modernize-loop-convert-negative.cpp
===
--- test/clang-tidy/modernize-loop-convert-negative.cpp
+++ test/clang-tidy/modernize-loop-convert-negative.cpp
@@ -290,7 +290,6 @@
 dependent v;
 dependent *pv;
 
-transparent cv;
 int Sum = 0;
 
 // Checks for the Index start and end:
@@ -473,3 +472,41 @@
 }
 
 } // namespace NegativeMultiEndCall
+
+namespace NoUsages {
+
+const int N = 6;
+int arr[N] = {1, 2, 3, 4, 5, 6};
+S s;
+dependent v;
+int Count = 0;
+
+void foo();
+
+void f() {
+  for (int I = 0; I < N; ++I) {}
+  for (int I = 0; I < N; ++I)
+printf("Hello world\n");
+  for (int I = 0; I < N; ++I)
+++Count;
+  for (int I = 0; I < N; ++I)
+foo();
+
+  for (S::iterator I = s.begin(), E = s.end(); I != E; ++I) {}
+  for (S::iterator I = s.begin(), E = s.end(); I != E; ++I)
+printf("Hello world\n");
+  for (S::iterator I = s.begin(), E = s.end(); I != E; ++I)
+++Count;
+  for (S::iterator I = s.begin(), E = s.end(); I != E; ++I)
+foo();
+
+  for (int I = 0; I < v.size(); ++I) {}
+  for (int I = 0; I < v.size(); ++I)
+printf("Hello world\n");
+  for (int I = 0; I < v.size(); ++I)
+++Count;
+  for (int I = 0; I < v.size(); ++I)
+foo();
+}
+
+} // namespace NoUsages
Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -14,10 +14,9 @@
 int b = arr[i][a];
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & elem : arr) {
+  // CHECK-FIXES: for (auto & elem : arr)
   // CHECK-FIXES-NEXT: int a = 0;
   // CHECK-FIXES-NEXT: int b = elem[a];
-  // CHECK-FIXES-NEXT: }
 
   for (int j = 0; j < M; ++j) {
 int a = 0;
@@ -121,16 +120,16 @@
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (auto alias : IntArr)
-  // CHECK-FIXES-NEXT: if (alias) {
+  // CHECK-FIXES-NEXT: if (alias)
 
   for (unsigned i = 0; i < N; ++i) {
 while (int alias = IntArr[i]) {
   sideEffect(alias);
 }
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (auto alias : IntArr)
-  // CHECK-FIXES-NEXT: while (alias) {
+  // CHECK-FIXES-NEXT: while (alias)
 
   for (unsigned i = 0; i < N; ++i) {
 switch (int alias = IntArr[i]) {
@@ -140,32 +139,32 @@
   }
   // CHECK-MESSAGES: :[[@LINE-6]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (auto alias : IntArr)
-  // CHECK-FIXES-NEXT: switch (alias) {
+  // CHECK-FIXES-NEXT: switch (alias)
 
   for (unsigned i = 0; i < N; ++i) {
 for (int alias = IntArr[i]; alias < N; ++alias) {
   sideEffect(alias);
 }
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (auto alias : IntArr)
-  // CHECK-FIXES-NEXT: for (; alias < N; ++alias) {
+  // CHECK-FIXES-NEXT: for (; alias < N; ++alias)
 
   for (unsigned i = 0; i < N; ++i) {
 for (unsigned j = 0; int alias = IntArr[i]; ++j) {
   sideEffect(alias);
 }
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (auto alias : IntArr)
-  // CHECK-FIXES-NEXT: for (unsigned j = 0; alias; ++j) {
+  // CHECK-FIXES-NEXT: for (unsigned j = 0; alias; ++j)
 
   struct IntRef { IntRef(const int& i); };
   for (int i = 0; i < N; ++i) {
 IntRef Int(IntArr[i]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & elem : IntArr) {
+  // CHECK-FIXES: for (auto & elem : IntArr)
   // CHECK-FIXES-NEXT: IntRef Int(elem);
 }
 
@@ -288,7 +287,7 @@
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (auto & DEFs_it : DEFs)
-  // CHECK-FIXES-NEXT: if (DEFs_it == DEF) {
+  // CHECK-FIXES-NEXT: if (DEFs_it == DEF)
   // CHECK-FIXES-NEXT: printf("I found %d\n", DEFs_it);
 }
 
@@ -315,8 +314,8 @@
   T Vals;
   // Using the name "Val", although it is the name of an existing struct, is
   // safe in this loop since it will only exist within this scope.
-  for (T::iterator it = Vals.begin(), e = Vals.end(); it != e; ++it) {
-  }
+  for (T::iterator it = Vals.begin(), e = Vals.end(); it != e; 

Re: [PATCH] D12358: [Analyzer] Handling constant bound loops

2015-09-11 Thread Sean Eveson via cfe-commits
seaneveson added a comment.

In http://reviews.llvm.org/D12358#241631, @cfe-commits wrote:

> Hi Sean,
>
> Ted provided more details off-list. He suspects that the problem is that we 
> likely don't add MemSpaceRegions to the worklist because every region is a 
> subregion of a MemSpaceRegion, and thus we would invalidate, by default, all 
> regions that were in the same MemSpace as the regions we were invalidating.  
> He thinks we want to not change that behavior, but also provide a way of 
> invalidating an entire MemSpace if so desired.  That's probably just a slight 
> tweak to the algorithm.
>
> I’ll take a look at your updated patch to reproduce what you are seeing and 
> investigate to see if that is what is going on.
>
> Thanks,
> Devin


Hi Devin,

That sounds good, thanks for looking at this.  Can you let me know when you 
will be able to look at this?  I am doing some work that builds on this patch's 
functionality and having this patch accepted would help.

Thanks,
Sean


http://reviews.llvm.org/D12358



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


r247397 - clang/test/Modules/ExtDebugInfo.cpp: Use %itanium_abi_triple.

2015-09-11 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Fri Sep 11 03:56:12 2015
New Revision: 247397

URL: http://llvm.org/viewvc/llvm-project?rev=247397=rev
Log:
clang/test/Modules/ExtDebugInfo.cpp: Use %itanium_abi_triple.

Modified:
cfe/trunk/test/Modules/ExtDebugInfo.cpp

Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=247397=247396=247397=diff
==
--- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Fri Sep 11 03:56:12 2015
@@ -3,14 +3,17 @@
 
 // Modules:
 // RUN: %clang_cc1 -x objective-c++ -std=c++11 -g -dwarf-ext-refs -fmodules \
+// RUN: -triple %itanium_abi_triple \
 // RUN: -fmodule-format=obj -fimplicit-module-maps -DMODULES \
 // RUN: -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o 
%t-mod.ll
 // RUN: cat %t-mod.ll |  FileCheck %s
 
 // PCH:
 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodule-format=obj -emit-pch -I%S/Inputs 
\
+// RUN: -triple %itanium_abi_triple \
 // RUN: -o %t.pch %S/Inputs/DebugCXX.h
 // RUN: %clang_cc1 -std=c++11 -g -dwarf-ext-refs -fmodule-format=obj \
+// RUN: -triple %itanium_abi_triple \
 // RUN: -include-pch %t.pch %s -emit-llvm -o %t-pch.ll %s
 // RUN: cat %t-pch.ll |  FileCheck %s
 


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


r247392 - Fix \param in r247251. [-Wdocumentation]

2015-09-11 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Fri Sep 11 03:13:32 2015
New Revision: 247392

URL: http://llvm.org/viewvc/llvm-project?rev=247392=rev
Log:
Fix \param in r247251. [-Wdocumentation]

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

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=247392=247391=247392=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Fri Sep 11 03:13:32 2015
@@ -398,7 +398,7 @@ public:
   /// CapturedStruct.
   /// \param OutlinedFn Outlined function to be run in parallel threads. Type 
of
   /// this function is void(*)(kmp_int32 *, kmp_int32, struct context_vars*).
-  /// \param CapturedStruct A pointer to the record with the references to
+  /// \param CapturedVars A pointer to the record with the references to
   /// variables used in \a OutlinedFn function.
   /// \param IfCond Condition in the associated 'if' clause, if it was
   /// specified, nullptr otherwise.


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


r247396 - clang/test/Modules/ExtDebugInfo.cpp: Use [[@LINE]].

2015-09-11 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Fri Sep 11 03:53:29 2015
New Revision: 247396

URL: http://llvm.org/viewvc/llvm-project?rev=247396=rev
Log:
clang/test/Modules/ExtDebugInfo.cpp: Use [[@LINE]].

Modified:
cfe/trunk/test/Modules/ExtDebugInfo.cpp

Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=247396=247395=247396=diff
==
--- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Fri Sep 11 03:53:29 2015
@@ -71,4 +71,4 @@ char _anchor = anon_enum + conflicting_u
 
 // CHECK: !DIGlobalVariable(name: "anon_enum", {{.*}}, type: ![[ANON_ENUM]]
 
-// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, 
entity: !"_ZTSN8DebugCXX6StructE", line: 21)
+// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, 
entity: !"_ZTSN8DebugCXX6StructE", line: [[@LINE-53]])


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


[clang-tools-extra] r247399 - Another patch for modernize-loop-convert.

2015-09-11 Thread Angel Garcia Gomez via cfe-commits
Author: angelgarcia
Date: Fri Sep 11 05:02:07 2015
New Revision: 247399

URL: http://llvm.org/viewvc/llvm-project?rev=247399=rev
Log:
Another patch for modernize-loop-convert.

Summary:
1. Avoid converting loops that iterate over the size of a container and don't 
use its elements, as this would result in an unused-result warning.
2. Never capture the elements by value on lambdas, thus avoiding doing 
unnecessary copies and errors with non-copyable types.
3. The 'const auto &' instead of 'auto &' substitution on const containers now 
works on arrays and pseudoarrays as well.
4. The error about multiple replacements in the same macro call is now 
documented in the tests (not solved though).
5. Due to [1], I had to add a dummy usage of the range element (like "(void) 
*It;" or similars) on the tests that had empty loops.
6. I removed the braces from the CHECK comments. I think that there is no need 
for them, and they confuse vim.

Reviewers: klimek

Subscribers: alexfh, cfe-commits

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

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

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

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp?rev=247399=247398=247399=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp Fri Sep 
11 05:02:07 2015
@@ -381,6 +381,20 @@ static bool usagesReturnRValues(const Us
   return true;
 }
 
+/// \brief Returns true if the container is const-qualified.
+static bool containerIsConst(const Expr *ContainerExpr, bool Dereference) {
+  if (const auto *VDec = getReferencedVariable(ContainerExpr)) {
+QualType CType = VDec->getType();
+if (Dereference) {
+  if (!CType->isPointerType())
+return false;
+  CType = CType->getPointeeType();
+}
+return CType.isConstQualified();
+  }
+  return false;
+}
+
 LoopConvertCheck::LoopConvertCheck(StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context), TUInfo(new TUTrackingInfo),
   MinConfidence(StringSwitch(
@@ -401,6 +415,11 @@ void LoopConvertCheck::doConversion(
 StringRef ContainerString, const UsageResult ,
 const DeclStmt *AliasDecl, bool AliasUseRequired, bool AliasFromForInit,
 const ForStmt *TheLoop, RangeDescriptor Descriptor) {
+  // If there aren't any usages, converting the loop would generate an unused
+  // variable warning.
+  if (Usages.size() == 0)
+return;
+
   auto Diag = diag(TheLoop->getForLoc(), "use range-based for loop instead");
 
   std::string VarName;
@@ -436,11 +455,23 @@ void LoopConvertCheck::doConversion(
 VarName = Namer.createIndexName();
 // First, replace all usages of the array subscript expression with our new
 // variable.
-for (const auto  : Usages) {
-  std::string ReplaceText = I.IsArrow ? VarName + "." : VarName;
+for (const auto  : Usages) {
+  std::string ReplaceText;
+  if (Usage.Expression) {
+// If this is an access to a member through the arrow operator, after
+// the replacement it must be accessed through the '.' operator.
+ReplaceText = Usage.Kind == Usage::UK_MemberThroughArrow ? VarName + 
"."
+ : VarName;
+  } else {
+// The Usage expression is only null in case of lambda captures (which
+// are VarDecl). If the index is captured by value, add '&' to capture
+// by reference instead.
+ReplaceText =
+Usage.Kind == Usage::UK_CaptureByCopy ? "&" + VarName : VarName;
+  }
   TUInfo->getReplacedVars().insert(std::make_pair(TheLoop, IndexVar));
   Diag << FixItHint::CreateReplacement(
-  CharSourceRange::getTokenRange(I.Range), ReplaceText);
+  CharSourceRange::getTokenRange(Usage.Range), ReplaceText);
 }
   }
 
@@ -537,16 +568,24 @@ void LoopConvertCheck::findAndVerifyUsag
   if (FixerKind == LFK_Array) {
 // The array being indexed by IndexVar was discovered during traversal.
 ContainerExpr = Finder.getContainerIndexed()->IgnoreParenImpCasts();
+
 // Very few loops are over expressions that generate arrays rather than
 // array variables. Consider loops 

Re: PATCH: Expose the 'file' that is associated with a compile database command

2015-09-11 Thread Manuel Klimek via cfe-commits
On Thu, Sep 10, 2015 at 8:36 PM Argyrios Kyrtzidis 
wrote:

> On Sep 10, 2015, at 1:48 AM, Manuel Klimek  wrote:
>
> @@ -179,11 +185,13 @@ public:
>/// \param Directory The base directory used in the
> FixedCompilationDatabase.
>static FixedCompilationDatabase *loadFromCommandLine(int ,
> const char *const
> *Argv,
> -   Twine Directory =
> ".");
> +   Twine Directory =
> ".",
> +   Twine File =
> Twine());
>
> A fixed compilation database returns the same command lines for all files,
> thus having a file in the function seems strange.
>
>
> Ah ok, thanks for clarifying.
>
>
> What exactly is the use case? So far, the compilation database has been
> designed for 2 use cases:
> 1. for a file, get the compile commands; the user already knows the file,
> no need to get the file
> 2. get all compile commands; for that, we have the getAllFiles() method,
> so a user can get all known files (for compilation databases that support
> that), and then get the compile command line.
>
>
> It’s #2, I want to get all compile commands. But it seems really strange
> to me that the ‘file’ starts as a property of the compile command in the
> json file but then it gets dropped and I need to do work to re-associate
> the files with the compile commands again.
>

The JSON file format is one possible implementation for the
compilation-database interface. The FixedCompilationDatabase is another
one, that doesn't have any information on files.


> I need to get a list of all the files and then for each one do a lookup to
> get the associated commands. I then have to maintain this association
> myself, passing a command along with its file separately or the structure
> that keeps track of the association.
>
> It seems simpler to me to include the file that was associated with the
> command (if the compilation database supports that) along with the command,
> is there a downside I’m missing ?
>

Well, to me, it's a design question - if it also makes sense to have a
CompileCommand without a file associated with it, putting the file in
there, while convenient, is a design smell.
That said, I'm happy to be convinced that I'm wrong :) I guess I don't see
yet that keeping track of the files outside is more than one line of extra
code.

Cheers,
/Manuel


>
>
> Thoughts?
> /Manuel
>
> On Wed, Sep 9, 2015 at 9:36 PM Argyrios Kyrtzidis 
> wrote:
>
>> Hi,
>>
>> The attached patch exposes the ‘file’ entry in a compilation database
>> command, via the CompileCommand structure.
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r247394 - clang-tidy/misc-sizeof-container.cpp: Add explicit triple.

2015-09-11 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Fri Sep 11 03:16:30 2015
New Revision: 247394

URL: http://llvm.org/viewvc/llvm-project?rev=247394=rev
Log:
clang-tidy/misc-sizeof-container.cpp: Add explicit triple.

For targeting LLP64, like Windows x86, size_t is not unsigned long.

  
tools/clang/tools/extra/test/clang-tidy/Output/misc-sizeof-container.cpp.tmp.cpp:33:12:
 error: target of using declaration conflicts with declaration already in scope 
[clang-diagnostic-error]
  using std::size_t;
 ^

Modified:
clang-tools-extra/trunk/test/clang-tidy/misc-sizeof-container.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-sizeof-container.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-sizeof-container.cpp?rev=247394=247393=247394=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-sizeof-container.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-sizeof-container.cpp Fri Sep 
11 03:16:30 2015
@@ -1,4 +1,4 @@
-// RUN: %python %S/check_clang_tidy.py %s misc-sizeof-container %t
+// RUN: %python %S/check_clang_tidy.py %s misc-sizeof-container %t -- 
-std=c++11 -target x86_64-unknown-unknown
 
 namespace std {
 


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


r247451 - Record function attribute "stackrealign" instead of using backend option

2015-09-11 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Fri Sep 11 13:55:09 2015
New Revision: 247451

URL: http://llvm.org/viewvc/llvm-project?rev=247451=rev
Log:
Record function attribute "stackrealign" instead of using backend option
-force-align-stack.

Also, make changes to the driver so that -mno-stack-realign is no longer
an option exposed to the end-user that disallows stack realignment in
the backend.

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

Added:
cfe/trunk/test/CodeGen/stackrealign.c
Modified:
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/rewrite-legacy-objc.m
cfe/trunk/test/Driver/rewrite-objc.m
cfe/trunk/test/Driver/stackrealign.c

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=247451=247450=247451=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Fri Sep 11 13:55:09 2015
@@ -150,7 +150,7 @@ CODEGENOPT(UseRegisterSizedBitfieldAcces
 CODEGENOPT(VerifyModule  , 1, 1) ///< Control whether the module should be 
run
  ///< through the LLVM Verifier.
 
-CODEGENOPT(StackRealignment  , 1, 0) ///< Control whether to permit stack
+CODEGENOPT(StackRealignment  , 1, 0) ///< Control whether to force stack
  ///< realignment.
 CODEGENOPT(UseInitArray  , 1, 0) ///< Control whether to use .init_array or
  ///< .ctors.

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=247451=247450=247451=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Fri Sep 11 13:55:09 2015
@@ -1494,8 +1494,8 @@ void CodeGenModule::ConstructAttributeLi
 FuncAttrs.addAttribute("stack-protector-buffer-size",
llvm::utostr(CodeGenOpts.SSPBufferSize));
 
-if (!CodeGenOpts.StackRealignment)
-  FuncAttrs.addAttribute("no-realign-stack");
+if (CodeGenOpts.StackRealignment)
+  FuncAttrs.addAttribute("stackrealign");
 
 // Add target-cpu and target-features attributes to functions. If
 // we have a decl for the function and it has a target attribute then

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=247451=247450=247451=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Sep 11 13:55:09 2015
@@ -4326,14 +4326,8 @@ void Clang::ConstructJob(Compilation ,
 
   // Translate -mstackrealign
   if (Args.hasFlag(options::OPT_mstackrealign, options::OPT_mno_stackrealign,
-   false)) {
-CmdArgs.push_back("-backend-option");
-CmdArgs.push_back("-force-align-stack");
-  }
-  if (!Args.hasFlag(options::OPT_mno_stackrealign, options::OPT_mstackrealign,
-false)) {
+   false))
 CmdArgs.push_back(Args.MakeArgString("-mstackrealign"));
-  }
 
   if (Args.hasArg(options::OPT_mstack_alignment)) {
 StringRef alignment = Args.getLastArgValue(options::OPT_mstack_alignment);

Added: cfe/trunk/test/CodeGen/stackrealign.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/stackrealign.c?rev=247451=auto
==
--- cfe/trunk/test/CodeGen/stackrealign.c (added)
+++ cfe/trunk/test/CodeGen/stackrealign.c Fri Sep 11 13:55:09 2015
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -mstackrealign | FileCheck %s 
-check-prefix=REALIGN
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s -check-prefix=NO-REALIGN
+
+// REALIGN: attributes #{{[0-9]+}} = {{{.*}} "stackrealign"
+// NO-REALIGN-NOT: attributes #{{[0-9]+}} = {{{.*}} "stackrealign"
+
+void test1() {
+}

Modified: cfe/trunk/test/Driver/rewrite-legacy-objc.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/rewrite-legacy-objc.m?rev=247451=247450=247451=diff
==
--- cfe/trunk/test/Driver/rewrite-legacy-objc.m (original)
+++ cfe/trunk/test/Driver/rewrite-legacy-objc.m Fri Sep 11 13:55:09 2015
@@ -3,11 +3,11 @@
 // TEST0: clang{{.*}}" "-cc1"
 // TEST0: "-rewrite-objc"
 // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency 
instead.
-// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" 
"-fblocks" "-fobjc-runtime=macosx-fragile" "-fencode-extended-block-signature" 
"-fno-objc-infer-related-result-type" "-fobjc-exceptions" 

Re: [PATCH] D11815: Pass subtarget feature "force-align-stack"

2015-09-11 Thread Akira Hatanaka via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247451: Record function attribute "stackrealign" instead of 
using backend option (authored by ahatanak).

Changed prior to commit:
  http://reviews.llvm.org/D11815?vs=33456=34569#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11815

Files:
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/CodeGen/stackrealign.c
  cfe/trunk/test/Driver/rewrite-legacy-objc.m
  cfe/trunk/test/Driver/rewrite-objc.m
  cfe/trunk/test/Driver/stackrealign.c

Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def
@@ -150,7 +150,7 @@
 CODEGENOPT(VerifyModule  , 1, 1) ///< Control whether the module should be run
  ///< through the LLVM Verifier.
 
-CODEGENOPT(StackRealignment  , 1, 0) ///< Control whether to permit stack
+CODEGENOPT(StackRealignment  , 1, 0) ///< Control whether to force stack
  ///< realignment.
 CODEGENOPT(UseInitArray  , 1, 0) ///< Control whether to use .init_array or
  ///< .ctors.
Index: cfe/trunk/test/CodeGen/stackrealign.c
===
--- cfe/trunk/test/CodeGen/stackrealign.c
+++ cfe/trunk/test/CodeGen/stackrealign.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -mstackrealign | FileCheck %s -check-prefix=REALIGN
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s -check-prefix=NO-REALIGN
+
+// REALIGN: attributes #{{[0-9]+}} = {{{.*}} "stackrealign"
+// NO-REALIGN-NOT: attributes #{{[0-9]+}} = {{{.*}} "stackrealign"
+
+void test1() {
+}
Index: cfe/trunk/test/Driver/rewrite-objc.m
===
--- cfe/trunk/test/Driver/rewrite-objc.m
+++ cfe/trunk/test/Driver/rewrite-objc.m
@@ -3,4 +3,4 @@
 // TEST0: clang{{.*}}" "-cc1"
 // TEST0: "-rewrite-objc"
 // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
-// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
+// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fobjc-runtime=macosx" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
Index: cfe/trunk/test/Driver/stackrealign.c
===
--- cfe/trunk/test/Driver/stackrealign.c
+++ cfe/trunk/test/Driver/stackrealign.c
@@ -1,12 +1,6 @@
-// RUN: %clang -### %s 2>&1 | FileCheck %s -check-prefix=NORMAL
-// NORMAL-NOT: -force-align-stack
-// NORMAL: -mstackrealign
+// RUN: %clang -### %s 2>&1 | FileCheck %s -check-prefix=NO-REALIGN
+// RUN: %clang -### -mno-stackrealign -mstackrealign %s 2>&1 | FileCheck %s -check-prefix=REALIGN
+// RUN: %clang -### -mstackrealign -mno-stackrealign %s 2>&1 | FileCheck %s -check-prefix=NO-REALIGN
 
-// RUN: %clang -### -mstackrealign %s 2>&1 | FileCheck %s -check-prefix=MREALIGN
-// MREALIGN: -force-align-stack
-// MREALIGN: -mstackrealign
-
-// RUN: %clang -### -mno-stackrealign %s 2>&1 | \
-// RUN: FileCheck %s -check-prefix=MNOREALIGN
-// MNOREALIGN-NOT: -force-align-stack
-// MNOREALIGN-NOT: -mstackrealign
+// REALIGN: -mstackrealign
+// NO-REALIGN-NOT: -mstackrealign
Index: cfe/trunk/test/Driver/rewrite-legacy-objc.m
===
--- cfe/trunk/test/Driver/rewrite-legacy-objc.m
+++ cfe/trunk/test/Driver/rewrite-legacy-objc.m
@@ -3,11 +3,11 @@
 // TEST0: clang{{.*}}" "-cc1"
 // TEST0: "-rewrite-objc"
 // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
-// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
+// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
 // TEST0: rewrite-legacy-objc.m"
 // RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.9.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=TEST1 %s
 // RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.6.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \
 

Re: [PATCH] D12780: [analyzer] Add generateErrorNode() APIs to CheckerContext

2015-09-11 Thread Jordan Rose via cfe-commits
jordan_rose added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp:53
@@ -52,3 +52,3 @@
 
-  if (ExplodedNode *N = C.addTransition()) {
+  if (ExplodedNode *N = C.generateNonFatalErrorNode()) {
 if (!BT)

zaks.anna wrote:
> Can this ever fail? In some cases we just assume it won't in others we tests..
> 
> Maybe it only fails when we cache out?
It does fail when we cache out, and I think we can still cache out if Pred has 
a different tag the second time around.


http://reviews.llvm.org/D12780



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


Re: [PATCH] D10018: C11 _Bool bitfield diagnostic

2015-09-11 Thread Rachel Craik via cfe-commits
rcraik updated the summary for this revision.
rcraik updated this revision to Diff 34571.
rcraik added a comment.

switched to using getIntWidth instead of getTypeSize and updated the error and 
warning messages accordingly, as have the necessary test cases. The separate 
check for _Bool bitfields has been removed, so the check is now consistent for 
all types.


http://reviews.llvm.org/D10018

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/CodeGen/bitfield-2.c
  test/CodeGenCXX/warn-padded-packed.cpp
  test/Misc/warning-flags.c
  test/Sema/bitfield.c
  test/SemaCXX/bitfield-layout.cpp
  test/SemaCXX/constant-expression-cxx11.cpp
  test/SemaCXX/constant-expression-cxx1y.cpp
  test/SemaCXX/ms_wide_bitfield.cpp
  test/SemaObjC/class-bitfield.m

Index: test/SemaObjC/class-bitfield.m
===
--- test/SemaObjC/class-bitfield.m
+++ test/SemaObjC/class-bitfield.m
@@ -5,7 +5,7 @@
   int a : -1; // expected-error{{bit-field 'a' has negative width}}
 
   // rdar://6081627
-  int b : 33; // expected-error{{size of bit-field 'b' (33 bits) exceeds size of its type (32 bits)}}
+  int b : 33; // expected-error{{width of bit-field 'b' (33 bits) exceeds width of its type (32 bits)}}
 
   int c : (1 + 0.25); // expected-error{{expression is not an integer constant expression}}
   int d : (int)(1 + 0.25); 
Index: test/SemaCXX/ms_wide_bitfield.cpp
===
--- test/SemaCXX/ms_wide_bitfield.cpp
+++ test/SemaCXX/ms_wide_bitfield.cpp
@@ -1,9 +1,10 @@
 // RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 -fdump-record-layouts -fsyntax-only -mms-bitfields -verify %s 2>&1
 
 struct A {
-  char a : 9; // expected-error{{size of bit-field 'a' (9 bits) exceeds size of its type (8 bits)}}
-  int b : 33; // expected-error{{size of bit-field 'b' (33 bits) exceeds size of its type (32 bits)}}
-  bool c : 9; // expected-error{{size of bit-field 'c' (9 bits) exceeds size of its type (8 bits)}}
+  char a : 9; // expected-error{{width of bit-field 'a' (9 bits) exceeds width of its type (8 bits)}}
+  int b : 33; // expected-error{{width of bit-field 'b' (33 bits) exceeds width of its type (32 bits)}}
+  bool c : 9; // expected-error{{width of bit-field 'c' (9 bits) exceeds width of its type (1 bit)}}
+  bool d : 3; // expected-error{{width of bit-field 'd' (3 bits) exceeds width of its type (1 bit)}}
 };
 
 int a[sizeof(A) == 1 ? 1 : -1];
Index: test/SemaCXX/constant-expression-cxx1y.cpp
===
--- test/SemaCXX/constant-expression-cxx1y.cpp
+++ test/SemaCXX/constant-expression-cxx1y.cpp
@@ -872,7 +872,7 @@
 
 namespace Bitfields {
   struct A {
-bool b : 3;
+bool b : 1;
 int n : 4;
 unsigned u : 5;
   };
Index: test/SemaCXX/constant-expression-cxx11.cpp
===
--- test/SemaCXX/constant-expression-cxx11.cpp
+++ test/SemaCXX/constant-expression-cxx11.cpp
@@ -1801,9 +1801,9 @@
 bool b : 1;
 unsigned u : 5;
 int n : 5;
-bool b2 : 3;
-unsigned u2 : 74; // expected-warning {{exceeds the size of its type}}
-int n2 : 81; // expected-warning {{exceeds the size of its type}}
+bool b2 : 3; // expected-warning {{exceeds the width of its type}}
+unsigned u2 : 74; // expected-warning {{exceeds the width of its type}}
+int n2 : 81; // expected-warning {{exceeds the width of its type}}
   };
 
   constexpr A a = { false, 33, 31, false, 0x, 0x7fff }; // expected-warning 2{{truncation}}
Index: test/SemaCXX/bitfield-layout.cpp
===
--- test/SemaCXX/bitfield-layout.cpp
+++ test/SemaCXX/bitfield-layout.cpp
@@ -5,25 +5,25 @@
 
 // Simple tests.
 struct Test1 {
-  char c : 9; // expected-warning {{size of bit-field 'c' (9 bits) exceeds the size of its type; value will be truncated to 8 bits}}
+  char c : 9; // expected-warning {{width of bit-field 'c' (9 bits) exceeds the width of its type; value will be truncated to 8 bits}}
 };
 CHECK_SIZE(Test1, 2);
 CHECK_ALIGN(Test1, 1);
 
 struct Test2 {
-  char c : 16; // expected-warning {{size of bit-field 'c' (16 bits) exceeds the size of its type; value will be truncated to 8 bits}}
+  char c : 16; // expected-warning {{width of bit-field 'c' (16 bits) exceeds the width of its type; value will be truncated to 8 bits}}
 };
 CHECK_SIZE(Test2, 2);
 CHECK_ALIGN(Test2, 2);
 
 struct Test3 {
-  char c : 32; // expected-warning {{size of bit-field 'c' (32 bits) exceeds the size of its type; value will be truncated to 8 bits}}
+  char c : 32; // expected-warning {{width of bit-field 'c' (32 bits) exceeds the width of its type; value will be truncated to 8 bits}}
 };
 CHECK_SIZE(Test3, 4);
 CHECK_ALIGN(Test3, 4);
 
 struct Test4 {
-  char c : 64; // expected-warning {{size of 

Re: [PATCH] D10018: C11 _Bool bitfield diagnostic

2015-09-11 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Looks great, please go ahead. Sorry it's taken so long to get this reviewed.


http://reviews.llvm.org/D10018



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


r247448 - Remove an unnecessary check. NFC

2015-09-11 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Sep 11 13:54:31 2015
New Revision: 247448

URL: http://llvm.org/viewvc/llvm-project?rev=247448=rev
Log:
Remove an unnecessary check. NFC

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

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=247448=247447=247448=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep 11 13:54:31 2015
@@ -2129,7 +2129,7 @@ ObjCInterfaceDecl *CGDebugInfo::getObjCI
 }
 
 llvm::DIModule *CGDebugInfo::getParentModuleOrNull(const Decl *D) {
-  if (!DebugTypeExtRefs || !D || !D->isFromASTFile())
+  if (!DebugTypeExtRefs || !D->isFromASTFile())
 return nullptr;
 
   llvm::DIModule *ModuleRef = nullptr;


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


r247449 - Fix a typo and make this test stricter.

2015-09-11 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Sep 11 13:54:34 2015
New Revision: 247449

URL: http://llvm.org/viewvc/llvm-project?rev=247449=rev
Log:
Fix a typo and make this test stricter.

Modified:
cfe/trunk/test/Modules/ExtDebugInfo.m

Modified: cfe/trunk/test/Modules/ExtDebugInfo.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.m?rev=247449=247448=247449=diff
==
--- cfe/trunk/test/Modules/ExtDebugInfo.m (original)
+++ cfe/trunk/test/Modules/ExtDebugInfo.m Fri Sep 11 13:54:34 2015
@@ -1,5 +1,5 @@
 // RUN: rm -rf %t
-// Test that only forward declarations are emitted for types dfined in modules.
+// Test that only forward declarations are emitted for types defined in 
modules.
 
 // Modules:
 // RUN: %clang_cc1 -x objective-c -g -dwarf-ext-refs -fmodules \
@@ -23,7 +23,10 @@ int foo(ObjCClass *c) {
   return [c property];
 }
 
-// CHECK: !DICompositeType(tag: DW_TAG_structure_type,
+// CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type,
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass",
 // CHECK-SAME: scope: ![[MOD:[0-9]+]],
 // CHECK-SAME: flags: DIFlagFwdDecl)
+// CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type,
 // CHECK: ![[MOD]] = !DIModule(scope: null, name: {{.*}}DebugObjC
+// CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type,


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


r247447 - Remove a redundant check from CGDebugInfo::shouldOmitDefinition() (NFC).

2015-09-11 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Sep 11 13:54:28 2015
New Revision: 247447

URL: http://llvm.org/viewvc/llvm-project?rev=247447=rev
Log:
Remove a redundant check from CGDebugInfo::shouldOmitDefinition() (NFC).

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

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=247447=247446=247447=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep 11 13:54:28 2015
@@ -1480,14 +1480,8 @@ static bool shouldOmitDefinition(CodeGen
  const RecordDecl *RD,
  const LangOptions ) {
   // Does the type exist in an imported clang module?
-  if (DebugTypeExtRefs && RD->isFromASTFile()) {
-if (auto *CTSD = dyn_cast(RD))
-  if (CTSD->isExplicitInstantiationOrSpecialization())
-// We may not assume that this type made it into the module.
-return true;
-if (RD->getDefinition())
+  if (DebugTypeExtRefs && RD->isFromASTFile() && RD->getDefinition())
   return true;
-  }
 
   if (DebugKind > CodeGenOptions::LimitedDebugInfo)
 return false;


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


r247467 - [CMake] [Darwin] Add support for building bootstrap builds with -flto

2015-09-11 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Fri Sep 11 15:42:57 2015
New Revision: 247467

URL: http://llvm.org/viewvc/llvm-project?rev=247467=rev
Log:
[CMake] [Darwin] Add support for building bootstrap builds with -flto

When building with LTO the bootstrap builds need to depend on libLTO, llvm-ar, 
and llvm-ranlib, which all need to be passed into the bootstrap build. This 
functionality only works on Darwin.

Modified:
cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=247467=247466=247467=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Fri Sep 11 15:42:57 2015
@@ -588,12 +588,21 @@ if (CLANG_ENABLE_BOOTSTRAP)
   set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-stamps/)
   set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-bins/)
 
+  # If on Darwin we need to make bootstrap depend on LTO and pass
+  # DARWIN_LTO_LIBRARY so that -flto will work using the just-built compiler
+  if(APPLE)
+set(LTO_DEP LTO llvm-ar llvm-ranlib)
+set(LTO_LIBRARY -DDARWIN_LTO_LIBRARY=${CMAKE_BINARY_DIR}/lib/libLTO.dylib)
+set(LTO_AR -DCMAKE_AR=${CMAKE_BINARY_DIR}/bin/llvm-ar)
+set(LTO_RANLIB -DCMAKE_RANLIB=${CMAKE_BINARY_DIR}/bin/llvm-ranlib)
+  endif()
+
   add_custom_target(bootstrap-clear
 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-cleared
 )
   add_custom_command(
 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-cleared
-DEPENDS clang
+DEPENDS clang ${LTO_DEP}
 COMMAND ${CMAKE_COMMAND} -E remove_directory ${BINARY_DIR}
 COMMAND ${CMAKE_COMMAND} -E make_directory ${BINARY_DIR}
 COMMAND ${CMAKE_COMMAND} -E remove_directory ${STAMP_DIR}
@@ -602,7 +611,7 @@ if (CLANG_ENABLE_BOOTSTRAP)
 )
 
   ExternalProject_Add(bootstrap
-DEPENDS clang
+DEPENDS clang ${LTO_DEP}
 PREFIX bootstrap
 SOURCE_DIR ${CMAKE_SOURCE_DIR}
 STAMP_DIR ${STAMP_DIR}
@@ -615,6 +624,8 @@ if (CLANG_ENABLE_BOOTSTRAP)
 ${CLANG_BOOTSTRAP_CMAKE_ARGS}
 -DCMAKE_CXX_COMPILER=${CMAKE_BINARY_DIR}/bin/clang++
 -DCMAKE_C_COMPILER=${CMAKE_BINARY_DIR}/bin/clang
+-DCMAKE_ASM_COMPILER=${CMAKE_BINARY_DIR}/bin/clang
+${LTO_LIBRARY} ${LTO_AR} ${LTO_RANLIB}
 INSTALL_COMMAND ""
 STEP_TARGETS configure build
 ${cmake_3_4_USES_TERMINAL_OPTIONS}


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


Re: r246877 - Increase accuracy of __builtin_object_size.

2015-09-11 Thread Mikhail Zolotukhin via cfe-commits
Hi George,

After this commit we started to trap on the following case:

#include 
typedef struct {
  int n;
  char key[1];
} obj_t;

char *str = "hello";

int main() {
  obj_t* p = (obj_t*)malloc(strlen(str) + 1 + sizeof(int));
  strcpy(p->key, str);
  free(p);
  return 0;
}

As far as I understand, this might be a common pattern in pre-C99 codebase, and 
it fails when compiled with -D_FORTIFY_SOURCE=2. Is there a way we could fix it 
in clang, or the only fix is to use less strict FORTIFY_SOURCE level?

Thanks,
Michael

> On Sep 4, 2015, at 2:28 PM, George Burgess IV via cfe-commits 
>  wrote:
> 
> Author: gbiv
> Date: Fri Sep  4 16:28:13 2015
> New Revision: 246877
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=246877=rev
> Log:
> Increase accuracy of __builtin_object_size.
> 
> Improvements:
> 
> - For all types, we would give up in a case such as:
>__builtin_object_size((char*), N);
>  even if we could provide an answer to
>__builtin_object_size(, N);
>  We now provide the same answer for both of the above examples in all
>  cases.
> 
> - For type=1|3, we now support subobjects with unknown bases, as long
>  as the designator is valid.
> 
> Thanks to Richard Smith for the review + design planning.
> 
> Review: http://reviews.llvm.org/D12169
> 
> 
> Modified:
>cfe/trunk/lib/AST/ExprConstant.cpp
>cfe/trunk/test/CodeGen/object-size.c
> 
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=246877=246876=246877=diff
> ==
> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> +++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Sep  4 16:28:13 2015
> @@ -492,7 +492,11 @@ namespace {
>   /// optimizer if we don't constant fold them here, but in an unevaluated
>   /// context we try to fold them immediately since the optimizer never
>   /// gets a chance to look at it.
> -  EM_PotentialConstantExpressionUnevaluated
> +  EM_PotentialConstantExpressionUnevaluated,
> +
> +  /// Evaluate as a constant expression. Continue evaluating if we find a
> +  /// MemberExpr with a base that can't be evaluated.
> +  EM_DesignatorFold,
> } EvalMode;
> 
> /// Are we checking whether the expression is a potential constant
> @@ -595,6 +599,7 @@ namespace {
>   case EM_PotentialConstantExpression:
>   case EM_ConstantExpressionUnevaluated:
>   case EM_PotentialConstantExpressionUnevaluated:
> +  case EM_DesignatorFold:
> HasActiveDiagnostic = false;
> return OptionalDiagnostic();
>   }
> @@ -674,6 +679,7 @@ namespace {
>   case EM_ConstantExpression:
>   case EM_ConstantExpressionUnevaluated:
>   case EM_ConstantFold:
> +  case EM_DesignatorFold:
> return false;
>   }
>   llvm_unreachable("Missed EvalMode case");
> @@ -702,10 +708,15 @@ namespace {
>   case EM_ConstantExpressionUnevaluated:
>   case EM_ConstantFold:
>   case EM_IgnoreSideEffects:
> +  case EM_DesignatorFold:
> return false;
>   }
>   llvm_unreachable("Missed EvalMode case");
> }
> +
> +bool allowInvalidBaseExpr() const {
> +  return EvalMode == EM_DesignatorFold;
> +}
>   };
> 
>   /// Object used to treat all foldable expressions as constant expressions.
> @@ -736,6 +747,21 @@ namespace {
> }
>   };
> 
> +  /// RAII object used to treat the current evaluation as the correct pointer
> +  /// offset fold for the current EvalMode
> +  struct FoldOffsetRAII {
> +EvalInfo 
> +EvalInfo::EvaluationMode OldMode;
> +explicit FoldOffsetRAII(EvalInfo , bool Subobject)
> +: Info(Info), OldMode(Info.EvalMode) {
> +  if (!Info.checkingPotentialConstantExpression())
> +Info.EvalMode = Subobject ? EvalInfo::EM_DesignatorFold
> +  : EvalInfo::EM_ConstantFold;
> +}
> +
> +~FoldOffsetRAII() { Info.EvalMode = OldMode; }
> +  };
> +
>   /// RAII object used to suppress diagnostics and side-effects from a
>   /// speculative evaluation.
>   class SpeculativeEvaluationRAII {
> @@ -917,7 +943,8 @@ namespace {
>   struct LValue {
> APValue::LValueBase Base;
> CharUnits Offset;
> -unsigned CallIndex;
> +bool InvalidBase : 1;
> +unsigned CallIndex : 31;
> SubobjectDesignator Designator;
> 
> const APValue::LValueBase getLValueBase() const { return Base; }
> @@ -938,17 +965,23 @@ namespace {
>   assert(V.isLValue());
>   Base = V.getLValueBase();
>   Offset = V.getLValueOffset();
> +  InvalidBase = false;
>   CallIndex = V.getLValueCallIndex();
>   Designator = SubobjectDesignator(Ctx, V);
> }
> 
> -void set(APValue::LValueBase B, unsigned I = 0) {
> +void set(APValue::LValueBase B, unsigned I = 0, bool BInvalid = false) {
>   Base = B;
>   Offset = CharUnits::Zero();
> +   

r247464 - [MS ABI] Select an inheritance model in template arguments

2015-09-11 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Fri Sep 11 15:18:09 2015
New Revision: 247464

URL: http://llvm.org/viewvc/llvm-project?rev=247464=rev
Log:
[MS ABI] Select an inheritance model in template arguments

We used to only select an inheritance model if the pointer to member was
nullptr.  Instead, select a model regardless of the member pointer's
value.

N.B.  This bug was exposed by making member pointers report true for
isIncompleteType but has been latent since the member pointer scheme's
inception.

Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=247464=247463=247464=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Sep 11 15:18:09 2015
@@ -4222,7 +4222,11 @@ isNullPointerValueTemplateArgument(Sema
QualType ParamType, Expr *Arg) {
   if (Arg->isValueDependent() || Arg->isTypeDependent())
 return NPV_NotNullPointer;
-  
+
+  if (ParamType->isMemberPointerType())
+if (S.Context.getTargetInfo().getCXXABI().isMicrosoft())
+  S.RequireCompleteType(Arg->getExprLoc(), ParamType, 0);
+
   if (!S.getLangOpts().CPlusPlus11)
 return NPV_NotNullPointer;
   
@@ -4670,8 +4674,6 @@ static bool CheckTemplateArgumentPointer
 S.Diag(Arg->getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
 Converted = TemplateArgument(S.Context.getCanonicalType(ParamType),
  /*isNullPtr*/true);
-if (S.Context.getTargetInfo().getCXXABI().isMicrosoft())
-  S.RequireCompleteType(Arg->getExprLoc(), ParamType, 0);
 return false;
   case NPV_NotNullPointer:
 break;

Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp?rev=247464=247463=247464=diff
==
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp Fri Sep 11 
15:18:09 2015
@@ -768,3 +768,14 @@ bool g(int J::*, int J::*) { return
 // CHECK-LABEL: @"\01?h@ReferenceToMPTWithIncompleteClass@@YAHAAPQK@1@H@Z"(
 int h(int K::*) { return k->*p; }
 }
+
+namespace PMFInTemplateArgument {
+template 
+void JSMethod();
+class A {
+  int printd(int);
+  void printd();
+};
+void A::printd() { JSMethod(); }
+// CHECK-LABEL: 
@"\01??$JSMethod@VA@PMFInTemplateArgument@@$1?printd@12@AAEHH@Z@PMFInTemplateArgument@@YAXXZ"(
+}


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


Re: r246877 - Increase accuracy of __builtin_object_size.

2015-09-11 Thread George Burgess IV via cfe-commits
> It might be reasonable for __builtin_object_size(..., 2) to give up if
[...]

That sounds like the best overall solution to me, as well. Working on a fix
now.

On Fri, Sep 11, 2015 at 1:22 PM, Richard Smith 
wrote:

> On Fri, Sep 11, 2015 at 12:15 PM, Mikhail Zolotukhin via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Hi George,
>>
>> After this commit we started to trap on the following case:
>>
>> #include 
>> typedef struct {
>>   int n;
>>   char key[1];
>> } obj_t;
>>
>> char *str = "hello";
>>
>> int main() {
>>   obj_t* p = (obj_t*)malloc(strlen(str) + 1 + sizeof(int));
>>   strcpy(p->key, str);
>>   free(p);
>>   return 0;
>> }
>>
>> As far as I understand, this might be a common pattern in pre-C99
>> codebase, and it fails when compiled with -D_FORTIFY_SOURCE=2. Is there a
>> way we could fix it in clang, or the only fix is to use less strict
>> FORTIFY_SOURCE level?
>>
>
> It might be reasonable for __builtin_object_size(..., 2) to give up if:
>
> 1) we lost track of the complete object, and
> 2) the designator refers to the final subobject of the currently-known
> complete object, and
> 3) that subobject is either a flexible array member or an array of bound 0
> or 1.
>
> Then we'd leave it to IR generation to do the llvm.object.size(..., i1
> false) dance, and in this case to grab the size of the malloc (minus the
> offset of 'key').
>
> Thanks,
>> Michael
>>
>> On Sep 4, 2015, at 2:28 PM, George Burgess IV via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>> Author: gbiv
>> Date: Fri Sep  4 16:28:13 2015
>> New Revision: 246877
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=246877=rev
>> Log:
>> Increase accuracy of __builtin_object_size.
>>
>> Improvements:
>>
>> - For all types, we would give up in a case such as:
>>__builtin_object_size((char*), N);
>>  even if we could provide an answer to
>>__builtin_object_size(, N);
>>  We now provide the same answer for both of the above examples in all
>>  cases.
>>
>> - For type=1|3, we now support subobjects with unknown bases, as long
>>  as the designator is valid.
>>
>> Thanks to Richard Smith for the review + design planning.
>>
>> Review: http://reviews.llvm.org/D12169
>>
>>
>> Modified:
>>cfe/trunk/lib/AST/ExprConstant.cpp
>>cfe/trunk/test/CodeGen/object-size.c
>>
>> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=246877=246876=246877=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
>> +++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Sep  4 16:28:13 2015
>> @@ -492,7 +492,11 @@ namespace {
>>   /// optimizer if we don't constant fold them here, but in an
>> unevaluated
>>   /// context we try to fold them immediately since the optimizer
>> never
>>   /// gets a chance to look at it.
>> -  EM_PotentialConstantExpressionUnevaluated
>> +  EM_PotentialConstantExpressionUnevaluated,
>> +
>> +  /// Evaluate as a constant expression. Continue evaluating if we
>> find a
>> +  /// MemberExpr with a base that can't be evaluated.
>> +  EM_DesignatorFold,
>> } EvalMode;
>>
>> /// Are we checking whether the expression is a potential constant
>> @@ -595,6 +599,7 @@ namespace {
>>   case EM_PotentialConstantExpression:
>>   case EM_ConstantExpressionUnevaluated:
>>   case EM_PotentialConstantExpressionUnevaluated:
>> +  case EM_DesignatorFold:
>> HasActiveDiagnostic = false;
>> return OptionalDiagnostic();
>>   }
>> @@ -674,6 +679,7 @@ namespace {
>>   case EM_ConstantExpression:
>>   case EM_ConstantExpressionUnevaluated:
>>   case EM_ConstantFold:
>> +  case EM_DesignatorFold:
>> return false;
>>   }
>>   llvm_unreachable("Missed EvalMode case");
>> @@ -702,10 +708,15 @@ namespace {
>>   case EM_ConstantExpressionUnevaluated:
>>   case EM_ConstantFold:
>>   case EM_IgnoreSideEffects:
>> +  case EM_DesignatorFold:
>> return false;
>>   }
>>   llvm_unreachable("Missed EvalMode case");
>> }
>> +
>> +bool allowInvalidBaseExpr() const {
>> +  return EvalMode == EM_DesignatorFold;
>> +}
>>   };
>>
>>   /// Object used to treat all foldable expressions as constant
>> expressions.
>> @@ -736,6 +747,21 @@ namespace {
>> }
>>   };
>>
>> +  /// RAII object used to treat the current evaluation as the correct
>> pointer
>> +  /// offset fold for the current EvalMode
>> +  struct FoldOffsetRAII {
>> +EvalInfo 
>> +EvalInfo::EvaluationMode OldMode;
>> +explicit FoldOffsetRAII(EvalInfo , bool Subobject)
>> +: Info(Info), OldMode(Info.EvalMode) {
>> +  if (!Info.checkingPotentialConstantExpression())
>> +Info.EvalMode = Subobject ? EvalInfo::EM_DesignatorFold
>> +  : 

Re: r247346 - [MS ABI] Make member pointers return true for isIncompleteType

2015-09-11 Thread David Majnemer via cfe-commits
Reduced it a bit:
template 
void JSMethod();
class A {
  int printd(int);
  void printd();
};
void A::printd() { JSMethod(); }

This test case will crash clang at the revision before this commit which
means that something more mysterious/horrific is going on...

On Fri, Sep 11, 2015 at 11:10 AM, David Majnemer 
wrote:

> Taking a look, would appreciate it if we didn't revert this until I give
> it a fair shot.  Shouldn't take too long.
>
> On Fri, Sep 11, 2015 at 10:58 AM, Hans Wennborg  wrote:
>
>> This made the Chromium build sad. For example:
>>
>> http://build.chromium.org/p/chromium.fyi/builders/ClangToTWin/builds/3092/steps/compile/logs/stdio
>>
>> Reduction:
>>
>> $ clang -cc1 -triple i686-pc-windows-msvc18.0.0 -w -fms-extensions
>> -fms-compatibility -fms-compatibility-version=18.0 -std=c++11
>> -fdelayed-template-parsing a.ii
>>
>> template 
>> void JSMethod(char *, char *, int);
>> class A {
>>   int printd(int *, const int &, int &, int &);
>>   int printd_info;
>>   void printd() { JSMethod("", "", printd_info); }
>> };
>>
>>
>> On Thu, Sep 10, 2015 at 2:52 PM, David Majnemer via cfe-commits
>>  wrote:
>> > Author: majnemer
>> > Date: Thu Sep 10 16:52:00 2015
>> > New Revision: 247346
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=247346=rev
>> > Log:
>> > [MS ABI] Make member pointers return true for isIncompleteType
>> >
>> > The type of a member pointer is incomplete if it has no inheritance
>> > model.  This lets us reuse more general logic already embedded in clang.
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D10018: C11 _Bool bitfield diagnostic

2015-09-11 Thread Rachel Craik via cfe-commits
rcraik marked 3 inline comments as done.
rcraik added a comment.

http://reviews.llvm.org/D10018



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


Re: recordDecl() AST matcher

2015-09-11 Thread Richard Smith via cfe-commits
I don't think CXXRecordDecl is an anachronism, so much as an implementation
detail; it makes sense to use a smaller class when in C mode, as we don't
need most of the features and complexity that CXXRecordDecl brings with it.
But... as a user of clang matchers, I don't think I'd want to care about
the difference, and it'd be more convenient if I could nest (say) a
hasMethod matcher within a recordDecl matcher, since it's completely
obvious what that should mean. If I have a matcher that says:

  recordDecl(or(hasMethod(...), hasField(...)))

I would expect that to work in both C and C++ (and the only way it could
match in C would be on a record with the specified field, since the
hasMethod matcher would always fail).

On Fri, Sep 11, 2015 at 6:30 AM, Manuel Klimek  wrote:

> Richard! We need an informed opinion :D
>
> On Fri, Sep 11, 2015 at 3:07 PM Aaron Ballman 
> wrote:
>
>> Ping?
>>
>> On Tue, Sep 8, 2015 at 9:26 AM, Manuel Klimek  wrote:
>> > On Tue, Sep 8, 2015 at 3:23 PM Aaron Ballman 
>> wrote:
>> >>
>> >> On Tue, Sep 8, 2015 at 9:18 AM, Manuel Klimek 
>> wrote:
>> >> > On Tue, Sep 8, 2015 at 2:23 PM Aaron Ballman > >
>> >> > wrote:
>> >> >>
>> >> >> On Tue, Sep 8, 2015 at 5:40 AM, Manuel Klimek 
>> >> >> wrote:
>> >> >> > Yea, we had that discussion a few times, and I can never remember
>> why
>> >> >> > we
>> >> >> > ended up in the state we're in.
>> >> >> > We definitely had a time where we switched to just using the exact
>> >> >> > same
>> >> >> > name
>> >> >> > as the node's class name for the matchers.
>> >> >> > I *think* we didn't do it for cxxRecordDecl, because Richard said
>> >> >> > that's
>> >> >> > a
>> >> >> > relic we should get rid of anyway, but I'm not sure.
>> >> >>
>> >> >> FWIW, I think the state we're in is the worst of all worlds. It's
>> not
>> >> >> intuitive that recordDecl() doesn't match a struct in C mode, and as
>> >> >> it stands, there is no way to match a struct or union declaration
>> in C
>> >> >> at all.
>> >> >
>> >> >
>> >> > Agreed. Best intentions. Worst possible outcome. That's software
>> >> > development
>> >> > :)
>> >> >
>> >> >> >
>> >> >> > On Fri, Sep 4, 2015 at 8:32 PM Aaron Ballman <
>> aa...@aaronballman.com>
>> >> >> > wrote:
>> >> >> >>
>> >> >> >> It turns out that the recordDecl() AST matcher doesn't match
>> >> >> >> RecordDecl objects; instead, it matches CXXRecordDecl objects.
>> This
>> >> >> >> is... unfortunate... as it makes writing AST matchers more
>> >> >> >> complicated
>> >> >> >> because of having to translate between
>> recordDecl()/CXXRecordDecl.
>> >> >> >> It
>> >> >> >> also makes it impossible to match a struct or union declaration
>> in C
>> >> >> >> or ObjC. However, given how prevalent recordDecl()'s use is in
>> the
>> >> >> >> wild (I'm guessing), changing it at this point would be a Bad
>> Thing.
>> >> >> >>
>> >> >> >> For people trying to write AST matchers for languages like C or
>> >> >> >> ObjC,
>> >> >> >> I would like to propose adding:
>> >> >> >>
>> >> >> >> structDecl()
>> >> >> >> unionDecl()
>> >> >> >> tagDecl()
>> >> >> >>
>> >> >> >> These will match nicely with the existing enumDecl() AST matcher.
>> >> >> >>
>> >> >> >> Additionally, I would like to add cxxRecordDecl() to match
>> >> >> >> CXXRecordDecl objects. While it duplicates the functionality
>> exposed
>> >> >> >> by recordDecl(), it more clearly matches the intention of which
>> AST
>> >> >> >> node it corresponds to.
>> >> >> >>
>> >> >> >> Finally, I would like to undocument recordDecl() and change our
>> >> >> >> existing documentation and AST matcher uses to use
>> >> >> >> cxxRecordDecl/structDecl() instead. Maybe someday we can
>> deprecate
>> >> >> >> recordDecl() more officially.
>> >> >> >>
>> >> >> >> I'm open to other ideas if there are better ways to move
>> forward. If
>> >> >> >> you think changing the meaning of recordDecl() is acceptable, I
>> can
>> >> >> >> also go that route (though I would still propose adding
>> unionDecl()
>> >> >> >> and cxxRecordDecl() in that case).
>> >> >> >
>> >> >> >
>> >> >> > I think changing recordDecl is acceptable. I believe very few
>> tools
>> >> >> > will
>> >> >> > actually start doing wrong things because of it. I'd like more
>> >> >> > opinions
>> >> >> > first, though :)
>> >> >>
>> >> >> I was giving this more thought over the long weekend, and I think
>> you
>> >> >> may be right. I think changing recordDecl() to mean RecordDecl will
>> >> >> fix more code than it breaks, so long as we take a holistic approach
>> >> >> to the change and see which narrowing and traversal matchers we need
>> >> >> to fix up at the same time. When I tried to think of AST matchers
>> that
>> >> >> mean CXXRecordDecl but *not* RecordDecl, they were horribly
>> contrived
>> >> >> because you usually are matching on additional selection criteria
>> that
>> 

Re: r247447 - Remove a redundant check from CGDebugInfo::shouldOmitDefinition() (NFC).

2015-09-11 Thread David Blaikie via cfe-commits
On Fri, Sep 11, 2015 at 11:54 AM, Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: adrian
> Date: Fri Sep 11 13:54:28 2015
> New Revision: 247447
>
> URL: http://llvm.org/viewvc/llvm-project?rev=247447=rev
> Log:
> Remove a redundant check from CGDebugInfo::shouldOmitDefinition() (NFC).
>
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=247447=247446=247447=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep 11 13:54:28 2015
> @@ -1480,14 +1480,8 @@ static bool shouldOmitDefinition(CodeGen
>   const RecordDecl *RD,
>   const LangOptions ) {
>// Does the type exist in an imported clang module?
> -  if (DebugTypeExtRefs && RD->isFromASTFile()) {
> -if (auto *CTSD = dyn_cast(RD))
> -  if (CTSD->isExplicitInstantiationOrSpecialization())
> -// We may not assume that this type made it into the module.
> -return true;
> -if (RD->getDefinition())
> +  if (DebugTypeExtRefs && RD->isFromASTFile() && RD->getDefinition())
>

Oh - and do we need to check for "getDefinition" here? Since this function
is itself (by name/use) already about whether definitions should be
omitted? I'm not sure, maybe it still makes sense...


>return true;
> -  }
>
>if (DebugKind > CodeGenOptions::LimitedDebugInfo)
>  return false;
>
>
> ___
> 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] D12743: [CodeGen] Teach SimplifyPersonality about the updated LandingPadInst

2015-09-11 Thread John McCall via cfe-commits
rjmccall added a comment.

In http://reviews.llvm.org/D12743#244375, @vsk wrote:

> Ah, ok. We have some objective-c++ code which calls into a boost routine 
> which throws an exception. That results in an undefined reference to 
> ___objc_personality_v0, because the boost library we linked against doesn't 
> have ___objc_personality_v0.
>
> Should the compiler have found the ___objc_personality_v0 symbol in this case 
> regardless?


It's pretty straightforward.  Sometimes people write code in ObjC++ files 
that's really pure C++.  Such code is generally compiled with -fexceptions 
because that's the default, and so it has cleanups, and those cleanups require 
us to pick a personality function.  When they do so, they generally don't link 
against the ObjC runtime, and so __objc_personality_v0 isn't found.  The 
workaround here is to recognize that they're not actually catching ObjC 
exception types and just quietly degrade to use the C++ personality.

It is probably technically an optimization, because it removes some overhead 
from double-parsing the exception tables (because the ObjC personality 
delegates to the C++ personality, instead of being tightly integrated with it), 
but that's not the real reason we do it.


Repository:
  rL LLVM

http://reviews.llvm.org/D12743



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


Re: [PATCH] D12406: [Analyzer] Add -analyzer-config option for function size the inliner considers as large

2015-09-11 Thread Devin Coughlin via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247463: [analyzer] Add -analyzer-config option for function 
size the inliner… (authored by dcoughlin).

Changed prior to commit:
  http://reviews.llvm.org/D12406?vs=34196=34574#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12406

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  cfe/trunk/test/Analysis/analyzer-config.c
  cfe/trunk/test/Analysis/analyzer-config.cpp

Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -870,7 +870,8 @@
   // Do not inline large functions too many times.
   if ((Engine.FunctionSummaries->getNumTimesInlined(D) >
Opts.getMaxTimesInlineLarge()) &&
-  CalleeCFG->getNumBlockIDs() > 13) {
+   CalleeCFG->getNumBlockIDs() >=
+   Opts.getMinCFGSizeTreatFunctionsAsLarge()) {
 NumReachedInlineCountMax++;
 return false;
   }
Index: cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
@@ -295,6 +295,13 @@
   return MaxTimesInlineLarge.getValue();
 }
 
+unsigned AnalyzerOptions::getMinCFGSizeTreatFunctionsAsLarge() {
+  if (!MinCFGSizeTreatFunctionsAsLarge.hasValue())
+MinCFGSizeTreatFunctionsAsLarge = getOptionAsInteger(
+  "min-cfg-size-treat-functions-as-large", 14);
+  return MinCFGSizeTreatFunctionsAsLarge.getValue();
+}
+
 unsigned AnalyzerOptions::getMaxNodesPerTopLevelFunction() {
   if (!MaxNodesPerTopLevelFunction.hasValue()) {
 int DefaultValue = 0;
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -253,6 +253,9 @@
   /// \sa getMaxTimesInlineLarge
   Optional MaxTimesInlineLarge;
 
+  /// \sa getMinCFGSizeTreatFunctionsAsLarge
+  Optional MinCFGSizeTreatFunctionsAsLarge;
+
   /// \sa getMaxNodesPerTopLevelFunction
   Optional MaxNodesPerTopLevelFunction;
 
@@ -505,6 +508,13 @@
   /// This is controlled by the 'max-times-inline-large' config option.
   unsigned getMaxTimesInlineLarge();
 
+  /// Returns the number of basic blocks a function needs to have to be
+  /// considered large for the 'max-times-inline-large' config option.
+  ///
+  /// This is controlled by the 'min-cfg-size-treat-functions-as-large' config
+  /// option.
+  unsigned getMinCFGSizeTreatFunctionsAsLarge();
+
   /// Returns the maximum number of nodes the analyzer can generate while
   /// exploring a top level function (for each exploded graph).
   /// 15 is default; 0 means no limit.
Index: cfe/trunk/test/Analysis/analyzer-config.c
===
--- cfe/trunk/test/Analysis/analyzer-config.c
+++ cfe/trunk/test/Analysis/analyzer-config.c
@@ -1,22 +1,30 @@
-// RUN: %clang -target x86_64-apple-darwin10 --analyze %s -o /dev/null -Xclang -analyzer-checker=debug.ConfigDumper > %t 2>&1
+// RUN: %clang -target x86_64-apple-darwin10 --analyze %s -o /dev/null -Xclang -analyzer-checker=debug.ConfigDumper -Xclang -analyzer-max-loop -Xclang 34 > %t 2>&1
 // RUN: FileCheck --input-file=%t %s
 
 void bar() {}
-void foo() { bar(); }
+void foo() {
+  // Call bar 33 times so max-times-inline-large is met and
+  // min-blocks-for-inline-large is checked
+  for (int i = 0; i < 34; ++i) {
+bar();
+  }
+}
 
 // CHECK: [config]
 // CHECK-NEXT: cfg-conditional-static-initializers = true
 // CHECK-NEXT: cfg-temporary-dtors = false
 // CHECK-NEXT: faux-bodies = true
 // CHECK-NEXT: graph-trim-interval = 1000
+// CHECK-NEXT: inline-lambdas = true
 // CHECK-NEXT: ipa = dynamic-bifurcate
 // CHECK-NEXT: ipa-always-inline-size = 3
 // CHECK-NEXT: leak-diagnostics-reference-allocation = false
 // CHECK-NEXT: max-inlinable-size = 50
 // CHECK-NEXT: max-nodes = 15
 // CHECK-NEXT: max-times-inline-large = 32
+// CHECK-NEXT: min-cfg-size-treat-functions-as-large = 14
 // CHECK-NEXT: mode = deep
 // CHECK-NEXT: region-store-small-struct-limit = 2
 // CHECK-NEXT: [stats]
-// CHECK-NEXT: num-entries = 12
+// CHECK-NEXT: num-entries = 14
 
Index: cfe/trunk/test/Analysis/analyzer-config.cpp
===
--- cfe/trunk/test/Analysis/analyzer-config.cpp
+++ cfe/trunk/test/Analysis/analyzer-config.cpp
@@ -1,8 +1,14 @@
-// RUN: %clang -target x86_64-apple-darwin10 --analyze %s -o /dev/null -Xclang -analyzer-checker=debug.ConfigDumper > 

r247466 - [analyzer] Improve behavior if Clang not found.

2015-09-11 Thread Anton Yartsev via cfe-commits
Author: ayartsev
Date: Fri Sep 11 15:41:09 2015
New Revision: 247466

URL: http://llvm.org/viewvc/llvm-project?rev=247466=rev
Log:
[analyzer] Improve behavior if Clang not found.

- Eliminate 'No such file or directory at scan-build line ...' error if 
'$RealBin/bin/clang' or '$RealBin/clang' directory does not exist.
- Eliminate 'Use of uninitialized value $Clang in concatenation (.) or string 
at scan-build line ...' error if help is displayed while $Clang was not found.

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

Modified: cfe/trunk/tools/scan-build/scan-build
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build/scan-build?rev=247466=247465=247466=diff
==
--- cfe/trunk/tools/scan-build/scan-build (original)
+++ cfe/trunk/tools/scan-build/scan-build Fri Sep 11 15:41:09 2015
@@ -1258,39 +1258,40 @@ LOADING CHECKERS:
  -load-plugin [plugin library]
 ENDTEXT
 
-  # Query clang for list of checkers that are enabled.
-
-  # create a list to load the plugins via the 'Xclang' command line
-  # argument
-  my @PluginLoadCommandline_xclang;
-  foreach my $param ( @{$Options{PluginsToLoad}} ) {
-push ( @PluginLoadCommandline_xclang, "-Xclang" );
-push ( @PluginLoadCommandline_xclang, "-load" );
-push ( @PluginLoadCommandline_xclang, "-Xclang" );
-push ( @PluginLoadCommandline_xclang, $param );
-  }
+  if (defined $Clang && -x $Clang) {
+# Query clang for list of checkers that are enabled.
 
-  my %EnabledCheckers;
-  foreach my $lang ("c", "objective-c", "objective-c++", "c++") {
-my $ExecLine = join(' ', qq/"$Clang"/, @PluginLoadCommandline_xclang, 
"--analyze", "-x", $lang, "-", "-###", "2>&1", "|");
-open(PS, $ExecLine);
-while () {
-  foreach my $val (split /\s+/) {
-$val =~ s/\"//g;
-if ($val =~ /-analyzer-checker\=([^\s]+)/) {
-  $EnabledCheckers{$1} = 1;
+# create a list to load the plugins via the 'Xclang' command line
+# argument
+my @PluginLoadCommandline_xclang;
+foreach my $param ( @{$Options{PluginsToLoad}} ) {
+  push ( @PluginLoadCommandline_xclang, "-Xclang" );
+  push ( @PluginLoadCommandline_xclang, "-load" );
+  push ( @PluginLoadCommandline_xclang, "-Xclang" );
+  push ( @PluginLoadCommandline_xclang, $param );
+}
+
+my %EnabledCheckers;
+foreach my $lang ("c", "objective-c", "objective-c++", "c++") {
+  my $ExecLine = join(' ', qq/"$Clang"/, @PluginLoadCommandline_xclang, 
"--analyze", "-x", $lang, "-", "-###", "2>&1", "|");
+  open(PS, $ExecLine);
+  while () {
+foreach my $val (split /\s+/) {
+  $val =~ s/\"//g;
+  if ($val =~ /-analyzer-checker\=([^\s]+)/) {
+$EnabledCheckers{$1} = 1;
+  }
 }
   }
 }
-  }
 
-  # Query clang for complete list of checkers.
-  my @PluginLoadCommandline;
-  foreach my $param ( @{$Options{PluginsToLoad}} ) {
-push ( @PluginLoadCommandline, "-load" );
-push ( @PluginLoadCommandline, $param );
-  }
-  if (defined $Clang && -x $Clang) {
+# Query clang for complete list of checkers.
+my @PluginLoadCommandline;
+foreach my $param ( @{$Options{PluginsToLoad}} ) {
+  push ( @PluginLoadCommandline, "-load" );
+  push ( @PluginLoadCommandline, $param );
+}
+
 my $ExecLine = join(' ', qq/"$Clang"/, "-cc1", @PluginLoadCommandline, 
"-analyzer-checker-help", "2>&1", "|");
 open(PS, $ExecLine);
 my $foundCheckers = 0;
@@ -1634,6 +1635,7 @@ if (!@ARGV) {
 }
 
 ProcessArgs(\@ARGV);
+# All arguments are now shifted from @ARGV. The rest is a build command, if 
any.
 
 if (!@ARGV and !$RequestDisplayHelp) {
   ErrorDiag("No build command specified.\n\n");
@@ -1642,9 +1644,9 @@ if (!@ARGV and !$RequestDisplayHelp) {
 
 # Find 'clang'
 if (!defined $Options{AnalyzerDiscoveryMethod}) {
-  $Clang = Cwd::realpath("$RealBin/bin/clang");
+  $Clang = Cwd::realpath("$RealBin/bin/clang") if (-d "$RealBin/bin/clang");
   if (!defined $Clang || ! -x $Clang) {
-$Clang = Cwd::realpath("$RealBin/clang");
+$Clang = Cwd::realpath("$RealBin/clang") if (-d "$RealBin/clang");
   }
   if (!defined $Clang || ! -x $Clang) {
 if (!$RequestDisplayHelp && !$ForceDisplayHelp) {


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


Re: [PATCH] D12780: [analyzer] Add generateErrorNode() APIs to CheckerContext

2015-09-11 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

In general I like this change, the node handling of the checkers are more 
readable and reflects the intent in a clearer way.  I have some comments inline.



Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h:244
@@ +243,3 @@
+  const ProgramPointTag *Tag = nullptr) {
+return generateSink(State, /*Pred=*/nullptr,
+   (Tag ? Tag : Location.getTag()));

zaks.anna wrote:
> Please, use a non-null Pred for clarity
The following workflow is not supported by this API: a checker that generates 
multiple transition in the same callback (the generated nodes are added 
sequentially to the path), and one of the might be an error node.

This also applies to generateNonFatalErrorNode.

In case we would like to improve the documentation it might be useful to give 
some pointers to the users which when should an error node be considered as 
fatal.


Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h:322
@@ -290,1 +321,3 @@
+// the same as the predecessor state has made a mistake. We return the
+// predecessor and rather than cache out.
 if (!State || (State == Pred->getState() && !Tag && !MarkAsSink))

As a slightly related note: is it documented anywhere what "cache out" means? 
Maybe it would be great to refer to that document or write it if it is not 
written yet.


http://reviews.llvm.org/D12780



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


r247462 - [Edit] Fix issue with tracking what macro argument inputs have been edited.

2015-09-11 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Fri Sep 11 15:09:11 2015
New Revision: 247462

URL: http://llvm.org/viewvc/llvm-project?rev=247462=rev
Log:
[Edit] Fix issue with tracking what macro argument inputs have been edited.

This was not working correctly, leading to erroneously rejecting valid edits.

Modified:
cfe/trunk/include/clang/Edit/EditedSource.h
cfe/trunk/lib/Edit/EditedSource.cpp
cfe/trunk/test/ARCMT/objcmt-subscripting-literals.m
cfe/trunk/test/ARCMT/objcmt-subscripting-literals.m.result

Modified: cfe/trunk/include/clang/Edit/EditedSource.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Edit/EditedSource.h?rev=247462=247461=247462=diff
==
--- cfe/trunk/include/clang/Edit/EditedSource.h (original)
+++ cfe/trunk/include/clang/Edit/EditedSource.h Fri Sep 11 15:09:11 2015
@@ -10,9 +10,11 @@
 #ifndef LLVM_CLANG_EDIT_EDITEDSOURCE_H
 #define LLVM_CLANG_EDIT_EDITEDSOURCE_H
 
+#include "clang/Basic/IdentifierTable.h"
 #include "clang/Edit/FileOffset.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/TinyPtrVector.h"
 #include "llvm/Support/Allocator.h"
 #include 
 
@@ -39,14 +41,18 @@ class EditedSource {
   typedef std::map FileEditsTy;
   FileEditsTy FileEdits;
 
-  llvm::DenseMap ExpansionToArgMap;
+  llvm::DenseMap>
+ExpansionToArgMap;
+  SmallVector, 2>
+CurrCommitMacroArgExps;
 
+  IdentifierTable IdentTable;
   llvm::BumpPtrAllocator StrAlloc;
 
 public:
   EditedSource(const SourceManager , const LangOptions ,
const PPConditionalDirectiveRecord *PPRec = nullptr)
-: SourceMgr(SM), LangOpts(LangOpts), PPRec(PPRec),
+: SourceMgr(SM), LangOpts(LangOpts), PPRec(PPRec), IdentTable(LangOpts),
   StrAlloc() { }
 
   const SourceManager () const { return SourceMgr; }
@@ -76,6 +82,12 @@ private:
   StringRef getSourceText(FileOffset BeginOffs, FileOffset EndOffs,
   bool );
   FileEditsTy::iterator getActionForOffset(FileOffset Offs);
+  void deconstructMacroArgLoc(SourceLocation Loc,
+  SourceLocation ,
+  IdentifierInfo *);
+
+  void startingCommit();
+  void finishedCommit();
 };
 
 }

Modified: cfe/trunk/lib/Edit/EditedSource.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Edit/EditedSource.cpp?rev=247462=247461=247462=diff
==
--- cfe/trunk/lib/Edit/EditedSource.cpp (original)
+++ cfe/trunk/lib/Edit/EditedSource.cpp Fri Sep 11 15:09:11 2015
@@ -23,6 +23,36 @@ void EditsReceiver::remove(CharSourceRan
   replace(range, StringRef());
 }
 
+void EditedSource::deconstructMacroArgLoc(SourceLocation Loc,
+  SourceLocation ,
+  IdentifierInfo *) {
+  assert(SourceMgr.isMacroArgExpansion(Loc));
+  SourceLocation DefArgLoc = SourceMgr.getImmediateExpansionRange(Loc).first;
+  ExpansionLoc = SourceMgr.getImmediateExpansionRange(DefArgLoc).first;
+  SmallString<20> Buf;
+  StringRef ArgName = Lexer::getSpelling(SourceMgr.getSpellingLoc(DefArgLoc),
+ Buf, SourceMgr, LangOpts);
+  II = nullptr;
+  if (!ArgName.empty()) {
+II = (ArgName);
+  }
+}
+
+void EditedSource::startingCommit() {}
+
+void EditedSource::finishedCommit() {
+  for (auto  : CurrCommitMacroArgExps) {
+SourceLocation ExpLoc;
+IdentifierInfo *II;
+std::tie(ExpLoc, II) = ExpArg;
+auto  = ExpansionToArgMap[ExpLoc.getRawEncoding()];
+if (std::find(ArgNames.begin(), ArgNames.end(), II) == ArgNames.end()) {
+  ArgNames.push_back(II);
+}
+  }
+  CurrCommitMacroArgExps.clear();
+}
+
 StringRef EditedSource::copyString(const Twine ) {
   SmallString<128> Data;
   return copyString(twine.toStringRef(Data));
@@ -36,15 +66,27 @@ bool EditedSource::canInsertInOffset(Sou
   }
 
   if (SourceMgr.isMacroArgExpansion(OrigLoc)) {
-SourceLocation
-  DefArgLoc = SourceMgr.getImmediateExpansionRange(OrigLoc).first;
-SourceLocation
-  ExpLoc = SourceMgr.getImmediateExpansionRange(DefArgLoc).first;
-llvm::DenseMap::iterator
-  I = ExpansionToArgMap.find(ExpLoc.getRawEncoding());
-if (I != ExpansionToArgMap.end() && I->second != DefArgLoc)
-  return false; // Trying to write in a macro argument input that has
- // already been written for another argument of the same 
macro. 
+IdentifierInfo *II;
+SourceLocation ExpLoc;
+deconstructMacroArgLoc(OrigLoc, ExpLoc, II);
+auto I = ExpansionToArgMap.find(ExpLoc.getRawEncoding());
+if (I != ExpansionToArgMap.end() &&
+std::find(I->second.begin(), I->second.end(), II) != I->second.end()) {
+  // Trying to 

Re: recordDecl() AST matcher

2015-09-11 Thread Aaron Ballman via cfe-commits
On Fri, Sep 11, 2015 at 4:30 PM, Richard Smith  wrote:
> I don't think CXXRecordDecl is an anachronism, so much as an implementation
> detail; it makes sense to use a smaller class when in C mode, as we don't
> need most of the features and complexity that CXXRecordDecl brings with it.
> But... as a user of clang matchers, I don't think I'd want to care about the
> difference, and it'd be more convenient if I could nest (say) a hasMethod
> matcher within a recordDecl matcher, since it's completely obvious what that
> should mean. If I have a matcher that says:
>
>   recordDecl(or(hasMethod(...), hasField(...)))
>
> I would expect that to work in both C and C++ (and the only way it could
> match in C would be on a record with the specified field, since the
> hasMethod matcher would always fail).

Okay, so then it sounds like we want recordDecl to *mean* RecordDecl,
but we want the traversal and narrowing matchers that currently take a
CXXRecordDecl to instead take a RecordDecl and handle the CXX part
transparently? This means we would not need to add a cxxRecordDecl()
matcher, but could still access CXX-only functionality (like access
control, base classes, etc) through recordDecl()?

~Aaron

>
> On Fri, Sep 11, 2015 at 6:30 AM, Manuel Klimek  wrote:
>>
>> Richard! We need an informed opinion :D
>>
>> On Fri, Sep 11, 2015 at 3:07 PM Aaron Ballman 
>> wrote:
>>>
>>> Ping?
>>>
>>> On Tue, Sep 8, 2015 at 9:26 AM, Manuel Klimek  wrote:
>>> > On Tue, Sep 8, 2015 at 3:23 PM Aaron Ballman 
>>> > wrote:
>>> >>
>>> >> On Tue, Sep 8, 2015 at 9:18 AM, Manuel Klimek 
>>> >> wrote:
>>> >> > On Tue, Sep 8, 2015 at 2:23 PM Aaron Ballman
>>> >> > 
>>> >> > wrote:
>>> >> >>
>>> >> >> On Tue, Sep 8, 2015 at 5:40 AM, Manuel Klimek 
>>> >> >> wrote:
>>> >> >> > Yea, we had that discussion a few times, and I can never remember
>>> >> >> > why
>>> >> >> > we
>>> >> >> > ended up in the state we're in.
>>> >> >> > We definitely had a time where we switched to just using the
>>> >> >> > exact
>>> >> >> > same
>>> >> >> > name
>>> >> >> > as the node's class name for the matchers.
>>> >> >> > I *think* we didn't do it for cxxRecordDecl, because Richard said
>>> >> >> > that's
>>> >> >> > a
>>> >> >> > relic we should get rid of anyway, but I'm not sure.
>>> >> >>
>>> >> >> FWIW, I think the state we're in is the worst of all worlds. It's
>>> >> >> not
>>> >> >> intuitive that recordDecl() doesn't match a struct in C mode, and
>>> >> >> as
>>> >> >> it stands, there is no way to match a struct or union declaration
>>> >> >> in C
>>> >> >> at all.
>>> >> >
>>> >> >
>>> >> > Agreed. Best intentions. Worst possible outcome. That's software
>>> >> > development
>>> >> > :)
>>> >> >
>>> >> >> >
>>> >> >> > On Fri, Sep 4, 2015 at 8:32 PM Aaron Ballman
>>> >> >> > 
>>> >> >> > wrote:
>>> >> >> >>
>>> >> >> >> It turns out that the recordDecl() AST matcher doesn't match
>>> >> >> >> RecordDecl objects; instead, it matches CXXRecordDecl objects.
>>> >> >> >> This
>>> >> >> >> is... unfortunate... as it makes writing AST matchers more
>>> >> >> >> complicated
>>> >> >> >> because of having to translate between
>>> >> >> >> recordDecl()/CXXRecordDecl.
>>> >> >> >> It
>>> >> >> >> also makes it impossible to match a struct or union declaration
>>> >> >> >> in C
>>> >> >> >> or ObjC. However, given how prevalent recordDecl()'s use is in
>>> >> >> >> the
>>> >> >> >> wild (I'm guessing), changing it at this point would be a Bad
>>> >> >> >> Thing.
>>> >> >> >>
>>> >> >> >> For people trying to write AST matchers for languages like C or
>>> >> >> >> ObjC,
>>> >> >> >> I would like to propose adding:
>>> >> >> >>
>>> >> >> >> structDecl()
>>> >> >> >> unionDecl()
>>> >> >> >> tagDecl()
>>> >> >> >>
>>> >> >> >> These will match nicely with the existing enumDecl() AST
>>> >> >> >> matcher.
>>> >> >> >>
>>> >> >> >> Additionally, I would like to add cxxRecordDecl() to match
>>> >> >> >> CXXRecordDecl objects. While it duplicates the functionality
>>> >> >> >> exposed
>>> >> >> >> by recordDecl(), it more clearly matches the intention of which
>>> >> >> >> AST
>>> >> >> >> node it corresponds to.
>>> >> >> >>
>>> >> >> >> Finally, I would like to undocument recordDecl() and change our
>>> >> >> >> existing documentation and AST matcher uses to use
>>> >> >> >> cxxRecordDecl/structDecl() instead. Maybe someday we can
>>> >> >> >> deprecate
>>> >> >> >> recordDecl() more officially.
>>> >> >> >>
>>> >> >> >> I'm open to other ideas if there are better ways to move
>>> >> >> >> forward. If
>>> >> >> >> you think changing the meaning of recordDecl() is acceptable, I
>>> >> >> >> can
>>> >> >> >> also go that route (though I would still propose adding
>>> >> >> >> unionDecl()
>>> >> >> >> and cxxRecordDecl() in that case).
>>> >> >> >
>>> >> >> >
>>> >> >> > I 

r247473 - Specify target triple in alwaysinline tests.

2015-09-11 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Fri Sep 11 16:10:12 2015
New Revision: 247473

URL: http://llvm.org/viewvc/llvm-project?rev=247473=rev
Log:
Specify target triple in alwaysinline tests.

This should fix the tests on Windows (failing due to mangling differencies).

Modified:
cfe/trunk/test/CodeGen/always_inline.c
cfe/trunk/test/CodeGenCXX/alwaysinline.cpp

Modified: cfe/trunk/test/CodeGen/always_inline.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/always_inline.c?rev=247473=247472=247473=diff
==
--- cfe/trunk/test/CodeGen/always_inline.c (original)
+++ cfe/trunk/test/CodeGen/always_inline.c Fri Sep 11 16:10:12 2015
@@ -1,5 +1,5 @@
-// RUN: %clang -emit-llvm -S -o - %s | FileCheck %s
-// RUN: %clang -mllvm -disable-llvm-optzns -emit-llvm -S -o - %s | FileCheck 
%s --check-prefix=CHECK-NO-OPTZNS
+// RUN: %clang -target x86_64-pc-linux-gnu -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang -target x86_64-pc-linux-gnu -mllvm -disable-llvm-optzns 
-emit-llvm -S -o - %s | FileCheck %s --check-prefix=CHECK-NO-OPTZNS
 
 //static int f0() { 
 static int __attribute__((always_inline)) f0() { 

Modified: cfe/trunk/test/CodeGenCXX/alwaysinline.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/alwaysinline.cpp?rev=247473=247472=247473=diff
==
--- cfe/trunk/test/CodeGenCXX/alwaysinline.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/alwaysinline.cpp Fri Sep 11 16:10:12 2015
@@ -1,10 +1,10 @@
 // Test different kinds of alwaysinline *structor definitions.
 
-// RUN: %clang_cc1 -disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s 
--check-prefix=CHECK
-// RUN: %clang_cc1 -disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s 
--check-prefix=CHECK-CALL
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -disable-llvm-optzns -emit-llvm 
%s -o - | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -disable-llvm-optzns -emit-llvm 
%s -o - | FileCheck %s --check-prefix=CHECK-CALL
 
-// RUN: %clang_cc1 -mconstructor-aliases -disable-llvm-optzns -emit-llvm %s -o 
- | FileCheck %s --check-prefix=CHECK
-// RUN: %clang_cc1 -mconstructor-aliases -disable-llvm-optzns -emit-llvm %s -o 
- | FileCheck %s --check-prefix=CHECK-CALL
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -mconstructor-aliases 
-disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -mconstructor-aliases 
-disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-CALL
 
 struct A1 {
   __attribute__((__always_inline__)) A1() {}


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


Re: [PATCH] D12759: [clang-tidy] Add misc-sizeof-container check to find sizeof() uses on stlcontainers.

2015-09-11 Thread Alexander Kornienko via cfe-commits
Indeed. But this has been fixed before I could get to it.

On Thu, Sep 10, 2015 at 10:47 PM, Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> aaron.ballman added a comment.
>
> This appears to have broken one of the bots:
>
> http://bb.pgr.jp/builders/ninja-x64-msvc-RA-centos6/builds/15065
>
>
> http://reviews.llvm.org/D12759
>
>
>
> ___
> 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


[clang-tools-extra] r247489 - [clang-tidy] misc-sizeof-container: whitelist std::bitset<>.

2015-09-11 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Sep 11 17:54:44 2015
New Revision: 247489

URL: http://llvm.org/viewvc/llvm-project?rev=247489=rev
Log:
[clang-tidy] misc-sizeof-container: whitelist std::bitset<>.

It's fine to use sizeof on std::bitset<>, since it doesn't have any external
storage, everything's inside.

Modified:
clang-tools-extra/trunk/clang-tidy/misc/SizeofContainerCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-sizeof-container.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/SizeofContainerCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/SizeofContainerCheck.cpp?rev=247489=247488=247489=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/SizeofContainerCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/SizeofContainerCheck.cpp Fri Sep 11 
17:54:44 2015
@@ -36,6 +36,7 @@ void SizeofContainerCheck::registerMatch
   expr(unless(isInTemplateInstantiation()),
expr(sizeOfExpr(has(expr(hasType(hasCanonicalType(hasDeclaration(
 recordDecl(matchesName("^(::std::|::string)"),
+   unless(hasName("::std::bitset")),
hasMethod(methodDecl(hasName("size"), 
isPublic(),
 isConst()))
.bind("sizeof"),

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-sizeof-container.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-sizeof-container.cpp?rev=247489=247488=247489=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-sizeof-container.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-sizeof-container.cpp Fri Sep 
11 17:54:44 2015
@@ -19,6 +19,12 @@ struct vector {
   size_t size() const;
 };
 
+// std::bitset<> is not a container. sizeof() is reasonable for it.
+template 
+struct bitset {
+  size_t size() const;
+};
+
 class fake_container1 {
   size_t size() const; // non-public
 };
@@ -78,9 +84,11 @@ void f() {
 
   std::fake_container1 f1;
   std::fake_container2 f2;
+  std::bitset<7> bs;
 
   a = sizeof(f1);
   a = sizeof(f2);
+  a = sizeof(bs);
 
 
   std::string arr[3];


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


r247488 - Add new test file missing from r247486.

2015-09-11 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Sep 11 17:54:01 2015
New Revision: 247488

URL: http://llvm.org/viewvc/llvm-project?rev=247488=rev
Log:
Add new test file missing from r247486.

Added:
cfe/trunk/test/Modules/Inputs/template-default-args/d.h

Added: cfe/trunk/test/Modules/Inputs/template-default-args/d.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/template-default-args/d.h?rev=247488=auto
==
--- cfe/trunk/test/Modules/Inputs/template-default-args/d.h (added)
+++ cfe/trunk/test/Modules/Inputs/template-default-args/d.h Fri Sep 11 17:54:01 
2015
@@ -0,0 +1,6 @@
+BEGIN
+template struct L;
+struct FriendL {
+  template friend struct L;
+};
+END


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


r247482 - When comparing two block captures for layout, don't crash

2015-09-11 Thread John McCall via cfe-commits
Author: rjmccall
Date: Fri Sep 11 17:00:51 2015
New Revision: 247482

URL: http://llvm.org/viewvc/llvm-project?rev=247482=rev
Log:
When comparing two block captures for layout, don't crash
if they have the same alignment and one was 'this'.

Fixes PR24780.

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/test/CodeGenObjCXX/blocks.mm

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=247482=247481=247482=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Fri Sep 11 17:00:51 2015
@@ -221,7 +221,7 @@ namespace {
   return left.Alignment > right.Alignment;
 
 auto getPrefOrder = [](const BlockLayoutChunk ) {
-  if (chunk.Capture->isByRef())
+  if (chunk.Capture && chunk.Capture->isByRef())
 return 1;
   if (chunk.Lifetime == Qualifiers::OCL_Strong)
 return 0;

Modified: cfe/trunk/test/CodeGenObjCXX/blocks.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/blocks.mm?rev=247482=247481=247482=diff
==
--- cfe/trunk/test/CodeGenObjCXX/blocks.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/blocks.mm Fri Sep 11 17:00:51 2015
@@ -8,6 +8,8 @@
 @end
 
 void f(int (^bl)(B* b));
+void takeBlock(void (^block)());
+void useValues(...);
 
 // Test1
 void g() {
@@ -59,3 +61,10 @@ void gun() {
 return foovar;
   };
 }
+
+// PR24780
+class CaptureThisAndAnotherPointer {
+  void test(void *ptr) {
+takeBlock(^{ useValues(ptr, this); });
+  }
+};


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


r247476 - [Static Analyzer] Properly cash the configuration option for lambda support.

2015-09-11 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Fri Sep 11 16:19:39 2015
New Revision: 247476

URL: http://llvm.org/viewvc/llvm-project?rev=247476=rev
Log:
[Static Analyzer] Properly cash the configuration option for lambda support. 

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

Modified: cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp?rev=247476=247475=247476=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp Fri Sep 11 16:19:39 
2015
@@ -334,5 +334,7 @@ bool AnalyzerOptions::shouldConditionali
 }
 
 bool AnalyzerOptions::shouldInlineLambdas() {
-  return getBooleanOption("inline-lambdas", /*Default=*/true);
+  if (!InlineLambdas.hasValue())
+InlineLambdas = getBooleanOption("inline-lambdas", /*Default=*/true);
+  return InlineLambdas.getValue();
 }


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


r247477 - Let selector-expr-lvalue.mm actually test something.

2015-09-11 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Sep 11 16:24:40 2015
New Revision: 247477

URL: http://llvm.org/viewvc/llvm-project?rev=247477=rev
Log:
Let selector-expr-lvalue.mm actually test something.

I accidentally introduced a bug locally, and noticed that none of the tests
caught it. No longer!

Modified:
cfe/trunk/test/CodeGenObjCXX/selector-expr-lvalue.mm

Modified: cfe/trunk/test/CodeGenObjCXX/selector-expr-lvalue.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/selector-expr-lvalue.mm?rev=247477=247476=247477=diff
==
--- cfe/trunk/test/CodeGenObjCXX/selector-expr-lvalue.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/selector-expr-lvalue.mm Fri Sep 11 16:24:40 
2015
@@ -1,16 +1,23 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 
-fobjc-runtime=macosx-fragile-10.5  -emit-llvm -o - %s 
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 
-fobjc-runtime=macosx-fragile-10.5  -emit-llvm -o - %s | FileCheck %s
 // PR7390
 
-@interface NSObject {}
-- (void)respondsToSelector:(const SEL&)s : (SEL*)s1;
-- (void) setPriority:(int)p;
+// CHECK: @[[setprioname:[^ ]*]] = {{.*}}"setPriority:
+// CHECK-NEXT: @[[setpriosel:[^ ]*]] = {{.*}}getelementptr{{.*}}[[setprioname]]
+@interface NSObject
+- (void)respondsToSelector:(const SEL &)s ps:(SEL *)s1;
+- (void)setPriority:(int)p;
 - (void)Meth;
 @end
 
-@implementation  NSObject
+@implementation NSObject
+
+// CHECK-LABEL: define internal void @"\01-[NSObject Meth]"(
 - (void)Meth {
-[self respondsToSelector:@selector(setPriority:) : 
&@selector(setPriority:)];
+// CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, 
i8*, i8**, i8**)*){{.*}}, i8** @[[setpriosel]])
+  [self respondsToSelector:@selector(setPriority:) 
ps:&@selector(setPriority:)];
+}
+- (void)setPriority:(int)p {
+}
+- (void)respondsToSelector:(const SEL &)s ps:(SEL *)s1 {
 }
-- (void) setPriority:(int)p{}
-- (void)respondsToSelector:(const SEL&)s : (SEL*)s1 {}
 @end


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


r247486 - [modules] When picking one of two template declarations as a lookup result,

2015-09-11 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Sep 11 17:39:35 2015
New Revision: 247486

URL: http://llvm.org/viewvc/llvm-project?rev=247486=rev
Log:
[modules] When picking one of two template declarations as a lookup result,
it's not sufficient to prefer the declaration with more default arguments, or
the one that's visible; they might both be visible, but one of them might have
a visible default argument where the other has a hidden default argument.

Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/test/Modules/Inputs/template-default-args/a.h
cfe/trunk/test/Modules/Inputs/template-default-args/module.modulemap
cfe/trunk/test/Modules/template-default-args.cpp

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=247486=247485=247486=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Fri Sep 11 17:39:35 2015
@@ -387,6 +387,8 @@ static bool isPreferredLookupResult(Sema
 // If D has more default arguments, it is preferred.
 if (DMin != EMin)
   return DMin < EMin;
+// FIXME: When we track visibility for default function arguments, check
+// that we pick the declaration with more visible default arguments.
   }
 
   // Pick the template with more default template arguments.
@@ -394,9 +396,22 @@ static bool isPreferredLookupResult(Sema
 auto *ETD = cast(EUnderlying);
 unsigned DMin = DTD->getTemplateParameters()->getMinRequiredArguments();
 unsigned EMin = ETD->getTemplateParameters()->getMinRequiredArguments();
-// If D has more default arguments, it is preferred.
+// If D has more default arguments, it is preferred. Note that default
+// arguments (and their visibility) is monotonically increasing across the
+// redeclaration chain, so this is a quick proxy for "is more recent".
 if (DMin != EMin)
   return DMin < EMin;
+// If D has more *visible* default arguments, it is preferred. Note, an
+// earlier default argument being visible does not imply that a later
+// default argument is visible, so we can't just check the first one.
+for (unsigned I = DMin, N = DTD->getTemplateParameters()->size();
+I != N; ++I) {
+  if (!S.hasVisibleDefaultArgument(
+  ETD->getTemplateParameters()->getParam(I)) &&
+  S.hasVisibleDefaultArgument(
+  DTD->getTemplateParameters()->getParam(I)))
+return true;
+}
   }
 
   // For most kinds of declaration, it doesn't really matter which one we pick.

Modified: cfe/trunk/test/Modules/Inputs/template-default-args/a.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/template-default-args/a.h?rev=247486=247485=247486=diff
==
--- cfe/trunk/test/Modules/Inputs/template-default-args/a.h (original)
+++ cfe/trunk/test/Modules/Inputs/template-default-args/a.h Fri Sep 11 17:39:35 
2015
@@ -9,4 +9,8 @@ template struct H;
 template struct J {};
 template struct J;
 struct K : J<> {};
+template struct L;
+struct FriendL {
+  template friend struct L;
+};
 END

Modified: cfe/trunk/test/Modules/Inputs/template-default-args/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/template-default-args/module.modulemap?rev=247486=247485=247486=diff
==
--- cfe/trunk/test/Modules/Inputs/template-default-args/module.modulemap 
(original)
+++ cfe/trunk/test/Modules/Inputs/template-default-args/module.modulemap Fri 
Sep 11 17:39:35 2015
@@ -3,3 +3,6 @@ module X {
   module B { header "b.h" }
   module C { header "c.h" }
 }
+module Y {
+  module D { header "d.h" }
+}

Modified: cfe/trunk/test/Modules/template-default-args.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/template-default-args.cpp?rev=247486=247485=247486=diff
==
--- cfe/trunk/test/Modules/template-default-args.cpp (original)
+++ cfe/trunk/test/Modules/template-default-args.cpp Fri Sep 11 17:39:35 2015
@@ -13,6 +13,7 @@ template struct A {};
@@ -41,4 +42,5 @@ G<> g; // expected-error {{default argum
 H<> h; // expected-error {{default argument of 'H' must be imported from 
module 'X.A' before it is required}}
 // expected-note@a.h:8 {{default argument declared here}}
 I<> i;
+L<> *l;
 END


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


[PATCH] D12821: Allow for C's "writing off the end" idiom in __builtin_object_size

2015-09-11 Thread George Burgess IV via cfe-commits
george.burgess.iv created this revision.
george.burgess.iv added a reviewer: rsmith.
george.burgess.iv added subscribers: cfe-commits, mzolotukhin.

In C, a common idiom is:

```
struct Foo { int a; char cs[1] };
struct Foo *F = (struct Foo *)malloc(sizeof(Foo) + strlen(SomeString));
strcpy(F->cs, SomeString);
```

Currently, __builtin_object_size does not allow for this, which breaks some 
existing code. This patch makes us answer conservatively in Clang if the 
following conditions are met:

- Type is 1 or 3
- The Base is invalid/can't be determined
- The subobject we're referencing is the last subobject in the struct
- The subobject we're referencing is an array with 0 or 1 elements (for 0 
elements, both `char foo[]` and `char foo[0]` syntaxes are supported)

http://reviews.llvm.org/D12821

Files:
  lib/AST/ExprConstant.cpp
  test/CodeGen/object-size.c

Index: test/CodeGen/object-size.c
===
--- test/CodeGen/object-size.c
+++ test/CodeGen/object-size.c
@@ -391,3 +391,63 @@
   gi = __builtin_object_size(addCasts([1].v[1]), 3);
 #undef addCasts
 }
+
+struct DynStructVar {
+  char fst[16];
+  char snd[];
+};
+
+struct DynStruct0 {
+  char fst[16];
+  char snd[0];
+};
+
+struct DynStruct1 {
+  char fst[16];
+  char snd[1];
+};
+
+struct StaticStruct {
+  char fst[16];
+  char snd[2];
+};
+
+// CHECK: @test29
+void test29(struct DynStructVar *dv, struct DynStruct0 *d0,
+struct DynStruct1 *d1, struct StaticStruct *ss) {
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(dv->snd, 0);
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(dv->snd, 1);
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 true)
+  gi = __builtin_object_size(dv->snd, 2);
+  // CHECK: store i32 0
+  gi = __builtin_object_size(dv->snd, 3);
+
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(d0->snd, 0);
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(d0->snd, 1);
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 true)
+  gi = __builtin_object_size(d0->snd, 2);
+  // CHECK: store i32 0
+  gi = __builtin_object_size(d0->snd, 3);
+
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(d1->snd, 0);
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(d1->snd, 1);
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 true)
+  gi = __builtin_object_size(d1->snd, 2);
+  // CHECK: store i32 0
+  gi = __builtin_object_size(d1->snd, 3);
+
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(ss->snd, 0);
+  // CHECK: store i32 2
+  gi = __builtin_object_size(ss->snd, 1);
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 true)
+  gi = __builtin_object_size(ss->snd, 2);
+  // CHECK: store i32 2
+  gi = __builtin_object_size(ss->snd, 3);
+}
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -114,7 +114,8 @@
   static
   unsigned findMostDerivedSubobject(ASTContext , QualType Base,
 ArrayRef Path,
-uint64_t , QualType ) {
+uint64_t , QualType ,
+bool ) {
 unsigned MostDerivedLength = 0;
 Type = Base;
 for (unsigned I = 0, N = Path.size(); I != N; ++I) {
@@ -124,18 +125,22 @@
 Type = CAT->getElementType();
 ArraySize = CAT->getSize().getZExtValue();
 MostDerivedLength = I + 1;
+IsArray = true;
   } else if (Type->isAnyComplexType()) {
 const ComplexType *CT = Type->castAs();
 Type = CT->getElementType();
 ArraySize = 2;
 MostDerivedLength = I + 1;
+IsArray = true;
   } else if (const FieldDecl *FD = getAsField(Path[I])) {
 Type = FD->getType();
 ArraySize = 0;
 MostDerivedLength = I + 1;
+IsArray = false;
   } else {
 // Path[I] describes a base class.
 ArraySize = 0;
+IsArray = false;
   }
 }
 return MostDerivedLength;
@@ -157,12 +162,17 @@
 /// Is this a pointer one past the end of an object?
 bool IsOnePastTheEnd : 1;
 
+/// Indicator of whether the most-derived object is an array.
+bool MostDerivedIsArrayElement : 1;
+
 /// The length of the path to the most-derived object of which this is a
 /// subobject.
-unsigned MostDerivedPathLength : 30;
+unsigned MostDerivedPathLength : 29;
 
-/// The size of the array of which the most-derived object is an element, or
-/// 0 if the most-derived object is not an array element.
+/// The size 

[PATCH] D12797: Refactor LoopConvertCheck.

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

Reorder the code in a more logical and understandable way.

http://reviews.llvm.org/D12797

Files:
  clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tidy/modernize/LoopConvertCheck.h
  test/clang-tidy/modernize-loop-convert-basic.cpp

Index: test/clang-tidy/modernize-loop-convert-basic.cpp
===
--- test/clang-tidy/modernize-loop-convert-basic.cpp
+++ test/clang-tidy/modernize-loop-convert-basic.cpp
@@ -406,12 +406,12 @@
 for (const_iterator I = begin(), E = end(); I != E; ++I)
   (void) *I;
 // CHECK-MESSAGES: :[[@LINE-2]]:5: warning: use range-based for loop instead
-// CHECK-FIXES: for (auto & elem : *this)
+// CHECK-FIXES: for (const auto & elem : *this)
 
 for (const_iterator I = C::begin(), E = C::end(); I != E; ++I)
   (void) *I;
 // CHECK-MESSAGES: :[[@LINE-2]]:5: warning: use range-based for loop instead
-// CHECK-FIXES: for (auto & elem : *this)
+// CHECK-FIXES: for (const auto & elem : *this)
 
 for (const_iterator I = begin(), E = end(); I != E; ++I) {
   (void) *I;
Index: clang-tidy/modernize/LoopConvertCheck.h
===
--- clang-tidy/modernize/LoopConvertCheck.h
+++ clang-tidy/modernize/LoopConvertCheck.h
@@ -26,25 +26,32 @@
 
 private:
   struct RangeDescriptor {
+RangeDescriptor();
 bool ContainerNeedsDereference;
 bool DerefByConstRef;
 bool DerefByValue;
 bool IsTriviallyCopyable;
+StringRef ContainerString;
   };
 
   void doConversion(ASTContext *Context, const VarDecl *IndexVar,
-const VarDecl *MaybeContainer, StringRef ContainerString,
-const UsageResult , const DeclStmt *AliasDecl,
-bool AliasUseRequired, bool AliasFromForInit,
-const ForStmt *TheLoop, RangeDescriptor Descriptor);
-
-  StringRef checkRejections(ASTContext *Context, const Expr *ContainerExpr,
-const ForStmt *TheLoop);
-
-  void findAndVerifyUsages(ASTContext *Context, const VarDecl *LoopVar,
-   const VarDecl *EndVar, const Expr *ContainerExpr,
-   const Expr *BoundExpr, const ForStmt *TheLoop,
-   LoopFixerKind FixerKind, RangeDescriptor Descriptor);
+const VarDecl *MaybeContainer, const UsageResult ,
+const DeclStmt *AliasDecl, bool AliasUseRequired,
+bool AliasFromForInit, const ForStmt *Loop,
+RangeDescriptor Descriptor);
+
+  StringRef getContainerString(ASTContext *Context, const ForStmt *Loop,
+   const Expr *ContainerExpr);
+
+  void determineRangeDescriptor(ASTContext *Context,
+const ast_matchers::BoundNodes ,
+const ForStmt *Loop, LoopFixerKind FixerKind,
+const Expr *ContainerExpr,
+const UsageResult ,
+RangeDescriptor );
+
+  bool isConvertible(ASTContext *Context, const ast_matchers::BoundNodes ,
+ const ForStmt *Loop, LoopFixerKind FixerKind);
 
   std::unique_ptr TUInfo;
   Confidence::Level MinConfidence;
Index: clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tidy/modernize/LoopConvertCheck.cpp
@@ -395,6 +395,10 @@
   return false;
 }
 
+LoopConvertCheck::RangeDescriptor::RangeDescriptor()
+: ContainerNeedsDereference(false), DerefByConstRef(false),
+  DerefByValue(false), IsTriviallyCopyable(false) {}
+
 LoopConvertCheck::LoopConvertCheck(StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context), TUInfo(new TUTrackingInfo),
   MinConfidence(StringSwitch(
@@ -408,19 +412,24 @@
   Options.store(Opts, "MinConfidence", Confs[static_cast(MinConfidence)]);
 }
 
+void LoopConvertCheck::registerMatchers(MatchFinder *Finder) {
+  // Only register the matchers for C++. Because this checker is used for
+  // modernization, it is reasonable to run it on any C++ standard with the
+  // assumption the user is trying to modernize their codebase.
+  if (getLangOpts().CPlusPlus) {
+Finder->addMatcher(makeArrayLoopMatcher(), this);
+Finder->addMatcher(makeIteratorLoopMatcher(), this);
+Finder->addMatcher(makePseudoArrayLoopMatcher(), this);
+  }
+}
+
 /// \brief Computes the changes needed to convert a given for loop, and
-/// applies it.
+/// applies them.
 void LoopConvertCheck::doConversion(
 ASTContext *Context, const VarDecl *IndexVar, const VarDecl *MaybeContainer,
-StringRef ContainerString, const UsageResult ,
-const DeclStmt *AliasDecl, bool AliasUseRequired, 

Re: [PATCH] D12695: [Driver] Use UniversalCRT on Windows if available

2015-09-11 Thread İsmail Dönmez via cfe-commits
This doesn't seem to work here, VS 2015 on Win 10 x64:

C:\Users\ismail\Desktop>clang-cl.exe -fms-compatibility-version=19 foo.cpp
LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
clang-cl.exe: error: linker command failed with exit code 1104 (use -v
to see invocation)

Works fine after setting LIB.

On Fri, Sep 11, 2015 at 3:11 AM, Reid Kleckner via cfe-commits
 wrote:
> This revision was automatically updated to reflect the committed changes.
> Closed by commit rL247362: [Driver] Use UniversalCRT on Windows if available 
> (authored by rnk).
>
> Changed prior to commit:
>   http://reviews.llvm.org/D12695?vs=34475=34515#toc
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D12695
>
> Files:
>   cfe/trunk/lib/Driver/MSVCToolChain.cpp
>   cfe/trunk/lib/Driver/ToolChains.h
>   cfe/trunk/lib/Driver/Tools.cpp
>
>
> ___
> 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: r247410 - This test requires UTF-8 output to print the UT-8 characters.

2015-09-11 Thread Yaron Keren via cfe-commits
The test was passing before r247253 without LLVM_ON_WIN32 defined in
lib/Support/Locale.cpp, so the llvm::sys::unicode::* functions were used,
which may mean that the LLVM_ON_WIN32 functions are overly restrictive.
For example, Windows can output the UTF-8 character from source-col-map.c
correctly. Maybe the correct fix it to actually eliminate the
LLVM_ON_WIN32 versions.

What I still don't understand - how the Windows bots were passing this test
and green?


2015-09-11 16:31 GMT+03:00 Aaron Ballman :

> Thank you for this! I wasn't certain of what the right way to fix it was.
> :-)
>
> ~Aaron
>
> On Fri, Sep 11, 2015 at 9:29 AM, Yaron Keren via cfe-commits
>  wrote:
> > Author: yrnkrn
> > Date: Fri Sep 11 08:29:12 2015
> > New Revision: 247410
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=247410=rev
> > Log:
> > This test requires UTF-8 output to print the UT-8 characters.
> >
> >
> > Modified:
> > cfe/trunk/test/Frontend/source-col-map.c
> >
> > Modified: cfe/trunk/test/Frontend/source-col-map.c
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/source-col-map.c?rev=247410=247409=247410=diff
> >
> ==
> > --- cfe/trunk/test/Frontend/source-col-map.c (original)
> > +++ cfe/trunk/test/Frontend/source-col-map.c Fri Sep 11 08:29:12 2015
> > @@ -1,4 +1,5 @@
> >  // RUN: not %clang_cc1 -fsyntax-only -fmessage-length 75 -o /dev/null
> -x c < %s 2>&1 | FileCheck %s -strict-whitespace
> > +// REQUIRES: utf8-capable-terminal
> >
> >  // Test case for the text diagnostics source column conversion crash.
> >
> >
> >
> > ___
> > 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] D12695: [Driver] Use UniversalCRT on Windows if available

2015-09-11 Thread İsmail Dönmez via cfe-commits
Hi,

C:\Users\ismail\Desktop>set include
INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio
14.0\VC\INCLUDE;C:\Program Files (x86)\Microsoft Visual Studio
14.0\VC\ATLMFC\INCLUDE;C:\Program Files (x86)\Windows
Kits\10\include\10.0.10240.0\ucrt;C:\Program Files (x86)\Windows
Kits\NETFXSDK\4.6\include\um;C:\Program Files (x86)\Windows
Kits\10\include\10.0.10240.0\shared;C:\Program Files (x86)\Windows
Kits\10\include\10.0.10240.0\um;C:\Program Files (x86)\Windows
Kits\10\include\10.0.10240.0\winrt;

C:\Users\ismail\Desktop>set lib
LIB=C:\Program Files (x86)\Microsoft Visual Studio
14.0\VC\LIB\amd64;C:\Program Files (x86)\Microsoft Visual Studio
14.0\VC\ATLMFC\LIB\amd64;C:\Program Files (x86)\Windows
Kits\10\lib\10.0.10240.0\ucrt\x64;C:\Program Files (x86)\Windows
Kits\NETFXSDK\4.6\lib\um\x64;C:\Program Files (x86)\Windows
Kits\10\lib\10.0.10240.0\um\x64;
LIBPATH=C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319;C:\Program
Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64;C:\Program Files
(x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\LIB\amd64;C:\Program
Files (x86)\Windows Kits\10\UnionMetadata;C:\Program Files
(x86)\Windows Kits\10\References;C:\Program Files (x86)\Windows
Kits\10\References\Windows.Foundation.UniversalApiContract\1.0.0.0;C:\Program
Files (x86)\Windows
Kits\10\References\Windows.Foundation.FoundationContract\1.0.0.0;C:\Program
Files (x86)\Windows
Kits\10\References\indows.Networking.Connectivity.WwanContract\1.0.0.0;C:\Program
Files (x86)\Microsoft SDKs\Windows
Kits\10\ExtensionSDKs\Microsoft.VCLibs\14.0\References\CommonConfiguration\neutral;

C:\Users\ismail\Desktop>clang-cl.exe -###
-fms-compatibility-version=19 mandelbrot-mp.cpp
clang version 3.8.0 (http://llvm.org/git/clang
d2dc884a74b40711955713829e7a09b8ff5ca1bc) (http://llvm.org/git/llvm
595af7ed8595ccf005efb087b5bb7d9a19e50e3b)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin
 "C:\\Program Files\\LLVM\\bin\\clang-cl.exe" "-cc1" "-triple"
"x86_64-pc-windows-msvc19.0.0" "-emit-obj" "-mrelax-all"
"-disable-free" "-main-file-name" "mandelbrot-mp.cpp"
"-mrelocation-model" "pic" "-pic-level" "2" "-mthread-model" "posix"
"-relaxed-aliasing" "-fmath-errno" "-masm-verbose"
"-mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64"
"-D_MT" "--dependent-lib=libcmt" "--dependent-lib=oldnames"
"-fms-volatile" "-fdiagnostics-format" "msvc"
"-momit-leaf-frame-pointer" "-dwarf-column-info" "-resource-dir"
"C:\\Program Files\\LLVM\\bin\\..\\lib\\clang\\3.8.0"
"-internal-isystem" "C:\\Program
Files\\LLVM\\bin\\..\\lib\\clang\\3.8.0\\include" "-internal-isystem"
"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\INCLUDE"
"-internal-isystem" "C:\\Program Files (x86)\\Microsoft Visual Studio
14.0\\VC\\ATLMFC\\INCLUDE" "-internal-isystem" "C:\\Program Files
(x86)\\Windows Kits\\10\\include\\10.0.10240.0\\ucrt"
"-internal-isystem" "C:\\Program Files (x86)\\Windows
Kits\\NETFXSDK\\4.6\\include\\um" "-internal-isystem" "C:\\Program
Files (x86)\\Windows Kits\\10\\include\\10.0.10240.0\\shared"
"-internal-isystem" "C:\\Program Files (x86)\\Windows
Kits\\10\\include\\10.0.10240.0\\um" "-internal-isystem" "C:\\Program
Files (x86)\\Windows Kits\\10\\include\\10.0.10240.0\\winrt" "-Wall"
"-fdeprecated-macro" "-fdebug-compilation-dir"
"C:\\Users\\ismail\\Desktop" "-ferror-limit" "19" "-fmessage-length"
"100" "-mstackrealign" "-fms-extensions" "-fms-compatibility"
"-fms-compatibility-version=19" "-std=c++14"
"-fdelayed-template-parsing" "-fobjc-runtime=gcc"
"-fdiagnostics-show-option" "-fcolor-diagnostics" "-o"
"C:\\Users\\ismail\\AppData\\Local\\Temp\\mandelbrot-mp-d6f68c.obj"
"-x" "c++" "mandelbrot-mp.cpp"
 "C:\\Program Files (x86)\\Microsoft Visual Studio
14.0\\VC\\bin\\amd64\\link.exe" "-out:mandelbrot-mp.exe" "-nologo"
"C:\\Users\\ismail\\AppData\\Local\\Temp\\mandelbrot-mp-d6f68c.obj"


On Fri, Sep 11, 2015 at 4:42 PM, Igor Kudrin  wrote:
> Please, can you show the output of the following commands:
>
> 1) set include
> 2) set lib
> 3) clang-cl.exe -### -fms-compatibility-version=19 foo.cpp
>
>
> On 11.09.2015 17:44, İsmail Dönmez wrote:
>>
>> This doesn't seem to work here, VS 2015 on Win 10 x64:
>>
>> C:\Users\ismail\Desktop>clang-cl.exe -fms-compatibility-version=19 foo.cpp
>> LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
>> clang-cl.exe: error: linker command failed with exit code 1104 (use -v
>> to see invocation)
>>
>> Works fine after setting LIB.
>>
>> On Fri, Sep 11, 2015 at 3:11 AM, Reid Kleckner via cfe-commits
>>  wrote:
>>>
>>> This revision was automatically updated to reflect the committed changes.
>>> Closed by commit rL247362: [Driver] Use UniversalCRT on Windows if
>>> available (authored by rnk).
>>>
>>> Changed prior to commit:
>>>http://reviews.llvm.org/D12695?vs=34475=34515#toc
>>>
>>> Repository:
>>>rL LLVM
>>>
>>> http://reviews.llvm.org/D12695
>>>
>>> Files:
>>>cfe/trunk/lib/Driver/MSVCToolChain.cpp

Re: r247410 - This test requires UTF-8 output to print the UT-8 characters.

2015-09-11 Thread Aaron Ballman via cfe-commits
Thank you for this! I wasn't certain of what the right way to fix it was. :-)

~Aaron

On Fri, Sep 11, 2015 at 9:29 AM, Yaron Keren via cfe-commits
 wrote:
> Author: yrnkrn
> Date: Fri Sep 11 08:29:12 2015
> New Revision: 247410
>
> URL: http://llvm.org/viewvc/llvm-project?rev=247410=rev
> Log:
> This test requires UTF-8 output to print the UT-8 characters.
>
>
> Modified:
> cfe/trunk/test/Frontend/source-col-map.c
>
> Modified: cfe/trunk/test/Frontend/source-col-map.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/source-col-map.c?rev=247410=247409=247410=diff
> ==
> --- cfe/trunk/test/Frontend/source-col-map.c (original)
> +++ cfe/trunk/test/Frontend/source-col-map.c Fri Sep 11 08:29:12 2015
> @@ -1,4 +1,5 @@
>  // RUN: not %clang_cc1 -fsyntax-only -fmessage-length 75 -o /dev/null -x c < 
> %s 2>&1 | FileCheck %s -strict-whitespace
> +// REQUIRES: utf8-capable-terminal
>
>  // Test case for the text diagnostics source column conversion crash.
>
>
>
> ___
> 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] D12695: [Driver] Use UniversalCRT on Windows if available

2015-09-11 Thread Igor Kudrin via cfe-commits

Please, can you show the output of the following commands:

1) set include
2) set lib
3) clang-cl.exe -### -fms-compatibility-version=19 foo.cpp

On 11.09.2015 17:44, İsmail Dönmez wrote:

This doesn't seem to work here, VS 2015 on Win 10 x64:

C:\Users\ismail\Desktop>clang-cl.exe -fms-compatibility-version=19 foo.cpp
LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
clang-cl.exe: error: linker command failed with exit code 1104 (use -v
to see invocation)

Works fine after setting LIB.

On Fri, Sep 11, 2015 at 3:11 AM, Reid Kleckner via cfe-commits
 wrote:

This revision was automatically updated to reflect the committed changes.
Closed by commit rL247362: [Driver] Use UniversalCRT on Windows if available 
(authored by rnk).

Changed prior to commit:
   http://reviews.llvm.org/D12695?vs=34475=34515#toc

Repository:
   rL LLVM

http://reviews.llvm.org/D12695

Files:
   cfe/trunk/lib/Driver/MSVCToolChain.cpp
   cfe/trunk/lib/Driver/ToolChains.h
   cfe/trunk/lib/Driver/Tools.cpp


___
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: Expose the 'file' that is associated with a compile database command

2015-09-11 Thread Argyrios Kyrtzidis via cfe-commits

> On Sep 11, 2015, at 12:21 AM, Manuel Klimek  wrote:
> 
> On Thu, Sep 10, 2015 at 8:36 PM Argyrios Kyrtzidis  > wrote:
>> On Sep 10, 2015, at 1:48 AM, Manuel Klimek > > wrote:
>> 
>> @@ -179,11 +185,13 @@ public:
>>/// \param Directory The base directory used in the 
>> FixedCompilationDatabase.
>>static FixedCompilationDatabase *loadFromCommandLine(int ,
>> const char *const 
>> *Argv,
>> -   Twine Directory = 
>> ".");
>> +   Twine Directory = 
>> ".",
>> +   Twine File = 
>> Twine());
>>  
>> A fixed compilation database returns the same command lines for all files, 
>> thus having a file in the function seems strange.
> 
> Ah ok, thanks for clarifying.
> 
>> 
>> What exactly is the use case? So far, the compilation database has been 
>> designed for 2 use cases:
>> 1. for a file, get the compile commands; the user already knows the file, no 
>> need to get the file
>> 2. get all compile commands; for that, we have the getAllFiles() method, so 
>> a user can get all known files (for compilation databases that support 
>> that), and then get the compile command line.
> 
> It’s #2, I want to get all compile commands. But it seems really strange to 
> me that the ‘file’ starts as a property of the compile command in the json 
> file but then it gets dropped and I need to do work to re-associate the files 
> with the compile commands again.
> 
> The JSON file format is one possible implementation for the 
> compilation-database interface. The FixedCompilationDatabase is another one, 
> that doesn't have any information on files.
>  
> I need to get a list of all the files and then for each one do a lookup to 
> get the associated commands. I then have to maintain this association myself, 
> passing a command along with its file separately or the structure that keeps 
> track of the association.
> 
> It seems simpler to me to include the file that was associated with the 
> command (if the compilation database supports that) along with the command, 
> is there a downside I’m missing ?
> 
> Well, to me, it's a design question - if it also makes sense to have a 
> CompileCommand without a file associated with it, putting the file in there, 
> while convenient, is a design smell.

It can be optional to communicate that it may not be there. Note that, IMO, 
having multiple files and compile commands for them is the overwhelmingly most 
common use of the compilation database.

> That said, I'm happy to be convinced that I'm wrong :) I guess I don't see 
> yet that keeping track of the files outside is more than one line of extra 
> code.

Not sure what one line this is, I have to declare a map and then populate it, 
no ? And to do it in c-index-test it would take way more that one line.
But it is also beyond populating a map, this has an effect on APIs using a 
CompileCommand. For example:

void doSomethingWithCompileCommand(const CompileCommand ); 

Ah it would be useful to know the file that this command was associated with:

void doSomethingWithCompileCommand(const CompileCommand , StringRef 
filename); 

What do I have now ? This is a function taking a command and a string for the 
filename separately.
Is this flexibility useful ? Does it make sense to pass any filename there ? No 
there’s only one filename that the command was associated with so this 
‘flexibility’ only increases the complexity of using the function. And this can 
propagate to other function’s callees.
This seems like a design smell to me.

> 
> Cheers,
> /Manuel
>  
> 
>> 
>> Thoughts?
>> /Manuel
>> 
>> On Wed, Sep 9, 2015 at 9:36 PM Argyrios Kyrtzidis > > wrote:
>> Hi,
>> 
>> The attached patch exposes the ‘file’ entry in a compilation database 
>> command, via the CompileCommand structure.

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


Re: [PATCH] D12767: [Static Analyzer] Properly clean up the dynamic type information for dead regions.

2015-09-11 Thread Gábor Horváth via cfe-commits
xazax.hun marked 2 inline comments as done.
xazax.hun added a comment.

http://reviews.llvm.org/D12767



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


Re: [PATCH] D12743: [CodeGen] Teach SimplifyPersonality about the updated LandingPadInst

2015-09-11 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247437: [test] Specify exception object type in two tests 
(authored by vedantk).

Changed prior to commit:
  http://reviews.llvm.org/D12743?vs=34408=34560#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12743

Files:
  cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm
  cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm

Index: cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm
===
--- cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm
+++ cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm
@@ -11,7 +11,7 @@
 void foo() {
   try {
 throw 0;
-  } catch (...) {
+  } catch (int e) {
 return;
   }
 }
Index: cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm
===
--- cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm
+++ cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm
@@ -5,7 +5,7 @@
   void foo() {
 try {
   throw 0;
-} catch (...) {
+} catch (int e) {
   return;
 }
   }


Index: cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm
===
--- cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm
+++ cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm
@@ -11,7 +11,7 @@
 void foo() {
   try {
 throw 0;
-  } catch (...) {
+  } catch (int e) {
 return;
   }
 }
Index: cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm
===
--- cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm
+++ cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm
@@ -5,7 +5,7 @@
   void foo() {
 try {
   throw 0;
-} catch (...) {
+} catch (int e) {
   return;
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r247346 - [MS ABI] Make member pointers return true for isIncompleteType

2015-09-11 Thread David Majnemer via cfe-commits
Taking a look, would appreciate it if we didn't revert this until I give it
a fair shot.  Shouldn't take too long.

On Fri, Sep 11, 2015 at 10:58 AM, Hans Wennborg  wrote:

> This made the Chromium build sad. For example:
>
> http://build.chromium.org/p/chromium.fyi/builders/ClangToTWin/builds/3092/steps/compile/logs/stdio
>
> Reduction:
>
> $ clang -cc1 -triple i686-pc-windows-msvc18.0.0 -w -fms-extensions
> -fms-compatibility -fms-compatibility-version=18.0 -std=c++11
> -fdelayed-template-parsing a.ii
>
> template 
> void JSMethod(char *, char *, int);
> class A {
>   int printd(int *, const int &, int &, int &);
>   int printd_info;
>   void printd() { JSMethod("", "", printd_info); }
> };
>
>
> On Thu, Sep 10, 2015 at 2:52 PM, David Majnemer via cfe-commits
>  wrote:
> > Author: majnemer
> > Date: Thu Sep 10 16:52:00 2015
> > New Revision: 247346
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=247346=rev
> > Log:
> > [MS ABI] Make member pointers return true for isIncompleteType
> >
> > The type of a member pointer is incomplete if it has no inheritance
> > model.  This lets us reuse more general logic already embedded in clang.
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r247404 - Fixed HasDeclarationMatcher to properly convert all types into decls where possible. Added objcObjectPointerType(), objcInterfaceDecl(), templateTypeParmType(), injectedClassNameType(), and

2015-09-11 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Sep 11 06:51:24 2015
New Revision: 247404

URL: http://llvm.org/viewvc/llvm-project?rev=247404=rev
Log:
Fixed HasDeclarationMatcher to properly convert all types into decls where 
possible. Added objcObjectPointerType(), objcInterfaceDecl(), 
templateTypeParmType(), injectedClassNameType(), and 
unresolvedUsingTypenameDecl(). Updated documentation for pointerType() to call 
out that it does not match ObjCObjectPointerType types. Changed pointsTo() to 
handle ObjCObjectPointerType as well as PointerType.

While this may seem like a lot of unrelated changes, they all relate back to 
fixing HasDeclarationMatcher.

This now allows us to write a matcher like:

varDecl(hasType(namedDecl(hasName("Foo"

that matches code using typedefs, objc interfaces, template type parameters, 
injected class names, or unresolved using typenames.

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.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=247404=247403=247404=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Fri Sep 11 06:51:24 2015
@@ -307,6 +307,15 @@ namespaceDecl()
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DeclobjcInterfaceDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html;>ObjCInterfaceDecl...
+Matches 
Objective-C interface declarations.
+
+Example matches Foo
+  @interface Foo
+  @end
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DeclparmVarDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html;>ParmVarDecl...
 Matches parameter 
variable declarations.
 
@@ -364,6 +373,22 @@ typedefDecl()
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DeclunresolvedUsingTypenameDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingTypenameDecl.html;>UnresolvedUsingTypenameDecl...
+Matches 
unresolved using value declarations that involve the
+typename.
+
+Given
+  template typename T
+  struct Base { typedef T Foo; };
+
+  templatetypename T
+  struct S : private BaseT {
+using typename BaseT::Foo;
+  };
+unresolvedUsingTypenameDecl()
+  matches using BaseT::Foo 
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DeclunresolvedUsingValueDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingValueDecl.html;>UnresolvedUsingValueDecl...
 Matches 
unresolved using value declarations.
 
@@ -1254,6 +1279,18 @@ incompleteArrayType()
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Type.html;>TypeinjectedClassNameTypeMatcherhttp://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html;>InjectedClassNameType...
+Matches 
injected class name types.
+
+Example matches S s, but not ST s.
+(matcher = parmVarDecl(hasType(injectedClassNameType(
+  template typename T struct S {
+void f(S s);
+void g(ST s);
+  };
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Type.html;>TypelValueReferenceTypeMatcherhttp://clang.llvm.org/doxygen/classclang_1_1LValueReferenceType.html;>LValueReferenceType...
 Matches lvalue 
reference types.
 
@@ -1281,6 +1318,21 @@ memberPointerType()
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Type.html;>TypeobjcObjectPointerTypeMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCObjectPointerType.html;>ObjCObjectPointerType...
+Matches an 
Objective-C object pointer type, which is different from
+a pointer type, despite being syntactically similar.
+
+Given
+  int *a;
+
+  @interface Foo
+  @end
+  Foo *f;
+pointerType()
+  matches "Foo *f", but does not match "int *a".
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Type.html;>TypeparenTypeMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ParenType.html;>ParenType...
 Matches ParenType nodes.
 
@@ -1294,14 +1346,19 @@ array_of_ptrs.
 
 
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Type.html;>TypepointerTypeMatcherhttp://clang.llvm.org/doxygen/classclang_1_1PointerType.html;>PointerType...
-Matches pointer types.
+Matches pointer types, 
but does not match Objective-C object pointer
+types.
 
 Given
   int *a;
   int b = *a;
   int c = 5;
+
+  @interface Foo
+  @end
+  Foo *f;
 pointerType()
-  matches "int *a"
+  matches "int *a", but does not match "Foo *f".
 
 
 
@@ -1382,6 +1439,15 @@ instantiation in A and the type of the v
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Type.html;>TypetemplateTypeParmTypeMatcherhttp://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html;>TemplateTypeParmType...
+Matches 
template type 

r247401 - [OPENMP] Preserve alignment of the original variables for the captured references.

2015-09-11 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Sep 11 05:29:41 2015
New Revision: 247401

URL: http://llvm.org/viewvc/llvm-project?rev=247401=rev
Log:
[OPENMP] Preserve alignment of the original variables for the captured 
references.
Patch makes codegen to preserve alignment of the shared variables captured and 
used in OpenMP regions.

Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/OpenMP/parallel_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/task_codegen.cpp
cfe/trunk/test/OpenMP/task_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/task_private_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=247401=247400=247401=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Sep 11 05:29:41 2015
@@ -2061,8 +2061,12 @@ LValue CodeGenFunction::EmitDeclRefLValu
   }
   return MakeAddrLValue(it->second, T);
 }
-return EmitCapturedFieldLValue(*this, CapturedStmtInfo->lookup(VD),
-   CapturedStmtInfo->getContextValue());
+LValue CapLVal =
+EmitCapturedFieldLValue(*this, CapturedStmtInfo->lookup(VD),
+CapturedStmtInfo->getContextValue());
+return MakeAddrLValue(
+Address(CapLVal.getPointer(), getContext().getDeclAlign(VD)),
+CapLVal.getType(), AlignmentSource::Decl);
   }
 
   assert(isa(CurCodeDecl));

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=247401=247400=247401=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Sep 11 05:29:41 2015
@@ -1848,14 +1848,15 @@ void CGOpenMPRuntime::emitKmpRoutineEntr
   }
 }
 
-static void addFieldToRecordDecl(ASTContext , DeclContext *DC,
- QualType FieldTy) {
+static FieldDecl *addFieldToRecordDecl(ASTContext , DeclContext *DC,
+   QualType FieldTy) {
   auto *Field = FieldDecl::Create(
   C, DC, SourceLocation(), SourceLocation(), /*Id=*/nullptr, FieldTy,
   C.getTrivialTypeSourceInfo(FieldTy, SourceLocation()),
   /*BW=*/nullptr, /*Mutable=*/false, /*InitStyle=*/ICIS_NoInit);
   Field->setAccess(AS_public);
   DC->addDecl(Field);
+  return Field;
 }
 
 namespace {
@@ -1882,9 +1883,16 @@ createPrivatesRecordDecl(CodeGenModule &
 auto *RD = C.buildImplicitRecord(".kmp_privates.t");
 RD->startDefinition();
 for (auto & : Privates) {
-  auto Type = Pair.second.Original->getType();
+  auto *VD = Pair.second.Original;
+  auto Type = VD->getType();
   Type = Type.getNonReferenceType();
-  addFieldToRecordDecl(C, RD, Type);
+  auto *FD = addFieldToRecordDecl(C, RD, Type);
+  if (VD->hasAttrs()) {
+for (specific_attr_iterator I(VD->getAttrs().begin()),
+ E(VD->getAttrs().end());
+ I != E; ++I)
+  FD->addAttr(*I);
+  }
 }
 RD->completeDefinition();
 return RD;
@@ -2173,7 +2181,7 @@ void CGOpenMPRuntime::emitTaskCall(
   for (auto *E : PrivateVars) {
 auto *VD = cast(cast(E)->getDecl());
 Privates.push_back(std::make_pair(
-C.getTypeAlignInChars(VD->getType()),
+C.getDeclAlign(VD),
 PrivateHelpersTy(VD, cast(cast(*I)->getDecl()),
  /*PrivateElemInit=*/nullptr)));
 ++I;
@@ -2183,7 +2191,7 @@ void CGOpenMPRuntime::emitTaskCall(
   for (auto *E : FirstprivateVars) {
 auto *VD = cast(cast(E)->getDecl());
 Privates.push_back(std::make_pair(
-C.getTypeAlignInChars(VD->getType()),
+C.getDeclAlign(VD),
 PrivateHelpersTy(
 VD, cast(cast(*I)->getDecl()),
 cast(cast(*IElemInitRef)->getDecl();
@@ -2302,6 +2310,9 @@ void CGOpenMPRuntime::emitTaskCall(
   auto *SharedField = CapturesInfo.lookup(OriginalVD);
   auto SharedRefLValue =
   CGF.EmitLValueForField(SharedsBase, SharedField);
+  SharedRefLValue = CGF.MakeAddrLValue(
+  Address(SharedRefLValue.getPointer(), 
C.getDeclAlign(OriginalVD)),
+  SharedRefLValue.getType(), AlignmentSource::Decl);
   QualType Type = OriginalVD->getType();
   if (Type->isArrayType()) {
 // Initialize firstprivate array.

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=247401=247400=247401=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp 

Re: [PATCH] D11182: [OPENMP 4.0] Initial support for 'omp declare reduction' construct.

2015-09-11 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

Richard?


http://reviews.llvm.org/D11182



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


Re: [PATCH] D12689: [libc++][static linking] std streams are not initialized prior to their use in static object constructors

2015-09-11 Thread Evgeny Astigeevich via cfe-commits
eastig added a comment.

In http://reviews.llvm.org/D12689#243674, @jroelofs wrote:

> A testcase would be good, regardless of which of the proposed fixes ends up 
> being chosen.


I will write it.


http://reviews.llvm.org/D12689



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


Re: [PATCH] D12684: [INSTALL.txt] Fix formatting - 80 character line

2015-09-11 Thread Vedant Kumar via cfe-commits
vsk added a subscriber: vsk.
vsk accepted this revision.
vsk added a reviewer: vsk.
vsk added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM.


http://reviews.llvm.org/D12684



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


Re: [PATCH] D12087: always_inline codegen rewrite

2015-09-11 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

second attempt in r247494


Repository:
  rL LLVM

http://reviews.llvm.org/D12087



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


Re: [PATCH] D12686: Add support for GCC's '__auto_type' extension.

2015-09-11 Thread Vedant Kumar via cfe-commits
vsk added a subscriber: vsk.
vsk added a comment.

First off, welcome! And thanks for patch.

This basically LGTM, but I have one small change I'd like to see (inline 
comment).

Hm, the spec says "The sizeof operator shall not be applied to... an lvalue 
that designates a bit-field". Sounds like a bug to me.



Comment at: lib/Sema/SemaType.cpp:2698
@@ -2693,1 +2697,3 @@
+  const unsigned Keyword =
+  D.getDeclSpec().getTypeSpecType() - DeclSpec::TST_auto;
   SemaRef.Diag(AutoRange.getBegin(), diag::err_auto_not_allowed)

Hm, this is a little hard to read. IIUC it's also sensitive to re-ordering of 
enum values. I'd be happier if you introduced a switch here, and made the LHS 
enum type explicit.


Comment at: test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1y.cpp:4
@@ -3,3 +3,3 @@
 
 // FIXME: This is in p11 (?) in C++1y.
 void f() {

Do you know what this FIXME alludes to? Seems rather mysterious to me.


http://reviews.llvm.org/D12686



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


Re: [PATCH] D12712: Implementation and testing for poisoning vtable ptr in dtor.

2015-09-11 Thread Naomi Musgrave via cfe-commits
nmusgrave updated this revision to Diff 34614.
nmusgrave marked 2 inline comments as done.
nmusgrave added a comment.

- Fixed testing callback emission order to account for vptr.


http://reviews.llvm.org/D12712

Files:
  lib/CodeGen/CGClass.cpp
  test/CodeGenCXX/sanitize-dtor-derived-class.cpp
  test/CodeGenCXX/sanitize-dtor-vtable.cpp

Index: test/CodeGenCXX/sanitize-dtor-vtable.cpp
===
--- /dev/null
+++ test/CodeGenCXX/sanitize-dtor-vtable.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -O0 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-optzns -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-optzns -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+
+class A {
+ public:
+  int x;
+  A() {}
+  virtual ~A() {}
+};
+A a;
+
+// CHECK-LABEL: define {{.*}}AD2Ev
+// CHECK: call void @__sanitizer_dtor_callback
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 8
+// CHECK-NOT: call void @__sanitizer_dtor_callback
+// CHECK: ret void
Index: test/CodeGenCXX/sanitize-dtor-derived-class.cpp
===
--- test/CodeGenCXX/sanitize-dtor-derived-class.cpp
+++ test/CodeGenCXX/sanitize-dtor-derived-class.cpp
@@ -52,14 +52,17 @@
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
+// Poison member and vtable pointer.
 // CHECK-LABEL: define {{.*}}BaseD2Ev
 // CHECK: call void @__sanitizer_dtor_callback
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 8
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
+// Poison member and vtable pointer.
 // CHECK-LABEL: define {{.*}}DerivedD2Ev
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: call void {{.*}}BaseD2Ev
-// CHECK-NOT: call void @__sanitizer_dtor_callback
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 8
 // CHECK: ret void
Index: lib/CodeGen/CGClass.cpp
===
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -1648,11 +1648,27 @@
 }
   };
 
-  class SanitizeDtor final : public EHScopeStack::Cleanup {
+ static void EmitSanitizerDtorCallback(CodeGenFunction , llvm::Value *Ptr,
+ CharUnits::QuantityType PoisonSize) {
+   // Pass in void pointer and size of region as arguments to runtime
+   // function
+   llvm::Value *Args[] = {CGF.Builder.CreateBitCast(Ptr, CGF.VoidPtrTy),
+  llvm::ConstantInt::get(CGF.SizeTy, PoisonSize)};
+
+   llvm::Type *ArgTypes[] = {CGF.VoidPtrTy, CGF.SizeTy};
+
+   llvm::FunctionType *FnType =
+   llvm::FunctionType::get(CGF.VoidTy, ArgTypes, false);
+   llvm::Value *Fn =
+   CGF.CGM.CreateRuntimeFunction(FnType, "__sanitizer_dtor_callback");
+   CGF.EmitNounwindRuntimeCall(Fn, Args);
+ }
+
+  class SanitizeDtorMembers final : public EHScopeStack::Cleanup {
 const CXXDestructorDecl *Dtor;
 
   public:
-SanitizeDtor(const CXXDestructorDecl *Dtor) : Dtor(Dtor) {}
+SanitizeDtorMembers(const CXXDestructorDecl *Dtor) : Dtor(Dtor) {}
 
 // Generate function call for handling object poisoning.
 // Disables tail call elimination, to prevent the current stack frame
@@ -1684,11 +1700,11 @@
   // Currently on the last field, and it must be poisoned with the
   // current block.
   if (fieldIndex == Layout.getFieldCount() - 1) {
-PoisonBlock(CGF, startIndex, Layout.getFieldCount());
+PoisonMembers(CGF, startIndex, Layout.getFieldCount());
   }
 } else if (startIndex >= 0) {
   // No longer within a block of memory to poison, so poison the block
-  PoisonBlock(CGF, startIndex, fieldIndex);
+  PoisonMembers(CGF, startIndex, fieldIndex);
   // Re-set the start index
   startIndex = -1;
 }
@@ -1701,7 +1717,7 @@
 /// start poisoning (inclusive)
 /// \param layoutEndOffset index of the ASTRecordLayout field to
 /// end poisoning (exclusive)
-void PoisonBlock(CodeGenFunction , unsigned layoutStartOffset,
+void PoisonMembers(CodeGenFunction , unsigned layoutStartOffset,
  unsigned layoutEndOffset) {
   ASTContext  = CGF.getContext();
   const ASTRecordLayout  =
@@ -1732,20 +1748,30 @@
   if (PoisonSize == 0)
 return;
 
-  // Pass in void pointer and size of region as arguments to runtime
-  // function
-  llvm::Value *Args[] = {CGF.Builder.CreateBitCast(OffsetPtr, CGF.VoidPtrTy),
- llvm::ConstantInt::get(CGF.SizeTy, PoisonSize)};
+  EmitSanitizerDtorCallback(CGF, OffsetPtr, PoisonSize);
+}
+  };
+
+ class SanitizeDtorVTable final : public EHScopeStack::Cleanup {
+const CXXDestructorDecl *Dtor;
+
+  public:
+

Re: [PATCH] D12087: always_inline codegen rewrite

2015-09-11 Thread Evgenii Stepanov via cfe-commits
Thanks. I just reproduced it on release w/o asserts build and fixed locally.
The other problem is fixed as well, I'll try re-landing now. I'll keep
an eye on the bot later today and will revert again if necessary.


On Fri, Sep 11, 2015 at 6:02 PM, H.J. Lu  wrote:
> On Fri, Sep 11, 2015 at 4:45 PM, Evgenii Stepanov  wrote:
>> Does it say that there is no entry basic block? I.e. the output
>> apparently looks like
>>
>> define void @h() #1 {
>>   store void ()* @f1, void ()** @p, align 8
>>
>> Could you confirm it? Never seen this behavior.
>>
>> I'm going to revert the change due to this and also one broken gdb
>> test (something wrong with debug info in the code that has been
>> always-inlined twice).
>
> I got
>
> [hjl@gnu-mic-2 llvm-clang]$
> /export/build/gnu/llvm-clang/build-x86_64-linux/./bin/clang  -target
> x86_64-pc-linux-gnu -mllvm -disable-llvm-optzns -emit-llvm -S -o -
> /export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline.c
> ; ModuleID = 
> '/export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline.c'
> target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
> target triple = "x86_64-pc-linux-gnu"
>
> ; Function Attrs: nounwind uwtable
> define i32 @f1() #0 {
>   %1 = call i32 @f0.alwaysinline()
>   ret i32 %1
> }
>
> ; Function Attrs: alwaysinline inlinehint nounwind uwtable
> define internal i32 @f2.alwaysinline() #1 {
>   ret i32 7
> }
>
> ; Function Attrs: inlinehint nounwind uwtable
> define i32 @f2() #2 {
> entry:
>   %0 = musttail call i32 @f2.alwaysinline() #2
>   ret i32 %0
> }
>
> ; Function Attrs: nounwind uwtable
> define i32 @f3() #0 {
>   %1 = call i32 @f2.alwaysinline()
>   ret i32 %1
> }
>
> ; Function Attrs: alwaysinline nounwind uwtable
> define internal i32 @f0.alwaysinline() #3 {
>   ret i32 1
> }
>
> attributes #0 = { nounwind uwtable "disable-tail-calls"="false"
> "less-precise-fpmad"="false" "no-frame-pointer-elim"="true"
> "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false"
> "no-nans-fp-math"="false" "stack-protector-buffer-size"="8"
> "target-cpu"="x86-64" "target-features"="+sse,+sse2"
> "unsafe-fp-math"="false" "use-soft-float"="false" }
> attributes #1 = { alwaysinline inlinehint nounwind uwtable
> "disable-tail-calls"="false" "less-precise-fpmad"="false"
> "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"
> "no-infs-fp-math"="false" "no-nans-fp-math"="false"
> "stack-protector-buffer-size"="8" "target-cpu"="x86-64"
> "target-features"="+sse,+sse2" "unsafe-fp-math"="false"
> "use-soft-float"="false" }
> attributes #2 = { inlinehint nounwind uwtable
> "disable-tail-calls"="false" "less-precise-fpmad"="false"
> "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"
> "no-infs-fp-math"="false" "no-nans-fp-math"="false"
> "stack-protector-buffer-size"="8" "target-cpu"="x86-64"
> "target-features"="+sse,+sse2" "unsafe-fp-math"="false"
> "use-soft-float"="false" }
> attributes #3 = { alwaysinline nounwind uwtable
> "disable-tail-calls"="false" "less-precise-fpmad"="false"
> "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"
> "no-infs-fp-math"="false" "no-nans-fp-math"="false"
> "stack-protector-buffer-size"="8" "target-cpu"="x86-64"
> "target-features"="+sse,+sse2" "unsafe-fp-math"="false"
> "use-soft-float"="false" }
>
> !llvm.ident = !{!0}
>
> !0 = !{!"clang version 3.8.0 (http://llvm.org/git/clang.git
> 4c682cf50f928f82e286df97d10a3d1fcf68e1a1)
> (http://llvm.org/git/llvm.git
> 125be70dbf9784ef4fab69633afa067c1cceffc9)"}
> [hjl@gnu-mic-2 llvm-clang]$
> [hjl@gnu-mic-2 llvm-clang]$
> /export/build/gnu/llvm-clang/build-x86_64-linux/./bin/clang  -target
> x86_64-pc-linux-gnu -mllvm -disable-llvm-optzns -emit-llvm -S -o -
> /export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline.c |
> /export/build/gnu/llvm-clang/build-x86_64-linux/./bin/FileCheck
> /export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline.c
> --check-prefix=CHECK-NO-OPTZNS
> /export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline.c:26:26:
> error: expected string not found in input
> // CHECK-NO-OPTZNS-NEXT: entry:
>  ^
> :24:18: note: scanning from here
> define i32 @f3() #0 {
>  ^
> :29:12: note: possible intended match here
> ; Function Attrs: alwaysinline nounwind uwtable
>^
> [hjl@gnu-mic-2 llvm-clang]$
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r247494 - Always_inline codegen rewrite.

2015-09-11 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Fri Sep 11 20:07:37 2015
New Revision: 247494

URL: http://llvm.org/viewvc/llvm-project?rev=247494=rev
Log:
Always_inline codegen rewrite.

Current implementation may end up emitting an undefined reference for
an "inline __attribute__((always_inline))" function by generating an
"available_externally alwaysinline" IR function for it and then failing to
inline all the calls. This happens when a call to such function is in dead
code. As the inliner is an SCC pass, it does not process dead code.

Libc++ relies on the compiler never emitting such undefined reference.

With this patch, we emit a pair of
1. internal alwaysinline definition (called F.alwaysinline)
2a. A stub F() { musttail call F.alwaysinline }
  -- or, depending on the linkage --
2b. A declaration of F.

The frontend ensures that F.inlinefunction is only used for direct
calls, and the stub is used for everything else (taking the address of
the function, really). Declaration (2b) is emitted in the case when
"inline" is meant for inlining only (like __gnu_inline__ and some
other cases).

This approach, among other nice properties, ensures that alwaysinline
functions are always internal, making it impossible for a direct call
to such function to produce an undefined symbol reference.

This patch is based on ideas by Chandler Carruth and Richard Smith.

Added:
cfe/trunk/test/CodeGen/always_inline-unused.c
cfe/trunk/test/CodeGen/always_inline-wrappers.c
cfe/trunk/test/CodeGenCXX/alwaysinline.cpp
Modified:
cfe/trunk/lib/CodeGen/CGCXX.cpp
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGen/always-inline.c
cfe/trunk/test/CodeGen/always_inline.c
cfe/trunk/test/CodeGen/function-attributes.c
cfe/trunk/test/CodeGen/pr9614.c
cfe/trunk/test/Frontend/optimization-remark-line-directive.c
cfe/trunk/test/Frontend/optimization-remark.c
cfe/trunk/test/Modules/cxx-irgen.cpp

Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=247494=247493=247494=diff
==
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Fri Sep 11 20:07:37 2015
@@ -109,6 +109,9 @@ bool CodeGenModule::TryEmitBaseDestructo
   D->getType()->getAs()->getCallConv())
 return true;
 
+  if (BaseD->hasAttr())
+return true;
+
   return TryEmitDefinitionAsAlias(GlobalDecl(D, Dtor_Base),
   GlobalDecl(BaseD, Dtor_Base),
   false);
@@ -161,14 +164,7 @@ bool CodeGenModule::TryEmitDefinitionAsA
 
   // Instead of creating as alias to a linkonce_odr, replace all of the uses
   // of the aliasee.
-  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage) &&
- (TargetLinkage != llvm::GlobalValue::AvailableExternallyLinkage ||
-  !TargetDecl.getDecl()->hasAttr())) {
-// FIXME: An extern template instantiation will create functions with
-// linkage "AvailableExternally". In libc++, some classes also define
-// members with attribute "AlwaysInline" and expect no reference to
-// be generated. It is desirable to reenable this optimisation after
-// corresponding LLVM changes.
+  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage)) {
 Replacements[MangledName] = Aliasee;
 return false;
   }

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=247494=247493=247494=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Fri Sep 11 20:07:37 2015
@@ -1557,7 +1557,7 @@ void CodeGenFunction::EmitDestructorBody
 // -fapple-kext must inline any call to this dtor into
 // the caller's body.
 if (getLangOpts().AppleKext)
-  CurFn->addFnAttr(llvm::Attribute::AlwaysInline);
+  CGM.AddAlwaysInlineFunction(CurFn);
 
 break;
   }

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=247494=247493=247494=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Sep 11 20:07:37 2015
@@ -2114,7 +2114,7 @@ emitTaskPrivateMappingFunction(CodeGenMo
   ".omp_task_privates_map.", ());
   CGM.SetLLVMFunctionAttributes(/*D=*/nullptr, TaskPrivatesMapFnInfo,
 TaskPrivatesMap);
-  TaskPrivatesMap->addFnAttr(llvm::Attribute::AlwaysInline);
+  CGM.AddAlwaysInlineFunction(TaskPrivatesMap);
   CodeGenFunction CGF(CGM);
   CGF.disableDebugInfo();
   

r247496 - clang/test/Driver/stackrealign.c REQUIRES clang-driver.

2015-09-11 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Fri Sep 11 20:29:35 2015
New Revision: 247496

URL: http://llvm.org/viewvc/llvm-project?rev=247496=rev
Log:
clang/test/Driver/stackrealign.c REQUIRES clang-driver.

GCC driver, for example cygwin, both "-mstackrealign" "-mno-stackrealign" are 
passed.

Modified:
cfe/trunk/test/Driver/stackrealign.c

Modified: cfe/trunk/test/Driver/stackrealign.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/stackrealign.c?rev=247496=247495=247496=diff
==
--- cfe/trunk/test/Driver/stackrealign.c (original)
+++ cfe/trunk/test/Driver/stackrealign.c Fri Sep 11 20:29:35 2015
@@ -1,6 +1,7 @@
 // RUN: %clang -### %s 2>&1 | FileCheck %s -check-prefix=NO-REALIGN
 // RUN: %clang -### -mno-stackrealign -mstackrealign %s 2>&1 | FileCheck %s 
-check-prefix=REALIGN
 // RUN: %clang -### -mstackrealign -mno-stackrealign %s 2>&1 | FileCheck %s 
-check-prefix=NO-REALIGN
+// REQUIRES: clang-driver
 
 // REALIGN: -mstackrealign
 // NO-REALIGN-NOT: -mstackrealign


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


Re: [PATCH] D12712: Implementation and testing for poisoning vtable ptr in dtor.

2015-09-11 Thread Naomi Musgrave via cfe-commits
nmusgrave updated this revision to Diff 34617.
nmusgrave added a comment.

- Poison vtable in either complete or base dtor.


http://reviews.llvm.org/D12712

Files:
  lib/CodeGen/CGClass.cpp
  test/CodeGenCXX/sanitize-dtor-derived-class.cpp
  test/CodeGenCXX/sanitize-dtor-vtable.cpp

Index: test/CodeGenCXX/sanitize-dtor-vtable.cpp
===
--- /dev/null
+++ test/CodeGenCXX/sanitize-dtor-vtable.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -O0 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-optzns -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-optzns -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+
+class A {
+ public:
+  int x;
+  A() {}
+  virtual ~A() {}
+};
+A a;
+
+// CHECK-LABEL: define {{.*}}AD2Ev
+// CHECK: call void @__sanitizer_dtor_callback
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 8
+// CHECK-NOT: call void @__sanitizer_dtor_callback
+// CHECK: ret void
Index: test/CodeGenCXX/sanitize-dtor-derived-class.cpp
===
--- test/CodeGenCXX/sanitize-dtor-derived-class.cpp
+++ test/CodeGenCXX/sanitize-dtor-derived-class.cpp
@@ -1,8 +1,9 @@
 // RUN: %clang_cc1 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-optzns -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-optzns -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
 
-// Only the last dtor of a class invokes the sanitizing callback
-// Sanitizing callback emited prior to base class dtor invocations
+// Base dtor poisons members
+// Complete dtor poisons vtable ptr after destroying members and
+// virtual bases
 
 class Base {
  public:
@@ -52,14 +53,17 @@
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
+// Poison member and vtable pointer.
 // CHECK-LABEL: define {{.*}}BaseD2Ev
 // CHECK: call void @__sanitizer_dtor_callback
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 8
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
+// Poison member and vtable pointer.
 // CHECK-LABEL: define {{.*}}DerivedD2Ev
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: call void {{.*}}BaseD2Ev
-// CHECK-NOT: call void @__sanitizer_dtor_callback
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 8
 // CHECK: ret void
Index: lib/CodeGen/CGClass.cpp
===
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -1648,11 +1648,27 @@
 }
   };
 
-  class SanitizeDtor final : public EHScopeStack::Cleanup {
+ static void EmitSanitizerDtorCallback(CodeGenFunction , llvm::Value *Ptr,
+ CharUnits::QuantityType PoisonSize) {
+   // Pass in void pointer and size of region as arguments to runtime
+   // function
+   llvm::Value *Args[] = {CGF.Builder.CreateBitCast(Ptr, CGF.VoidPtrTy),
+  llvm::ConstantInt::get(CGF.SizeTy, PoisonSize)};
+
+   llvm::Type *ArgTypes[] = {CGF.VoidPtrTy, CGF.SizeTy};
+
+   llvm::FunctionType *FnType =
+   llvm::FunctionType::get(CGF.VoidTy, ArgTypes, false);
+   llvm::Value *Fn =
+   CGF.CGM.CreateRuntimeFunction(FnType, "__sanitizer_dtor_callback");
+   CGF.EmitNounwindRuntimeCall(Fn, Args);
+ }
+
+  class SanitizeDtorMembers final : public EHScopeStack::Cleanup {
 const CXXDestructorDecl *Dtor;
 
   public:
-SanitizeDtor(const CXXDestructorDecl *Dtor) : Dtor(Dtor) {}
+SanitizeDtorMembers(const CXXDestructorDecl *Dtor) : Dtor(Dtor) {}
 
 // Generate function call for handling object poisoning.
 // Disables tail call elimination, to prevent the current stack frame
@@ -1684,11 +1700,11 @@
   // Currently on the last field, and it must be poisoned with the
   // current block.
   if (fieldIndex == Layout.getFieldCount() - 1) {
-PoisonBlock(CGF, startIndex, Layout.getFieldCount());
+PoisonMembers(CGF, startIndex, Layout.getFieldCount());
   }
 } else if (startIndex >= 0) {
   // No longer within a block of memory to poison, so poison the block
-  PoisonBlock(CGF, startIndex, fieldIndex);
+  PoisonMembers(CGF, startIndex, fieldIndex);
   // Re-set the start index
   startIndex = -1;
 }
@@ -1701,7 +1717,7 @@
 /// start poisoning (inclusive)
 /// \param layoutEndOffset index of the ASTRecordLayout field to
 /// end poisoning (exclusive)
-void PoisonBlock(CodeGenFunction , unsigned layoutStartOffset,
+void PoisonMembers(CodeGenFunction , unsigned layoutStartOffset,
  unsigned layoutEndOffset) {
   ASTContext  = CGF.getContext();
   

r247498 - Clean up trailing whitespace in the builtin headers

2015-09-11 Thread Sean Silva via cfe-commits
Author: silvas
Date: Fri Sep 11 21:55:19 2015
New Revision: 247498

URL: http://llvm.org/viewvc/llvm-project?rev=247498=rev
Log:
Clean up trailing whitespace in the builtin headers

Modified:
cfe/trunk/lib/Headers/altivec.h
cfe/trunk/lib/Headers/ammintrin.h
cfe/trunk/lib/Headers/avx512vlbwintrin.h
cfe/trunk/lib/Headers/avx512vldqintrin.h
cfe/trunk/lib/Headers/avxintrin.h
cfe/trunk/lib/Headers/htmxlintrin.h
cfe/trunk/lib/Headers/mmintrin.h
cfe/trunk/lib/Headers/pmmintrin.h
cfe/trunk/lib/Headers/smmintrin.h
cfe/trunk/lib/Headers/stdint.h
cfe/trunk/lib/Headers/tgmath.h
cfe/trunk/lib/Headers/tmmintrin.h
cfe/trunk/lib/Headers/xmmintrin.h

Modified: cfe/trunk/lib/Headers/altivec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/altivec.h?rev=247498=247497=247498=diff
==
--- cfe/trunk/lib/Headers/altivec.h (original)
+++ cfe/trunk/lib/Headers/altivec.h Fri Sep 11 21:55:19 2015
@@ -137,7 +137,7 @@ static vector double __ATTRS_o_ai vec_ab
 }
 #endif
 
-/* vec_abss */ 
+/* vec_abss */
 #define __builtin_altivec_abss_v16qi vec_abss
 #define __builtin_altivec_abss_v8hi vec_abss
 #define __builtin_altivec_abss_v4si vec_abss
@@ -3651,21 +3651,21 @@ static vector float __ATTRS_o_ai vec_vmr
 static vector bool int __ATTRS_o_ai
 vec_mergee(vector bool int __a, vector bool int __b) {
   return vec_perm(__a, __b, (vector unsigned char)
-  (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13, 
+  (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, 0x1A, 0x1B));
 }
 
 static vector signed int __ATTRS_o_ai
 vec_mergee(vector signed int __a, vector signed int __b) {
   return vec_perm(__a, __b, (vector unsigned char)
-  (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13, 
+  (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, 0x1A, 0x1B));
 }
 
 static vector unsigned int __ATTRS_o_ai
 vec_mergee(vector unsigned int __a, vector unsigned int __b) {
   return vec_perm(__a, __b, (vector unsigned char)
-  (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13, 
+  (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, 0x1A, 0x1B));
 }
 

Modified: cfe/trunk/lib/Headers/ammintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/ammintrin.h?rev=247498=247497=247498=diff
==
--- cfe/trunk/lib/Headers/ammintrin.h (original)
+++ cfe/trunk/lib/Headers/ammintrin.h Fri Sep 11 21:55:19 2015
@@ -34,13 +34,13 @@
 ///
 /// \headerfile 
 ///
-/// \code 
+/// \code
 /// __m128i _mm_extracti_si64(__m128i x, const int len, const int idx);
-/// \endcode 
+/// \endcode
 ///
-/// \code
+/// \code
 /// This intrinsic corresponds to the \c EXTRQ instruction.
-/// \endcode 
+/// \endcode
 ///
 /// \param x
 ///The value from which bits are extracted.
@@ -48,10 +48,10 @@
 ///Bits [5:0] specify the length; the other bits are ignored. If bits [5:0]
 ///are zero, the length is interpreted as 64.
 /// \param idx
-///Bits [5:0] specify the index of the least significant bit; the other 
-///bits are ignored. If the sum of the index and length is greater than 
-///64, the result is undefined. If the length and index are both zero, 
-///bits [63:0] of parameter x are extracted. If the length is zero 
+///Bits [5:0] specify the index of the least significant bit; the other
+///bits are ignored. If the sum of the index and length is greater than
+///64, the result is undefined. If the length and index are both zero,
+///bits [63:0] of parameter x are extracted. If the length is zero
 ///but the index is non-zero, the result is undefined.
 /// \returns A 128-bit integer vector whose lower 64 bits contain the bits
 ///extracted from the source operand.
@@ -64,21 +64,21 @@
 ///
 /// \headerfile 
 ///
-/// \code 
+/// \code
 /// This intrinsic corresponds to the \c EXTRQ instruction.
-/// \endcode 
+/// \endcode
 ///
 /// \param __x
 ///The value from which bits are extracted.
 /// \param __y
-///Specifies the index of the least significant bit at [13:8] 
-///and the length at [5:0]; all other bits are ignored. 
+///Specifies the index of the least significant bit at [13:8]
+///and the length at [5:0]; all other bits are ignored.
 ///If bits [5:0] are zero, the length is interpreted as 64.
-///If the sum of the index and length is greater than 64, the result is 
-///undefined. If the length and index are both zero, bits [63:0] of 
-///parameter __x are extracted. If the length is zero but the index is 
-///non-zero, the result is undefined. 
-/// \returns A 

Re: [PATCH] D12821: Allow for C's "writing off the end" idiom in __builtin_object_size

2015-09-11 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/AST/ExprConstant.cpp:165
@@ -159,1 +164,3 @@
 
+/// Indicator of whether the most-derived object is an array.
+bool MostDerivedIsArrayElement : 1;

array -> array element.


Comment at: lib/AST/ExprConstant.cpp:4457-4460
@@ -4434,1 +4456,6 @@
 
+// Because we set the Base to be the MemberExpr instead of E->getBase(), 
the
+// Offset should be from the MemberExpr instead of the MemberExpr's base.
+if (Result.InvalidBase)
+  Result.Offset = CharUnits::Zero();
+

I think you should bail out above, with the base set to the `MemberExpr` and 
with an empty designator, rather than applying a member designator on top of a 
base that already refers to the member (and then needing to undo the effect on 
the offset here).


Comment at: lib/AST/ExprConstant.cpp:6402
@@ +6401,3 @@
+  // that behaves this way.
+  if (End.InvalidBase && (Type & 1) != 0 &&
+  End.Designator.MostDerivedIsArrayElement &&

This only seems necessary when `Type` is 1; for type 3, returning 1 would be 
conservatively correct as a lower bound on the known-accessible storage, and is 
better than giving up here and evaluating the object size as 0.


Comment at: lib/AST/ExprConstant.cpp:6403-6404
@@ +6402,4 @@
+  if (End.InvalidBase && (Type & 1) != 0 &&
+  End.Designator.MostDerivedIsArrayElement &&
+  End.Designator.MostDerivedArraySize < 2) {
+// EM_FoldDesignator requires that all invalid bases be MemberExprs

Ideally, we should walk the designator and make sure that at each step we 
picked the last subobject (last array element, last field, ...) -- that is, we 
want to know that we're really looking at a trailing flexible array member, and 
not just a size-1 array in the middle of some object.

You should also check that the designator refers to the most-derived object 
(that is, that `Entries.size() == MostDerivedPathLength`), because given:

  struct A { char buffer[10]; };
  struct B : A {};
  struct C { B b[1]; } *c;
  int m = __builtin_object_size(c->b[0], 1);
  int n = __builtin_object_size((A*)c->b[0], 1);

... we should presumably compute `m == -1` but `n == 10`, because for `n` the 
`A` subobject of the `B` object is known to have size 10, even though we're 
looking at a base subobject of a size-1 trailing array.


http://reviews.llvm.org/D12821



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


Re: [PATCH] D12087: always_inline codegen rewrite

2015-09-11 Thread Evgeniy Stepanov via cfe-commits
eugenis added inline comments.


Comment at: lib/CodeGen/CodeGenModule.cpp:543
@@ +542,3 @@
+  if (Fn->isUsedByMetadata())
+llvm::ValueAsMetadata::handleRAUW(Fn, StubFn);
+}

As the comment says.
W/o this, the debug info for .alwaysinline instructions is attached to the 
.alwaysinline function, which gets deleted before codegen, and we end up with 
DI as if it is just a declaration (no low/high pc, etc).



Repository:
  rL LLVM

http://reviews.llvm.org/D12087



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


Re: [PATCH] D12087: always_inline codegen rewrite

2015-09-11 Thread Evgeniy Stepanov via cfe-commits
eugenis updated this revision to Diff 34610.
eugenis added a comment.

Fixed the debug info problem.


Repository:
  rL LLVM

http://reviews.llvm.org/D12087

Files:
  lib/CodeGen/CGCXX.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGen/always-inline.c
  test/CodeGen/always_inline-unused.c
  test/CodeGen/always_inline-wrappers.c
  test/CodeGen/always_inline.c
  test/CodeGen/function-attributes.c
  test/CodeGen/pr9614.c
  test/CodeGenCXX/alwaysinline.cpp
  test/Frontend/optimization-remark-line-directive.c
  test/Frontend/optimization-remark.c
  test/Modules/cxx-irgen.cpp

Index: test/Modules/cxx-irgen.cpp
===
--- test/Modules/cxx-irgen.cpp
+++ test/Modules/cxx-irgen.cpp
@@ -26,14 +26,14 @@
   };
 }
 
-// CHECK-DAG: define available_externally hidden {{.*}}{{signext i32|i32}} @_ZN1SIiE1gEv({{.*}} #[[ALWAYS_INLINE:.*]] align
+// CHECK-DAG: define internal i32 @_ZN1SIiE1gEv.alwaysinline() #[[ALWAYS_INLINE:.*]] align
 int a = S::g();
 
 int b = h();
 
 // CHECK-DAG: define linkonce_odr {{.*}}{{signext i32|i32}} @_Z3minIiET_S0_S0_(i32
 int c = min(1, 2);
-// CHECK: define available_externally {{.*}}{{signext i32|i32}} @_ZN1SIiE1fEv({{.*}} #[[ALWAYS_INLINE]] align
+// CHECK-DAG: define internal {{.*}}{{signext i32|i32}} @_ZN1SIiE1fEv.alwaysinline() #[[ALWAYS_INLINE]] align
 
 namespace ImplicitSpecialMembers {
   // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1BC2ERKS0_(
Index: test/Frontend/optimization-remark.c
===
--- test/Frontend/optimization-remark.c
+++ test/Frontend/optimization-remark.c
@@ -32,6 +32,8 @@
 // CHECK-NOT: !llvm.dbg.cu = !{
 
 int foo(int x, int y) __attribute__((always_inline));
+// expected-remark@+2 {{foo.alwaysinline should always be inlined}}
+// expected-remark@+1 {{foo.alwaysinline inlined into foo}}
 int foo(int x, int y) { return x + y; }
 
 float foz(int x, int y) __attribute__((noinline));
@@ -45,7 +47,7 @@
 // expected-remark@+5 {{foz will not be inlined into bar}}
 // expected-remark@+4 {{foz should never be inlined}}
 // expected-remark@+3 {{foz will not be inlined into bar}}
-// expected-remark@+2 {{foo should always be inlined}}
-// expected-remark@+1 {{foo inlined into bar}}
+// expected-remark@+2 {{foo.alwaysinline should always be inlined}}
+// expected-remark@+1 {{foo.alwaysinline inlined into bar}}
   return foo(j, j - 2) * foz(j - 2, j);
 }
Index: test/Frontend/optimization-remark-line-directive.c
===
--- test/Frontend/optimization-remark-line-directive.c
+++ test/Frontend/optimization-remark-line-directive.c
@@ -5,8 +5,9 @@
 // RUN: %clang_cc1 %s -Rpass=inline -gline-tables-only -dwarf-column-info -emit-llvm-only -verify
 
 int foo(int x, int y) __attribute__((always_inline));
+// expected-remark@+1 {{foo.alwaysinline inlined into foo}}
 int foo(int x, int y) { return x + y; }
 
-// expected-remark@+2 {{foo inlined into bar}} expected-note@+2 {{could not determine the original source location for /bad/path/to/original.c:1230:25}}
+// expected-remark@+2 {{foo.alwaysinline inlined into bar}} expected-note@+2 {{could not determine the original source location for /bad/path/to/original.c:1230:25}}
 #line 1230 "/bad/path/to/original.c"
 int bar(int j) { return foo(j, j - 2); }
Index: test/CodeGenCXX/alwaysinline.cpp
===
--- /dev/null
+++ test/CodeGenCXX/alwaysinline.cpp
@@ -0,0 +1,68 @@
+// Test different kinds of alwaysinline *structor definitions.
+
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-CALL
+
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -mconstructor-aliases -disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -mconstructor-aliases -disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-CALL
+
+struct A1 {
+  __attribute__((__always_inline__)) A1() {}
+  __attribute__((__always_inline__)) ~A1() {}
+};
+
+void g1() {
+  A1 a1;
+}
+
+struct A2 {
+  inline __attribute__((__always_inline__)) A2() {}
+  inline __attribute__((__always_inline__)) ~A2() {}
+};
+
+void g2() {
+  A2 a2;
+}
+
+struct A3 {
+  inline __attribute__((gnu_inline, __always_inline__)) A3() {}
+  inline __attribute__((gnu_inline, __always_inline__)) ~A3() {}
+};
+
+void g3() {
+  A3 a3;
+}
+
+// CHECK-DAG: define internal void @_ZN2A1C1Ev.alwaysinline(%struct.A1* %this) unnamed_addr #[[AI:[01-9]+]]
+// CHECK-DAG: define internal void @_ZN2A1C2Ev.alwaysinline(%struct.A1* %this) unnamed_addr #[[AI]]
+// CHECK-DAG: define 

Re: [PATCH] D12686: Add support for GCC's '__auto_type' extension.

2015-09-11 Thread Richard Smith via cfe-commits
rsmith added a subscriber: rsmith.


Comment at: include/clang/AST/Type.h:1210
@@ +1209,3 @@
+/// Which keyword(s) were used to create an AutoType.
+enum struct AutoTypeKeyword : unsigned char {
+  /// \brief auto

Please use `enum class` here; we don't use `enum struct` anywhere in Clang or 
LLVM.


Comment at: include/clang/AST/Type.h:1216
@@ +1215,3 @@
+  /// \brief __auto_type (GNU extension)
+  AutoTypeExt
+};

Maybe `GNUAutoType`?


Comment at: include/clang/AST/Type.h:3915-3916
@@ -3902,5 +3914,4 @@
 
   void Profile(llvm::FoldingSetNodeID ) {
-Profile(ID, getDeducedType(), isDecltypeAuto(), 
-   isDependentType());
+Profile(ID, getDeducedType(), AutoTypeBits.Keyword, isDependentType());
   }

`auto` and `__auto_type` should probably not profile differently; they mangle 
the same, so this will lead to mangling collisions. (It's not completely clear 
that we need to retain the distinction between `auto` and `__auto_type` here at 
all, since they have identical semantics, but it's probably a good thing for 
source fidelity. We don't maintain a difference between `bool` and `_Bool`, for 
what it's worth.)


Comment at: lib/Sema/SemaExpr.cpp:352
@@ -351,1 +351,3 @@
   if (ParsingInitForAutoVars.count(D)) {
+const AutoType* AT = 
cast(D)->getType().getTypePtr()->getContainedAutoType();
+

`const AutoType* AT` -> const AutoType *AT`. Also, remove the unnecessary 
`.getTypePtr()` here.


Comment at: test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1y.cpp:4
@@ -3,3 +3,3 @@
 
 // FIXME: This is in p11 (?) in C++1y.
 void f() {

vsk wrote:
> Do you know what this FIXME alludes to? Seems rather mysterious to me.
It says that the relevant wording in the standard got moved to a different 
paragraph number (due to the insertion of more rules beforehand for deduced 
return types and generic lambdas).


http://reviews.llvm.org/D12686



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


Re: [clang-tools-extra] r247393 - clang-tidy/readability-inconsistent-declaration-parameter-name.cpp: Appease MS-incompatibility [-fno-delayed-template-parsing]

2015-09-11 Thread Aaron Ballman via cfe-commits
On Fri, Sep 11, 2015 at 9:27 AM, Alexander Kornienko via cfe-commits
 wrote:
> Thank you for the fix and sorry for breaking this again. I wonder what's the
> reason windows-targeting enables -fdelayed-template-parsing?

Because that's required for MSVC compatibility.

> Would it be the right thing to always turn this off in clang-tidy?

 I don't think it would be a good thing to turn off in clang-tidy as
the behavior would diverge from the default in clang on Windows (with
MSVC mode).

~Aaron

>
>
> On Fri, Sep 11, 2015 at 10:16 AM, NAKAMURA Takumi via cfe-commits
>  wrote:
>>
>> Author: chapuni
>> Date: Fri Sep 11 03:16:22 2015
>> New Revision: 247393
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=247393=rev
>> Log:
>> clang-tidy/readability-inconsistent-declaration-parameter-name.cpp:
>> Appease MS-incompatibility [-fno-delayed-template-parsing]
>>
>> Modified:
>>
>> clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
>>
>> Modified:
>> clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp?rev=247393=247392=247393=diff
>>
>> ==
>> ---
>> clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
>> (original)
>> +++
>> clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
>> Fri Sep 11 03:16:22 2015
>> @@ -1,4 +1,4 @@
>> -// RUN: %python %S/check_clang_tidy.py %s
>> readability-inconsistent-declaration-parameter-name %t
>> +// RUN: %python %S/check_clang_tidy.py %s
>> readability-inconsistent-declaration-parameter-name %t -- -std=c++11
>> -fno-delayed-template-parsing
>>
>>  void consistentFunction(int a, int b, int c);
>>  void consistentFunction(int a, int b, int c);
>>
>>
>> ___
>> 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
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: recordDecl() AST matcher

2015-09-11 Thread Aaron Ballman via cfe-commits
Ping?

On Tue, Sep 8, 2015 at 9:26 AM, Manuel Klimek  wrote:
> On Tue, Sep 8, 2015 at 3:23 PM Aaron Ballman  wrote:
>>
>> On Tue, Sep 8, 2015 at 9:18 AM, Manuel Klimek  wrote:
>> > On Tue, Sep 8, 2015 at 2:23 PM Aaron Ballman 
>> > wrote:
>> >>
>> >> On Tue, Sep 8, 2015 at 5:40 AM, Manuel Klimek 
>> >> wrote:
>> >> > Yea, we had that discussion a few times, and I can never remember why
>> >> > we
>> >> > ended up in the state we're in.
>> >> > We definitely had a time where we switched to just using the exact
>> >> > same
>> >> > name
>> >> > as the node's class name for the matchers.
>> >> > I *think* we didn't do it for cxxRecordDecl, because Richard said
>> >> > that's
>> >> > a
>> >> > relic we should get rid of anyway, but I'm not sure.
>> >>
>> >> FWIW, I think the state we're in is the worst of all worlds. It's not
>> >> intuitive that recordDecl() doesn't match a struct in C mode, and as
>> >> it stands, there is no way to match a struct or union declaration in C
>> >> at all.
>> >
>> >
>> > Agreed. Best intentions. Worst possible outcome. That's software
>> > development
>> > :)
>> >
>> >> >
>> >> > On Fri, Sep 4, 2015 at 8:32 PM Aaron Ballman 
>> >> > wrote:
>> >> >>
>> >> >> It turns out that the recordDecl() AST matcher doesn't match
>> >> >> RecordDecl objects; instead, it matches CXXRecordDecl objects. This
>> >> >> is... unfortunate... as it makes writing AST matchers more
>> >> >> complicated
>> >> >> because of having to translate between recordDecl()/CXXRecordDecl.
>> >> >> It
>> >> >> also makes it impossible to match a struct or union declaration in C
>> >> >> or ObjC. However, given how prevalent recordDecl()'s use is in the
>> >> >> wild (I'm guessing), changing it at this point would be a Bad Thing.
>> >> >>
>> >> >> For people trying to write AST matchers for languages like C or
>> >> >> ObjC,
>> >> >> I would like to propose adding:
>> >> >>
>> >> >> structDecl()
>> >> >> unionDecl()
>> >> >> tagDecl()
>> >> >>
>> >> >> These will match nicely with the existing enumDecl() AST matcher.
>> >> >>
>> >> >> Additionally, I would like to add cxxRecordDecl() to match
>> >> >> CXXRecordDecl objects. While it duplicates the functionality exposed
>> >> >> by recordDecl(), it more clearly matches the intention of which AST
>> >> >> node it corresponds to.
>> >> >>
>> >> >> Finally, I would like to undocument recordDecl() and change our
>> >> >> existing documentation and AST matcher uses to use
>> >> >> cxxRecordDecl/structDecl() instead. Maybe someday we can deprecate
>> >> >> recordDecl() more officially.
>> >> >>
>> >> >> I'm open to other ideas if there are better ways to move forward. If
>> >> >> you think changing the meaning of recordDecl() is acceptable, I can
>> >> >> also go that route (though I would still propose adding unionDecl()
>> >> >> and cxxRecordDecl() in that case).
>> >> >
>> >> >
>> >> > I think changing recordDecl is acceptable. I believe very few tools
>> >> > will
>> >> > actually start doing wrong things because of it. I'd like more
>> >> > opinions
>> >> > first, though :)
>> >>
>> >> I was giving this more thought over the long weekend, and I think you
>> >> may be right. I think changing recordDecl() to mean RecordDecl will
>> >> fix more code than it breaks, so long as we take a holistic approach
>> >> to the change and see which narrowing and traversal matchers we need
>> >> to fix up at the same time. When I tried to think of AST matchers that
>> >> mean CXXRecordDecl but *not* RecordDecl, they were horribly contrived
>> >> because you usually are matching on additional selection criteria that
>> >> is specific to C++ (such as hasMethod() or isDerivedFrom()) which
>> >> would cause the match to continue to fail, as expected. Code that uses
>> >> recordDecl() to mean RecordDecl will suddenly start to match in more
>> >> cases, but that's likely to be a bug fix more than a breaking change.
>> >> To the best of my understanding, the only breaking cases would be
>> >> where you wrote recordDecl(), meant CXXRecordDecl, had no further
>> >> narrowing or traversal matchers, and were compiling in C mode; with
>> >> the result being additional unexpected matches.
>> >
>> >
>> > Ah, there's one thing that can break: the compile can break:
>> > recordDecl(hasMethod(...)) will *not* compile (it'll work in the dynamic
>> > matchers and fail as you suggest, but the in-C++ DSL does more static
>> > type
>> > checking).
>> > I don't think that's super bad though.
>> >
>> >>
>> >> So perhaps it would make sense to:
>> >>
>> >> 1) Make recordDecl() mean RecordDecl
>> >> 2) Do a comprehensive review of matchers that take a CXXRecordDecl and
>> >> see if they should instead take a RecordDecl
>> >> 3) Add unionDecl() as a node matcher (or should we add isUnion() and
>> >> isStruct() as narrowing matchers?)
>> >> 4) Add tagDecl() as a node matcher, but 

Re: [clang-tools-extra] r247393 - clang-tidy/readability-inconsistent-declaration-parameter-name.cpp: Appease MS-incompatibility [-fno-delayed-template-parsing]

2015-09-11 Thread Alexander Kornienko via cfe-commits
Thank you for the fix and sorry for breaking this again. I wonder what's
the reason windows-targeting enables -fdelayed-template-parsing? Would it
be the right thing to always turn this off in clang-tidy?

On Fri, Sep 11, 2015 at 10:16 AM, NAKAMURA Takumi via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: chapuni
> Date: Fri Sep 11 03:16:22 2015
> New Revision: 247393
>
> URL: http://llvm.org/viewvc/llvm-project?rev=247393=rev
> Log:
> clang-tidy/readability-inconsistent-declaration-parameter-name.cpp:
> Appease MS-incompatibility [-fno-delayed-template-parsing]
>
> Modified:
>
> clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
>
> Modified:
> clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp?rev=247393=247392=247393=diff
>
> ==
> ---
> clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
> (original)
> +++
> clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
> Fri Sep 11 03:16:22 2015
> @@ -1,4 +1,4 @@
> -// RUN: %python %S/check_clang_tidy.py %s
> readability-inconsistent-declaration-parameter-name %t
> +// RUN: %python %S/check_clang_tidy.py %s
> readability-inconsistent-declaration-parameter-name %t -- -std=c++11
> -fno-delayed-template-parsing
>
>  void consistentFunction(int a, int b, int c);
>  void consistentFunction(int a, int b, int c);
>
>
> ___
> 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: recordDecl() AST matcher

2015-09-11 Thread Manuel Klimek via cfe-commits
Richard! We need an informed opinion :D

On Fri, Sep 11, 2015 at 3:07 PM Aaron Ballman 
wrote:

> Ping?
>
> On Tue, Sep 8, 2015 at 9:26 AM, Manuel Klimek  wrote:
> > On Tue, Sep 8, 2015 at 3:23 PM Aaron Ballman 
> wrote:
> >>
> >> On Tue, Sep 8, 2015 at 9:18 AM, Manuel Klimek 
> wrote:
> >> > On Tue, Sep 8, 2015 at 2:23 PM Aaron Ballman 
> >> > wrote:
> >> >>
> >> >> On Tue, Sep 8, 2015 at 5:40 AM, Manuel Klimek 
> >> >> wrote:
> >> >> > Yea, we had that discussion a few times, and I can never remember
> why
> >> >> > we
> >> >> > ended up in the state we're in.
> >> >> > We definitely had a time where we switched to just using the exact
> >> >> > same
> >> >> > name
> >> >> > as the node's class name for the matchers.
> >> >> > I *think* we didn't do it for cxxRecordDecl, because Richard said
> >> >> > that's
> >> >> > a
> >> >> > relic we should get rid of anyway, but I'm not sure.
> >> >>
> >> >> FWIW, I think the state we're in is the worst of all worlds. It's not
> >> >> intuitive that recordDecl() doesn't match a struct in C mode, and as
> >> >> it stands, there is no way to match a struct or union declaration in
> C
> >> >> at all.
> >> >
> >> >
> >> > Agreed. Best intentions. Worst possible outcome. That's software
> >> > development
> >> > :)
> >> >
> >> >> >
> >> >> > On Fri, Sep 4, 2015 at 8:32 PM Aaron Ballman <
> aa...@aaronballman.com>
> >> >> > wrote:
> >> >> >>
> >> >> >> It turns out that the recordDecl() AST matcher doesn't match
> >> >> >> RecordDecl objects; instead, it matches CXXRecordDecl objects.
> This
> >> >> >> is... unfortunate... as it makes writing AST matchers more
> >> >> >> complicated
> >> >> >> because of having to translate between recordDecl()/CXXRecordDecl.
> >> >> >> It
> >> >> >> also makes it impossible to match a struct or union declaration
> in C
> >> >> >> or ObjC. However, given how prevalent recordDecl()'s use is in the
> >> >> >> wild (I'm guessing), changing it at this point would be a Bad
> Thing.
> >> >> >>
> >> >> >> For people trying to write AST matchers for languages like C or
> >> >> >> ObjC,
> >> >> >> I would like to propose adding:
> >> >> >>
> >> >> >> structDecl()
> >> >> >> unionDecl()
> >> >> >> tagDecl()
> >> >> >>
> >> >> >> These will match nicely with the existing enumDecl() AST matcher.
> >> >> >>
> >> >> >> Additionally, I would like to add cxxRecordDecl() to match
> >> >> >> CXXRecordDecl objects. While it duplicates the functionality
> exposed
> >> >> >> by recordDecl(), it more clearly matches the intention of which
> AST
> >> >> >> node it corresponds to.
> >> >> >>
> >> >> >> Finally, I would like to undocument recordDecl() and change our
> >> >> >> existing documentation and AST matcher uses to use
> >> >> >> cxxRecordDecl/structDecl() instead. Maybe someday we can deprecate
> >> >> >> recordDecl() more officially.
> >> >> >>
> >> >> >> I'm open to other ideas if there are better ways to move forward.
> If
> >> >> >> you think changing the meaning of recordDecl() is acceptable, I
> can
> >> >> >> also go that route (though I would still propose adding
> unionDecl()
> >> >> >> and cxxRecordDecl() in that case).
> >> >> >
> >> >> >
> >> >> > I think changing recordDecl is acceptable. I believe very few tools
> >> >> > will
> >> >> > actually start doing wrong things because of it. I'd like more
> >> >> > opinions
> >> >> > first, though :)
> >> >>
> >> >> I was giving this more thought over the long weekend, and I think you
> >> >> may be right. I think changing recordDecl() to mean RecordDecl will
> >> >> fix more code than it breaks, so long as we take a holistic approach
> >> >> to the change and see which narrowing and traversal matchers we need
> >> >> to fix up at the same time. When I tried to think of AST matchers
> that
> >> >> mean CXXRecordDecl but *not* RecordDecl, they were horribly contrived
> >> >> because you usually are matching on additional selection criteria
> that
> >> >> is specific to C++ (such as hasMethod() or isDerivedFrom()) which
> >> >> would cause the match to continue to fail, as expected. Code that
> uses
> >> >> recordDecl() to mean RecordDecl will suddenly start to match in more
> >> >> cases, but that's likely to be a bug fix more than a breaking change.
> >> >> To the best of my understanding, the only breaking cases would be
> >> >> where you wrote recordDecl(), meant CXXRecordDecl, had no further
> >> >> narrowing or traversal matchers, and were compiling in C mode; with
> >> >> the result being additional unexpected matches.
> >> >
> >> >
> >> > Ah, there's one thing that can break: the compile can break:
> >> > recordDecl(hasMethod(...)) will *not* compile (it'll work in the
> dynamic
> >> > matchers and fail as you suggest, but the in-C++ DSL does more static
> >> > type
> >> > checking).
> >> > I don't think that's super bad though.
> >> >
> >> >>
> >> >> So perhaps 

Re: [PATCH] D12358: [Analyzer] Handling constant bound loops

2015-09-11 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

I'll look at this today. Thanks for your patience!


http://reviews.llvm.org/D12358



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


Re: [PATCH] D12402: PR24595: clang-cl fails to compile vswriter.h header from Windows SDK 8.1 in 32 bit mode

2015-09-11 Thread Reid Kleckner via cfe-commits
rnk added inline comments.


Comment at: lib/Sema/SemaType.cpp:5876
@@ +5875,3 @@
+
+if (!IsCtorOrDtor) {
+  if (CurCC != DefaultCC || DefaultCC == ToCC)

This looks like the !IsCtorOrDtor check that affects Itanium. Isn't it already 
handled for MS C++ above?


Comment at: test/CodeGenCXX/ctor-dtor-alias.cpp:170
@@ -169,3 +169,3 @@
   // it has a different calling conversion.
-  // CHECK4: call void @_ZN5test93barD2Ev
+  // CHECK4: call void @_ZN6test103barD2Ev
   bar ptr;

andreybokhanko wrote:
> rnk wrote:
> > Isn't this still in the test9 namespace? Shouldn't this change be reverted?
> Now, after making the change you requested (wrapping checks in "default" part 
> of adjustMemberFunctionCC function with !IsCtorOrDtor (SemaType.cpp:5876)) we 
> start to call ~foo() here, so the check should be changed to:
> 
>   // CHECK4: call void bitcast (void (%"struct.test9::foo"*)* 
> @_ZN5test93fooD2Ev
> 
> Please confirm you are OK with this change and I'll go ahead with commit.
That seems like a bug, we don't want this change to affect destructors on Linux 
or mingw.


http://reviews.llvm.org/D12402



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


Re: r247369 - Module Debugging: Emit forward declarations for types that are defined in

2015-09-11 Thread David Blaikie via cfe-commits
On Fri, Sep 11, 2015 at 8:18 AM, Adrian Prantl  wrote:

>
> On Sep 10, 2015, at 6:56 PM, David Blaikie  wrote:
>
>
>
> On Thu, Sep 10, 2015 at 6:40 PM, David Blaikie  wrote:
>
>>
>>
>> On Thu, Sep 10, 2015 at 6:03 PM, Adrian Prantl via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: adrian
>>> Date: Thu Sep 10 20:03:26 2015
>>> New Revision: 247369
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=247369=rev
>>> Log:
>>> Module Debugging: Emit forward declarations for types that are defined in
>>> clang modules, if -dwarf-ext-refs (DebugTypesExtRefs) is specified.
>>>
>>
>> This change seems to have a lot more code in it than I was expecting...
>>
>> I was rather expecting something a lot like the flimit-debug-info
>> support. Specifically, I would've expected one more conditional added to
>> CGDebugInfo::shouldOmitDefinition.
>>
>> Why the extra complexity?
>>
>> I guess part of it is to be able to omit definitions of things other than
>> record types - is there much value in that? (especially typedefs - it seems
>> like a typedef is too small to benefit from a declaration (even if we could
>> emit one)?)
>>
>
> The typedef itself is not interesting, but it can be used to anchor
> template instantiations like std::string. The contract between the debug
> info in the module and the debug info referencing the module is that all
> explicit template specializations
>

This I get ^ (though does that case need any special handling, or will the
isFromASTFile return true for the location of the explicit specialization
declaration/definition?)


> and template instantiations referenced used in a typedef can be expected
> to exist in the module.
>

This I do not get & would imagine it could cause substantial size
increase...

Might be worth splitting out that change to look at it more carefully. I'd
love to see numbers here.

> Also, we could possibly solve both the problem of "don't emit definitions
> for module things when compiling the main source file" and "don't emit
> definitions for module things defined in other modules" with the same tool.
> If there's a way to say "is this in a foreign AST file" then testing for
> that in CGDebugInfo::shouldOmitDefinition would solve both problems, I
> think (conditionalized on the appropriate flags, either dwarf-ext-refs or
> "I'm building a module here”).
>
>
> I believe that this is a good point. Really, getExtRefOrNull is a separate
> function mostly for evolutionary reasons — it used to do different things
> like mangling names of ObjC types etc. I will see if I can merge the
> existing functionality into shouldOmitDefinition().
>

>From a review perspective it might be easier to revert this & commit a new
patch - I haven't reviewed all these changes in detail because they just
seemed more complex than necessary, but if you're going to evolve it from
here I'll need to dig into the current implementation/be more careful about
checking that future changes remove the complexity along with whatever they
add.

- Dave


>
> -- adrian
>
>
>
>>
>>
>>>
>>> Added:
>>> cfe/trunk/test/Modules/ExtDebugInfo.cpp
>>> cfe/trunk/test/Modules/ExtDebugInfo.m
>>> Modified:
>>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>>> cfe/trunk/lib/CodeGen/CGDebugInfo.h
>>>
>>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=247369=247368=247369=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Sep 10 20:03:26 2015
>>> @@ -148,7 +148,9 @@ void CGDebugInfo::setLocation(SourceLoca
>>>  }
>>>
>>>  llvm::DIScope *CGDebugInfo::getDeclContextDescriptor(const Decl *D) {
>>> -  return getContextDescriptor(cast(D->getDeclContext()), TheCU);
>>> +  llvm::DIScope *Mod = getParentModuleOrNull(D);
>>> +  return getContextDescriptor(cast(D->getDeclContext()),
>>> +  Mod ? Mod : TheCU);
>>>  }
>>>
>>>  llvm::DIScope *CGDebugInfo::getContextDescriptor(const Decl *Context,
>>> @@ -1448,6 +1450,9 @@ void CGDebugInfo::completeRequiredType(c
>>>  if (CXXDecl->isDynamicClass())
>>>return;
>>>
>>> +  if (DebugTypeExtRefs && RD->isFromASTFile())
>>> +return;
>>> +
>>>QualType Ty = CGM.getContext().getRecordType(RD);
>>>llvm::DIType *T = getTypeOrNull(Ty);
>>>if (T && T->isForwardDecl())
>>> @@ -1669,9 +1674,9 @@ CGDebugInfo::getOrCreateModuleRef(Extern
>>>TheCU->getSourceLanguage(), internString(Mod.ModuleName),
>>>internString(Mod.Path), TheCU->getProducer(), true, StringRef(),
>>> 0,
>>>internString(Mod.ASTFile), llvm::DIBuilder::FullDebug,
>>> Mod.Signature);
>>> -  llvm::DIModule *M =
>>> -  DIB.createModule(CU, Mod.ModuleName, ConfigMacros,
>>> internString(Mod.Path),
>>> -   

Re: r247369 - Module Debugging: Emit forward declarations for types that are defined in

2015-09-11 Thread Adrian Prantl via cfe-commits

> On Sep 10, 2015, at 6:56 PM, David Blaikie  wrote:
> 
> 
> 
> On Thu, Sep 10, 2015 at 6:40 PM, David Blaikie  > wrote:
> 
> 
> On Thu, Sep 10, 2015 at 6:03 PM, Adrian Prantl via cfe-commits 
> > wrote:
> Author: adrian
> Date: Thu Sep 10 20:03:26 2015
> New Revision: 247369
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=247369=rev 
> 
> Log:
> Module Debugging: Emit forward declarations for types that are defined in
> clang modules, if -dwarf-ext-refs (DebugTypesExtRefs) is specified.
> 
> This change seems to have a lot more code in it than I was expecting... 
> 
> I was rather expecting something a lot like the flimit-debug-info support. 
> Specifically, I would've expected one more conditional added to 
> CGDebugInfo::shouldOmitDefinition.
> 
> Why the extra complexity?
> 
> I guess part of it is to be able to omit definitions of things other than 
> record types - is there much value in that? (especially typedefs - it seems 
> like a typedef is too small to benefit from a declaration (even if we could 
> emit one)?)

The typedef itself is not interesting, but it can be used to anchor template 
instantiations like std::string. The contract between the debug info in the 
module and the debug info referencing the module is that all explicit template 
specializations and template instantiations referenced used in a typedef can be 
expected to exist in the module.

> Also, we could possibly solve both the problem of "don't emit definitions for 
> module things when compiling the main source file" and "don't emit 
> definitions for module things defined in other modules" with the same tool. 
> If there's a way to say "is this in a foreign AST file" then testing for that 
> in CGDebugInfo::shouldOmitDefinition would solve both problems, I think 
> (conditionalized on the appropriate flags, either dwarf-ext-refs or "I'm 
> building a module here”).

I believe that this is a good point. Really, getExtRefOrNull is a separate 
function mostly for evolutionary reasons — it used to do different things like 
mangling names of ObjC types etc. I will see if I can merge the existing 
functionality into shouldOmitDefinition().

-- adrian
>  
>  
> 
> Added:
> cfe/trunk/test/Modules/ExtDebugInfo.cpp
> cfe/trunk/test/Modules/ExtDebugInfo.m
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CGDebugInfo.h
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=247369=247368=247369=diff
>  
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Sep 10 20:03:26 2015
> @@ -148,7 +148,9 @@ void CGDebugInfo::setLocation(SourceLoca
>  }
> 
>  llvm::DIScope *CGDebugInfo::getDeclContextDescriptor(const Decl *D) {
> -  return getContextDescriptor(cast(D->getDeclContext()), TheCU);
> +  llvm::DIScope *Mod = getParentModuleOrNull(D);
> +  return getContextDescriptor(cast(D->getDeclContext()),
> +  Mod ? Mod : TheCU);
>  }
> 
>  llvm::DIScope *CGDebugInfo::getContextDescriptor(const Decl *Context,
> @@ -1448,6 +1450,9 @@ void CGDebugInfo::completeRequiredType(c
>  if (CXXDecl->isDynamicClass())
>return;
> 
> +  if (DebugTypeExtRefs && RD->isFromASTFile())
> +return;
> +
>QualType Ty = CGM.getContext().getRecordType(RD);
>llvm::DIType *T = getTypeOrNull(Ty);
>if (T && T->isForwardDecl())
> @@ -1669,9 +1674,9 @@ CGDebugInfo::getOrCreateModuleRef(Extern
>TheCU->getSourceLanguage(), internString(Mod.ModuleName),
>internString(Mod.Path), TheCU->getProducer(), true, StringRef(), 0,
>internString(Mod.ASTFile), llvm::DIBuilder::FullDebug, Mod.Signature);
> -  llvm::DIModule *M =
> -  DIB.createModule(CU, Mod.ModuleName, ConfigMacros, 
> internString(Mod.Path),
> -   internString(CGM.getHeaderSearchOpts().Sysroot));
> +  llvm::DIModule *M = DIB.createModule(
> +  CU, Mod.ModuleName, ConfigMacros, internString(Mod.Path),
> +  internString(CGM.getHeaderSearchOpts().Sysroot));
>DIB.finalize();
>ModRef.reset(M);
>return M;
> @@ -2081,9 +2086,16 @@ llvm::DIType *CGDebugInfo::getOrCreateTy
>if (auto *T = getTypeOrNull(Ty))
>  return T;
> 
> +  llvm::DIType *Res = nullptr;
> +  if (DebugTypeExtRefs)
> +// Make a forward declaration of an external type.
> +Res = getTypeExtRefOrNull(Ty, Unit);
> +
>// Otherwise create the type.
> -  llvm::DIType *Res = CreateTypeNode(Ty, Unit);
> -  void *TyPtr = Ty.getAsOpaquePtr();
> +  if (!Res)
> +Res = CreateTypeNode(Ty, 

r247421 - [CodeGen] Teach SimplifyPersonality about the updated LandingPadInst

2015-09-11 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Sep 11 10:40:05 2015
New Revision: 247421

URL: http://llvm.org/viewvc/llvm-project?rev=247421=rev
Log:
[CodeGen] Teach SimplifyPersonality about the updated LandingPadInst

When uses of personality functions were moved from LandingPadInst to
Function, we forgot to update SimplifyPersonality(). This patch corrects
that.

Note: SimplifyPersonality() is an optimization which replaces
personality functions with the default C++ personality when possible.
Without this update, some ObjC++ projects fail to link against C++
libraries (seeing as the exception ABI had effectively changed).

rdar://problem/22155434

Added:
cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm
cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm
Modified:
cfe/trunk/lib/CodeGen/CGException.cpp

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=247421=247420=247421=diff
==
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Fri Sep 11 10:40:05 2015
@@ -229,6 +229,36 @@ static llvm::Constant *getOpaquePersonal
   return llvm::ConstantExpr::getBitCast(Fn, CGM.Int8PtrTy);
 }
 
+/// Check whether a landingpad instruction only uses C++ features.
+static bool LandingPadHasOnlyCXXUses(llvm::LandingPadInst *LPI) {
+  for (unsigned I = 0, E = LPI->getNumClauses(); I != E; ++I) {
+// Look for something that would've been returned by the ObjC
+// runtime's GetEHType() method.
+llvm::Value *Val = LPI->getClause(I)->stripPointerCasts();
+if (LPI->isCatch(I)) {
+  // Check if the catch value has the ObjC prefix.
+  if (llvm::GlobalVariable *GV = dyn_cast(Val))
+// ObjC EH selector entries are always global variables with
+// names starting like this.
+if (GV->getName().startswith("OBJC_EHTYPE"))
+  return false;
+} else {
+  // Check if any of the filter values have the ObjC prefix.
+  llvm::Constant *CVal = cast(Val);
+  for (llvm::User::op_iterator
+  II = CVal->op_begin(), IE = CVal->op_end(); II != IE; ++II) {
+if (llvm::GlobalVariable *GV =
+cast((*II)->stripPointerCasts()))
+  // ObjC EH selector entries are always global variables with
+  // names starting like this.
+  if (GV->getName().startswith("OBJC_EHTYPE"))
+return false;
+  }
+}
+  }
+  return true;
+}
+
 /// Check whether a personality function could reasonably be swapped
 /// for a C++ personality function.
 static bool PersonalityHasOnlyCXXUses(llvm::Constant *Fn) {
@@ -241,34 +271,14 @@ static bool PersonalityHasOnlyCXXUses(ll
   continue;
 }
 
-// Otherwise, it has to be a landingpad instruction.
-llvm::LandingPadInst *LPI = dyn_cast(U);
-if (!LPI) return false;
+// Otherwise it must be a function.
+llvm::Function *F = dyn_cast(U);
+if (!F) return false;
 
-for (unsigned I = 0, E = LPI->getNumClauses(); I != E; ++I) {
-  // Look for something that would've been returned by the ObjC
-  // runtime's GetEHType() method.
-  llvm::Value *Val = LPI->getClause(I)->stripPointerCasts();
-  if (LPI->isCatch(I)) {
-// Check if the catch value has the ObjC prefix.
-if (llvm::GlobalVariable *GV = dyn_cast(Val))
-  // ObjC EH selector entries are always global variables with
-  // names starting like this.
-  if (GV->getName().startswith("OBJC_EHTYPE"))
-return false;
-  } else {
-// Check if any of the filter values have the ObjC prefix.
-llvm::Constant *CVal = cast(Val);
-for (llvm::User::op_iterator
-   II = CVal->op_begin(), IE = CVal->op_end(); II != IE; ++II) {
-  if (llvm::GlobalVariable *GV =
-  cast((*II)->stripPointerCasts()))
-// ObjC EH selector entries are always global variables with
-// names starting like this.
-if (GV->getName().startswith("OBJC_EHTYPE"))
-  return false;
-}
-  }
+for (auto BB = F->begin(), E = F->end(); BB != E; ++BB) {
+  if (BB->isLandingPad())
+if (!LandingPadHasOnlyCXXUses(BB->getLandingPadInst()))
+  return false;
 }
   }
 

Added: cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm?rev=247421=auto
==
--- cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm (added)
+++ cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm Fri Sep 11 10:40:05 2015
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -emit-llvm 
-fcxx-exceptions -fexceptions -fobjc-exceptions -o - %s | FileCheck %s
+
+// rdar://problem/22155434
+namespace test0 {
+  void foo() {
+try {
+  throw 

Re: [PATCH] D12743: [CodeGen] Teach SimplifyPersonality about the updated LandingPadInst

2015-09-11 Thread Vedant Kumar via cfe-commits
vsk accepted this revision.
vsk added a reviewer: vsk.
vsk marked an inline comment as done.
vsk added a comment.
This revision is now accepted and ready to land.

Committed r247421


http://reviews.llvm.org/D12743



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


r247426 - [Static Analyzer] Lambda support.

2015-09-11 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Fri Sep 11 11:55:01 2015
New Revision: 247426

URL: http://llvm.org/viewvc/llvm-project?rev=247426=rev
Log:
[Static Analyzer] Lambda support.

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


Added:
cfe/trunk/test/Analysis/lambda-notes.cpp
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
cfe/trunk/test/Analysis/dead-stores.cpp
cfe/trunk/test/Analysis/lambdas.cpp
cfe/trunk/test/Analysis/temporaries.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h?rev=247426=247425=247426=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Fri Sep 11 
11:55:01 2015
@@ -256,6 +256,9 @@ private:
   /// \sa getMaxNodesPerTopLevelFunction
   Optional MaxNodesPerTopLevelFunction;
 
+  /// \sa shouldInlineLambdas
+  Optional InlineLambdas;
+
   /// A helper function that retrieves option for a given full-qualified
   /// checker name.
   /// Options for checkers can be specified via 'analyzer-config' command-line
@@ -509,6 +512,10 @@ public:
   /// This is controlled by the 'max-nodes' config option.
   unsigned getMaxNodesPerTopLevelFunction();
 
+  /// Returns true if lambdas should be inlined. Otherwise a sink node will be
+  /// generated each time a LambdaExpr is visited.
+  bool shouldInlineLambdas();
+
 public:
   AnalyzerOptions() :
 AnalysisStoreOpt(RegionStoreModel),

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h?rev=247426=247425=247426=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h Fri 
Sep 11 11:55:01 2015
@@ -341,6 +341,10 @@ public:
   void VisitBlockExpr(const BlockExpr *BE, ExplodedNode *Pred, 
   ExplodedNodeSet );
 
+  /// VisitLambdaExpr - Transfer function logic for LambdaExprs.
+  void VisitLambdaExpr(const LambdaExpr *LE, ExplodedNode *Pred, 
+   ExplodedNodeSet );
+
   /// VisitBinaryOperator - Transfer function logic for binary operators.
   void VisitBinaryOperator(const BinaryOperator* B, ExplodedNode *Pred, 
ExplodedNodeSet );

Modified: cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp?rev=247426=247425=247426=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp Fri Sep 11 11:55:01 
2015
@@ -325,3 +325,7 @@ bool AnalyzerOptions::shouldPrunePaths()
 bool AnalyzerOptions::shouldConditionalizeStaticInitializers() {
   return getBooleanOption("cfg-conditional-static-initializers", true);
 }
+
+bool AnalyzerOptions::shouldInlineLambdas() {
+  return getBooleanOption("inline-lambdas", /*Default=*/true);
+}

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=247426=247425=247426=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Fri Sep 11 11:55:01 2015
@@ -769,7 +769,6 @@ void ExprEngine::Visit(const Stmt *S, Ex
 case Stmt::SEHTryStmtClass:
 case Stmt::SEHExceptStmtClass:
 case Stmt::SEHLeaveStmtClass:
-case Stmt::LambdaExprClass:
 case Stmt::SEHFinallyStmtClass: {
   const ExplodedNode *node = Bldr.generateSink(S, Pred, Pred->getState());
   Engine.addAbortedBlock(node, currBldrCtx->getBlock());
@@ -1013,6 +1012,17 @@ void ExprEngine::Visit(const Stmt *S, Ex
   Bldr.addNodes(Dst);
   break;
 
+case Stmt::LambdaExprClass:
+  if (AMgr.options.shouldInlineLambdas()) {
+Bldr.takeNodes(Pred);
+VisitLambdaExpr(cast(S), Pred, Dst);
+Bldr.addNodes(Dst);
+  } else {
+const ExplodedNode *node = Bldr.generateSink(S, Pred, 
Pred->getState());
+Engine.addAbortedBlock(node, currBldrCtx->getBlock());
+  }
+  break;
+
 case Stmt::BinaryOperatorClass: {