r315439 - Revert r314955: "Remove PendingBody mechanism for function and ObjC method deserialization."

2017-10-11 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Wed Oct 11 00:47:54 2017
New Revision: 315439

URL: http://llvm.org/viewvc/llvm-project?rev=315439&view=rev
Log:
Revert r314955: "Remove PendingBody mechanism for function and ObjC method 
deserialization."

This is breaking a build of https://github.com/abseil/abseil-cpp and so
likely not really NFC. Also reverted subsequent r314956/7.

I'll forward reproduction instructions to Richard.

Removed:
cfe/trunk/test/Modules/merge-lambdas.cpp
Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTCommon.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=315439&r1=315438&r2=315439&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Wed Oct 11 00:47:54 2017
@@ -559,9 +559,13 @@ private:
   /// declarations that have not yet been linked to their definitions.
   llvm::SmallPtrSet PendingDefinitions;
 
-  /// \brief Functions or methods that are known to already have a definition
-  /// (that might not yet be merged into the redeclaration chain).
-  llvm::SmallDenseMap FunctionDefinitions;
+  typedef llvm::MapVector,
+  SmallVector, 4> >
+PendingBodiesMap;
+
+  /// \brief Functions or methods that have bodies that will be attached.
+  PendingBodiesMap PendingBodies;
 
   /// \brief Definitions for which we have added merged definitions but not yet
   /// performed deduplication.
@@ -987,13 +991,25 @@ private:
   /// the last time we loaded information about this identifier.
   llvm::DenseMap IdentifierGeneration;
 
+  class InterestingDecl {
+Decl *D;
+bool DeclHasPendingBody;
+
+  public:
+InterestingDecl(Decl *D, bool HasBody)
+: D(D), DeclHasPendingBody(HasBody) {}
+Decl *getDecl() { return D; }
+/// Whether the declaration has a pending body.
+bool hasPendingBody() { return DeclHasPendingBody; }
+  };
+
   /// \brief Contains declarations and definitions that could be
   /// "interesting" to the ASTConsumer, when we get that AST consumer.
   ///
   /// "Interesting" declarations are those that have data that may
   /// need to be emitted, such as inline function definitions or
   /// Objective-C protocols.
-  std::deque PotentiallyInterestingDecls;
+  std::deque PotentiallyInterestingDecls;
 
   /// \brief The list of redeclaration chains that still need to be 
   /// reconstructed, and the local offset to the corresponding list

Modified: cfe/trunk/lib/Serialization/ASTCommon.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTCommon.cpp?rev=315439&r1=315438&r2=315439&view=diff
==
--- cfe/trunk/lib/Serialization/ASTCommon.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTCommon.cpp Wed Oct 11 00:47:54 2017
@@ -344,8 +344,8 @@ bool serialization::needsAnonymousDeclar
 return true;
   }
 
-  // Otherwise, we only care about anonymous class members / block-scope decls.
-  if (D->getDeclName() || D->getLexicalDeclContext()->isFileContext())
+  // Otherwise, we only care about anonymous class members.
+  if (D->getDeclName() || !isa(D->getLexicalDeclContext()))
 return false;
   return isa(D) || isa(D);
 }

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=315439&r1=315438&r2=315439&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Wed Oct 11 00:47:54 2017
@@ -9169,6 +9169,30 @@ void ASTReader::finishPendingActions() {
   }
   PendingDefinitions.clear();
 
+  // Load the bodies of any functions or methods we've encountered. We do
+  // this now (delayed) so that we can be sure that the declaration chains
+  // have been fully wired up (hasBody relies on this).
+  // FIXME: We shouldn't require complete redeclaration chains here.
+  for (PendingBodiesMap::iterator PB = PendingBodies.begin(),
+   PBEnd = PendingBodies.end();
+   PB != PBEnd; ++PB) {
+if (FunctionDecl *FD = dyn_cast(PB->first)) {
+  // FIXME: Check for =delete/=default?
+  // FIXME: Complain about ODR violations here?
+  const FunctionDecl *Defn = nullptr;
+  if (!getContext().getLangOpts().Modules || !FD->hasBody(Defn)) {
+FD->setLazyBody(PB->second);
+  } else
+mergeDefinitionVisibility(const_cast(Defn), FD);
+  continue;
+}
+
+ObjCMethodDecl *MD = cast(PB->first);
+if (!getContext().getLangOpts().Modules || !MD->hasBody())
+  MD->setLazyBody(

[PATCH] D36973: [libclang] Add support for querying cursor availability

2017-10-11 Thread Johann Klähn via Phabricator via cfe-commits
jklaehn marked an inline comment as done.
jklaehn added a comment.

In https://reviews.llvm.org/D36973#893851, @jbcoe wrote:

> LGTM
>
> Would you like me to commit this for you?


Yes, that would be great!


https://reviews.llvm.org/D36973



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


[PATCH] D38402: [clang-refactor] Apply source replacements

2017-10-11 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.

LGTM, let's check in it.


Repository:
  rL LLVM

https://reviews.llvm.org/D38402



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


[PATCH] D36955: [libclang] Visit attributes for function and class templates

2017-10-11 Thread Johann Klähn via Phabricator via cfe-commits
jklaehn added a comment.

In https://reviews.llvm.org/D36955#893856, @jbcoe wrote:

> LGTM
>
> Would you like me to commit this for you?


Yes, I would appreciate it.


https://reviews.llvm.org/D36955



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


[PATCH] D38733: [CodeGen] Generate TBAA info along with LValue base info

2017-10-11 Thread Ivan A. Kosarev via Phabricator via cfe-commits
kosarev updated this revision to Diff 118551.
kosarev added a comment.

Removed changes related to functions like getNaturalTypeAlignment() that 
generate LValue base info objects to simplify the patch. These removed changes 
will be addressed with separate patches.


https://reviews.llvm.org/D38733

Files:
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h

Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1917,9 +1917,9 @@
 CGM.getTBAAAccessInfo(T));
   }
 
-  LValue MakeAddrLValue(Address Addr, QualType T, LValueBaseInfo BaseInfo) {
-return LValue::MakeAddr(Addr, T, getContext(), BaseInfo,
-CGM.getTBAAAccessInfo(T));
+  LValue MakeAddrLValue(Address Addr, QualType T, LValueBaseInfo BaseInfo,
+TBAAAccessInfo TBAAInfo) {
+return LValue::MakeAddr(Addr, T, getContext(), BaseInfo, TBAAInfo);
   }
 
   LValue MakeAddrLValue(llvm::Value *V, QualType T, CharUnits Alignment,
@@ -1930,9 +1930,9 @@
   }
 
   LValue MakeAddrLValue(llvm::Value *V, QualType T, CharUnits Alignment,
-LValueBaseInfo BaseInfo) {
+LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo) {
 return LValue::MakeAddr(Address(V, Alignment), T, getContext(),
-BaseInfo, CGM.getTBAAAccessInfo(T));
+BaseInfo, TBAAInfo);
   }
 
   LValue MakeNaturalAlignPointeeAddrLValue(llvm::Value *V, QualType T);
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -180,7 +180,8 @@
 CodeGenFunction::MakeNaturalAlignPointeeAddrLValue(llvm::Value *V, QualType T) {
   LValueBaseInfo BaseInfo;
   CharUnits Align = getNaturalTypeAlignment(T, &BaseInfo, /*pointee*/ true);
-  return MakeAddrLValue(Address(V, Align), T, BaseInfo);
+  return MakeAddrLValue(Address(V, Align), T, BaseInfo,
+CGM.getTBAAAccessInfo(T));
 }
 
 
Index: lib/CodeGen/CGOpenMPRuntime.cpp
===
--- lib/CodeGen/CGOpenMPRuntime.cpp
+++ lib/CodeGen/CGOpenMPRuntime.cpp
@@ -980,7 +980,8 @@
   SharedLVal = CGF.MakeAddrLValue(
   CGF.Builder.CreateElementBitCast(SharedLVal.getAddress(),
CGF.ConvertTypeForMem(SharedType)),
-  SharedType, SharedAddresses[N].first.getBaseInfo());
+  SharedType, SharedAddresses[N].first.getBaseInfo(),
+  CGF.CGM.getTBAAAccessInfo(SharedType));
   if (isa(ClausesData[N].Ref) ||
   CGF.getContext().getAsArrayType(PrivateVD->getType())) {
 emitAggregateInitialization(CGF, N, PrivateAddr, SharedLVal, DRD);
@@ -1033,7 +1034,8 @@
   return CGF.MakeAddrLValue(
   CGF.Builder.CreateElementBitCast(BaseLV.getAddress(),
CGF.ConvertTypeForMem(ElTy)),
-  BaseLV.getType(), BaseLV.getBaseInfo());
+  BaseLV.getType(), BaseLV.getBaseInfo(),
+  CGF.CGM.getTBAAAccessInfo(BaseLV.getType()));
 }
 
 static Address castToBase(CodeGenFunction &CGF, QualType BaseTy, QualType ElTy,
@@ -4072,7 +4074,8 @@
 Address(SharedRefLValue.getPointer(), C.getDeclAlign(OriginalVD)),
 SharedRefLValue.getType(),
 LValueBaseInfo(AlignmentSource::Decl,
-   SharedRefLValue.getBaseInfo().getMayAlias()));
+   SharedRefLValue.getBaseInfo().getMayAlias()),
+CGF.CGM.getTBAAAccessInfo(SharedRefLValue.getType()));
 QualType Type = OriginalVD->getType();
 if (Type->isArrayType()) {
   // Initialize firstprivate array.
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -2159,7 +2159,8 @@
   const ReferenceType *RefTy) {
   LValueBaseInfo BaseInfo;
   Address Addr = EmitLoadOfReference(RefAddr, RefTy, &BaseInfo);
-  return MakeAddrLValue(Addr, RefTy->getPointeeType(), BaseInfo);
+  return MakeAddrLValue(Addr, RefTy->getPointeeType(), BaseInfo,
+CGM.getTBAAAccessInfo(RefTy->getPointeeType()));
 }
 
 Address CodeGenFunction::EmitLoadOfPointer(Address Ptr,
@@ -2175,7 +2176,8 @@
 const PointerType *PtrTy) {
   LValueBaseInfo BaseInfo;
   Address Addr = EmitLoadOfPointer(PtrAddr, PtrTy, &BaseInfo);
-  return MakeAddrLValue(Addr, PtrTy->getPointeeType(), BaseInfo);
+  return MakeAddrLValue(Addr, PtrTy->getPointeeType(), BaseInfo,
+CGM.getTBAAAccessInfo(PtrTy->getPointeeType()));
 }
 
 static LValue EmitGlobalVarDeclLValue(CodeGenFunction &CGF,
@@ -2328,7 +2330,8 @

[PATCH] D38772: [refactor] allow the use of refactoring diagnostics

2017-10-11 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

The code looks most good to me, a few nits.




Comment at: lib/Basic/DiagnosticIDs.cpp:46
   unsigned WarnShowInSystemHeader : 1;
-  unsigned Category : 5;
+  unsigned Category : 6;
 

just curious: is this change needed?



Comment at: tools/clang-refactor/ToolRefactoringResultConsumer.h:19
+
+/// A subclass of \c RefactoringResultConsumer that stores the reference to the
+/// TU-specific diagnostics engine.

I'd name it "interface", because it has unimplemented virtual function 
(`handleError`), clients can't create an instance of it. 

or alternatively,  does it make more sense to just add these methods and 
`DiagnosticsEngine` variable to the `tooling::RefactoringResultConsumer` 
interface? I see you have replaced "RefactoringResultConsumer" with this new 
interface in many places. 


Repository:
  rL LLVM

https://reviews.llvm.org/D38772



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


[PATCH] D38788: [CodeGen] EmitCXXMemberDataPointerAddress() to generate TBAA info along with LValue base info

2017-10-11 Thread Ivan A. Kosarev via Phabricator via cfe-commits
kosarev created this revision.
kosarev added a project: clang.

Prepared on top of https://reviews.llvm.org/D38733.


Repository:
  rL LLVM

https://reviews.llvm.org/D38788

Files:
  CodeGen/CGClass.cpp
  CodeGen/CGExpr.cpp
  CodeGen/CodeGenFunction.h


Index: CodeGen/CodeGenFunction.h
===
--- CodeGen/CodeGenFunction.h
+++ CodeGen/CodeGenFunction.h
@@ -3327,7 +3327,8 @@
   Address EmitCXXMemberDataPointerAddress(const Expr *E, Address base,
   llvm::Value *memberPtr,
   const MemberPointerType 
*memberPtrType,
-  LValueBaseInfo *BaseInfo = nullptr);
+  LValueBaseInfo *BaseInfo = nullptr,
+  TBAAAccessInfo *TBAAInfo = nullptr);
   RValue EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E,
   ReturnValueSlot ReturnValue);
 
Index: CodeGen/CGExpr.cpp
===
--- CodeGen/CGExpr.cpp
+++ CodeGen/CGExpr.cpp
@@ -4571,11 +4571,12 @@
 = E->getRHS()->getType()->getAs();
 
   LValueBaseInfo BaseInfo;
+  TBAAAccessInfo TBAAInfo;
   Address MemberAddr =
-EmitCXXMemberDataPointerAddress(E, BaseAddr, OffsetV, MPT, &BaseInfo);
+EmitCXXMemberDataPointerAddress(E, BaseAddr, OffsetV, MPT, &BaseInfo,
+&TBAAInfo);
 
-  return MakeAddrLValue(MemberAddr, MPT->getPointeeType(), BaseInfo,
-CGM.getTBAAAccessInfo(MPT->getPointeeType()));
+  return MakeAddrLValue(MemberAddr, MPT->getPointeeType(), BaseInfo, TBAAInfo);
 }
 
 /// Given the address of a temporary variable, produce an r-value of
Index: CodeGen/CGClass.cpp
===
--- CodeGen/CGClass.cpp
+++ CodeGen/CGClass.cpp
@@ -129,13 +129,16 @@
 CodeGenFunction::EmitCXXMemberDataPointerAddress(const Expr *E, Address base,
  llvm::Value *memberPtr,
   const MemberPointerType *memberPtrType,
- LValueBaseInfo *BaseInfo) {
+ LValueBaseInfo *BaseInfo,
+ TBAAAccessInfo *TBAAInfo) {
   // Ask the ABI to compute the actual address.
   llvm::Value *ptr =
 CGM.getCXXABI().EmitMemberDataPointerAddress(*this, E, base,
  memberPtr, memberPtrType);
 
   QualType memberType = memberPtrType->getPointeeType();
+  if (TBAAInfo)
+*TBAAInfo = CGM.getTBAAAccessInfo(memberType);
   CharUnits memberAlign = getNaturalTypeAlignment(memberType, BaseInfo);
   memberAlign =
 CGM.getDynamicOffsetAlignment(base.getAlignment(),


Index: CodeGen/CodeGenFunction.h
===
--- CodeGen/CodeGenFunction.h
+++ CodeGen/CodeGenFunction.h
@@ -3327,7 +3327,8 @@
   Address EmitCXXMemberDataPointerAddress(const Expr *E, Address base,
   llvm::Value *memberPtr,
   const MemberPointerType *memberPtrType,
-  LValueBaseInfo *BaseInfo = nullptr);
+  LValueBaseInfo *BaseInfo = nullptr,
+  TBAAAccessInfo *TBAAInfo = nullptr);
   RValue EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E,
   ReturnValueSlot ReturnValue);
 
Index: CodeGen/CGExpr.cpp
===
--- CodeGen/CGExpr.cpp
+++ CodeGen/CGExpr.cpp
@@ -4571,11 +4571,12 @@
 = E->getRHS()->getType()->getAs();
 
   LValueBaseInfo BaseInfo;
+  TBAAAccessInfo TBAAInfo;
   Address MemberAddr =
-EmitCXXMemberDataPointerAddress(E, BaseAddr, OffsetV, MPT, &BaseInfo);
+EmitCXXMemberDataPointerAddress(E, BaseAddr, OffsetV, MPT, &BaseInfo,
+&TBAAInfo);
 
-  return MakeAddrLValue(MemberAddr, MPT->getPointeeType(), BaseInfo,
-CGM.getTBAAAccessInfo(MPT->getPointeeType()));
+  return MakeAddrLValue(MemberAddr, MPT->getPointeeType(), BaseInfo, TBAAInfo);
 }
 
 /// Given the address of a temporary variable, produce an r-value of
Index: CodeGen/CGClass.cpp
===
--- CodeGen/CGClass.cpp
+++ CodeGen/CGClass.cpp
@@ -129,13 +129,16 @@
 CodeGenFunction::EmitCXXMemberDataPointerAddress(const Expr *E, Address base,
  llvm::Value *memberPtr,
   const MemberPointerType *memberPtrType,
- LValueBaseInfo *BaseInfo) {
+   

[PATCH] D38452: Mark test as a long-test

2017-10-11 Thread Oliver Stannard via Phabricator via cfe-commits
olista01 accepted this revision.
olista01 added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D38452



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


[PATCH] D38723: [clang-rename] Don't add prefix qualifiers to the declaration and definition of the renamed symbol.

2017-10-11 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 118573.
hokein marked 3 inline comments as done.
hokein added a comment.

Address review comments.


https://reviews.llvm.org/D38723

Files:
  lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
  unittests/Rename/RenameClassTest.cpp

Index: unittests/Rename/RenameClassTest.cpp
===
--- unittests/Rename/RenameClassTest.cpp
+++ unittests/Rename/RenameClassTest.cpp
@@ -469,8 +469,6 @@
   CompareSnippets(Expected, After);
 }
 
-// FIXME: no prefix qualifiers being added to the class definition and
-// constructor.
 TEST_F(ClangRenameTest, RenameClassWithNamespaceWithInlineMembers) {
   std::string Before = R"(
   namespace ns {
@@ -488,9 +486,9 @@
 )";
   std::string Expected = R"(
   namespace ns {
-  class ns::New {
+  class New {
public:
-ns::New() {}
+New() {}
 ~New() {}
 
 New* next() { return next_; }
@@ -504,8 +502,6 @@
   CompareSnippets(Expected, After);
 }
 
-// FIXME: no prefix qualifiers being added to the class definition and
-// constructor.
 TEST_F(ClangRenameTest, RenameClassWithNamespaceWithOutOfInlineMembers) {
   std::string Before = R"(
   namespace ns {
@@ -527,32 +523,32 @@
 )";
   std::string Expected = R"(
   namespace ns {
-  class ns::New {
+  class New {
public:
-ns::New();
+New();
 ~New();
 
 New* next();
 
private:
 New* next_;
   };
 
-  New::ns::New() {}
+  New::New() {}
   New::~New() {}
   New* New::next() { return next_; }
   }  // namespace ns
 )";
   std::string After = runClangRenameOnCode(Before, "ns::Old", "ns::New");
   CompareSnippets(Expected, After);
 }
 
-// FIXME: no prefix qualifiers being added to the definition.
 TEST_F(ClangRenameTest, RenameClassInInheritedConstructor) {
   // `using Base::Base;` will generate an implicit constructor containing usage
   // of `::ns::Old` which should not be matched.
   std::string Before = R"(
   namespace ns {
+  class Old;
   class Old {
 int x;
   };
@@ -574,7 +570,8 @@
   })";
   std::string Expected = R"(
   namespace ns {
-  class ns::New {
+  class New;
+  class New {
 int x;
   };
   class Base {
@@ -615,7 +612,7 @@
   )";
   std::string Expected = R"(
   namespace ns {
-  class ::new_ns::New {
+  class New {
   };
   } // namespace ns
   struct S {
@@ -632,7 +629,6 @@
   CompareSnippets(Expected, After);
 }
 
-// FIXME: no prefix qualifiers being adding to the definition.
 TEST_F(ClangRenameTest, ReferencesInLambdaFunctionParameters) {
   std::string Before = R"(
   template 
@@ -669,7 +665,7 @@
   };
 
   namespace ns {
-  class ::new_ns::New {};
+  class New {};
   void f() {
 function func;
   }
Index: lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
===
--- lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
+++ lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
@@ -160,13 +160,15 @@
 const Decl *Context;
 // The nested name being replaced (can be nullptr).
 const NestedNameSpecifier *Specifier;
+// Determine whether the prefix qualifiers of the NewName should be ignored.
+// Normally, we set it to true for the symbol declaration and definition to
+// avoid adding prefix qualifiers.
+// For example, if it is true and NewName is
+// "a::b::foo", then the symbol occurrence which the RenameInfo points to
+// will be renamed to "foo".
+bool IgnorePrefixQualifers;
   };
 
-  // FIXME: Currently, prefix qualifiers will be added to the renamed symbol
-  // definition (e.g. "class Foo {};" => "class b::Bar {};" when renaming
-  // "a::Foo" to "b::Bar").
-  // For renaming declarations/definitions, prefix qualifiers should be filtered
-  // out.
   bool VisitNamedDecl(const NamedDecl *Decl) {
 // UsingDecl has been handled in other place.
 if (llvm::isa(Decl))
@@ -180,8 +182,12 @@
   return true;
 
 if (isInUSRSet(Decl)) {
-  RenameInfo Info = {Decl->getLocation(), Decl->getLocation(), nullptr,
- nullptr, nullptr};
+  RenameInfo Info = {Decl->getLocation(),
+ Decl->getLocation(),
+ /*FromDecl=*/nullptr,
+ /*Context=*/nullptr,
+ /*Specifier=*/nullptr,
+ /*IgnorePrefixQualifers=*/true};
   RenameInfos.push_back(Info);
 }
 return true;
@@ -191,8 +197,11 @@
 const NamedDecl *Decl = Expr->getFoundDecl();
 if (isInUSRSet(Decl)) {
   RenameInfo Info = {Expr->getSourceRange().getBegin(),
- Expr->getSourceRange().getEnd(), Decl,
- getClosestAncestorDecl(*Expr), Expr->getQualifier()};
+ Expr->getSourceR

[PATCH] D38791: [CodeGen] EmitLoadOfPointerLValue() to generate TBAA info along with LValue base info

2017-10-11 Thread Ivan A. Kosarev via Phabricator via cfe-commits
kosarev created this revision.
kosarev added a project: clang.

This patch should not bring in any functional changes. Prepared on top of 
https://reviews.llvm.org/D38733.


Repository:
  rL LLVM

https://reviews.llvm.org/D38791

Files:
  CodeGen/CGExpr.cpp
  CodeGen/CodeGenFunction.h


Index: CodeGen/CodeGenFunction.h
===
--- CodeGen/CodeGenFunction.h
+++ CodeGen/CodeGenFunction.h
@@ -1948,7 +1948,8 @@
   LValue EmitLoadOfReferenceLValue(Address Ref, const ReferenceType *RefTy);
 
   Address EmitLoadOfPointer(Address Ptr, const PointerType *PtrTy,
-LValueBaseInfo *BaseInfo = nullptr);
+LValueBaseInfo *BaseInfo = nullptr,
+TBAAAccessInfo *TBAAInfo = nullptr);
   LValue EmitLoadOfPointerLValue(Address Ptr, const PointerType *PtrTy);
 
   /// CreateTempAlloca - This creates an alloca and inserts it into the entry
Index: CodeGen/CGExpr.cpp
===
--- CodeGen/CGExpr.cpp
+++ CodeGen/CGExpr.cpp
@@ -2165,7 +2165,11 @@
 
 Address CodeGenFunction::EmitLoadOfPointer(Address Ptr,
const PointerType *PtrTy,
-   LValueBaseInfo *BaseInfo) {
+   LValueBaseInfo *BaseInfo,
+   TBAAAccessInfo *TBAAInfo) {
+  if (TBAAInfo)
+*TBAAInfo = CGM.getTBAAAccessInfo(PtrTy->getPointeeType());
+
   llvm::Value *Addr = Builder.CreateLoad(Ptr);
   return Address(Addr, getNaturalTypeAlignment(PtrTy->getPointeeType(),
BaseInfo,
@@ -2175,9 +2179,9 @@
 LValue CodeGenFunction::EmitLoadOfPointerLValue(Address PtrAddr,
 const PointerType *PtrTy) {
   LValueBaseInfo BaseInfo;
-  Address Addr = EmitLoadOfPointer(PtrAddr, PtrTy, &BaseInfo);
-  return MakeAddrLValue(Addr, PtrTy->getPointeeType(), BaseInfo,
-CGM.getTBAAAccessInfo(PtrTy->getPointeeType()));
+  TBAAAccessInfo TBAAInfo;
+  Address Addr = EmitLoadOfPointer(PtrAddr, PtrTy, &BaseInfo, &TBAAInfo);
+  return MakeAddrLValue(Addr, PtrTy->getPointeeType(), BaseInfo, TBAAInfo);
 }
 
 static LValue EmitGlobalVarDeclLValue(CodeGenFunction &CGF,


Index: CodeGen/CodeGenFunction.h
===
--- CodeGen/CodeGenFunction.h
+++ CodeGen/CodeGenFunction.h
@@ -1948,7 +1948,8 @@
   LValue EmitLoadOfReferenceLValue(Address Ref, const ReferenceType *RefTy);
 
   Address EmitLoadOfPointer(Address Ptr, const PointerType *PtrTy,
-LValueBaseInfo *BaseInfo = nullptr);
+LValueBaseInfo *BaseInfo = nullptr,
+TBAAAccessInfo *TBAAInfo = nullptr);
   LValue EmitLoadOfPointerLValue(Address Ptr, const PointerType *PtrTy);
 
   /// CreateTempAlloca - This creates an alloca and inserts it into the entry
Index: CodeGen/CGExpr.cpp
===
--- CodeGen/CGExpr.cpp
+++ CodeGen/CGExpr.cpp
@@ -2165,7 +2165,11 @@
 
 Address CodeGenFunction::EmitLoadOfPointer(Address Ptr,
const PointerType *PtrTy,
-   LValueBaseInfo *BaseInfo) {
+   LValueBaseInfo *BaseInfo,
+   TBAAAccessInfo *TBAAInfo) {
+  if (TBAAInfo)
+*TBAAInfo = CGM.getTBAAAccessInfo(PtrTy->getPointeeType());
+
   llvm::Value *Addr = Builder.CreateLoad(Ptr);
   return Address(Addr, getNaturalTypeAlignment(PtrTy->getPointeeType(),
BaseInfo,
@@ -2175,9 +2179,9 @@
 LValue CodeGenFunction::EmitLoadOfPointerLValue(Address PtrAddr,
 const PointerType *PtrTy) {
   LValueBaseInfo BaseInfo;
-  Address Addr = EmitLoadOfPointer(PtrAddr, PtrTy, &BaseInfo);
-  return MakeAddrLValue(Addr, PtrTy->getPointeeType(), BaseInfo,
-CGM.getTBAAAccessInfo(PtrTy->getPointeeType()));
+  TBAAAccessInfo TBAAInfo;
+  Address Addr = EmitLoadOfPointer(PtrAddr, PtrTy, &BaseInfo, &TBAAInfo);
+  return MakeAddrLValue(Addr, PtrTy->getPointeeType(), BaseInfo, TBAAInfo);
 }
 
 static LValue EmitGlobalVarDeclLValue(CodeGenFunction &CGF,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38793: [CodeGen] EmitLoadOfReference() to generate TBAA info along with LValue base info

2017-10-11 Thread Ivan A. Kosarev via Phabricator via cfe-commits
kosarev created this revision.
kosarev added a project: clang.

Repository:
  rL LLVM

https://reviews.llvm.org/D38793

Files:
  CodeGen/CGExpr.cpp
  CodeGen/CodeGenFunction.h


Index: CodeGen/CodeGenFunction.h
===
--- CodeGen/CodeGenFunction.h
+++ CodeGen/CodeGenFunction.h
@@ -1944,7 +1944,8 @@
LValueBaseInfo *BaseInfo = nullptr);
 
   Address EmitLoadOfReference(Address Ref, const ReferenceType *RefTy,
-  LValueBaseInfo *BaseInfo = nullptr);
+  LValueBaseInfo *BaseInfo = nullptr,
+  TBAAAccessInfo *TBAAInfo = nullptr);
   LValue EmitLoadOfReferenceLValue(Address Ref, const ReferenceType *RefTy);
 
   Address EmitLoadOfPointer(Address Ptr, const PointerType *PtrTy,
Index: CodeGen/CGExpr.cpp
===
--- CodeGen/CGExpr.cpp
+++ CodeGen/CGExpr.cpp
@@ -2149,18 +2149,22 @@
 
 Address CodeGenFunction::EmitLoadOfReference(Address Addr,
  const ReferenceType *RefTy,
- LValueBaseInfo *BaseInfo) {
+ LValueBaseInfo *BaseInfo,
+ TBAAAccessInfo *TBAAInfo) {
+  if (TBAAInfo)
+*TBAAInfo = CGM.getTBAAAccessInfo(RefTy->getPointeeType());
+
   llvm::Value *Ptr = Builder.CreateLoad(Addr);
   return Address(Ptr, getNaturalTypeAlignment(RefTy->getPointeeType(),
   BaseInfo, /*forPointee*/ true));
 }
 
 LValue CodeGenFunction::EmitLoadOfReferenceLValue(Address RefAddr,
   const ReferenceType *RefTy) {
   LValueBaseInfo BaseInfo;
-  Address Addr = EmitLoadOfReference(RefAddr, RefTy, &BaseInfo);
-  return MakeAddrLValue(Addr, RefTy->getPointeeType(), BaseInfo,
-CGM.getTBAAAccessInfo(RefTy->getPointeeType()));
+  TBAAAccessInfo TBAAInfo;
+  Address Addr = EmitLoadOfReference(RefAddr, RefTy, &BaseInfo, &TBAAInfo);
+  return MakeAddrLValue(Addr, RefTy->getPointeeType(), BaseInfo, TBAAInfo);
 }
 
 Address CodeGenFunction::EmitLoadOfPointer(Address Ptr,


Index: CodeGen/CodeGenFunction.h
===
--- CodeGen/CodeGenFunction.h
+++ CodeGen/CodeGenFunction.h
@@ -1944,7 +1944,8 @@
LValueBaseInfo *BaseInfo = nullptr);
 
   Address EmitLoadOfReference(Address Ref, const ReferenceType *RefTy,
-  LValueBaseInfo *BaseInfo = nullptr);
+  LValueBaseInfo *BaseInfo = nullptr,
+  TBAAAccessInfo *TBAAInfo = nullptr);
   LValue EmitLoadOfReferenceLValue(Address Ref, const ReferenceType *RefTy);
 
   Address EmitLoadOfPointer(Address Ptr, const PointerType *PtrTy,
Index: CodeGen/CGExpr.cpp
===
--- CodeGen/CGExpr.cpp
+++ CodeGen/CGExpr.cpp
@@ -2149,18 +2149,22 @@
 
 Address CodeGenFunction::EmitLoadOfReference(Address Addr,
  const ReferenceType *RefTy,
- LValueBaseInfo *BaseInfo) {
+ LValueBaseInfo *BaseInfo,
+ TBAAAccessInfo *TBAAInfo) {
+  if (TBAAInfo)
+*TBAAInfo = CGM.getTBAAAccessInfo(RefTy->getPointeeType());
+
   llvm::Value *Ptr = Builder.CreateLoad(Addr);
   return Address(Ptr, getNaturalTypeAlignment(RefTy->getPointeeType(),
   BaseInfo, /*forPointee*/ true));
 }
 
 LValue CodeGenFunction::EmitLoadOfReferenceLValue(Address RefAddr,
   const ReferenceType *RefTy) {
   LValueBaseInfo BaseInfo;
-  Address Addr = EmitLoadOfReference(RefAddr, RefTy, &BaseInfo);
-  return MakeAddrLValue(Addr, RefTy->getPointeeType(), BaseInfo,
-CGM.getTBAAAccessInfo(RefTy->getPointeeType()));
+  TBAAAccessInfo TBAAInfo;
+  Address Addr = EmitLoadOfReference(RefAddr, RefTy, &BaseInfo, &TBAAInfo);
+  return MakeAddrLValue(Addr, RefTy->getPointeeType(), BaseInfo, TBAAInfo);
 }
 
 Address CodeGenFunction::EmitLoadOfPointer(Address Ptr,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38794: [CodeGen] getNaturalTypeAlignment() to generate TBAA info along with LValue base info

2017-10-11 Thread Ivan A. Kosarev via Phabricator via cfe-commits
kosarev created this revision.
kosarev added a project: clang.

This patch should not bring in any functional changes. Prepared on top of 
https://reviews.llvm.org/D38733, https://reviews.llvm.org/D38788,  
https://reviews.llvm.org/D38791 and https://reviews.llvm.org/D38793.


Repository:
  rL LLVM

https://reviews.llvm.org/D38794

Files:
  CodeGen/CGClass.cpp
  CodeGen/CGExpr.cpp
  CodeGen/CodeGenFunction.cpp
  CodeGen/CodeGenFunction.h

Index: CodeGen/CodeGenFunction.h
===
--- CodeGen/CodeGenFunction.h
+++ CodeGen/CodeGenFunction.h
@@ -1939,6 +1939,7 @@
   LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T);
   CharUnits getNaturalTypeAlignment(QualType T,
 LValueBaseInfo *BaseInfo = nullptr,
+TBAAAccessInfo *TBAAInfo = nullptr,
 bool forPointeeType = false);
   CharUnits getNaturalPointeeTypeAlignment(QualType T,
LValueBaseInfo *BaseInfo = nullptr);
Index: CodeGen/CodeGenFunction.cpp
===
--- CodeGen/CodeGenFunction.cpp
+++ CodeGen/CodeGenFunction.cpp
@@ -120,12 +120,17 @@
 CharUnits CodeGenFunction::getNaturalPointeeTypeAlignment(QualType T,
 LValueBaseInfo *BaseInfo) {
   return getNaturalTypeAlignment(T->getPointeeType(), BaseInfo,
- /*forPointee*/ true);
+ /* TBAAInfo= */ nullptr,
+ /* forPointeeType= */ true);
 }
 
 CharUnits CodeGenFunction::getNaturalTypeAlignment(QualType T,
LValueBaseInfo *BaseInfo,
+   TBAAAccessInfo *TBAAInfo,
bool forPointeeType) {
+  if (TBAAInfo)
+*TBAAInfo = CGM.getTBAAAccessInfo(T);
+
   // Honor alignment typedef attributes even on incomplete types.
   // We also honor them straight for C++ class types, even as pointees;
   // there's an expressivity gap here.
@@ -169,19 +174,21 @@
 
 LValue CodeGenFunction::MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T) {
   LValueBaseInfo BaseInfo;
-  CharUnits Alignment = getNaturalTypeAlignment(T, &BaseInfo);
+  TBAAAccessInfo TBAAInfo;
+  CharUnits Alignment = getNaturalTypeAlignment(T, &BaseInfo, &TBAAInfo);
   return LValue::MakeAddr(Address(V, Alignment), T, getContext(), BaseInfo,
-  CGM.getTBAAAccessInfo(T));
+  TBAAInfo);
 }
 
 /// Given a value of type T* that may not be to a complete object,
 /// construct an l-value with the natural pointee alignment of T.
 LValue
 CodeGenFunction::MakeNaturalAlignPointeeAddrLValue(llvm::Value *V, QualType T) {
   LValueBaseInfo BaseInfo;
-  CharUnits Align = getNaturalTypeAlignment(T, &BaseInfo, /*pointee*/ true);
-  return MakeAddrLValue(Address(V, Align), T, BaseInfo,
-CGM.getTBAAAccessInfo(T));
+  TBAAAccessInfo TBAAInfo;
+  CharUnits Align = getNaturalTypeAlignment(T, &BaseInfo, &TBAAInfo,
+/* forPointeeType= */ true);
+  return MakeAddrLValue(Address(V, Align), T, BaseInfo, TBAAInfo);
 }
 
 
Index: CodeGen/CGExpr.cpp
===
--- CodeGen/CGExpr.cpp
+++ CodeGen/CGExpr.cpp
@@ -2151,12 +2151,10 @@
  const ReferenceType *RefTy,
  LValueBaseInfo *BaseInfo,
  TBAAAccessInfo *TBAAInfo) {
-  if (TBAAInfo)
-*TBAAInfo = CGM.getTBAAAccessInfo(RefTy->getPointeeType());
-
   llvm::Value *Ptr = Builder.CreateLoad(Addr);
   return Address(Ptr, getNaturalTypeAlignment(RefTy->getPointeeType(),
-  BaseInfo, /*forPointee*/ true));
+  BaseInfo, TBAAInfo,
+  /* forPointeeType= */ true));
 }
 
 LValue CodeGenFunction::EmitLoadOfReferenceLValue(Address RefAddr,
@@ -2171,12 +2169,9 @@
const PointerType *PtrTy,
LValueBaseInfo *BaseInfo,
TBAAAccessInfo *TBAAInfo) {
-  if (TBAAInfo)
-*TBAAInfo = CGM.getTBAAAccessInfo(PtrTy->getPointeeType());
-
   llvm::Value *Addr = Builder.CreateLoad(Ptr);
   return Address(Addr, getNaturalTypeAlignment(PtrTy->getPointeeType(),
-   BaseInfo,
+   BaseInfo, TBAAInfo,
/*forPointeeType=*/true));
 }
 
@@ -2315,8 +2310,10 @@
   // FIXME: Eventually we will want to emit vector element re

[PATCH] D38723: [clang-rename] Don't add prefix qualifiers to the declaration and definition of the renamed symbol.

2017-10-11 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315452: [clang-rename] Don't add prefix qualifiers to the 
declaration and definition of… (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D38723?vs=118573&id=118587#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38723

Files:
  cfe/trunk/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
  cfe/trunk/unittests/Rename/RenameClassTest.cpp

Index: cfe/trunk/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
===
--- cfe/trunk/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
+++ cfe/trunk/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
@@ -160,13 +160,14 @@
 const Decl *Context;
 // The nested name being replaced (can be nullptr).
 const NestedNameSpecifier *Specifier;
+// Determine whether the prefix qualifiers of the NewName should be ignored.
+// Normally, we set it to true for the symbol declaration and definition to
+// avoid adding prefix qualifiers.
+// For example, if it is true and NewName is "a::b::foo", then the symbol
+// occurrence which the RenameInfo points to will be renamed to "foo".
+bool IgnorePrefixQualifers;
   };
 
-  // FIXME: Currently, prefix qualifiers will be added to the renamed symbol
-  // definition (e.g. "class Foo {};" => "class b::Bar {};" when renaming
-  // "a::Foo" to "b::Bar").
-  // For renaming declarations/definitions, prefix qualifiers should be filtered
-  // out.
   bool VisitNamedDecl(const NamedDecl *Decl) {
 // UsingDecl has been handled in other place.
 if (llvm::isa(Decl))
@@ -180,8 +181,12 @@
   return true;
 
 if (isInUSRSet(Decl)) {
-  RenameInfo Info = {Decl->getLocation(), Decl->getLocation(), nullptr,
- nullptr, nullptr};
+  RenameInfo Info = {Decl->getLocation(),
+ Decl->getLocation(),
+ /*FromDecl=*/nullptr,
+ /*Context=*/nullptr,
+ /*Specifier=*/nullptr,
+ /*IgnorePrefixQualifers=*/true};
   RenameInfos.push_back(Info);
 }
 return true;
@@ -191,8 +196,11 @@
 const NamedDecl *Decl = Expr->getFoundDecl();
 if (isInUSRSet(Decl)) {
   RenameInfo Info = {Expr->getSourceRange().getBegin(),
- Expr->getSourceRange().getEnd(), Decl,
- getClosestAncestorDecl(*Expr), Expr->getQualifier()};
+ Expr->getSourceRange().getEnd(),
+ Decl,
+ getClosestAncestorDecl(*Expr),
+ Expr->getQualifier(),
+ /*IgnorePrefixQualifers=*/false};
   RenameInfos.push_back(Info);
 }
 
@@ -220,8 +228,10 @@
   if (isInUSRSet(TargetDecl)) {
 RenameInfo Info = {NestedLoc.getBeginLoc(),
EndLocationForType(NestedLoc.getTypeLoc()),
-   TargetDecl, getClosestAncestorDecl(NestedLoc),
-   NestedLoc.getNestedNameSpecifier()->getPrefix()};
+   TargetDecl,
+   getClosestAncestorDecl(NestedLoc),
+   NestedLoc.getNestedNameSpecifier()->getPrefix(),
+   /*IgnorePrefixQualifers=*/false};
 RenameInfos.push_back(Info);
   }
 }
@@ -265,9 +275,12 @@
 if (!ParentTypeLoc.isNull() &&
 isInUSRSet(getSupportedDeclFromTypeLoc(ParentTypeLoc)))
   return true;
-RenameInfo Info = {StartLocationForType(Loc), EndLocationForType(Loc),
-   TargetDecl, getClosestAncestorDecl(Loc),
-   GetNestedNameForType(Loc)};
+RenameInfo Info = {StartLocationForType(Loc),
+   EndLocationForType(Loc),
+   TargetDecl,
+   getClosestAncestorDecl(Loc),
+   GetNestedNameForType(Loc),
+   /*IgnorePrefixQualifers=*/false};
 RenameInfos.push_back(Info);
 return true;
   }
@@ -293,11 +306,13 @@
 llvm::isa(ParentTypeLoc.getType()))
   TargetLoc = ParentTypeLoc;
 RenameInfo Info = {
-StartLocationForType(TargetLoc), EndLocationForType(TargetLoc),
+StartLocationForType(TargetLoc),
+EndLocationForType(TargetLoc),
 TemplateSpecType->getTemplateName().getAsTemplateDecl(),
 getClosestAncestorDecl(
 ast_type_traits::DynTypedNode::create(TargetLoc)),
-GetNestedNameForType(TargetLoc)};
+GetNestedNameForType(TargetLoc),
+/*IgnorePrefixQualifers=*/false};
 RenameInfos.push_back(Info);
   }
 }
@@ -423,18 +438,26 @@
 
   for (const auto &RenameInfo : Finder.getRenameInfos()) {
 std::string ReplacedName = 

r315452 - [clang-rename] Don't add prefix qualifiers to the declaration and definition of the renamed symbol.

2017-10-11 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed Oct 11 04:15:48 2017
New Revision: 315452

URL: http://llvm.org/viewvc/llvm-project?rev=315452&view=rev
Log:
[clang-rename] Don't add prefix qualifiers to the declaration and definition of 
the renamed symbol.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: klimek, cfe-commits, arphaman

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

Modified:
cfe/trunk/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
cfe/trunk/unittests/Rename/RenameClassTest.cpp

Modified: cfe/trunk/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp?rev=315452&r1=315451&r2=315452&view=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp Wed Oct 11 
04:15:48 2017
@@ -160,13 +160,14 @@ public:
 const Decl *Context;
 // The nested name being replaced (can be nullptr).
 const NestedNameSpecifier *Specifier;
+// Determine whether the prefix qualifiers of the NewName should be 
ignored.
+// Normally, we set it to true for the symbol declaration and definition to
+// avoid adding prefix qualifiers.
+// For example, if it is true and NewName is "a::b::foo", then the symbol
+// occurrence which the RenameInfo points to will be renamed to "foo".
+bool IgnorePrefixQualifers;
   };
 
-  // FIXME: Currently, prefix qualifiers will be added to the renamed symbol
-  // definition (e.g. "class Foo {};" => "class b::Bar {};" when renaming
-  // "a::Foo" to "b::Bar").
-  // For renaming declarations/definitions, prefix qualifiers should be 
filtered
-  // out.
   bool VisitNamedDecl(const NamedDecl *Decl) {
 // UsingDecl has been handled in other place.
 if (llvm::isa(Decl))
@@ -180,8 +181,12 @@ public:
   return true;
 
 if (isInUSRSet(Decl)) {
-  RenameInfo Info = {Decl->getLocation(), Decl->getLocation(), nullptr,
- nullptr, nullptr};
+  RenameInfo Info = {Decl->getLocation(),
+ Decl->getLocation(),
+ /*FromDecl=*/nullptr,
+ /*Context=*/nullptr,
+ /*Specifier=*/nullptr,
+ /*IgnorePrefixQualifers=*/true};
   RenameInfos.push_back(Info);
 }
 return true;
@@ -191,8 +196,11 @@ public:
 const NamedDecl *Decl = Expr->getFoundDecl();
 if (isInUSRSet(Decl)) {
   RenameInfo Info = {Expr->getSourceRange().getBegin(),
- Expr->getSourceRange().getEnd(), Decl,
- getClosestAncestorDecl(*Expr), Expr->getQualifier()};
+ Expr->getSourceRange().getEnd(),
+ Decl,
+ getClosestAncestorDecl(*Expr),
+ Expr->getQualifier(),
+ /*IgnorePrefixQualifers=*/false};
   RenameInfos.push_back(Info);
 }
 
@@ -220,8 +228,10 @@ public:
   if (isInUSRSet(TargetDecl)) {
 RenameInfo Info = {NestedLoc.getBeginLoc(),
EndLocationForType(NestedLoc.getTypeLoc()),
-   TargetDecl, getClosestAncestorDecl(NestedLoc),
-   NestedLoc.getNestedNameSpecifier()->getPrefix()};
+   TargetDecl,
+   getClosestAncestorDecl(NestedLoc),
+   NestedLoc.getNestedNameSpecifier()->getPrefix(),
+   /*IgnorePrefixQualifers=*/false};
 RenameInfos.push_back(Info);
   }
 }
@@ -265,9 +275,12 @@ public:
 if (!ParentTypeLoc.isNull() &&
 isInUSRSet(getSupportedDeclFromTypeLoc(ParentTypeLoc)))
   return true;
-RenameInfo Info = {StartLocationForType(Loc), EndLocationForType(Loc),
-   TargetDecl, getClosestAncestorDecl(Loc),
-   GetNestedNameForType(Loc)};
+RenameInfo Info = {StartLocationForType(Loc),
+   EndLocationForType(Loc),
+   TargetDecl,
+   getClosestAncestorDecl(Loc),
+   GetNestedNameForType(Loc),
+   /*IgnorePrefixQualifers=*/false};
 RenameInfos.push_back(Info);
 return true;
   }
@@ -293,11 +306,13 @@ public:
 llvm::isa(ParentTypeLoc.getType()))
   TargetLoc = ParentTypeLoc;
 RenameInfo Info = {
-StartLocationForType(TargetLoc), EndLocationForType(TargetLoc),
+StartLocationForType(TargetLoc),
+EndLocationForType(TargetLoc),
 TemplateSpecType->getTemplateName().getAsTemplateDecl(),
 getClosestAncestorDecl(
 ast_type_traits::DynTypedNode::create(TargetLoc)),
-GetNestedNameForTy

r315453 - [OpenCL] Allow function declaration with empty argument list.

2017-10-11 Thread Alexey Bader via cfe-commits
Author: bader
Date: Wed Oct 11 04:16:31 2017
New Revision: 315453

URL: http://llvm.org/viewvc/llvm-project?rev=315453&view=rev
Log:
[OpenCL] Allow function declaration with empty argument list.

Treat 'f()' as 'f(void)' rather than a function w/o a prototype.

Reviewers: Anastasia, yaxunl

Reviewed By: Anastasia, yaxunl

Subscribers: cfe-commits, echuraev, chapuni

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

Re-apply revision 306653.


Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaOpenCL/func.cl
cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=315453&r1=315452&r2=315453&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Wed Oct 11 04:16:31 2017
@@ -5989,7 +5989,8 @@ void Parser::ParseFunctionDeclarator(Dec
 else if (RequiresArg)
   Diag(Tok, diag::err_argument_required_after_attribute);
 
-HasProto = ParamInfo.size() || getLangOpts().CPlusPlus;
+HasProto = ParamInfo.size() || getLangOpts().CPlusPlus
+|| getLangOpts().OpenCL;
 
 // If we have the closing ')', eat it.
 Tracker.consumeClose();

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=315453&r1=315452&r2=315453&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed Oct 11 04:16:31 2017
@@ -4460,7 +4460,8 @@ static TypeSourceInfo *GetFullTypeForDec
 
   FunctionType::ExtInfo EI(getCCForDeclaratorChunk(S, D, FTI, chunkIndex));
 
-  if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus) {
+  if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus
+&& !LangOpts.OpenCL) {
 // Simple void foo(), where the incoming T is the result type.
 T = Context.getFunctionNoProtoType(T, EI);
   } else {

Modified: cfe/trunk/test/SemaOpenCL/func.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/func.cl?rev=315453&r1=315452&r2=315453&view=diff
==
--- cfe/trunk/test/SemaOpenCL/func.cl (original)
+++ cfe/trunk/test/SemaOpenCL/func.cl Wed Oct 11 04:16:31 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -triple 
spir-unknown-unknown
 
 // Variadic functions
 void vararg_f(int, ...);// expected-error {{invalid 
prototype, variadic arguments are not allowed in OpenCL}}
@@ -16,6 +16,9 @@ typedef struct s
 //Function pointer
 void foo(void*);
 
+// Expect no diagnostics for an empty parameter list.
+void bar();
+
 void bar()
 {
   // declaring a function pointer is an error

Modified: cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl?rev=315453&r1=315452&r2=315453&view=diff
==
--- cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl (original)
+++ cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl Wed Oct 11 04:16:31 2017
@@ -3,7 +3,7 @@
 global pipe int gp;// expected-error {{type '__global read_only 
pipe int' can only be used as a function parameter in OpenCL}}
 global reserve_id_t rid;  // expected-error {{the '__global 
reserve_id_t' type cannot be used to declare a program scope variable}}
 
-extern pipe write_only int get_pipe(); // expected-error {{type '__global 
write_only pipe int ()' can only be used as a function parameter in OpenCL}}
+extern pipe write_only int get_pipe(); // expected-error {{type '__global 
write_only pipe int (void)' can only be used as a function parameter in OpenCL}}
 
 kernel void test_invalid_reserved_id(reserve_id_t ID) { // expected-error 
{{'reserve_id_t' cannot be used as the type of a kernel parameter}}
 }


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


[PATCH] D33681: [OpenCL] Allow function declaration with empty argument list.

2017-10-11 Thread Alexey Bader via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315453: [OpenCL] Allow function declaration with empty 
argument list. (authored by bader).

Changed prior to commit:
  https://reviews.llvm.org/D33681?vs=118437&id=118588#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33681

Files:
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/SemaOpenCL/func.cl
  cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl


Index: cfe/trunk/test/SemaOpenCL/func.cl
===
--- cfe/trunk/test/SemaOpenCL/func.cl
+++ cfe/trunk/test/SemaOpenCL/func.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -triple 
spir-unknown-unknown
 
 // Variadic functions
 void vararg_f(int, ...);// expected-error {{invalid 
prototype, variadic arguments are not allowed in OpenCL}}
@@ -16,6 +16,9 @@
 //Function pointer
 void foo(void*);
 
+// Expect no diagnostics for an empty parameter list.
+void bar();
+
 void bar()
 {
   // declaring a function pointer is an error
Index: cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -3,7 +3,7 @@
 global pipe int gp;// expected-error {{type '__global read_only 
pipe int' can only be used as a function parameter in OpenCL}}
 global reserve_id_t rid;  // expected-error {{the '__global 
reserve_id_t' type cannot be used to declare a program scope variable}}
 
-extern pipe write_only int get_pipe(); // expected-error {{type '__global 
write_only pipe int ()' can only be used as a function parameter in OpenCL}}
+extern pipe write_only int get_pipe(); // expected-error {{type '__global 
write_only pipe int (void)' can only be used as a function parameter in OpenCL}}
 
 kernel void test_invalid_reserved_id(reserve_id_t ID) { // expected-error 
{{'reserve_id_t' cannot be used as the type of a kernel parameter}}
 }
Index: cfe/trunk/lib/Sema/SemaType.cpp
===
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -4460,7 +4460,8 @@
 
   FunctionType::ExtInfo EI(getCCForDeclaratorChunk(S, D, FTI, chunkIndex));
 
-  if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus) {
+  if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus
+&& !LangOpts.OpenCL) {
 // Simple void foo(), where the incoming T is the result type.
 T = Context.getFunctionNoProtoType(T, EI);
   } else {
Index: cfe/trunk/lib/Parse/ParseDecl.cpp
===
--- cfe/trunk/lib/Parse/ParseDecl.cpp
+++ cfe/trunk/lib/Parse/ParseDecl.cpp
@@ -5989,7 +5989,8 @@
 else if (RequiresArg)
   Diag(Tok, diag::err_argument_required_after_attribute);
 
-HasProto = ParamInfo.size() || getLangOpts().CPlusPlus;
+HasProto = ParamInfo.size() || getLangOpts().CPlusPlus
+|| getLangOpts().OpenCL;
 
 // If we have the closing ')', eat it.
 Tracker.consumeClose();


Index: cfe/trunk/test/SemaOpenCL/func.cl
===
--- cfe/trunk/test/SemaOpenCL/func.cl
+++ cfe/trunk/test/SemaOpenCL/func.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -triple spir-unknown-unknown
 
 // Variadic functions
 void vararg_f(int, ...);// expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}}
@@ -16,6 +16,9 @@
 //Function pointer
 void foo(void*);
 
+// Expect no diagnostics for an empty parameter list.
+void bar();
+
 void bar()
 {
   // declaring a function pointer is an error
Index: cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -3,7 +3,7 @@
 global pipe int gp;// expected-error {{type '__global read_only pipe int' can only be used as a function parameter in OpenCL}}
 global reserve_id_t rid;  // expected-error {{the '__global reserve_id_t' type cannot be used to declare a program scope variable}}
 
-extern pipe write_only int get_pipe(); // expected-error {{type '__global write_only pipe int ()' can only be used as a function parameter in OpenCL}}
+extern pipe write_only int get_pipe(); // expected-error {{type '__global write_only pipe int (void)' can only be used as a function parameter in OpenCL}}
 
 kernel void test_invalid_reserved_id(reserve_id_t ID) { // expected-error {{'reserve_id_t' cannot be used as the ty

[PATCH] D38795: [CodeGen] emitOMPArraySectionBase() to generate TBAA info along with LValue base info

2017-10-11 Thread Ivan Kosarev via Phabricator via cfe-commits
kosarev created this revision.
kosarev added a project: clang.

Prepared on top of https://reviews.llvm.org/D38733.


Repository:
  rL LLVM

https://reviews.llvm.org/D38795

Files:
  CodeGen/CGExpr.cpp


Index: CodeGen/CGExpr.cpp
===
--- CodeGen/CGExpr.cpp
+++ CodeGen/CGExpr.cpp
@@ -3318,8 +3318,11 @@
 
 static Address emitOMPArraySectionBase(CodeGenFunction &CGF, const Expr *Base,
LValueBaseInfo &BaseInfo,
+   TBAAAccessInfo &TBAAInfo,
QualType BaseTy, QualType ElTy,
bool IsLowerBound) {
+  TBAAInfo = CGF.CGM.getTBAAAccessInfo(ElTy);
+
   LValue BaseLVal;
   if (auto *ASE = dyn_cast(Base->IgnoreParenImpCasts())) {
 BaseLVal = CGF.EmitOMPArraySectionExpr(ASE, IsLowerBound);
@@ -3454,13 +3457,14 @@
 
   Address EltPtr = Address::invalid();
   LValueBaseInfo BaseInfo;
+  TBAAAccessInfo TBAAInfo;
   if (auto *VLA = getContext().getAsVariableArrayType(ResultExprTy)) {
 // The base must be a pointer, which is not an aggregate.  Emit
 // it.  It needs to be emitted first in case it's what captures
 // the VLA bounds.
 Address Base =
-emitOMPArraySectionBase(*this, E->getBase(), BaseInfo, BaseTy,
-VLA->getElementType(), IsLowerBound);
+emitOMPArraySectionBase(*this, E->getBase(), BaseInfo, TBAAInfo,
+BaseTy, VLA->getElementType(), IsLowerBound);
 // The element count here is the total number of non-VLA elements.
 llvm::Value *NumElements = getVLASize(VLA).first;
 
@@ -3496,16 +3500,17 @@
 ResultExprTy, !getLangOpts().isSignedOverflowDefined(),
 /*SignedIndices=*/false, E->getExprLoc());
 BaseInfo = ArrayLV.getBaseInfo();
+TBAAInfo = CGM.getTBAAAccessInfo(ResultExprTy);
   } else {
 Address Base = emitOMPArraySectionBase(*this, E->getBase(), BaseInfo,
-   BaseTy, ResultExprTy, IsLowerBound);
+   TBAAInfo, BaseTy, ResultExprTy,
+   IsLowerBound);
 EltPtr = emitArraySubscriptGEP(*this, Base, Idx, ResultExprTy,
!getLangOpts().isSignedOverflowDefined(),
/*SignedIndices=*/false, E->getExprLoc());
   }
 
-  return MakeAddrLValue(EltPtr, ResultExprTy, BaseInfo,
-CGM.getTBAAAccessInfo(ResultExprTy));
+  return MakeAddrLValue(EltPtr, ResultExprTy, BaseInfo, TBAAInfo);
 }
 
 LValue CodeGenFunction::


Index: CodeGen/CGExpr.cpp
===
--- CodeGen/CGExpr.cpp
+++ CodeGen/CGExpr.cpp
@@ -3318,8 +3318,11 @@
 
 static Address emitOMPArraySectionBase(CodeGenFunction &CGF, const Expr *Base,
LValueBaseInfo &BaseInfo,
+   TBAAAccessInfo &TBAAInfo,
QualType BaseTy, QualType ElTy,
bool IsLowerBound) {
+  TBAAInfo = CGF.CGM.getTBAAAccessInfo(ElTy);
+
   LValue BaseLVal;
   if (auto *ASE = dyn_cast(Base->IgnoreParenImpCasts())) {
 BaseLVal = CGF.EmitOMPArraySectionExpr(ASE, IsLowerBound);
@@ -3454,13 +3457,14 @@
 
   Address EltPtr = Address::invalid();
   LValueBaseInfo BaseInfo;
+  TBAAAccessInfo TBAAInfo;
   if (auto *VLA = getContext().getAsVariableArrayType(ResultExprTy)) {
 // The base must be a pointer, which is not an aggregate.  Emit
 // it.  It needs to be emitted first in case it's what captures
 // the VLA bounds.
 Address Base =
-emitOMPArraySectionBase(*this, E->getBase(), BaseInfo, BaseTy,
-VLA->getElementType(), IsLowerBound);
+emitOMPArraySectionBase(*this, E->getBase(), BaseInfo, TBAAInfo,
+BaseTy, VLA->getElementType(), IsLowerBound);
 // The element count here is the total number of non-VLA elements.
 llvm::Value *NumElements = getVLASize(VLA).first;
 
@@ -3496,16 +3500,17 @@
 ResultExprTy, !getLangOpts().isSignedOverflowDefined(),
 /*SignedIndices=*/false, E->getExprLoc());
 BaseInfo = ArrayLV.getBaseInfo();
+TBAAInfo = CGM.getTBAAAccessInfo(ResultExprTy);
   } else {
 Address Base = emitOMPArraySectionBase(*this, E->getBase(), BaseInfo,
-   BaseTy, ResultExprTy, IsLowerBound);
+   TBAAInfo, BaseTy, ResultExprTy,
+   IsLowerBound);
 EltPtr = emitArraySubscriptGEP(*this, Base, Idx, ResultExprTy,
!getLangOpts().isSignedOverflowDefined(),
/*SignedIndices=*/false, E->getExprLoc());
   }
 
-  return MakeAddrLValue(EltPt

[PATCH] D38728: [analyzer] Use the signature of the primary template for issue hash calculation

2017-10-11 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: lib/StaticAnalyzer/Core/IssueHash.cpp:39
+  // primary template.
+  if (const FunctionDecl *InstantiatedFrom =
+  Target->getInstantiatedFromMemberFunction())

martong wrote:
> Could we use here FunctionDecl::getPrimaryTemplate() ? That seems more 
> general, it handles both specializations and instantiations.
Unfortunately `getPrimaryTemplate` is not sufficient. The function might be a 
member function of a template class. In this case, there is no primary template 
for the function (only for the enclosing class) but it still depends on a 
template parameter.



Comment at: test/Analysis/bug_hash_test.cpp:61
 
-// CHECK: diagnostics
+template 
+T f(T i) {

martong wrote:
> We could add a few more test cases:
> - a function template in class template
> - specializations vs instantiations
> - the combination of the above two (?)
> 
Good point.



Comment at: test/Analysis/bug_hash_test.cpp:1363
 // CHECK-NEXT:  
+// CHECK-NEXT:  
+// CHECK-NEXT:   path

martong wrote:
> I am not sure if this is possible, but could we add unit test just for the 
> `GetSignature` function? Instead of these huge plist files?
> 
> I am thinking something like this:
> https://github.com/martong/friend-stats/blob/ed0c69ea3669c933204c799f59b85cd7b2507c34/ut/FriendFunctionsTest.cpp#L31
I think it is more convenient to use regression test for this purpose than 
unittests. But I replaced the long plist checking with something much more 
concise. 


https://reviews.llvm.org/D38728



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


[PATCH] D38728: [analyzer] Use the signature of the primary template for issue hash calculation

2017-10-11 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: test/Analysis/bug_hash_test.cpp:105
+void g() {
+  TX x;
+  TX xl;

As we discussed, the checking of the equality of the `IssueString` in case of 
`TX` and `TX` is implicit. And as such it is hard to see that it 
is really tested. Perhaps a comment here could indicate this implicit checking 
mechanism.


https://reviews.llvm.org/D38728



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


[PATCH] D37182: [libcxx] Special visibility macros for the experimental library

2017-10-11 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood added a comment.

I have access now, so I'm able to commit this myself.
However it's been a while since it was approved, so I'd be grateful if someone 
could take another look to make sure nothing has changed in the meantime 
(besides potentially needing to re-tag some new APIs).


https://reviews.llvm.org/D37182



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


[PATCH] D35109: [Analyzer] SValBuilder Comparison Rearrangement

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

I tried to extend the type to avoid overflow scenarios. Unfortunately, this 
breaks essential calculations based on the overflow scenarios (e.g. 
ProgramSate::assumeInbound()). So I see no other option than to abandon this 
patch and return to the local solution in the iterator checkers.


https://reviews.llvm.org/D35109



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


[PATCH] D36111: [COFF, ARM64] Add MS builtins __dmb, __dsb, __isb

2017-10-11 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

@mgrang, did you ever get to completing this? I've got a need for this now 
(only `__dmb` so far), and if you don't have time, I can try to finish it.


https://reviews.llvm.org/D36111



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


[PATCH] D38796: [CodeGen] EmitPointerWithAlignment() to generate TBAA info along with LValue base info

2017-10-11 Thread Ivan Kosarev via Phabricator via cfe-commits
kosarev created this revision.
kosarev added a project: clang.

Prepared on top of https://reviews.llvm.org/D38795.


Repository:
  rL LLVM

https://reviews.llvm.org/D38796

Files:
  CodeGen/CGExpr.cpp
  CodeGen/CodeGenFunction.cpp
  CodeGen/CodeGenFunction.h
  CodeGen/CodeGenModule.cpp
  CodeGen/CodeGenModule.h
  CodeGen/CodeGenTBAA.cpp
  CodeGen/CodeGenTBAA.h

Index: CodeGen/CodeGenTBAA.h
===
--- CodeGen/CodeGenTBAA.h
+++ CodeGen/CodeGenTBAA.h
@@ -47,6 +47,12 @@
 : TBAAAccessInfo(/* AccessType= */ nullptr)
   {}
 
+  bool operator==(const TBAAAccessInfo &Other) const {
+return BaseType == Other.BaseType &&
+   AccessType == Other.AccessType &&
+   Offset == Other.Offset;
+  }
+
   /// BaseType - The base/leading access type. May be null if this access
   /// descriptor represents an access that is not considered to be an access
   /// to an aggregate or union member.
@@ -136,6 +142,11 @@
   /// getMayAliasAccessInfo - Get TBAA information that represents may-alias
   /// accesses.
   TBAAAccessInfo getMayAliasAccessInfo();
+
+  /// mergeTBAAInfoForCast - Get merged TBAA information for the purpose of
+  /// type casts.
+  TBAAAccessInfo mergeTBAAInfoForCast(TBAAAccessInfo SourceInfo,
+  TBAAAccessInfo TargetInfo);
 };
 
 }  // end namespace CodeGen
Index: CodeGen/CodeGenTBAA.cpp
===
--- CodeGen/CodeGenTBAA.cpp
+++ CodeGen/CodeGenTBAA.cpp
@@ -309,3 +309,11 @@
 TBAAAccessInfo CodeGenTBAA::getMayAliasAccessInfo() {
   return TBAAAccessInfo(getChar());
 }
+
+TBAAAccessInfo CodeGenTBAA::mergeTBAAInfoForCast(TBAAAccessInfo SourceInfo,
+ TBAAAccessInfo TargetInfo) {
+  TBAAAccessInfo MayAliasInfo = getMayAliasAccessInfo();
+  if (SourceInfo == MayAliasInfo || TargetInfo == MayAliasInfo)
+return MayAliasInfo;
+  return TargetInfo;
+}
Index: CodeGen/CodeGenModule.h
===
--- CodeGen/CodeGenModule.h
+++ CodeGen/CodeGenModule.h
@@ -677,6 +677,11 @@
   /// may-alias accesses.
   TBAAAccessInfo getTBAAMayAliasAccessInfo();
 
+  /// mergeTBAAInfoForCast - Get merged TBAA information for the purposes of
+  /// type casts.
+  TBAAAccessInfo mergeTBAAInfoForCast(TBAAAccessInfo SourceInfo,
+  TBAAAccessInfo TargetInfo);
+
   bool isTypeConstant(QualType QTy, bool ExcludeCtorDtor);
 
   bool isPaddedAtomicType(QualType type);
Index: CodeGen/CodeGenModule.cpp
===
--- CodeGen/CodeGenModule.cpp
+++ CodeGen/CodeGenModule.cpp
@@ -612,6 +612,13 @@
   return TBAA->getMayAliasAccessInfo();
 }
 
+TBAAAccessInfo CodeGenModule::mergeTBAAInfoForCast(TBAAAccessInfo SourceInfo,
+   TBAAAccessInfo TargetInfo) {
+  if (!TBAA)
+return TBAAAccessInfo();
+  return TBAA->mergeTBAAInfoForCast(SourceInfo, TargetInfo);
+}
+
 void CodeGenModule::DecorateInstructionWithTBAA(llvm::Instruction *Inst,
 TBAAAccessInfo TBAAInfo) {
   if (llvm::MDNode *Tag = getTBAAAccessTagInfo(TBAAInfo))
Index: CodeGen/CodeGenFunction.h
===
--- CodeGen/CodeGenFunction.h
+++ CodeGen/CodeGenFunction.h
@@ -1942,7 +1942,8 @@
 TBAAAccessInfo *TBAAInfo = nullptr,
 bool forPointeeType = false);
   CharUnits getNaturalPointeeTypeAlignment(QualType T,
-   LValueBaseInfo *BaseInfo = nullptr);
+   LValueBaseInfo *BaseInfo = nullptr,
+   TBAAAccessInfo *TBAAInfo = nullptr);
 
   Address EmitLoadOfReference(Address Ref, const ReferenceType *RefTy,
   LValueBaseInfo *BaseInfo = nullptr,
@@ -3188,7 +3189,8 @@
   RValue EmitRValueForField(LValue LV, const FieldDecl *FD, SourceLocation Loc);
 
   Address EmitArrayToPointerDecay(const Expr *Array,
-  LValueBaseInfo *BaseInfo = nullptr);
+  LValueBaseInfo *BaseInfo = nullptr,
+  TBAAAccessInfo *TBAAInfo = nullptr);
 
   class ConstantEmission {
 llvm::PointerIntPair ValueAndIsReference;
@@ -3910,7 +3912,8 @@
   /// reasonable to just ignore the returned alignment when it isn't from an
   /// explicit source.
   Address EmitPointerWithAlignment(const Expr *Addr,
-   LValueBaseInfo *BaseInfo = nullptr);
+   LValueBaseInfo *BaseInfo = nullptr,
+   TBAAAccessInfo *TBAAInfo = nullptr);
 
   void EmitSanitizerStatReport(llvm::SanitizerStatKind SSK);
 
Index: CodeGen/CodeGenFuncti

[PATCH] D38797: [analyzer] CStringChecker: pr34460: Admit that some casts are hard to model.

2017-10-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
Herald added a subscriber: szepet.

In https://bugs.llvm.org/show_bug.cgi?id=34460 CStringChecker tries to 
`evalCast()` a memory region from `void *` to `char *` for the purposes of 
modeling `mempcpy()`. The memory region turned out to be an element region of 
type `unsigned int` with a symbolic index. For such regions, even such trivial 
casts have turned out to be unsupported (modeled as `UnknownVal`), and the 
checker crashed upon asserting them to be supported.

I tried to get such trivial cast working for a few days and ended up believing 
that it not worth the effort because of:

1. How we represent casts in the SVal hierarchy.
  - In our case, the region is an ElementRegion with element type `unsigned 
int`, which //essentially// represents a pointer of type `unsigned int *`, not 
`void *`. It means that the cast is definitely not a no-op; the region needs to 
be modified.
  - Now, if the offset was concrete, we already try to replace ElementRegion 
with another ElementRegion of the other type, and recompute element index 
accordingly. It is only possible if byte offset of the region is divisible by 
size of the target type (in our case it is because the target type is `char`). 
If it's not divisible, we make two ElementRegions on top of each other, first 
with element-type `char` to represent a raw offset, other of the target type to 
represent the cast. It means that for symbolic index case, we need to account 
for being able to receive such two-element-regions construct in the first 
place, and then investigate divisibility of a linear expression of form `a*N + 
b`, where `N` is concrete but `a` and `b` are possibly symbolic, to  a concrete 
type size, which our range constraint manager would never handle.
  - In fact, now we not only unpack the top one or two ElementRegions while 
computing the offset (that needs to be divisible), but also we unpack all other 
top-level element regions (i.e. if we look into a multi-dimensional array; see 
`ElementRegion::getAsArrayOffset()`). This was never tested; i added relevant 
tests into `casts.c` in this patch to demonstrate the problems caused by that 
(which are unrelated to the rest of the patch). I believe that unpacking 
multi-dimensional arrays in this way is not ideal; however, i also added tests 
that would fail if this behavior is disabled. This needs much more work. Of 
course, this work would be even harder if we intend to support symbolic offsets.
2. How we split the responsibilities between entities. When trying to implement 
the plan described in 1., i ended up moving a lot of code around and passing 
ProgramState through dozens of APIs. We need the state to perform binary 
operations on `SVal` objects through `SValBuilder`. Originally, `castRegion()` 
resides in `RegionStore` which is not intended to access the program state. It 
is trivial to move `castRegion` to `SimpleSValBuilder`, but passing `State` 
into it results in a huge cascade of changes in `SValBuilder` method arguments. 
I have given up when i had to pass `State` to 
`SValBuilder::getConstantVal(const Expr *);`, which seemed ridiculous (it's 
constant, why does it depend on the state?). Introducing all this complexity 
only to compute an `SVal` that nobody would be able to understand was not worth 
the effort, in my opinion.

Hence the quick fix. Code slightly simplified to use a more high-level API.


https://reviews.llvm.org/D38797

Files:
  lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  test/Analysis/bstring.cpp
  test/Analysis/casts.c

Index: test/Analysis/casts.c
===
--- test/Analysis/casts.c
+++ test/Analysis/casts.c
@@ -123,3 +123,29 @@
   int x = (int) p;
   clang_analyzer_eval(++x < 10); // no-crash // expected-warning{{UNKNOWN}}
 }
+
+void multiDimensionalArrayPointerCasts() {
+  static int x[10][10];
+  int *y1 = &(x[3][5]);
+  char *z = ((char *) y1) + 2;
+  int *y2 = (int *)(z - 2);
+  int *y3 = ((int *)x) + 35; // This is offset for [3][5].
+
+  clang_analyzer_eval(y1 == y2); // expected-warning{{TRUE}}
+
+  // FIXME: should be FALSE (i.e. equal pointers).
+  clang_analyzer_eval(y1 - y2); // expected-warning{{UNKNOWN}}
+  // FIXME: should be TRUE (i.e. same symbol).
+  clang_analyzer_eval(*y1 == *y2); // expected-warning{{UNKNOWN}}
+
+  clang_analyzer_eval(*((char *)y1) == *((char *) y2)); // expected-warning{{TRUE}}
+
+  clang_analyzer_eval(y1 == y3); // expected-warning{{TRUE}}
+
+  // FIXME: should be FALSE (i.e. equal pointers).
+  clang_analyzer_eval(y1 - y3); // expected-warning{{UNKNOWN}}
+  // FIXME: should be TRUE (i.e. same symbol).
+  clang_analyzer_eval(*y1 == *y3); // expected-warning{{UNKNOWN}}
+
+  clang_analyzer_eval(*((char *)y1) == *((char *) y3)); // expected-warning{{TRUE}}
+}
Index: test/Analysis/bstring.cpp
===
--- test/Analysis/bstring.cpp
+++ test/Analysis/bstring.cpp
@@ -1,8 +1,35 @

[PATCH] D38797: [analyzer] CStringChecker: pr34460: Admit that some casts are hard to model.

2017-10-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: test/Analysis/casts.c:134-139
+  clang_analyzer_eval(y1 == y2); // expected-warning{{TRUE}}
+
+  // FIXME: should be FALSE (i.e. equal pointers).
+  clang_analyzer_eval(y1 - y2); // expected-warning{{UNKNOWN}}
+  // FIXME: should be TRUE (i.e. same symbol).
+  clang_analyzer_eval(*y1 == *y2); // expected-warning{{UNKNOWN}}

Here we have `y1` pointing to `element{element{x, 3}, 5}` vs. both `y2` and 
`y3` pointing to `element{x, 35}`. While `y3` is inevitably looking like that, 
`y2` could have been same as `y1` if we didn't unwrap multi-dimensional array 
elements.


https://reviews.llvm.org/D38797



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


[PATCH] D37856: [refactor] add support for refactoring options

2017-10-11 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Sorry for the delay. I saw you have reverted this commit somehow. A post commit.




Comment at: cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp:113
 Rules.push_back(createRefactoringActionRule(
-SymbolSelectionRequirement()));
+SymbolSelectionRequirement(), OptionRequirement()));
 return Rules;

Thought it a bit more: it requires all of the requirements are satisfied, I 
think we need to support "one-of" option. For example,  we have two option "-a" 
and "-b",  only one of them is allowed to be present at the same time.


Repository:
  rL LLVM

https://reviews.llvm.org/D37856



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


r315459 - [clang-rename] Add more unittest.

2017-10-11 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed Oct 11 07:00:42 2017
New Revision: 315459

URL: http://llvm.org/viewvc/llvm-project?rev=315459&view=rev
Log:
[clang-rename] Add more unittest.

Modified:
cfe/trunk/unittests/Rename/RenameClassTest.cpp

Modified: cfe/trunk/unittests/Rename/RenameClassTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Rename/RenameClassTest.cpp?rev=315459&r1=315458&r2=315459&view=diff
==
--- cfe/trunk/unittests/Rename/RenameClassTest.cpp (original)
+++ cfe/trunk/unittests/Rename/RenameClassTest.cpp Wed Oct 11 07:00:42 2017
@@ -674,6 +674,124 @@ TEST_F(ClangRenameTest, ReferencesInLamb
   CompareSnippets(Expected, After);
 }
 
+TEST_F(ClangRenameTest, DontChangeIfSameName) {
+  std::string Before = R"(
+  namespace foo {
+  class Old {
+   public:
+ static void foo() {}
+  };
+  }
+
+  void f(foo::Old * x) {
+foo::Old::foo() ;
+  }
+  using foo::Old;)";
+  std::string Expected = R"(
+  namespace foo {
+  class Old {
+   public:
+ static void foo() {}
+  };
+  }
+
+  void f(foo::Old * x) {
+foo::Old::foo() ;
+  }
+  using foo::Old;)";
+  std::string After = runClangRenameOnCode(Before, "foo::Old", "foo::Old");
+  CompareSnippets(Expected, After);
+}
+
+TEST_F(ClangRenameTest, ChangeIfNewNameWithLeadingDotDot) {
+  std::string Before = R"(
+  namespace foo {
+  class Old {
+   public:
+ static void foo() {}
+  };
+  }
+
+  void f(foo::Old * x) {
+foo::Old::foo() ;
+  }
+  using foo::Old;)";
+  std::string Expected = R"(
+  namespace foo {
+  class Old {
+   public:
+ static void foo() {}
+  };
+  }
+
+  void f(::foo::Old * x) {
+::foo::Old::foo() ;
+  }
+  using ::foo::Old;)";
+  std::string After = runClangRenameOnCode(Before, "foo::Old", "::foo::Old");
+  CompareSnippets(Expected, After);
+}
+
+TEST_F(ClangRenameTest, ChangeIfSameNameWithLeadingDotDot) {
+  std::string Before = R"(
+  namespace foo {
+  class Old {
+   public:
+ static void foo() {}
+  };
+  }
+
+  void f(foo::Old * x) {
+foo::Old::foo() ;
+  }
+  using foo::Old;)";
+  std::string Expected = R"(
+  namespace foo {
+  class Old {
+   public:
+ static void foo() {}
+  };
+  }
+
+  void f(::foo::Old * x) {
+::foo::Old::foo() ;
+  }
+  using ::foo::Old;)";
+  std::string After = runClangRenameOnCode(Before, "::foo::Old", "::foo::Old");
+  CompareSnippets(Expected, After);
+}
+
+TEST_F(RenameClassTest, UsingAlias) {
+  std::string Before = R"(
+  namespace a { struct A {}; }
+
+  namespace foo {
+  using Alias = a::A;
+  Alias a;
+  })";
+  std::string Expected = R"(
+  namespace a { struct B {}; }
+
+  namespace foo {
+  using Alias = b::B;
+  Alias a;
+  })";
+  std::string After = runClangRenameOnCode(Before, "a::A", "b::B");
+  CompareSnippets(Expected, After);
+}
+
+TEST_F(ClangRenameTest, NestedTemplates) {
+  std::string Before = R"(
+  namespace a { template  struct A {}; }
+  a::A> foo;)";
+  std::string Expected = R"(
+  namespace a { template  struct B {}; }
+  b::B> foo;)";
+  std::string After = runClangRenameOnCode(Before, "a::A", "b::B");
+  CompareSnippets(Expected, After);
+}
+
+
 } // anonymous namespace
 } // namespace test
 } // namespace clang_rename


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


[PATCH] D38798: [OpenMP] Support for implicit "declare target" functions - Sema patch

2017-10-11 Thread George Rokos via Phabricator via cfe-commits
grokos created this revision.
grokos added a project: clang.

This patch completes the support for the "declare target" directive in Sema. 
With this patch Sema handles implicitly used functions (i.e. functions which 
are used inside a target region without having been "declared target") 
including lambdas, templated functions, functions called from within target 
functions and ctors/dtors.

By default, use of implicit declare target functions is enabled. An upcoming 
driver patch will change that.


Repository:
  rL LLVM

https://reviews.llvm.org/D38798

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Sema/Sema.h
  include/clang/Sema/SemaInternal.h
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaOpenMP.cpp

Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -19,6 +19,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclOpenMP.h"
+#include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/StmtOpenMP.h"
 #include "clang/AST/StmtVisitor.h"
@@ -1139,6 +1140,124 @@
   return false;
 }
 
+namespace {
+/// Visit actual function body and its associated nested functions bodies.
+class ImplicitDeviceFunctionChecker
+: public RecursiveASTVisitor {
+  Sema &SemaRef;
+
+public:
+  ImplicitDeviceFunctionChecker(Sema &SemaReference) : SemaRef(SemaReference){};
+
+  /// Traverse body of lambda, and mark it the with OMPDeclareTargetDeclAttr
+  bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C,
+ Expr *Init);
+
+  /// Traverse FunctionDecl and mark it the with OMPDeclareTargetDeclAttr
+  bool VisitFunctionDecl(FunctionDecl *F);
+
+  /// Traverse Callee of Calexpr and mark it the with OMPDeclareTargetDeclAttr
+  bool VisitCallExpr(CallExpr *Call);
+
+  /// Traverse Constructs and mark it the with OMPDeclareTargetDeclAttr
+  bool VisitCXXConstructExpr(CXXConstructExpr *E);
+
+  /// Traverse Destructor and mark it the with OMPDeclareTargetDeclAttr
+  bool VisitCXXDestructorDecl(CXXDestructorDecl *D);
+};
+}
+
+/// Traverse declaration of /param D to check whether it has
+/// OMPDeclareTargetDeclAttr or not. If so, it marks definition with
+/// OMPDeclareTargetDeclAttr.
+static void ImplicitDeclareTargetCheck(Sema &SemaRef, Decl *D) {
+  if (SemaRef.getLangOpts().OpenMPImplicitDeclareTarget) {
+// Structured block of target region is visited to catch function call.
+// Revealed function calls are marked with OMPDeclareTargetDeclAttr
+// attribute,
+// in case -fopenmp-implicit-declare-target extension is enabled.
+ImplicitDeviceFunctionChecker FunctionCallChecker(SemaRef);
+FunctionCallChecker.TraverseDecl(D);
+  }
+}
+
+/// Traverse declaration of /param D to check whether it has
+/// OMPDeclareTargetDeclAttr or not. If so, it marks definition with
+/// OMPDeclareTargetDeclAttr.
+void Sema::checkDeclImplicitlyUsedOpenMPTargetContext(Decl *D) {
+  if (!D || D->isInvalidDecl())
+return;
+
+  if (FunctionDecl *FD = dyn_cast(D)) {
+if (FD->hasBody()) {
+  for (auto RI : FD->redecls()) {
+if (RI->hasAttr()) {
+  Attr *A = OMPDeclareTargetDeclAttr::CreateImplicit(
+  Context, OMPDeclareTargetDeclAttr::MT_To);
+  D->addAttr(A);
+
+  ImplicitDeclareTargetCheck(*this, FD);
+  return;
+}
+  }
+}
+  }
+  return;
+}
+
+bool ImplicitDeviceFunctionChecker::TraverseLambdaCapture(
+LambdaExpr *LE, const LambdaCapture *C, Expr *Init) {
+  if (CXXRecordDecl *Class = LE->getLambdaClass())
+if (!Class->hasAttr()) {
+  Attr *A = OMPDeclareTargetDeclAttr::CreateImplicit(
+  SemaRef.Context, OMPDeclareTargetDeclAttr::MT_To);
+  Class->addAttr(A);
+}
+
+  TraverseStmt(LE->getBody());
+  return true;
+}
+
+bool ImplicitDeviceFunctionChecker::VisitFunctionDecl(FunctionDecl *F) {
+  assert(F);
+  if (!F->hasAttr()) {
+Attr *A = OMPDeclareTargetDeclAttr::CreateImplicit(
+SemaRef.Context, OMPDeclareTargetDeclAttr::MT_To);
+F->addAttr(A);
+TraverseDecl(F);
+  }
+  return true;
+}
+
+bool ImplicitDeviceFunctionChecker::VisitCallExpr(CallExpr *Call) {
+  if (FunctionDecl *Callee = Call->getDirectCallee()) {
+return VisitFunctionDecl(Callee);
+  }
+  return true;
+}
+
+bool ImplicitDeviceFunctionChecker::VisitCXXConstructExpr(CXXConstructExpr *E) {
+  CXXConstructorDecl *Constructor = E->getConstructor();
+  // When constructor is invoked, it is checked whether the object has
+  // destructor or not. In case it has destructor, destructor is automatically
+  // marked with declare target attribute since it is needed to emit for device,
+  QualType Ty = E->getType();
+  const RecordType *RT =
+  SemaRef.Context.getBaseElementType(Ty)->getAs();
+  CXXRecordDecl *RD = cast(RT->getDecl());
+
+  if (auto *Destructor = RD->getDestructor())
+VisitC

[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-11 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs accepted this revision.
jroelofs added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D38679



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


[PATCH] D38801: [analyzer] In getSVal() API, disable auto-detection of void type as char type.

2017-10-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
Herald added a subscriber: szepet.

In https://reviews.llvm.org/D38358, we ended up believing that reading the 
first byte of the void pointer is not the intended behavior of 
`ProgramState::getSVal(Loc)`. Hence the fix.

Additionally, allow specifying the type in the `ProgramState::getSVal(const 
MemRegion *)` override (i personally like this API better, and it is also used 
in the affected checker).


https://reviews.llvm.org/D38801

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
  lib/StaticAnalyzer/Core/RegionStore.cpp


Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -1403,10 +1403,7 @@
 T = Ctx.VoidTy;
 }
 assert(!T.isNull() && "Unable to auto-detect binding type!");
-if (T->isVoidType()) {
-  // When trying to dereference a void pointer, read the first byte.
-  T = Ctx.CharTy;
-}
+assert(!T->isVoidType() && "Attempting to dereference a void pointer!");
 MR = GetElementZeroRegion(cast(MR), T);
   }
 
Index: lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
@@ -179,7 +179,7 @@
 
   if (const MemRegion *SValMemRegion = V.getAsRegion()) {
 const ProgramStateRef State = C.getState();
-const SVal PSV = State->getSVal(SValMemRegion);
+const SVal PSV = State->getSVal(SValMemRegion, C.getASTContext().CharTy);
 if (PSV.isUndef()) {
   if (ExplodedNode *N = C.generateErrorNode()) {
 LazyInit_BT(BD, BT);
Index: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -308,8 +308,12 @@
 
   /// \brief Return the value bound to the specified location.
   /// Returns UnknownVal() if none found.
-  SVal getSVal(const MemRegion* R) const;
+  SVal getSVal(const MemRegion* R, QualType T = QualType()) const;
 
+  /// \brief Return the value bound to the specified location, assuming
+  /// that the value is a scalar integer or an enumeration or a pointer.
+  /// Returns UnknownVal() if none found or the region is not known to hold
+  /// a value of such type.
   SVal getSValAsScalarOrLoc(const MemRegion *R) const;
 
   /// \brief Visits the symbols reachable from the given SVal using the 
provided
@@ -758,9 +762,10 @@
   return getStateManager().StoreMgr->getBinding(getStore(), LV, T);
 }
 
-inline SVal ProgramState::getSVal(const MemRegion* R) const {
+inline SVal ProgramState::getSVal(const MemRegion* R, QualType T) const {
   return getStateManager().StoreMgr->getBinding(getStore(),
-loc::MemRegionVal(R));
+loc::MemRegionVal(R),
+T);
 }
 
 inline BasicValueFactory &ProgramState::getBasicVals() const {


Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -1403,10 +1403,7 @@
 T = Ctx.VoidTy;
 }
 assert(!T.isNull() && "Unable to auto-detect binding type!");
-if (T->isVoidType()) {
-  // When trying to dereference a void pointer, read the first byte.
-  T = Ctx.CharTy;
-}
+assert(!T->isVoidType() && "Attempting to dereference a void pointer!");
 MR = GetElementZeroRegion(cast(MR), T);
   }
 
Index: lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
@@ -179,7 +179,7 @@
 
   if (const MemRegion *SValMemRegion = V.getAsRegion()) {
 const ProgramStateRef State = C.getState();
-const SVal PSV = State->getSVal(SValMemRegion);
+const SVal PSV = State->getSVal(SValMemRegion, C.getASTContext().CharTy);
 if (PSV.isUndef()) {
   if (ExplodedNode *N = C.generateErrorNode()) {
 LazyInit_BT(BD, BT);
Index: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -308,8 +308,12 @@
 
   /// \brief Return the value bound to the specified location.
   /// Returns UnknownVal() if none found.
-  SVal getSVal(const MemRegion* R) const;
+  SVal getSVal(const MemRegion* R, Q

[PATCH] D33722: [clang-tidy] Add checker for undelegated copy of base classes

2017-10-11 Thread Dominik Szabó via Phabricator via cfe-commits
szdominik updated this revision to Diff 118617.
szdominik marked 4 inline comments as done.
szdominik added a comment.

Small changes after aaron.ballman's comments.


https://reviews.llvm.org/D33722

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/CopyConstructorInitCheck.cpp
  clang-tidy/misc/CopyConstructorInitCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-copy-constructor-init.rst
  test/clang-tidy/misc-copy-constructor-init.cpp

Index: test/clang-tidy/misc-copy-constructor-init.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-copy-constructor-init.cpp
@@ -0,0 +1,95 @@
+// RUN: %check_clang_tidy %s misc-copy-constructor-init %t
+
+class Copyable {
+	public:
+	Copyable() = default;
+	Copyable(const Copyable&) = default;
+};
+class X : public Copyable {
+	X(const X& other) : Copyable(other) {}
+	//Good code: the copy ctor call the ctor of the base class.
+};
+
+class Copyable2 {
+	public:
+	Copyable2() = default;
+	Copyable2(const Copyable2&) = default;
+};
+class X2 : public Copyable2 {
+	X2(const X2& other) {};
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X2(const X2& other) : Copyable2(other) {};
+};
+
+class X3 : public Copyable, public Copyable2 {
+	X3(const X3& other): Copyable(other) {};
+	// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X3(const X3& other): Copyable2(other), Copyable(other) {};
+};
+
+class X4 : public Copyable {
+	X4(const X4& other): Copyable() {};
+	// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X4(const X4& other): Copyable(other) {};
+};
+
+class Copyable3 : public Copyable {
+	public:
+	Copyable3() = default;
+	Copyable3(const Copyable3&) = default;
+};
+class X5 : public Copyable3 {
+	X5(const X5& other) {};
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X5(const X5& other) : Copyable3(other) {};
+};
+
+class X6 : public Copyable2, public Copyable3 {
+	X6(const X6& other) {};
+	// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X6(const X6& other) : Copyable2(other), Copyable3(other) {};
+};
+
+class X7 : public Copyable, public Copyable2 {
+	X7(const X7& other): Copyable() {};
+	// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-MESSAGES: :[[@LINE-2]]:22: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X7(const X7& other): Copyable2(other), Copyable(other) {};
+};
+
+template 
+class Copyable4 {
+	public:
+	Copyable4() = default;
+	Copyable4(const Copyable4&) = default;
+};
+
+class X8 : public Copyable4 {
+	X8(const X8& other): Copyable4(other) {};
+	//Good code: the copy ctor call the ctor of the base class.
+};
+
+class X9 : public Copyable4 {
+	X9(const X9& other): Copyable4() {};
+	// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X9(const X9& other): Copyable4(other) {};
+};
+
+class X10 : public Copyable4 {
+	X10(const X10& other) {};
+	// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X10(const X10& other) : Copyable4(other) {};
+};
+
+template 
+class Copyable5 {
+	public:
+	Copyable5() = default;
+	Copyable5(const Copyable5&) = default;
+};
+
+class X11 : public Copyable5 {
+	X11(const X11& other) {};
+	// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: calling an inherited constructor other than the copy constructor [misc-copy-constructor-init]
+	// CHECK-FIXES: X11(const X11& other) : Copyable5(other) {};
+};
Index: docs/clang-tidy/checks/misc-copy-constructor-init.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-copy-constructor-init.rst
@@ -0,0 +1,30 @@
+.. title:: clang-tidy - misc-copy-constructor-init
+
+misc-copy-constructor-init
+=
+
+Finds copy constructors where the constructor don't call 
+the constructor of the base class.
+
+.. code-block:: c++
+
+class Copyable {
+public:
+Copyable() = default;
+Copyable(const Copyable&) = default;
+};
+class X2 : public Copyable {
+X2(const X2& other) {}; // Copyable(other) is missing
+};
+

[PATCH] D33722: [clang-tidy] Add checker for undelegated copy of base classes

2017-10-11 Thread Dominik Szabó via Phabricator via cfe-commits
szdominik added inline comments.



Comment at: clang-tidy/misc/CopyConstructorInitCheck.cpp:37
+
+  // We match here because we want one warning (and FixIt) for every ctor.
+  const auto Matches = match(

aaron.ballman wrote:
> Wouldn't registering this matcher achieve the same goal instead of needing to 
> re-match?
I wanted to create //only one// FixIt to every ctor - if I move the 
forEachCtorInitializer to the register part, it would warn us twice.



Comment at: clang-tidy/misc/CopyConstructorInitCheck.cpp:104
+
+  diag(Tok.getLocation(),
+   "calling an inherited constructor other than the copy constructor")

aaron.ballman wrote:
> Insteaad of having to re-lex the physical source, can the AST should be 
> modified to carry the information you need if it doesn't already have it? For 
> instance, you can tell there is not initializer list by looking at 
> `CXXConstructorDecl::getNumCtorInitializers()`.
The getNumCtorInitializers method counts the generated initializers as well, 
not just the manually written ones.
My basic problem was that the AST's methods can't really distinguish the 
generated and the manually written initializers, so it's quite complicated to 
find the locations what we need. I found easier & more understandable if I 
start reading the tokens.



Comment at: test/clang-tidy/misc-copy-constructor-init.cpp:27
+   // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: calling an inherited 
constructor other than the copy constructor [misc-copy-constructor-init]
+   // CHECK-FIXES: X3(const X3& other): Copyable2(other), Copyable(other) 
{};
+};

aaron.ballman wrote:
> Don't we want the ctor-inits to be in the same order as the bases are 
> specified?
I think it's more readable if we put the FixIts to the beginning of the 
expression - it's easier to check that everyting is correct & it's more obvious 
what the changes are.


https://reviews.llvm.org/D33722



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


[PATCH] D37856: [refactor] add support for refactoring options

2017-10-11 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D37856#894638, @hokein wrote:

> Sorry for the delay. I saw you have reverted this commit somehow. A post 
> commit.


I had some issues with ppc64/s390x bots for some reason, so I had to revert. 
I'm still trying to investigate what went wrong there, it looks like ASAN/UBSAN 
are not catching anything though.




Comment at: cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp:113
 Rules.push_back(createRefactoringActionRule(
-SymbolSelectionRequirement()));
+SymbolSelectionRequirement(), OptionRequirement()));
 return Rules;

hokein wrote:
> Thought it a bit more: it requires all of the requirements are satisfied, I 
> think we need to support "one-of" option. For example,  we have two option 
> "-a" and "-b",  only one of them is allowed to be present at the same time.
That should be straightforward enough to implement, either with a custom class 
or with a built-in requirement class. I'll probably add a builtin one when the 
need comes up.


Repository:
  rL LLVM

https://reviews.llvm.org/D37856



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


r315462 - [Analyzer] Clarify error messages for undefined result

2017-10-11 Thread Daniel Marjamaki via cfe-commits
Author: danielmarjamaki
Date: Wed Oct 11 07:49:35 2017
New Revision: 315462

URL: http://llvm.org/viewvc/llvm-project?rev=315462&view=rev
Log:
[Analyzer] Clarify error messages for undefined result

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


Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
cfe/trunk/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CheckerContext.cpp
cfe/trunk/test/Analysis/bitwise-ops.c

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h?rev=315462&r1=315461&r2=315462&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h 
Wed Oct 11 07:49:35 2017
@@ -196,6 +196,13 @@ public:
 return getState()->getSVal(S, getLocationContext());
   }
 
+  /// \brief Returns true if the value of \p E is greater than or equal to \p
+  /// Val under unsigned comparison
+  bool isGreaterOrEqual(const Expr *E, unsigned long long Val);
+
+  /// Returns true if the value of \p E is negative.
+  bool isNegative(const Expr *E);
+
   /// \brief Generates a new transition in the program state graph
   /// (ExplodedGraph). Uses the default CheckerContext predecessor node.
   ///

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp?rev=315462&r1=315461&r2=315462&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp Wed Oct 11 
07:49:35 2017
@@ -123,57 +123,6 @@ void ConversionChecker::reportBug(Explod
   C.emitReport(std::move(R));
 }
 
-// Is E value greater or equal than Val?
-static bool isGreaterEqual(CheckerContext &C, const Expr *E,
-   unsigned long long Val) {
-  ProgramStateRef State = C.getState();
-  SVal EVal = C.getSVal(E);
-  if (EVal.isUnknownOrUndef())
-return false;
-  if (!EVal.getAs() && EVal.getAs()) {
-ProgramStateManager &Mgr = C.getStateManager();
-EVal =
-Mgr.getStoreManager().getBinding(State->getStore(), 
EVal.castAs());
-  }
-  if (EVal.isUnknownOrUndef() || !EVal.getAs())
-return false;
-
-  SValBuilder &Bldr = C.getSValBuilder();
-  DefinedSVal V = Bldr.makeIntVal(Val, C.getASTContext().LongLongTy);
-
-  // Is DefinedEVal greater or equal with V?
-  SVal GE = Bldr.evalBinOp(State, BO_GE, EVal, V, Bldr.getConditionType());
-  if (GE.isUnknownOrUndef())
-return false;
-  ConstraintManager &CM = C.getConstraintManager();
-  ProgramStateRef StGE, StLT;
-  std::tie(StGE, StLT) = CM.assumeDual(State, GE.castAs());
-  return StGE && !StLT;
-}
-
-// Is E value negative?
-static bool isNegative(CheckerContext &C, const Expr *E) {
-  ProgramStateRef State = C.getState();
-  SVal EVal = State->getSVal(E, C.getLocationContext());
-  if (EVal.isUnknownOrUndef() || !EVal.getAs())
-return false;
-  DefinedSVal DefinedEVal = EVal.castAs();
-
-  SValBuilder &Bldr = C.getSValBuilder();
-  DefinedSVal V = Bldr.makeIntVal(0, false);
-
-  SVal LT =
-  Bldr.evalBinOp(State, BO_LT, DefinedEVal, V, Bldr.getConditionType());
-
-  // Is E value greater than MaxVal?
-  ConstraintManager &CM = C.getConstraintManager();
-  ProgramStateRef StNegative, StPositive;
-  std::tie(StNegative, StPositive) =
-  CM.assumeDual(State, LT.castAs());
-
-  return StNegative && !StPositive;
-}
-
 bool ConversionChecker::isLossOfPrecision(const ImplicitCastExpr *Cast,
   QualType DestType,
   CheckerContext &C) const {
@@ -195,18 +144,18 @@ bool ConversionChecker::isLossOfPrecisio
 return false;
 
   unsigned long long MaxVal = 1ULL << W;
-  return isGreaterEqual(C, Cast->getSubExpr(), MaxVal);
+  return C.isGreaterOrEqual(Cast->getSubExpr(), MaxVal);
 }
 
 bool ConversionChecker::isLossOfSign(const ImplicitCastExpr *Cast,
-   CheckerContext &C) const {
+ CheckerContext &C) const {
   QualType CastType = Cast->getType();
   QualType SubType = Cast->IgnoreParenImpCasts()->getType();
 
   if (!CastType->isUnsignedIntegerType() || !SubType->isSignedIntegerType())
 return false;
 
-  return isNegative(C, Cast->getSubExpr());
+  return C.isNegative(Cast->getSubExpr());
 }
 
 void ento::registerConversionChecker(CheckerManager &mgr) {

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
URL: 
http://llv

[PATCH] D30295: [analyzer] clarify undef shift result when shift count is negative or exceeds the bit width

2017-10-11 Thread Daniel Marjamäki via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315462: [Analyzer] Clarify error messages for undefined 
result (authored by danielmarjamaki).

Changed prior to commit:
  https://reviews.llvm.org/D30295?vs=116865&id=118620#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30295

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/CheckerContext.cpp
  cfe/trunk/test/Analysis/bitwise-ops.c

Index: cfe/trunk/lib/StaticAnalyzer/Core/CheckerContext.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/CheckerContext.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/CheckerContext.cpp
@@ -99,3 +99,35 @@
   return Lexer::getSpelling(Loc, buf, getSourceManager(), getLangOpts());
 }
 
+/// Evaluate comparison and return true if it's known that condition is true
+static bool evalComparison(SVal LHSVal, BinaryOperatorKind ComparisonOp,
+   SVal RHSVal, ProgramStateRef State) {
+  if (LHSVal.isUnknownOrUndef())
+return false;
+  ProgramStateManager &Mgr = State->getStateManager();
+  if (!LHSVal.getAs()) {
+LHSVal = Mgr.getStoreManager().getBinding(State->getStore(),
+  LHSVal.castAs());
+if (LHSVal.isUnknownOrUndef() || !LHSVal.getAs())
+  return false;
+  }
+
+  SValBuilder &Bldr = Mgr.getSValBuilder();
+  SVal Eval = Bldr.evalBinOp(State, ComparisonOp, LHSVal, RHSVal,
+ Bldr.getConditionType());
+  if (Eval.isUnknownOrUndef())
+return false;
+  ProgramStateRef StTrue, StFalse;
+  std::tie(StTrue, StFalse) = State->assume(Eval.castAs());
+  return StTrue && !StFalse;
+}
+
+bool CheckerContext::isGreaterOrEqual(const Expr *E, unsigned long long Val) {
+  DefinedSVal V = getSValBuilder().makeIntVal(Val, getASTContext().LongLongTy);
+  return evalComparison(getSVal(E), BO_GE, V, getState());
+}
+
+bool CheckerContext::isNegative(const Expr *E) {
+  DefinedSVal V = getSValBuilder().makeIntVal(0, false);
+  return evalComparison(getSVal(E), BO_LT, V, getState());
+}
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
@@ -123,57 +123,6 @@
   C.emitReport(std::move(R));
 }
 
-// Is E value greater or equal than Val?
-static bool isGreaterEqual(CheckerContext &C, const Expr *E,
-   unsigned long long Val) {
-  ProgramStateRef State = C.getState();
-  SVal EVal = C.getSVal(E);
-  if (EVal.isUnknownOrUndef())
-return false;
-  if (!EVal.getAs() && EVal.getAs()) {
-ProgramStateManager &Mgr = C.getStateManager();
-EVal =
-Mgr.getStoreManager().getBinding(State->getStore(), EVal.castAs());
-  }
-  if (EVal.isUnknownOrUndef() || !EVal.getAs())
-return false;
-
-  SValBuilder &Bldr = C.getSValBuilder();
-  DefinedSVal V = Bldr.makeIntVal(Val, C.getASTContext().LongLongTy);
-
-  // Is DefinedEVal greater or equal with V?
-  SVal GE = Bldr.evalBinOp(State, BO_GE, EVal, V, Bldr.getConditionType());
-  if (GE.isUnknownOrUndef())
-return false;
-  ConstraintManager &CM = C.getConstraintManager();
-  ProgramStateRef StGE, StLT;
-  std::tie(StGE, StLT) = CM.assumeDual(State, GE.castAs());
-  return StGE && !StLT;
-}
-
-// Is E value negative?
-static bool isNegative(CheckerContext &C, const Expr *E) {
-  ProgramStateRef State = C.getState();
-  SVal EVal = State->getSVal(E, C.getLocationContext());
-  if (EVal.isUnknownOrUndef() || !EVal.getAs())
-return false;
-  DefinedSVal DefinedEVal = EVal.castAs();
-
-  SValBuilder &Bldr = C.getSValBuilder();
-  DefinedSVal V = Bldr.makeIntVal(0, false);
-
-  SVal LT =
-  Bldr.evalBinOp(State, BO_LT, DefinedEVal, V, Bldr.getConditionType());
-
-  // Is E value greater than MaxVal?
-  ConstraintManager &CM = C.getConstraintManager();
-  ProgramStateRef StNegative, StPositive;
-  std::tie(StNegative, StPositive) =
-  CM.assumeDual(State, LT.castAs());
-
-  return StNegative && !StPositive;
-}
-
 bool ConversionChecker::isLossOfPrecision(const ImplicitCastExpr *Cast,
   QualType DestType,
   CheckerContext &C) const {
@@ -195,18 +144,18 @@
 return false;
 
   unsigned long long MaxVal = 1ULL << W;
-  return isGreaterEqual(C, Cast->getSubExpr(), MaxVal);
+  return C.isGreaterOrEqual(Cast->getSubExpr(), MaxVal);
 }
 
 bool ConversionChecker::isLossOfSign(const ImplicitCastExpr *Cast,
-   CheckerContext &C) const {
+ CheckerContext &C) const {
   QualType CastType = Cast->getType();
   Q

r315463 - [clang-fuzzer] Fix shared library dependencies.

2017-10-11 Thread Matt Morehouse via cfe-commits
Author: morehouse
Date: Wed Oct 11 08:13:53 2017
New Revision: 315463

URL: http://llvm.org/viewvc/llvm-project?rev=315463&view=rev
Log:
[clang-fuzzer] Fix shared library dependencies.

Modified:
cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
cfe/trunk/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt

Modified: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/CMakeLists.txt?rev=315463&r1=315462&r2=315463&view=diff
==
--- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt Wed Oct 11 08:13:53 2017
@@ -37,6 +37,7 @@ if( LLVM_USE_SANITIZE_COVERAGE )
 add_clang_executable(clang-proto-fuzzer ExampleClangProtoFuzzer.cpp)
 target_link_libraries(clang-proto-fuzzer
   ${ProtobufMutator_LIBRARIES}
+  ${PROTOBUF_LIBRARIES}
   clangCXXProto
   clangHandleCXX
   clangProtoToCXX

Modified: cfe/trunk/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/handle-cxx/CMakeLists.txt?rev=315463&r1=315462&r2=315463&view=diff
==
--- cfe/trunk/tools/clang-fuzzer/handle-cxx/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/handle-cxx/CMakeLists.txt Wed Oct 11 08:13:53 
2017
@@ -1,9 +1,10 @@
-set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD})
+set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} Support)
 
 add_clang_library(clangHandleCXX
   handle_cxx.cpp
 
   LINK_LIBS
+  clangBasic
   clangCodeGen
   clangFrontend
   clangLex

Modified: cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt?rev=315463&r1=315462&r2=315463&view=diff
==
--- cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt Wed Oct 11 
08:13:53 2017
@@ -5,9 +5,9 @@ set(CMAKE_CXX_FLAGS ${CXX_FLAGS_NOFUZZ})
 # an executable built from this directory.
 set(LLVM_OPTIONAL_SOURCES proto_to_cxx.cpp proto_to_cxx_main.cpp)
 
-add_clang_library(clangProtoToCXX proto_to_cxx.cpp 
+add_clang_library(clangProtoToCXX proto_to_cxx.cpp
   DEPENDS clangCXXProto
-  LINK_LIBS clangCXXProto
+  LINK_LIBS clangCXXProto ${PROTOBUF_LIBRARIES}
   )
 
 add_clang_executable(clang-proto-to-cxx proto_to_cxx_main.cpp)


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


[PATCH] D23963: [analyzer] pr28449 - Move literal rvalue construction away from RegionStore.

2017-10-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 118625.
NoQ added a comment.
Herald added a subscriber: szepet.

Because i didn't get back to this in a while, and similar crashes keep coming, 
i decided to leave this refactoring as a FIXME.


https://reviews.llvm.org/D23963

Files:
  lib/StaticAnalyzer/Core/RegionStore.cpp
  test/Analysis/compound-literals.c
  test/Analysis/objc-encode.m


Index: test/Analysis/objc-encode.m
===
--- /dev/null
+++ test/Analysis/objc-encode.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.ExprInspection -verify %s
+// expected-no-diagnostics
+
+void clang_analyzer_eval(int);
+
+// rdar://problem/34831581: Used to crash.
+void foo(void) {
+  char buf1[] = @encode(int **);
+}
Index: test/Analysis/compound-literals.c
===
--- /dev/null
+++ test/Analysis/compound-literals.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple=i386-apple-darwin10 -analyze 
-analyzer-checker=debug.ExprInspection -verify %s
+void clang_analyzer_eval(int);
+
+// pr28449: Used to crash.
+void foo(void) {
+  static const unsigned short array[] = (const unsigned short[]){0x0F00};
+  // FIXME: Should be true.
+  clang_analyzer_eval(array[0] == 0x0F00); // expected-warning{{UNKNOWN}}
+}
Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2085,15 +2085,12 @@
   if (const ConstantArrayType* CAT = dyn_cast(AT))
 Size = CAT->getSize().getZExtValue();
 
-  // Check if the init expr is a string literal.
+  // Check if the init expr is a literal. If so, bind the rvalue instead.
+  // FIXME: It's not responsibility of the Store to transform this lvalue
+  // to rvalue. ExprEngine or maybe even CFG should do this before binding.
   if (Optional MRV = Init.getAs()) {
-const StringRegion *S = cast(MRV->getRegion());
-
-// Treat the string as a lazy compound value.
-StoreRef store(B.asStore(), *this);
-nonloc::LazyCompoundVal LCV = svalBuilder.makeLazyCompoundVal(store, S)
-.castAs();
-return bindAggregate(B, R, LCV);
+SVal V = getBinding(B.asStore(), *MRV, R->getValueType());
+return bindAggregate(B, R, V);
   }
 
   // Handle lazy compound values.


Index: test/Analysis/objc-encode.m
===
--- /dev/null
+++ test/Analysis/objc-encode.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.ExprInspection -verify %s
+// expected-no-diagnostics
+
+void clang_analyzer_eval(int);
+
+// rdar://problem/34831581: Used to crash.
+void foo(void) {
+  char buf1[] = @encode(int **);
+}
Index: test/Analysis/compound-literals.c
===
--- /dev/null
+++ test/Analysis/compound-literals.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple=i386-apple-darwin10 -analyze -analyzer-checker=debug.ExprInspection -verify %s
+void clang_analyzer_eval(int);
+
+// pr28449: Used to crash.
+void foo(void) {
+  static const unsigned short array[] = (const unsigned short[]){0x0F00};
+  // FIXME: Should be true.
+  clang_analyzer_eval(array[0] == 0x0F00); // expected-warning{{UNKNOWN}}
+}
Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2085,15 +2085,12 @@
   if (const ConstantArrayType* CAT = dyn_cast(AT))
 Size = CAT->getSize().getZExtValue();
 
-  // Check if the init expr is a string literal.
+  // Check if the init expr is a literal. If so, bind the rvalue instead.
+  // FIXME: It's not responsibility of the Store to transform this lvalue
+  // to rvalue. ExprEngine or maybe even CFG should do this before binding.
   if (Optional MRV = Init.getAs()) {
-const StringRegion *S = cast(MRV->getRegion());
-
-// Treat the string as a lazy compound value.
-StoreRef store(B.asStore(), *this);
-nonloc::LazyCompoundVal LCV = svalBuilder.makeLazyCompoundVal(store, S)
-.castAs();
-return bindAggregate(B, R, LCV);
+SVal V = getBinding(B.asStore(), *MRV, R->getValueType());
+return bindAggregate(B, R, V);
   }
 
   // Handle lazy compound values.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r315464 - [OPENMP] Fix PR34916: Crash on mixing taskloop|tasks directives.

2017-10-11 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Oct 11 08:29:40 2017
New Revision: 315464

URL: http://llvm.org/viewvc/llvm-project?rev=315464&view=rev
Log:
[OPENMP] Fix PR34916: Crash on mixing taskloop|tasks directives.

If both taskloop and task directives are used at the same time in one
program, we may ran into the situation when the particular type for task
directive is reused for taskloop directives. Patch fixes this problem.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/test/OpenMP/taskloop_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=315464&r1=315463&r2=315464&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed Oct 11 08:29:40 2017
@@ -4268,9 +4268,20 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFun
   // Build type kmp_routine_entry_t (if not built yet).
   emitKmpRoutineEntryT(KmpInt32Ty);
   // Build type kmp_task_t (if not built yet).
-  if (KmpTaskTQTy.isNull()) {
-KmpTaskTQTy = C.getRecordType(createKmpTaskTRecordDecl(
-CGM, D.getDirectiveKind(), KmpInt32Ty, KmpRoutineEntryPtrQTy));
+  if (isOpenMPTaskLoopDirective(D.getDirectiveKind())) {
+if (SavedKmpTaskloopTQTy.isNull()) {
+  SavedKmpTaskloopTQTy = C.getRecordType(createKmpTaskTRecordDecl(
+  CGM, D.getDirectiveKind(), KmpInt32Ty, KmpRoutineEntryPtrQTy));
+}
+KmpTaskTQTy = SavedKmpTaskloopTQTy;
+  } else if (D.getDirectiveKind() == OMPD_task) {
+assert(D.getDirectiveKind() == OMPD_task &&
+   "Expected taskloop or task directive");
+if (SavedKmpTaskTQTy.isNull()) {
+  SavedKmpTaskTQTy = C.getRecordType(createKmpTaskTRecordDecl(
+  CGM, D.getDirectiveKind(), KmpInt32Ty, KmpRoutineEntryPtrQTy));
+}
+KmpTaskTQTy = SavedKmpTaskTQTy;
   }
   auto *KmpTaskTQTyRD = cast(KmpTaskTQTy->getAsTagDecl());
   // Build particular struct kmp_task_t for the given task.

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=315464&r1=315463&r2=315464&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Wed Oct 11 08:29:40 2017
@@ -318,6 +318,10 @@ private:
   ///deconstructors of firstprivate C++ objects */
   /// } kmp_task_t;
   QualType KmpTaskTQTy;
+  /// Saved kmp_task_t for task directive.
+  QualType SavedKmpTaskTQTy;
+  /// Saved kmp_task_t for taskloop-based directive.
+  QualType SavedKmpTaskloopTQTy;
   /// \brief Type typedef struct kmp_depend_info {
   ///kmp_intptr_t   base_addr;
   ///size_t len;

Modified: cfe/trunk/test/OpenMP/taskloop_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/taskloop_codegen.cpp?rev=315464&r1=315463&r2=315464&view=diff
==
--- cfe/trunk/test/OpenMP/taskloop_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/taskloop_codegen.cpp Wed Oct 11 08:29:40 2017
@@ -8,6 +8,10 @@
 // CHECK-LABEL: @main
 int main(int argc, char **argv) {
 // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(%ident_t* 
[[DEFLOC:@.+]])
+// CHECK: call i8* @__kmpc_omp_task_alloc(%ident_t* [[DEFLOC]], i32 [[GTID]],
+// CHECK: call i32 @__kmpc_omp_task(%ident_t* [[DEFLOC]], i32 [[GTID]],
+#pragma omp task
+  ;
 // CHECK: call void @__kmpc_taskgroup(%ident_t* [[DEFLOC]], i32 [[GTID]])
 // CHECK: [[TASKV:%.+]] = call i8* @__kmpc_omp_task_alloc(%ident_t* 
[[DEFLOC]], i32 [[GTID]], i32 33, i64 80, i64 1, i32 (i32, i8*)* bitcast (i32 
(i32, [[TDP_TY:%.+]]*)* [[TASK1:@.+]] to i32 (i32, i8*)*))
 // CHECK: [[TASK:%.+]] = bitcast i8* [[TASKV]] to [[TDP_TY]]*


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


[PATCH] D38720: [clangd] Report proper kinds for 'Keyword' and 'Snippet' completion items.

2017-10-11 Thread Raoul Wols via Phabricator via cfe-commits
rwols accepted this revision.
rwols added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D38720



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


[PATCH] D38757: [libc++] Fix PR34898 - vector iterator constructors and assign method perform push_back instead of emplace_back.

2017-10-11 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

LGTM - thanks!


https://reviews.llvm.org/D38757



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


r315465 - Reland "[clang-fuzzer] Allow building without coverage instrumentation."

2017-10-11 Thread Matt Morehouse via cfe-commits
Author: morehouse
Date: Wed Oct 11 08:51:12 2017
New Revision: 315465

URL: http://llvm.org/viewvc/llvm-project?rev=315465&view=rev
Log:
Reland "[clang-fuzzer] Allow building without coverage instrumentation."

This relands r315336 after fixing bot breakage.

Added:
cfe/trunk/tools/clang-fuzzer/DummyClangFuzzer.cpp
Modified:
cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp

Modified: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/CMakeLists.txt?rev=315465&r1=315464&r2=315465&view=diff
==
--- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt Wed Oct 11 08:51:12 2017
@@ -1,61 +1,67 @@
-if( LLVM_USE_SANITIZE_COVERAGE )
-  set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD})
-  set(CXX_FLAGS_NOFUZZ "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer-no-link")
+set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzMutate)
+set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
+set(DUMMY_MAIN DummyClangFuzzer.cpp)
+if(LLVM_USE_SANITIZE_COVERAGE)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
+  set(CXX_FLAGS_NOFUZZ "${CXX_FLAGS_NOFUZZ} -fsanitize=fuzzer-no-link")
+  unset(DUMMY_MAIN)
+endif()
+
+# Hack to bypass LLVM's cmake sources check and allow multiple libraries and
+# executables from this directory.
+set(LLVM_OPTIONAL_SOURCES
+  ClangFuzzer.cpp
+  DummyClangFuzzer.cpp
+  ExampleClangProtoFuzzer.cpp
+  )
+
+if(CLANG_ENABLE_PROTO_FUZZER)
+  # Create protobuf .h and .cc files, and put them in a library for use by
+  # clang-proto-fuzzer components.
+  find_package(Protobuf REQUIRED)
+  add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI)
+  include_directories(${PROTOBUF_INCLUDE_DIRS})
+  include_directories(${CMAKE_CURRENT_BINARY_DIR})
+  protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS cxx_proto.proto)
+  set(LLVM_OPTIONAL_SOURCES ${LLVM_OPTIONAL_SOURCES} ${PROTO_SRCS})
+  add_clang_library(clangCXXProto
+${PROTO_SRCS}
+${PROTO_HDRS}
+
+LINK_LIBS
+${PROTOBUF_LIBRARIES}
+)
 
-  if(CLANG_ENABLE_PROTO_FUZZER)
-# Create protobuf .h and .cc files, and put them in a library for use by
-# clang-proto-fuzzer components.
-find_package(Protobuf REQUIRED)
-add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI)
-include_directories(${PROTOBUF_INCLUDE_DIRS})
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS cxx_proto.proto)
-# Hack to bypass LLVM's cmake sources check and allow multiple libraries 
and
-# executables from this directory.
-set(LLVM_OPTIONAL_SOURCES
-  ClangFuzzer.cpp
-  ExampleClangProtoFuzzer.cpp
-  ${PROTO_SRCS}
-  )
-add_clang_library(clangCXXProto
-  ${PROTO_SRCS}
-  ${PROTO_HDRS}
-
-  LINK_LIBS
-  ${PROTOBUF_LIBRARIES}
-  )
-
-# Build and include libprotobuf-mutator
-include(ProtobufMutator)
-include_directories(${ProtobufMutator_INCLUDE_DIRS})
-
-# Build the protobuf->C++ translation library and driver.
-add_clang_subdirectory(proto-to-cxx)
-
-# Build the protobuf fuzzer
-add_clang_executable(clang-proto-fuzzer ExampleClangProtoFuzzer.cpp)
-target_link_libraries(clang-proto-fuzzer
-  ${ProtobufMutator_LIBRARIES}
-  ${PROTOBUF_LIBRARIES}
-  clangCXXProto
-  clangHandleCXX
-  clangProtoToCXX
-  )
-  else()
-# Hack to bypass LLVM's cmake sources check and allow multiple libraries 
and
-# executables from this directory.
-set(LLVM_OPTIONAL_SOURCES ClangFuzzer.cpp ExampleClangProtoFuzzer.cpp)
-  endif()
-
-  add_clang_subdirectory(handle-cxx)
-
-  add_clang_executable(clang-fuzzer
-EXCLUDE_FROM_ALL
-ClangFuzzer.cpp
+  # Build and include libprotobuf-mutator
+  include(ProtobufMutator)
+  include_directories(${ProtobufMutator_INCLUDE_DIRS})
+
+  # Build the protobuf->C++ translation library and driver.
+  add_clang_subdirectory(proto-to-cxx)
+
+  # Build the protobuf fuzzer
+  add_clang_executable(clang-proto-fuzzer
+${DUMMY_MAIN}
+ExampleClangProtoFuzzer.cpp
 )
 
-  target_link_libraries(clang-fuzzer
+  target_link_libraries(clang-proto-fuzzer
+${ProtobufMutator_LIBRARIES}
+${PROTOBUF_LIBRARIES}
+clangCXXProto
 clangHandleCXX
+clangProtoToCXX
 )
 endif()
+
+add_clang_subdirectory(handle-cxx)
+
+add_clang_executable(clang-fuzzer
+  EXCLUDE_FROM_ALL
+  ${DUMMY_MAIN}
+  ClangFuzzer.cpp
+  )
+
+target_link_libraries(clang-fuzzer
+  clangHandleCXX
+  )

Modified: cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp?rev=315465&r1=315464&r2=315465&view=diff
==
--- cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp (original)
+++ cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp Wed Oct 11 08:51:12 2017
@@ -17,6 

r315467 - [OPENMP] Remove extra if, NFC.

2017-10-11 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Oct 11 08:56:38 2017
New Revision: 315467

URL: http://llvm.org/viewvc/llvm-project?rev=315467&view=rev
Log:
[OPENMP] Remove extra if, NFC.

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

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=315467&r1=315466&r2=315467&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed Oct 11 08:56:38 2017
@@ -4274,7 +4274,7 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFun
   CGM, D.getDirectiveKind(), KmpInt32Ty, KmpRoutineEntryPtrQTy));
 }
 KmpTaskTQTy = SavedKmpTaskloopTQTy;
-  } else if (D.getDirectiveKind() == OMPD_task) {
+  } else {
 assert(D.getDirectiveKind() == OMPD_task &&
"Expected taskloop or task directive");
 if (SavedKmpTaskTQTy.isNull()) {


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


r315470 - [X86] Correct type for argument to clflushopt intrinsic.

2017-10-11 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Oct 11 09:06:08 2017
New Revision: 315470

URL: http://llvm.org/viewvc/llvm-project?rev=315470&view=rev
Log:
[X86] Correct type for argument to clflushopt intrinsic.

Summary: According to Intel docs this should take void const *. We had char*. 
The lack of const is the main issue.

Reviewers: RKSimon, zvi, igorb

Reviewed By: igorb

Subscribers: llvm-commits

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/clflushoptintrin.h

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=315470&r1=315469&r2=315470&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed Oct 11 09:06:08 2017
@@ -639,7 +639,7 @@ TARGET_BUILTIN(__builtin_ia32_xsavec, "v
 TARGET_BUILTIN(__builtin_ia32_xsaves, "vv*ULLi", "", "xsaves")
 
 //CLFLUSHOPT
-TARGET_BUILTIN(__builtin_ia32_clflushopt, "vc*", "", "clflushopt")
+TARGET_BUILTIN(__builtin_ia32_clflushopt, "vvC*", "", "clflushopt")
 
 // ADX
 TARGET_BUILTIN(__builtin_ia32_addcarryx_u32, "UcUcUiUiUi*", "", "adx")

Modified: cfe/trunk/lib/Headers/clflushoptintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/clflushoptintrin.h?rev=315470&r1=315469&r2=315470&view=diff
==
--- cfe/trunk/lib/Headers/clflushoptintrin.h (original)
+++ cfe/trunk/lib/Headers/clflushoptintrin.h Wed Oct 11 09:06:08 2017
@@ -32,7 +32,7 @@
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__,  
__target__("clflushopt")))
 
 static __inline__ void __DEFAULT_FN_ATTRS
-_mm_clflushopt(char * __m) {
+_mm_clflushopt(void const * __m) {
   __builtin_ia32_clflushopt(__m);
 }
 


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


[PATCH] D37856: [refactor] add support for refactoring options

2017-10-11 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp:113
 Rules.push_back(createRefactoringActionRule(
-SymbolSelectionRequirement()));
+SymbolSelectionRequirement(), OptionRequirement()));
 return Rules;

arphaman wrote:
> hokein wrote:
> > Thought it a bit more: it requires all of the requirements are satisfied, I 
> > think we need to support "one-of" option. For example,  we have two option 
> > "-a" and "-b",  only one of them is allowed to be present at the same time.
> That should be straightforward enough to implement, either with a custom 
> class or with a built-in requirement class. I'll probably add a builtin one 
> when the need comes up.
Thanks. I'm asking it because I plan to add the `-qualified-name` option to the 
clang-refactor rename subtool. And obviously "-qualified-name" can not be 
present with "-selection".


Repository:
  rL LLVM

https://reviews.llvm.org/D37856



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


[PATCH] D38742: [CUDA] Added __hmma_m16n16k16_* builtins to support mma instructions in sm_70

2017-10-11 Thread Justin Lebar via Phabricator via cfe-commits
jlebar accepted this revision.
jlebar added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9726
+  case NVPTX::BI__hmma_m16n16k16_ld_c_f16:
+case NVPTX::BI__hmma_m16n16k16_ld_c_f32:{
+Address Dst = EmitPointerWithAlignment(E->getArg(0));

weird indentation?



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9733
+  return nullptr;
+bool isColMajor = isColMajorArg.getZExtValue();
+unsigned IID;

Urg, this isn't a bool?  Do we want it to be?



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9761
+
+//auto EltTy = cast(Src->getType())->getElementType();
+// Returned are 8 16x2 elements.

Accidentally left over?



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9762
+//auto EltTy = cast(Src->getType())->getElementType();
+// Returned are 8 16x2 elements.
+for (unsigned i = 0; i < NumResults; ++i) {

s/8/NumElements/?
s/16/f16/?

Maybe it would be better to write it as "Return value has type [[f16 x 2] x 
NumResults]."?



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9784
+unsigned IID;
+unsigned NumResults = 8;
+// PTX Instructions (and LLVM instrinsics) are defined for slice _d_, yet

Nit, at this point it's probably better to assign NumResults in each branch, 
since there are only two.  clang should make sure that we don't accidentally 
use it uninitialized.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9786
+// PTX Instructions (and LLVM instrinsics) are defined for slice _d_, yet
+// for some reason nvcc buildtins are using _c_.
+switch(BuiltinID) {

s/are using/use/



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9800
+}
+Function * Intrinsic = CGM.getIntrinsic(IID);
+llvm::Type *ParamType = Intrinsic->getFunctionType()->getParamType(1);

spacing.  (Probably just worth clang-formatting this and the other patch.)



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9802
+llvm::Type *ParamType = Intrinsic->getFunctionType()->getParamType(1);
+SmallVector Values;
+Values.push_back(Builder.CreatePointerCast(Dst, VoidPtrTy));

Nit, we know that there won't ever be more than 8 elements...


https://reviews.llvm.org/D38742



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


[PATCH] D38742: [CUDA] Added __hmma_m16n16k16_* builtins to support mma instructions in sm_70

2017-10-11 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 118636.
tra marked 6 inline comments as done.
tra added a comment.

Addressed Justin's comments.


https://reviews.llvm.org/D38742

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-nvptx-sm_70.cu

Index: clang/test/CodeGen/builtins-nvptx-sm_70.cu
===
--- /dev/null
+++ clang/test/CodeGen/builtins-nvptx-sm_70.cu
@@ -0,0 +1,166 @@
+// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -target-cpu sm_70 \
+// RUN:-fcuda-is-device -target-feature +ptx60 \
+// RUN:-S -emit-llvm -o - -x cuda %s \
+// RUN:   | FileCheck -check-prefix=CHECK %s
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_60 \
+// RUN:   -fcuda-is-device -S -o /dev/null -x cuda -verify %s
+
+#if !defined(CUDA_VERSION)
+#define __device__ __attribute__((device))
+#define __global__ __attribute__((global))
+#define __shared__ __attribute__((shared))
+#define __constant__ __attribute__((constant))
+
+typedef unsigned long long uint64_t;
+#endif
+// We have to keep all builtins that depend on particular target feature in the
+// same function, because the codegen will stop after the very first function
+// that encounters an error, so -verify will not be able to find errors in
+// subsequent functions.
+
+// CHECK-LABEL: nvvm_wmma
+__device__ void nvvm_wmma(int *src, int *dst,
+  float *fsrc, float *fdst,
+  int ldm) {
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.a.sync.row.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_a' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_a(dst, src, ldm, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.a.sync.col.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_a' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_a(dst, src+1, ldm, 1);
+
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.b.sync.row.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_b' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_b(dst, src, ldm, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.b.sync.col.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_b' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_b(dst, src+2, ldm, 1);
+
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.c.sync.row.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_c_f16' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_c_f16(dst, src, ldm, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.c.sync.col.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_c_f16' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_c_f16(dst, src, ldm, 1);
+
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.c.sync.row.m16n16k16.stride.f32
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_c_f32' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_c_f32(fdst, fsrc, ldm, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.c.sync.col.m16n16k16.stride.f32
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_c_f32' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_c_f32(fdst, fsrc, ldm, 1);
+
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.store.d.sync.row.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_st_c_f16' needs target feature ptx60}}
+  __hmma_m16n16k16_st_c_f16(dst, src, ldm, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.store.d.sync.col.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_st_c_f16' needs target feature ptx60}}
+  __hmma_m16n16k16_st_c_f16(dst, src, ldm, 1);
+
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.store.d.sync.row.m16n16k16.stride.f32
+  // expected-error@+1 {{'__hmma_m16n16k16_st_c_f32' needs target feature ptx60}}
+  __hmma_m16n16k16_st_c_f32(fdst, fsrc, ldm, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.store.d.sync.col.m16n16k16.stride.f32
+  // expected-error@+1 {{'__hmma_m16n16k16_st_c_f32' needs target feature ptx60}}
+  __hmma_m16n16k16_st_c_f32(fdst, fsrc, ldm, 1);
+
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.mma.sync.row.row.m16n16k16.f16.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_mma_f16f16' needs target feature ptx60}}
+  __hmma_m16n16k16_mma_f16f16(dst, src, src, src, 0, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.mma.sync.row.row.m16n16k16.f16.f16.satfinite
+  // expected-error@+1 {{'__hmma_m16n16k16_mma_f16f16' needs target feature ptx60}}
+  __hmma_m16n16k16_mma_f16f16(dst, src, src, src, 0, 1);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.mma.sync.row.col.m16n16k16.f16.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_mma_f16f16' needs target feature ptx60}}
+  __hmma_m16n16k16_mma_f16f16(dst, src, src, src, 1, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.mma.sync.row.col.m16n16k16.f16.f16.satfinite
+  // expected-error@+1 {{'__hmma_m16n16k16_mma_f16f16' needs target feature ptx60}}
+  __hmma_m16n16k16_mma_f16f16(dst, src, src, src, 1, 1);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.mma.sync.c

[PATCH] D38742: [CUDA] Added __hmma_m16n16k16_* builtins to support mma instructions in sm_70

2017-10-11 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9726
+  case NVPTX::BI__hmma_m16n16k16_ld_c_f16:
+case NVPTX::BI__hmma_m16n16k16_ld_c_f32:{
+Address Dst = EmitPointerWithAlignment(E->getArg(0));

jlebar wrote:
> weird indentation?
My emacs and clang-format keep fighting case indentation... Fixed.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9733
+  return nullptr;
+bool isColMajor = isColMajorArg.getZExtValue();
+unsigned IID;

jlebar wrote:
> Urg, this isn't a bool?  Do we want it to be?
There are no explicit declarations for these builtins in CUDA headers. Callers 
of these builtins pass 0/1 and corresponding intrinsic described in [[ 
http://docs.nvidia.com/cuda/nvvm-ir-spec/index.html#nvvm-intrin-warp-level-matrix-ld
 | NVVM-IR spec ]] shows the argument type as i32, so I've made the type 
integer in clang. 





Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9762
+//auto EltTy = cast(Src->getType())->getElementType();
+// Returned are 8 16x2 elements.
+for (unsigned i = 0; i < NumResults; ++i) {

jlebar wrote:
> s/8/NumElements/?
> s/16/f16/?
> 
> Maybe it would be better to write it as "Return value has type [[f16 x 2] x 
> NumResults]."?
That was part of the leftover block. Particular types are irrelevant here. All 
we care is to store whatever intrinsic call returned ([4 or 8 elements of v2f16 
or float] ) in the destination array (which is int[] ). 



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9802
+llvm::Type *ParamType = Intrinsic->getFunctionType()->getParamType(1);
+SmallVector Values;
+Values.push_back(Builder.CreatePointerCast(Dst, VoidPtrTy));

jlebar wrote:
> Nit, we know that there won't ever be more than 8 elements...
We have two extra arguments -- destination buffer and stride.


https://reviews.llvm.org/D38742



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


[PATCH] D38425: [clangd] Document highlights for clangd

2017-10-11 Thread William Enright via Phabricator via cfe-commits
Nebiroth marked 3 inline comments as done.
Nebiroth added inline comments.



Comment at: clangd/ClangdUnit.cpp:1017
+
+  auto DeclLocationsFinder = std::make_shared(
+  llvm::errs(), SourceLocationBeg, AST.getASTContext(),

ilya-biryukov wrote:
> I wonder if we really need to rerun indexer twice here. Probably ok for the 
> first version, but we should definitely think about a faster way to get the 
> `Decl` under cursor than visiting the whole AST. Not sure if it's easy to do 
> with clang's AST, though, maybe we'll need a separate index for that.
Yeah I realise it's definitely not the fastest way to go about it. Maybe there 
is a way to stop handling occurrences once the highlighted declaration is 
found. This would be the most straightforward way of improving the performance 
of the feature without re-writing a new AST indexer.


https://reviews.llvm.org/D38425



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


[PATCH] D38110: [libunwind][MIPS]: Add support for unwinding in O32 and N64 processes.

2017-10-11 Thread John Baldwin via Phabricator via cfe-commits
bsdjhb updated this revision to Diff 118638.
bsdjhb added a comment.

- Add more soft-float checks.


https://reviews.llvm.org/D38110

Files:
  include/__libunwind_config.h
  include/libunwind.h
  src/Registers.hpp
  src/UnwindCursor.hpp
  src/UnwindRegistersRestore.S
  src/UnwindRegistersSave.S
  src/config.h
  src/libunwind.cpp

Index: src/libunwind.cpp
===
--- src/libunwind.cpp
+++ src/libunwind.cpp
@@ -58,8 +58,12 @@
 # define REGISTER_KIND Registers_arm
 #elif defined(__or1k__)
 # define REGISTER_KIND Registers_or1k
+#elif defined(__mips__) && _MIPS_SIM == _ABIO32 && defined(__mips_soft_float)
+# define REGISTER_KIND Registers_mips_o32
+#elif defined(__mips__) && _MIPS_SIM == _ABI64 && defined(__mips_soft_float)
+# define REGISTER_KIND Registers_mips_n64
 #elif defined(__mips__)
-# warning The MIPS architecture is not supported.
+# warning The MIPS architecture is not supported with this ABI and environment!
 #else
 # error Architecture not supported
 #endif
Index: src/config.h
===
--- src/config.h
+++ src/config.h
@@ -65,7 +65,7 @@
 defined(__ppc__) || defined(__ppc64__) ||  \
 (!defined(__APPLE__) && defined(__arm__)) ||   \
 (defined(__arm64__) || defined(__aarch64__)) ||\
-(defined(__APPLE__) && defined(__mips__))
+defined(__mips__)
 #define _LIBUNWIND_BUILD_ZERO_COST_APIS
 #endif
 
Index: src/UnwindRegistersSave.S
===
--- src/UnwindRegistersSave.S
+++ src/UnwindRegistersSave.S
@@ -87,6 +87,76 @@
   xorl  %eax, %eax# return UNW_ESUCCESS
   ret
 
+#elif defined(__mips__) && _MIPS_SIM == _ABIO32 && defined(__mips_soft_float)
+
+#
+# extern int unw_getcontext(unw_context_t* thread_state)
+#
+# On entry:
+#  thread_state pointer is in a0 ($4)
+#
+# Only save registers preserved across calls.
+#
+DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
+  .set push
+  .set noat
+  .set noreorder
+  .set nomacro
+  # s0 - s7
+  sw$16, (4 * 16)($4)
+  sw$17, (4 * 17)($4)
+  sw$18, (4 * 18)($4)
+  sw$19, (4 * 19)($4)
+  sw$20, (4 * 20)($4)
+  sw$21, (4 * 21)($4)
+  sw$22, (4 * 22)($4)
+  sw$23, (4 * 23)($4)
+  # gp
+  sw$28, (4 * 28)($4)
+  # sp
+  sw$29, (4 * 29)($4)
+  # Store return address to pc
+  sw$31, (4 * 32)($4)
+  jr	$31
+  # fp (in delay slot)
+  sw$30, (4 * 30)($4)
+  .set pop
+
+#elif defined(__mips__) && _MIPS_SIM == _ABI64 && defined(__mips_soft_float)
+
+#
+# extern int unw_getcontext(unw_context_t* thread_state)
+#
+# On entry:
+#  thread_state pointer is in a0 ($4)
+#
+# Only save registers preserved across calls.
+#
+DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
+  .set push
+  .set noat
+  .set noreorder
+  .set nomacro
+  # s0 - s7
+  sd$16, (8 * 16)($4)
+  sd$17, (8 * 17)($4)
+  sd$18, (8 * 18)($4)
+  sd$19, (8 * 19)($4)
+  sd$20, (8 * 20)($4)
+  sd$21, (8 * 21)($4)
+  sd$22, (8 * 22)($4)
+  sd$23, (8 * 23)($4)
+  # gp
+  sd$28, (8 * 28)($4)
+  # sp
+  sd$29, (8 * 29)($4)
+  # Store return address to pc
+  sd$31, (8 * 32)($4)
+  jr	$31
+  # fp (in delay slot)
+  sd$30, (8 * 30)($4)
+  .set pop
+
 # elif defined(__mips__)
 
 #
Index: src/UnwindRegistersRestore.S
===
--- src/UnwindRegistersRestore.S
+++ src/UnwindRegistersRestore.S
@@ -489,6 +489,108 @@
   l.jr r9
l.nop
 
+#elif defined(__mips__) && _MIPS_SIM == _ABIO32 && defined(__mips_soft_float)
+
+//
+// void libunwind::Registers_mips_o32::jumpto()
+//
+// On entry:
+//  thread state pointer is in a0 ($4)
+//
+DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind18Registers_mips_o326jumptoEv)
+  .set push
+  .set noat
+  .set noreorder
+  .set nomacro
+  // r0 is zero
+  lw$1, (4 * 1)($4)
+  lw$2, (4 * 2)($4)
+  lw$3, (4 * 3)($4)
+  // skip a0 for now
+  lw$5, (4 * 5)($4)
+  lw$6, (4 * 6)($4)
+  lw$7, (4 * 7)($4)
+  lw$8, (4 * 8)($4)
+  lw$9, (4 * 9)($4)
+  lw$10, (4 * 10)($4)
+  lw$11, (4 * 11)($4)
+  lw$12, (4 * 12)($4)
+  lw$13, (4 * 13)($4)
+  lw$14, (4 * 14)($4)
+  lw$15, (4 * 15)($4)
+  lw$16, (4 * 16)($4)
+  lw$17, (4 * 17)($4)
+  lw$18, (4 * 18)($4)
+  lw$19, (4 * 19)($4)
+  lw$20, (4 * 20)($4)
+  lw$21, (4 * 21)($4)
+  lw$22, (4 * 22)($4)
+  lw$23, (4 * 23)($4)
+  lw$24, (4 * 24)($4)
+  lw$25, (4 * 25)($4)
+  lw$26, (4 * 26)($4)
+  lw$27, (4 * 27)($4)
+  lw$28, (4 * 28)($4)
+  lw$29, (4 * 29)($4)
+  lw$30, (4 * 30)($4)
+  // load new pc into ra
+  lw$31, (4 * 32)($4)
+  // jump to ra, load a0 in the delay slot
+  jr$31
+  lw$4, (4 * 4)($4)
+  .set pop
+
+#elif defined(__mips__) && _MIPS_SIM == _ABI64 && defined(__mips_soft_float)
+
+//
+// void libunwind::R

[PATCH] D38742: [CUDA] Added __hmma_m16n16k16_* builtins to support mma instructions in sm_70

2017-10-11 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9733
+  return nullptr;
+bool isColMajor = isColMajorArg.getZExtValue();
+unsigned IID;

tra wrote:
> jlebar wrote:
> > Urg, this isn't a bool?  Do we want it to be?
> There are no explicit declarations for these builtins in CUDA headers. 
> Callers of these builtins pass 0/1 and corresponding intrinsic described in 
> [[ 
> http://docs.nvidia.com/cuda/nvvm-ir-spec/index.html#nvvm-intrin-warp-level-matrix-ld
>  | NVVM-IR spec ]] shows the argument type as i32, so I've made the type 
> integer in clang. 
> 
> 
sgtm


https://reviews.llvm.org/D38742



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


[PATCH] D38810: [Analyzer] Support bodyfarming std::call_once for libstdc++

2017-10-11 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov created this revision.
Herald added subscribers: szepet, kristof.beyls, xazax.hun, javed.absar, 
aemerson.

https://reviews.llvm.org/D38810

Files:
  lib/Analysis/BodyFarm.cpp
  test/Analysis/call_once.cpp

Index: test/Analysis/call_once.cpp
===
--- test/Analysis/call_once.cpp
+++ test/Analysis/call_once.cpp
@@ -1,15 +1,24 @@
-// RUN: %clang_analyze_cc1 -std=c++11 -fblocks -analyzer-checker=core,debug.ExprInspection -w -verify %s
+// RUN: %clang_analyze_cc1 -std=c++11 -fblocks -analyzer-checker=core,debug.ExprInspection -verify %s
+// RUN: %clang_analyze_cc1 -std=c++11 -fblocks -analyzer-checker=core,debug.ExprInspection -DEMULATE_LIBSTDCPP -verify %s
 
 void clang_analyzer_eval(bool);
 
 // Faking std::std::call_once implementation.
 namespace std {
+
+#ifndef EMULATE_LIBSTDCPP
 typedef struct once_flag_s {
   unsigned long __state_ = 0;
 } once_flag;
+#else
+typedef struct once_flag_s {
+  int _M_once = 0;
+} once_flag;
+#endif
 
 template 
 void call_once(once_flag &o, Callable func, Args... args) {};
+
 } // namespace std
 
 // Check with Lambdas.
Index: lib/Analysis/BodyFarm.cpp
===
--- lib/Analysis/BodyFarm.cpp
+++ lib/Analysis/BodyFarm.cpp
@@ -108,7 +108,7 @@
 
   /// Returns a *first* member field of a record declaration with a given name.
   /// \return an nullptr if no member with such a name exists.
-  NamedDecl *findMemberField(const CXXRecordDecl *RD, StringRef Name);
+  NamedDecl *findMemberField(const RecordDecl *RD, StringRef Name);
 
 private:
   ASTContext &C;
@@ -234,7 +234,7 @@
   OK_Ordinary);
 }
 
-NamedDecl *ASTMaker::findMemberField(const CXXRecordDecl *RD, StringRef Name) {
+NamedDecl *ASTMaker::findMemberField(const RecordDecl *RD, StringRef Name) {
 
   CXXBasePaths Paths(
   /* FindAmbiguities=*/false,
@@ -328,28 +328,35 @@
   const ParmVarDecl *Callback = D->getParamDecl(1);
   QualType CallbackType = Callback->getType().getNonReferenceType();
   QualType FlagType = Flag->getType().getNonReferenceType();
-  CXXRecordDecl *FlagCXXDecl = FlagType->getAsCXXRecordDecl();
-  if (!FlagCXXDecl) {
-DEBUG(llvm::dbgs() << "Flag field is not a CXX record: "
-   << "unknown std::call_once implementation."
-   << "Ignoring the call.\n");
+  auto *FlagRecordDecl = dyn_cast_or_null(FlagType->getAsTagDecl());
+
+  if (!FlagRecordDecl) {
+DEBUG(llvm::dbgs() << "Flag field is not a record: "
+   << "unknown std::call_once implementation, "
+   << "ignoring the call.\n");
 return nullptr;
   }
 
-  // Note: here we are assuming libc++ implementation of call_once,
-  // which has a struct with a field `__state_`.
-  // Body farming might not work for other `call_once` implementations.
-  NamedDecl *FoundDecl = M.findMemberField(FlagCXXDecl, "__state_");
-  ValueDecl *FieldDecl;
-  if (FoundDecl) {
-FieldDecl = dyn_cast(FoundDecl);
-  } else {
+  // We initially assume libc++ implementation of call_once,
+  // where the once_flag struct has a field `__state_`.
+  NamedDecl *FoundDecl = M.findMemberField(FlagRecordDecl, "__state_");
+
+  // Otherwise, try libstdc++ implementation, with a field
+  // `_M_once`
+  if (!FoundDecl) {
 DEBUG(llvm::dbgs() << "No field __state_ found on std::once_flag struct, "
-   << "unable to synthesize call_once body, ignoring "
-   << "the call.\n");
+   << "trying libstdc++ implementation\n");
+FoundDecl = M.findMemberField(FlagRecordDecl, "_M_once");
+  }
+
+  if (!FoundDecl) {
+DEBUG(llvm::dbgs() << "No field _M_once found on std::once flag struct: "
+   << "unknown std::call_once implementation, "
+   << "ignoring the call");
 return nullptr;
   }
 
+  ValueDecl *FieldDecl = dyn_cast(FoundDecl);
   bool isLambdaCall = CallbackType->getAsCXXRecordDecl() &&
   CallbackType->getAsCXXRecordDecl()->isLambda();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38596: Implement attribute target multiversioning

2017-10-11 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 118648.
erichkeane added a comment.

Craig noticed a pair of ordering issues in the TargetArray list, so fixed htose.


https://reviews.llvm.org/D38596

Files:
  include/clang/AST/Decl.h
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TargetInfo.h
  include/clang/Sema/Sema.h
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Sema/SemaDecl.cpp
  test/CodeGen/attr-target-multiversion.c
  test/CodeGenCXX/attr-target-multiversion.cpp
  test/Sema/attr-target-multiversion.c
  test/SemaCXX/attr-target-multiversion.cpp

Index: test/SemaCXX/attr-target-multiversion.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-target-multiversion.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only %s
+
+struct S {
+  __attribute__((target("arch=sandybridge")))
+  void mv(){}
+  __attribute__((target("arch=ivybridge")))
+  void mv(){}
+  __attribute__((target("default")))
+  void mv(){}
+
+  // NOTE: Virtual functions aren't implement for multiversioning in GCC either,
+  // so this is a 'TBD' feature.
+  // expected-error@+2 {{function multiversioning with 'target' doesn't support virtual functions yet}}
+  __attribute__((target("arch=sandybridge")))
+  virtual void mv_2(){}
+  // expected-error@+4 {{function multiversioning with 'target' doesn't support virtual functions yet}}
+  // expected-error@+3 {{class member cannot be redeclared}}
+  // expected-note@-3 {{previous definition is here}}
+  __attribute__((target("arch=ivybridge")))
+  virtual void mv_2(){}
+  // expected-error@+3 {{class member cannot be redeclared}}
+  // expected-note@-7 {{previous definition is here}}
+  __attribute__((target("default")))
+  virtual void mv_2(){}
+};
+
+// Note: Template attribute 'target' isn't implemented in GCC either, and would
+// end up causing some nasty issues attempting it, so ensure that it still gives
+// the same errors as without the attribute.
+
+template
+__attribute__((target("arch=sandybridge")))
+void mv_temp(){}
+
+template
+__attribute__((target("arch=ivybridge")))
+//expected-error@+2 {{redefinition of}}
+//expected-note@-5{{previous definition is here}}
+void mv_temp(){}
+
+template
+__attribute__((target("default")))
+void mv_temp(){}
+
+void foo() {
+  //expected-error@+2{{no matching function for call to}}
+  //expected-note@-8{{candidate template ignored}}
+  mv_temp();
+}
Index: test/Sema/attr-target-multiversion.c
===
--- /dev/null
+++ test/Sema/attr-target-multiversion.c
@@ -0,0 +1,136 @@
+// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only %s
+// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only -DCHECK_DEFAULT %s
+
+#if defined(CHECK_DEFAULT)
+__attribute__((target("arch=sandybridge")))
+//expected-error@+1 {{function multiversioning with 'target' requires a 'default' implementation}}
+void no_default(){}
+__attribute__((target("arch=ivybridge")))
+void no_default(){}
+#else
+// Only multiversioning causes issues with redeclaration changing 'target'.
+__attribute__((target("arch=sandybridge")))
+void fine_since_no_mv();
+void fine_since_no_mv();
+
+void also_fine_since_no_mv();
+__attribute__((target("arch=sandybridge")))
+void also_fine_since_no_mv();
+
+__attribute__((target("arch=sandybridge")))
+void also_fine_since_no_mv2();
+__attribute__((target("arch=sandybridge")))
+void also_fine_since_no_mv2();
+void also_fine_since_no_mv2();
+
+__attribute__((target("arch=sandybridge")))
+void mv(){}
+__attribute__((target("arch=ivybridge")))
+void mv(){}
+__attribute__((target("default")))
+void mv(){}
+
+void redecl_causes_mv();
+__attribute__((target("arch=sandybridge")))
+void redecl_causes_mv();
+// expected-error@+3 {{function redeclaration declares a multiversioned function, but a previous declaration lacks a 'target' attribute}}
+// expected-note@-4 {{previous declaration is here}}
+__attribute__((target("arch=ivybridge")))
+void redecl_causes_mv();
+
+__attribute__((target("arch=sandybridge")))
+void redecl_causes_mv2();
+void redecl_causes_mv2();
+// expected-error@+3 {{function redeclaration declares a multiversioned function, but a previous declaration lacks a 'target' attribute}}
+// expected-note@-2 {{previous declaration is here}}
+__attribute__((target("arch=ivybridge")))
+void redecl_causes_mv2();
+
+__attribute__((target("arch=sandybridge")))
+void redecl_without_attr();
+__attribute__((target("arch=ivybridge")))
+void redecl_without_attr();
+// expected-error@+2 {{function redeclaration is missing 'target' attribute in a multiversioned function}}
+// expected-note@-4 {{previous declaration is here}}
+void redecl_without_attr(

[PATCH] D37897: [StaticAnalyzer] Fix ProgramState for static variables that are not written

2017-10-11 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a comment.

In https://reviews.llvm.org/D37897#892667, @dcoughlin wrote:

> Apologies for the delay reviewing! As I noted inline, I'm pretty worried 
> about the performance impact of this. Is it possible to do the analysis in a 
> single traversal of the translation unit?


I agree. I first tried more like that but ran into problems. Don't remember the 
details. I will try again.. however as far as I see this will mean the 
LoopUnroller AST matchers can't be reused unless I change them.


Repository:
  rL LLVM

https://reviews.llvm.org/D37897



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


[PATCH] D38812: [clang-fuzzer] Allow linking with any fuzzing engine.

2017-10-11 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse created this revision.
Herald added a subscriber: mgorny.

Makes clang-[proto-]fuzzer compatible with flags specified by OSS-Fuzz.

https://llvm.org/pr34314


https://reviews.llvm.org/D38812

Files:
  clang/tools/clang-fuzzer/CMakeLists.txt


Index: clang/tools/clang-fuzzer/CMakeLists.txt
===
--- clang/tools/clang-fuzzer/CMakeLists.txt
+++ clang/tools/clang-fuzzer/CMakeLists.txt
@@ -1,7 +1,9 @@
 set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzMutate)
 set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
 set(DUMMY_MAIN DummyClangFuzzer.cpp)
-if(LLVM_USE_SANITIZE_COVERAGE)
+if(DEFINED LIB_FUZZING_ENGINE)
+  unset(DUMMY_MAIN)
+elseif(LLVM_USE_SANITIZE_COVERAGE)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
   set(CXX_FLAGS_NOFUZZ "${CXX_FLAGS_NOFUZZ} -fsanitize=fuzzer-no-link")
   unset(DUMMY_MAIN)
@@ -48,6 +50,7 @@
   target_link_libraries(clang-proto-fuzzer
 ${ProtobufMutator_LIBRARIES}
 ${PROTOBUF_LIBRARIES}
+${LIB_FUZZING_ENGINE}
 clangCXXProto
 clangHandleCXX
 clangProtoToCXX
@@ -63,5 +66,6 @@
   )
 
 target_link_libraries(clang-fuzzer
+  ${LIB_FUZZING_ENGINE}
   clangHandleCXX
   )


Index: clang/tools/clang-fuzzer/CMakeLists.txt
===
--- clang/tools/clang-fuzzer/CMakeLists.txt
+++ clang/tools/clang-fuzzer/CMakeLists.txt
@@ -1,7 +1,9 @@
 set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzMutate)
 set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
 set(DUMMY_MAIN DummyClangFuzzer.cpp)
-if(LLVM_USE_SANITIZE_COVERAGE)
+if(DEFINED LIB_FUZZING_ENGINE)
+  unset(DUMMY_MAIN)
+elseif(LLVM_USE_SANITIZE_COVERAGE)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
   set(CXX_FLAGS_NOFUZZ "${CXX_FLAGS_NOFUZZ} -fsanitize=fuzzer-no-link")
   unset(DUMMY_MAIN)
@@ -48,6 +50,7 @@
   target_link_libraries(clang-proto-fuzzer
 ${ProtobufMutator_LIBRARIES}
 ${PROTOBUF_LIBRARIES}
+${LIB_FUZZING_ENGINE}
 clangCXXProto
 clangHandleCXX
 clangProtoToCXX
@@ -63,5 +66,6 @@
   )
 
 target_link_libraries(clang-fuzzer
+  ${LIB_FUZZING_ENGINE}
   clangHandleCXX
   )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38812: [clang-fuzzer] Allow linking with any fuzzing engine.

2017-10-11 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc accepted this revision.
kcc added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D38812



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


[PATCH] D38810: [Analyzer] Support bodyfarming std::call_once for libstdc++

2017-10-11 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

LGTM with the dyn_cast mentioned inline changed.




Comment at: lib/Analysis/BodyFarm.cpp:359
 
+  ValueDecl *FieldDecl = dyn_cast(FoundDecl);
   bool isLambdaCall = CallbackType->getAsCXXRecordDecl() &&

Should this be a cast<>() rather than a dyn_cast<>()? Do you expect this to 
fail? If so then you should check the result for null. If not then the idiom is 
to use cast<>().

An alternative would be to change findMemberField() to return a FieldDecl.


https://reviews.llvm.org/D38810



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


r315486 - [clang-fuzzer] Allow linking with any fuzzing engine.

2017-10-11 Thread Matt Morehouse via cfe-commits
Author: morehouse
Date: Wed Oct 11 11:29:24 2017
New Revision: 315486

URL: http://llvm.org/viewvc/llvm-project?rev=315486&view=rev
Log:
[clang-fuzzer] Allow linking with any fuzzing engine.

Summary:
Makes clang-[proto-]fuzzer compatible with flags specified by OSS-Fuzz.

https://llvm.org/pr34314

Reviewers: vitalybuka, kcc

Reviewed By: kcc

Subscribers: cfe-commits, mgorny

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

Modified:
cfe/trunk/tools/clang-fuzzer/CMakeLists.txt

Modified: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/CMakeLists.txt?rev=315486&r1=315485&r2=315486&view=diff
==
--- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt Wed Oct 11 11:29:24 2017
@@ -1,7 +1,9 @@
 set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzMutate)
 set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
 set(DUMMY_MAIN DummyClangFuzzer.cpp)
-if(LLVM_USE_SANITIZE_COVERAGE)
+if(DEFINED LIB_FUZZING_ENGINE)
+  unset(DUMMY_MAIN)
+elseif(LLVM_USE_SANITIZE_COVERAGE)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
   set(CXX_FLAGS_NOFUZZ "${CXX_FLAGS_NOFUZZ} -fsanitize=fuzzer-no-link")
   unset(DUMMY_MAIN)
@@ -48,6 +50,7 @@ if(CLANG_ENABLE_PROTO_FUZZER)
   target_link_libraries(clang-proto-fuzzer
 ${ProtobufMutator_LIBRARIES}
 ${PROTOBUF_LIBRARIES}
+${LIB_FUZZING_ENGINE}
 clangCXXProto
 clangHandleCXX
 clangProtoToCXX
@@ -63,5 +66,6 @@ add_clang_executable(clang-fuzzer
   )
 
 target_link_libraries(clang-fuzzer
+  ${LIB_FUZZING_ENGINE}
   clangHandleCXX
   )


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


[PATCH] D38812: [clang-fuzzer] Allow linking with any fuzzing engine.

2017-10-11 Thread Matt Morehouse via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315486: [clang-fuzzer] Allow linking with any fuzzing 
engine. (authored by morehouse).

Changed prior to commit:
  https://reviews.llvm.org/D38812?vs=118651&id=118655#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38812

Files:
  cfe/trunk/tools/clang-fuzzer/CMakeLists.txt


Index: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
===
--- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
+++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
@@ -1,7 +1,9 @@
 set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzMutate)
 set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
 set(DUMMY_MAIN DummyClangFuzzer.cpp)
-if(LLVM_USE_SANITIZE_COVERAGE)
+if(DEFINED LIB_FUZZING_ENGINE)
+  unset(DUMMY_MAIN)
+elseif(LLVM_USE_SANITIZE_COVERAGE)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
   set(CXX_FLAGS_NOFUZZ "${CXX_FLAGS_NOFUZZ} -fsanitize=fuzzer-no-link")
   unset(DUMMY_MAIN)
@@ -48,6 +50,7 @@
   target_link_libraries(clang-proto-fuzzer
 ${ProtobufMutator_LIBRARIES}
 ${PROTOBUF_LIBRARIES}
+${LIB_FUZZING_ENGINE}
 clangCXXProto
 clangHandleCXX
 clangProtoToCXX
@@ -63,5 +66,6 @@
   )
 
 target_link_libraries(clang-fuzzer
+  ${LIB_FUZZING_ENGINE}
   clangHandleCXX
   )


Index: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
===
--- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
+++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
@@ -1,7 +1,9 @@
 set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzMutate)
 set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
 set(DUMMY_MAIN DummyClangFuzzer.cpp)
-if(LLVM_USE_SANITIZE_COVERAGE)
+if(DEFINED LIB_FUZZING_ENGINE)
+  unset(DUMMY_MAIN)
+elseif(LLVM_USE_SANITIZE_COVERAGE)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
   set(CXX_FLAGS_NOFUZZ "${CXX_FLAGS_NOFUZZ} -fsanitize=fuzzer-no-link")
   unset(DUMMY_MAIN)
@@ -48,6 +50,7 @@
   target_link_libraries(clang-proto-fuzzer
 ${ProtobufMutator_LIBRARIES}
 ${PROTOBUF_LIBRARIES}
+${LIB_FUZZING_ENGINE}
 clangCXXProto
 clangHandleCXX
 clangProtoToCXX
@@ -63,5 +66,6 @@
   )
 
 target_link_libraries(clang-fuzzer
+  ${LIB_FUZZING_ENGINE}
   clangHandleCXX
   )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38797: [analyzer] CStringChecker: pr34460: Admit that some casts are hard to model.

2017-10-11 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

This looks good to me.


https://reviews.llvm.org/D38797



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


[PATCH] D38764: [Analyzer] Assume const string-like globals are non-null

2017-10-11 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov marked 9 inline comments as done.
george.karpenkov added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp:22
+//  Checker uses are defined in the test file:
+//   - test/Analysis/nonnull-string-constants.mm
+//

dcoughlin wrote:
> We generally don't do this kind of cross-reference in comments since they 
> tend to get stale fast when things get moved around. There is no tool support 
> to keep them in sync.
:(
I guess I'm too spoiled by Javadoc.



Comment at: lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp:53
+private:
+  /// Lazily initialize cache for required identifier informations.
+  void initIdentifierInfo(ASTContext &Ctx) const;

dcoughlin wrote:
> We usually put the oxygen comments on checkers on the implementation and not 
> the interface since they aren't API and people reading the code generally 
> look at the implementations. Can you move them to the implementations?
OK. I assume there's no good universal solution here.


https://reviews.llvm.org/D38764



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


[PATCH] D38764: [Analyzer] Assume const string-like globals are non-null

2017-10-11 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov updated this revision to Diff 118657.
george.karpenkov marked 2 inline comments as done.

https://reviews.llvm.org/D38764

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
  test/Analysis/nonnull-string-constants.mm

Index: test/Analysis/nonnull-string-constants.mm
===
--- /dev/null
+++ test/Analysis/nonnull-string-constants.mm
@@ -0,0 +1,90 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
+
+// Nullability of const string-like globals, testing
+// NonnullStringConstantsChecker.
+
+void clang_analyzer_eval(bool);
+
+@class NSString;
+typedef const struct __CFString *CFStringRef;
+
+// Global NSString* is non-null.
+extern NSString *const StringConstGlobal;
+void stringConstGlobal() {
+  clang_analyzer_eval(StringConstGlobal); // expected-warning{{TRUE}}
+}
+
+// The logic does not apply to local variables though.
+extern NSString *stringGetter();
+void stringConstLocal() {
+  NSString *const local = stringGetter();
+  clang_analyzer_eval(local); // expected-warning{{UNKNOWN}}
+}
+
+// Global const CFStringRef's are also assumed to be non-null.
+extern const CFStringRef CFStringConstGlobal;
+void cfStringCheckGlobal() {
+  clang_analyzer_eval(CFStringConstGlobal); // expected-warning{{TRUE}}
+}
+
+// But only "const" ones.
+extern CFStringRef CFStringNonConstGlobal;
+void cfStringCheckMutableGlobal() {
+  clang_analyzer_eval(CFStringNonConstGlobal); // expected-warning{{UNKNOWN}}
+}
+
+// char* const is also assumed to be non-null.
+extern const char *const ConstCharStarConst;
+void constCharStarCheckGlobal() {
+  clang_analyzer_eval(ConstCharStarConst); // expected-warning{{TRUE}}
+}
+
+// Pointer value can be mutable.
+extern char *const CharStarConst;
+void charStarCheckGlobal() {
+  clang_analyzer_eval(CharStarConst); // expected-warning{{TRUE}}
+}
+
+// But the pointer itself should be immutable.
+extern char *CharStar;
+void charStartCheckMutableGlobal() {
+  clang_analyzer_eval(CharStar); // expected-warning{{UNKNOWN}}
+}
+
+// Type definitions should also work across typedefs, for pointers:
+typedef char *const str;
+extern str globalStr;
+void charStarCheckTypedef() {
+  clang_analyzer_eval(globalStr); // expected-warning{{TRUE}}
+}
+
+// And for types.
+typedef NSString *const NStr;
+extern NStr globalNSString;
+void NSStringCheckTypedef() {
+  clang_analyzer_eval(globalNSString); // expected-warning{{TRUE}}
+}
+
+// Note that constness could be either inside
+// the var declaration, or in a typedef.
+typedef NSString *NStr2;
+extern const NStr2 globalNSString2;
+void NSStringCheckConstTypedef() {
+  clang_analyzer_eval(globalNSString2); // expected-warning{{TRUE}}
+}
+
+// Nested typedefs should work as well.
+typedef const CFStringRef str1;
+typedef str1 str2;
+extern str2 globalStr2;
+void testNestedTypedefs() {
+  clang_analyzer_eval(globalStr2); // expected-warning{{TRUE}}
+}
+
+// And for NSString *.
+typedef NSString *const nstr1;
+typedef nstr1 nstr2;
+extern nstr2 nglobalStr2;
+void testNestedTypedefsForNSString() {
+  clang_analyzer_eval(nglobalStr2); // expected-warning{{TRUE}}
+}
Index: lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
@@ -0,0 +1,134 @@
+//==- NonnullStringConstantsChecker.cpp ---*- C++ -*--//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This checker adds an assumption that constant string-like globals are
+//  non-null, as otherwise they generally do not convey any useful information.
+//  The assumption is useful, as many framework use such global const strings,
+//  and the analyzer might not be able to infer the global value if the
+//  definition is in a separate translation unit.
+//  The following types (and their typedef aliases) are considered string-like:
+//   - `char* const`
+//   - `const CFStringRef` from CoreFoundation
+//   - `NSString* const` from Foundation
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+
+class NonnullStringConstantsChecker : public Checker {
+  mutable IdentifierInfo *N

r315488 - [Analyzer] Assume that string-like const globals are non-nil.

2017-10-11 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed Oct 11 11:39:40 2017
New Revision: 315488

URL: http://llvm.org/viewvc/llvm-project?rev=315488&view=rev
Log:
[Analyzer] Assume that string-like const globals are non-nil.

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

Added:
cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
cfe/trunk/test/Analysis/nonnull-string-constants.mm
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=315488&r1=315487&r2=315488&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Wed Oct 11 
11:39:40 2017
@@ -132,6 +132,10 @@ def DynamicTypePropagation : Checker<"Dy
   HelpText<"Generate dynamic type information">,
   DescFile<"DynamicTypePropagation.cpp">;
 
+def NonnullStringConstantsChecker: Checker<"NonnilStringConstants">,
+  HelpText<"Assume that const string-like globals are non-null">,
+  DescFile<"NonilStringConstantsChecker.cpp">;
+
 } // end "core"
 
 let ParentPackage = CoreAlpha in {

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=315488&r1=315487&r2=315488&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Wed Oct 11 11:39:40 
2017
@@ -57,6 +57,7 @@ add_clang_library(clangStaticAnalyzerChe
   NSErrorChecker.cpp
   NoReturnFunctionChecker.cpp
   NonNullParamChecker.cpp
+  NonnullStringConstantsChecker.cpp
   NullabilityChecker.cpp
   NumberObjectConversionChecker.cpp
   ObjCAtSyncChecker.cpp

Added: cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp?rev=315488&view=auto
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp 
(added)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp Wed 
Oct 11 11:39:40 2017
@@ -0,0 +1,134 @@
+//==- NonnullStringConstantsChecker.cpp ---*- C++ 
-*--//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This checker adds an assumption that constant string-like globals are
+//  non-null, as otherwise they generally do not convey any useful information.
+//  The assumption is useful, as many framework use such global const strings,
+//  and the analyzer might not be able to infer the global value if the
+//  definition is in a separate translation unit.
+//  The following types (and their typedef aliases) are considered string-like:
+//   - `char* const`
+//   - `const CFStringRef` from CoreFoundation
+//   - `NSString* const` from Foundation
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+
+class NonnullStringConstantsChecker : public Checker {
+  mutable IdentifierInfo *NSStringII = nullptr;
+  mutable IdentifierInfo *CFStringRefII = nullptr;
+
+public:
+  NonnullStringConstantsChecker() {}
+
+  void checkLocation(SVal l, bool isLoad, const Stmt *S,
+ CheckerContext &C) const;
+
+private:
+  void initIdentifierInfo(ASTContext &Ctx) const;
+
+  bool isGlobalConstString(SVal V) const;
+
+  bool isStringlike(QualType Ty) const;
+};
+
+} // namespace
+
+/// Lazily initialize cache for required identifier informations.
+void NonnullStringConstantsChecker::initIdentifierInfo(ASTContext &Ctx) const {
+  if (NSStringII)
+return;
+
+  NSStringII = &Ctx.Idents.get("NSString");
+  CFStringRefII = &Ctx.Idents.get("CFStringRef");
+}
+
+/// Add an assumption that const string-like globals are non-null.
+void NonnullStringConstantsChecker::checkLocation(SVal location, bool isLoad,
+ const Stmt *S,
+   

[PATCH] D38764: [Analyzer] Assume const string-like globals are non-null

2017-10-11 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315488: [Analyzer] Assume that string-like const globals are 
non-nil. (authored by george.karpenkov).

Changed prior to commit:
  https://reviews.llvm.org/D38764?vs=118657&id=118660#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38764

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
  cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
  cfe/trunk/test/Analysis/nonnull-string-constants.mm

Index: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -57,6 +57,7 @@
   NSErrorChecker.cpp
   NoReturnFunctionChecker.cpp
   NonNullParamChecker.cpp
+  NonnullStringConstantsChecker.cpp
   NullabilityChecker.cpp
   NumberObjectConversionChecker.cpp
   ObjCAtSyncChecker.cpp
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
@@ -0,0 +1,134 @@
+//==- NonnullStringConstantsChecker.cpp ---*- C++ -*--//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This checker adds an assumption that constant string-like globals are
+//  non-null, as otherwise they generally do not convey any useful information.
+//  The assumption is useful, as many framework use such global const strings,
+//  and the analyzer might not be able to infer the global value if the
+//  definition is in a separate translation unit.
+//  The following types (and their typedef aliases) are considered string-like:
+//   - `char* const`
+//   - `const CFStringRef` from CoreFoundation
+//   - `NSString* const` from Foundation
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+
+class NonnullStringConstantsChecker : public Checker {
+  mutable IdentifierInfo *NSStringII = nullptr;
+  mutable IdentifierInfo *CFStringRefII = nullptr;
+
+public:
+  NonnullStringConstantsChecker() {}
+
+  void checkLocation(SVal l, bool isLoad, const Stmt *S,
+ CheckerContext &C) const;
+
+private:
+  void initIdentifierInfo(ASTContext &Ctx) const;
+
+  bool isGlobalConstString(SVal V) const;
+
+  bool isStringlike(QualType Ty) const;
+};
+
+} // namespace
+
+/// Lazily initialize cache for required identifier informations.
+void NonnullStringConstantsChecker::initIdentifierInfo(ASTContext &Ctx) const {
+  if (NSStringII)
+return;
+
+  NSStringII = &Ctx.Idents.get("NSString");
+  CFStringRefII = &Ctx.Idents.get("CFStringRef");
+}
+
+/// Add an assumption that const string-like globals are non-null.
+void NonnullStringConstantsChecker::checkLocation(SVal location, bool isLoad,
+ const Stmt *S,
+ CheckerContext &C) const {
+  initIdentifierInfo(C.getASTContext());
+  if (!isLoad || !location.isValid())
+return;
+
+  ProgramStateRef State = C.getState();
+  SVal V = State->getSVal(location.castAs());
+
+  if (isGlobalConstString(location)) {
+Optional Constr = V.getAs();
+
+if (Constr) {
+
+  // Assume that the variable is non-null.
+  ProgramStateRef OutputState = State->assume(*Constr, true);
+  C.addTransition(OutputState);
+}
+  }
+}
+
+/// \param V loaded lvalue.
+/// \return whether {@code val} is a string-like const global.
+bool NonnullStringConstantsChecker::isGlobalConstString(SVal V) const {
+  Optional RegionVal = V.getAs();
+  if (!RegionVal)
+return false;
+  auto *Region = dyn_cast(RegionVal->getAsRegion());
+  if (!Region)
+return false;
+  const VarDecl *Decl = Region->getDecl();
+
+  if (!Decl->hasGlobalStorage())
+return false;
+
+  QualType Ty = Decl->getType();
+  bool HasConst = Ty.isConstQualified();
+  if (isStringlike(Ty) && HasConst)
+return true;
+
+  // Look through the typedefs.
+  while (auto *T = dyn_cast(Ty)) {
+Ty = T->getDecl()->getUnderlyingType();
+
+// It is sufficient for any intermediate typ

r315489 - [Analyzer] Remove dead code from testing scripts

2017-10-11 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed Oct 11 11:42:39 2017
New Revision: 315489

URL: http://llvm.org/viewvc/llvm-project?rev=315489&view=rev
Log:
[Analyzer] Remove dead code from testing scripts

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

Modified:
cfe/trunk/utils/analyzer/SATestBuild.py

Modified: cfe/trunk/utils/analyzer/SATestBuild.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/SATestBuild.py?rev=315489&r1=315488&r2=315489&view=diff
==
--- cfe/trunk/utils/analyzer/SATestBuild.py (original)
+++ cfe/trunk/utils/analyzer/SATestBuild.py Wed Oct 11 11:42:39 2017
@@ -653,40 +653,6 @@ def cleanupReferenceResults(SBOutputDir)
 removeLogFile(SBOutputDir)
 
 
-def updateSVN(Mode, PMapFile):
-"""
-svn delete or svn add (depending on `Mode`) all folders defined in the file
-handler `PMapFile`.
-Commit the result to SVN.
-"""
-try:
-for I in iterateOverProjects(PMapFile):
-ProjName = I[0]
-Path = os.path.join(ProjName, getSBOutputDirName(True))
-
-if Mode == "delete":
-Command = "svn delete '%s'" % (Path,)
-else:
-Command = "svn add '%s'" % (Path,)
-
-if Verbose == 1:
-print "  Executing: %s" % (Command,)
-check_call(Command, shell=True)
-
-if Mode == "delete":
-CommitCommand = "svn commit -m \"[analyzer tests] Remove " \
-"reference results.\""
-else:
-CommitCommand = "svn commit -m \"[analyzer tests] Add new " \
-"reference results.\""
-if Verbose == 1:
-print "  Executing: %s" % (CommitCommand,)
-check_call(CommitCommand, shell=True)
-except:
-print "Error: SVN update failed."
-sys.exit(-1)
-
-
 def testProject(ID, ProjectBuildMode, IsReferenceBuild=False, Strictness=0):
 """
 Test a given project.
@@ -757,26 +723,16 @@ def validateProjectFile(PMapFile):
 raise Exception()
 
 
-def testAll(IsReferenceBuild=False, UpdateSVN=False, Strictness=0):
+def testAll(IsReferenceBuild=False, Strictness=0):
 TestsPassed = True
 with projectFileHandler() as PMapFile:
 validateProjectFile(PMapFile)
 
-# When we are regenerating the reference results, we might need to
-# update svn. Remove reference results from SVN.
-if UpdateSVN:
-assert(IsReferenceBuild)
-updateSVN("delete", PMapFile)
-
 # Test the projects.
 for (ProjName, ProjBuildMode) in iterateOverProjects(PMapFile):
 TestsPassed &= testProject(
 ProjName, int(ProjBuildMode), IsReferenceBuild, Strictness)
 
-# Re-add reference results to SVN.
-if UpdateSVN:
-updateSVN("add", PMapFile)
-
 
 if __name__ == '__main__':
 # Parse command line arguments.
@@ -789,20 +745,13 @@ if __name__ == '__main__':
  reference. Default is 0.')
 Parser.add_argument('-r', dest='regenerate', action='store_true',
 default=False, help='Regenerate reference output.')
-Parser.add_argument('-rs', dest='update_reference', action='store_true',
-default=False,
-help='Regenerate reference output and update svn.')
 Args = Parser.parse_args()
 
 IsReference = False
-UpdateSVN = False
 Strictness = Args.strictness
 if Args.regenerate:
 IsReference = True
-elif Args.update_reference:
-IsReference = True
-UpdateSVN = True
 
-TestsPassed = testAll(IsReference, UpdateSVN, Strictness)
+TestsPassed = testAll(IsReference, Strictness)
 if not TestsPassed:
 sys.exit(-1)


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


[PATCH] D35894: [clangd] Code hover for Clangd

2017-10-11 Thread William Enright via Phabricator via cfe-commits
Nebiroth added a comment.

Bumping this.

I've worked on a patch for this feature that currently supports showing the 
declaration of whatever is being hovered on instead of the raw source code. It 
also has basic support to distinguish declarations in types ( class/struct, 
namespace, global variable,  typedef, enum, namespace, etc.) so that we can 
have a 'kind' of a symbol like mentioned in the comments above.

The step I am at right now is figuring out a way to display this information 
inside the box that will be displayed to the client once a response 
(MarkedString) is sent back by the server. I would like some 
feedback/suggestions on whether it's possible to "append" information to a 
MarkedString to be displayed on client? I was also considering extending LSP to 
include more than just a MarkedString for the response in order to have 
something a bit more flexible to use in-client.


https://reviews.llvm.org/D35894



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


[PATCH] D38733: [CodeGen] Generate TBAA info along with LValue base info

2017-10-11 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Sure.


https://reviews.llvm.org/D38733



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


[PATCH] D23963: [analyzer] pr28449 - Move literal rvalue construction away from RegionStore.

2017-10-11 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

OK. Seems reasonable!


https://reviews.llvm.org/D23963



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


r315492 - [Analyzer] Fix introduced regression: properly check for nullable attribute.

2017-10-11 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed Oct 11 12:13:15 2017
New Revision: 315492

URL: http://llvm.org/viewvc/llvm-project?rev=315492&view=rev
Log:
[Analyzer] Fix introduced regression: properly check for nullable attribute.

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

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp?rev=315492&r1=315491&r2=315492&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp 
(original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp Wed 
Oct 11 12:13:15 2017
@@ -122,7 +122,8 @@ bool NonnullStringConstantsChecker::isSt
 return true;
 
   if (auto *T = dyn_cast(Ty)) {
-return T->getInterfaceDecl()->getIdentifier() == NSStringII;
+return T->getInterfaceDecl() &&
+  T->getInterfaceDecl()->getIdentifier() == NSStringII;
   } else if (auto *T = dyn_cast(Ty)) {
 return T->getDecl()->getIdentifier() == CFStringRefII;
   }


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


Re: [clang-tools-extra] r315060 - Renaming a test to start with the name of the check based on post-commit review feedback; NFC.

2017-10-11 Thread Alexander Kornienko via cfe-commits
On Fri, Oct 6, 2017 at 3:27 PM, Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: aaronballman
> Date: Fri Oct  6 06:27:59 2017
> New Revision: 315060
>
> URL: http://llvm.org/viewvc/llvm-project?rev=315060&view=rev
> Log:
> Renaming a test to start with the name of the check based on post-commit
> review feedback; NFC.
>
> Added:
> clang-tools-extra/trunk/test/clang-tidy/google-readability-
> namespace-comments-cxx17
>

Sorry for not being clear. I didn't mean the `.cpp` extension should be
removed. This effectively disables the test, since lit only runs tests in
files with certain extensions (under clang-tools-extra/test these are '.c',
'.cpp', '.hpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.modularize',
'.module-map-checker', '.test').

I've just renamed the file to *.cpp and the test fails for me:

[0/1] Running the Clang extra tools' regression tests
FAIL: Clang Tools ::
clang-tidy/google-readability-namespace-comments-cxx17.cpp (102 of 674)

 TEST 'Clang Tools ::
clang-tidy/google-readability-namespace-comments-cxx17.cpp' FAILED


Script:
--
/usr/bin/python2.7
/src/tools/clang/tools/extra/test/../test/clang-tidy/check_clang_tidy.py
/src/tools/clang/tools/extra/test/clang-tidy/google-readability-namespace-comments-cxx17.cpp
google-readability-namespace-comments
/build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp
-- -- -std=c++17
--
Exit Code: 1

Command Output (stdout):
--
Running ['clang-tidy',
'/build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp.cpp',
'-fix', '--checks=-*,google-readability-namespace-comments', '--',
'-std=c++17', '-nostdinc++']...
 clang-tidy output ---


--

-- Fixes -


--

FileCheck failed:
/src/tools/clang/tools/extra/test/clang-tidy/google-readability-namespace-comments-cxx17.cpp:13:17:
error: expected string not found in input

// CHECK-FIXES: }  // namespace n3
^
/build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp.cpp:1:1:
note: scanning from here

// RUN: %check_clang_tidy %s google-readability-namespace-comments %t -- --
-std=c++17
^
/build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp.cpp:5:7:
note: possible intended match here

  // So that namespace is not empty.
  ^


--
Command Output (stderr):
--
Traceback (most recent call last):
  File
"/src/tools/clang/tools/extra/test/../test/clang-tidy/check_clang_tidy.py",
line 140, in 
main()
  File
"/src/tools/clang/tools/extra/test/../test/clang-tidy/check_clang_tidy.py",
line 121, in main
stderr=subprocess.STDOUT)
  File "/usr/lib/python2.7/subprocess.py", line 573, in check_output

raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['FileCheck',
'-input-file=/build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp.cpp',
'/src/tools/clang/tools/extra/test/clang-tidy/google-readability-namespace-comments-cxx17.cpp',
'-check-prefix=CHECK-FIXES', '-strict-whitespace']' returned non-zero exit
status 1


--


Testing Time: 13.07s

Failing Tests (1):
Clang Tools ::
clang-tidy/google-readability-namespace-comments-cxx17.cpp


  Expected Passes: 673
  Unexpected Failures: 1
FAILED: tools/clang/tools/extra/test/CMakeFiles/check-clang-tools



Did you experience anything similar? Any ideas?

  - copied unchanged from r315059, clang-tools-extra/trunk/test/
> clang-tidy/google-readability-nested-namespace-comments.cpp
> Removed:
> clang-tools-extra/trunk/test/clang-tidy/google-readability-
> nested-namespace-comments.cpp
>
> Removed: clang-tools-extra/trunk/test/clang-tidy/google-readability-
> nested-namespace-comments.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/test/clang-tidy/google-readability-nested-namespace-
> comments.cpp?rev=315059&view=auto
> 
> ==
> --- 
> clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp
> (original)
> +++ 
> clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp
> (removed)
> @@ -1,15 +0,0 @@
> -// RUN: %check_clang_tidy %s google-readability-namespace-comments %t --
> -- -std=c++17
> -
> -namespace n1::n2 {
> -namespace n3 {
> -  // So that namespace is not empty.
> -  void f();
> -
> -// CHECK-MESSAGES: :[[@LINE+4]]:2: warning: namespace 'n3' not terminated
> with
> -// CHECK-MESSAGES: :[[@LINE-7]]:11: note: namespace 'n3' starts here
> -// CHEC

[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-11 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D38679#894668, @jroelofs wrote:

> LGTM


Thanks, will push this one without the docs update since it's still buggy in 
practice on windows until https://reviews.llvm.org/D38680 gets resolved.


https://reviews.llvm.org/D38679



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


[PATCH] D36111: [COFF, ARM64] Add MS builtins __dmb, __dsb, __isb

2017-10-11 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

In https://reviews.llvm.org/D36111#894604, @mstorsjo wrote:

> @mgrang, did you ever get to completing this? I've got a need for this now 
> (only `__dmb` so far), and if you don't have time, I can try to finish it.


Sorry, I never got to complete this as I moved to other priorities. I do not 
think I have cycles to do this now. Please feel free to take over this patch :)


https://reviews.llvm.org/D36111



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


Re: [clang-tools-extra] r315060 - Renaming a test to start with the name of the check based on post-commit review feedback; NFC.

2017-10-11 Thread Aaron Ballman via cfe-commits
On Wed, Oct 11, 2017 at 3:29 PM, Alexander Kornienko  wrote:
> On Fri, Oct 6, 2017 at 3:27 PM, Aaron Ballman via cfe-commits
>  wrote:
>>
>> Author: aaronballman
>> Date: Fri Oct  6 06:27:59 2017
>> New Revision: 315060
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=315060&view=rev
>> Log:
>> Renaming a test to start with the name of the check based on post-commit
>> review feedback; NFC.
>>
>> Added:
>>
>> clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments-cxx17
>
>
> Sorry for not being clear. I didn't mean the `.cpp` extension should be
> removed. This effectively disables the test, since lit only runs tests in
> files with certain extensions (under clang-tools-extra/test these are '.c',
> '.cpp', '.hpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.modularize',
> '.module-map-checker', '.test').

That's entirely my fault -- I should have recognized that. Sorry for
the trouble!

> I've just renamed the file to *.cpp and the test fails for me:
>
> [0/1] Running the Clang extra tools' regression tests
> FAIL: Clang Tools ::
> clang-tidy/google-readability-namespace-comments-cxx17.cpp (102 of 674)
>  TEST 'Clang Tools ::
> clang-tidy/google-readability-namespace-comments-cxx17.cpp' FAILED
> 
> Script:
> --
> /usr/bin/python2.7
> /src/tools/clang/tools/extra/test/../test/clang-tidy/check_clang_tidy.py
> /src/tools/clang/tools/extra/test/clang-tidy/google-readability-namespace-comments-cxx17.cpp
> google-readability-namespace-comments
> /build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp
> -- -- -std=c++17
> --
> Exit Code: 1
>
> Command Output (stdout):
> --
> Running ['clang-tidy',
> '/build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp.cpp',
> '-fix', '--checks=-*,google-readability-namespace-comments', '--',
> '-std=c++17', '-nostdinc++']...
>  clang-tidy output ---
>
> --
> -- Fixes -
>
> --
> FileCheck failed:
> /src/tools/clang/tools/extra/test/clang-tidy/google-readability-namespace-comments-cxx17.cpp:13:17:
> error: expected string not found in input
> // CHECK-FIXES: }  // namespace n3
> ^
> /build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp.cpp:1:1:
> note: scanning from here
> // RUN: %check_clang_tidy %s google-readability-namespace-comments %t -- --
> -std=c++17
> ^
> /build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp.cpp:5:7:
> note: possible intended match here
>   // So that namespace is not empty.
>   ^
>
>
> --
> Command Output (stderr):
> --
> Traceback (most recent call last):
>   File
> "/src/tools/clang/tools/extra/test/../test/clang-tidy/check_clang_tidy.py",
> line 140, in 
> main()
>   File
> "/src/tools/clang/tools/extra/test/../test/clang-tidy/check_clang_tidy.py",
> line 121, in main
> stderr=subprocess.STDOUT)
>   File "/usr/lib/python2.7/subprocess.py", line 573, in check_output
> raise CalledProcessError(retcode, cmd, output=output)
> subprocess.CalledProcessError: Command '['FileCheck',
> '-input-file=/build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp.cpp',
> '/src/tools/clang/tools/extra/test/clang-tidy/google-readability-namespace-comments-cxx17.cpp',
> '-check-prefix=CHECK-FIXES', '-strict-whitespace']' returned non-zero exit
> status 1
>
> --
>
> 
> Testing Time: 13.07s
> 
> Failing Tests (1):
> Clang Tools ::
> clang-tidy/google-readability-namespace-comments-cxx17.cpp
>
>   Expected Passes: 673
>   Unexpected Failures: 1
> FAILED: tools/clang/tools/extra/test/CMakeFiles/check-clang-tools
>
>
> Did you experience anything similar? Any ideas?

I now get the same behavior that you're seeing. I'm not certain what's
going on there (and don't have the time to look into it at the
moment), but perhaps Jonas has ideas.

~Aaron

>
>>   - copied unchanged from r315059,
>> clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp
>> Removed:
>>
>> clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp
>>
>> Removed:
>> clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp?rev=315059&view=auto
>>
>> ==
>> ---
>> clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp
>> (original)
>> +++
>> clang-tools-ex

[PATCH] D36111: [COFF, ARM64] Add MS builtins __dmb, __dsb, __isb

2017-10-11 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D36111#895084, @mgrang wrote:

> Sorry, I never got to complete this as I moved to other priorities. I do not 
> think I have cycles to do this now. Please feel free to take over this patch 
> :)


Ok - will do! Thanks for letting me know!


https://reviews.llvm.org/D36111



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


[PATCH] D38816: Convert clang::LangAS to a strongly typed enum

2017-10-11 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson created this revision.
Herald added subscribers: Anastasia, nhaehnle, jholewinski.

Currently both clang AST address spaces and target specific address spaces
are represented as unsigned which can lead to subtle errors if the wrong
type is passed. It is especially confusing in the CodeGen files as it is
not possible to see what kind of address space should be passed to a
function without looking at the implementation.
I originally made this change for our LLVM fork for the CHERI architecture
where we make extensive use of address spaces to differentiate between
capabilities and pointers. When merging the upstream changes I usually
run into some test failures or runtime crashes because the wrong kind of
address space is passed to a function. By converting the LangAS enum to a
C++11 we can catch these errors at compile time. Additionally, it is now
obvious from the function signature which kind of address space it expects.

I found the following errors while writing this patch:

- ItaniumRecordLayoutBuilder::LayoutField was passing a clang AST address space 
to  TargetInfo::getPointer{Width,Align}()
- TypePrinter::printAttributedAfter() was printing the numeric value of the 
clang AST address space instead of the target address space
- initializeForBlockHeader() in CGBlocks.cpp was passing LangAS::opencl_generic 
to TargetInfo::getPointer{Width,Align}()
- CodeGenFunction::EmitBlockLiteral() was passing a AST address space to 
TargetInfo::getPointerWidth()
- clang_getAddressSpace() was returning either a LangAS or a target address 
address space. I made it consistently return a target address space
- CGOpenMPRuntimeNVPTX::translateParameter() passed a target address space to 
Qualifiers::addAddressSpace()
- CGOpenMPRuntimeNVPTX::getParameterAddress() was using 
llvm::Type::getPointerTo() with a AST address space

Other than this the patch should not cause any functional changes.


Repository:
  rL LLVM

https://reviews.llvm.org/D38816

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Type.h
  include/clang/Basic/AddressSpaces.h
  include/clang/Basic/TargetInfo.h
  lib/AST/ASTContext.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/RecordLayoutBuilder.cpp
  lib/AST/TypePrinter.cpp
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets/AMDGPU.cpp
  lib/Basic/Targets/AMDGPU.h
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGValue.h
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/CodeGenTypeCache.h
  lib/CodeGen/ConstantEmitter.h
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaType.cpp
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -398,12 +398,8 @@
 
 unsigned clang_getAddressSpace(CXType CT) {
   QualType T = GetQualType(CT);
-
-  // For non language-specific address space, use separate helper function.
-  if (T.getAddressSpace() >= LangAS::FirstTargetAddressSpace) {
-return T.getQualifiers().getAddressSpaceAttributePrintValue();
-  }
-  return T.getAddressSpace();
+  ASTContext &Ctx = cxtu::getASTUnit(GetTU(CT))->getASTContext();
+  return Ctx.getTargetAddressSpace(T);
 }
 
 CXString clang_getTypedefName(CXType CT) {
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -5632,7 +5632,7 @@
 // If this type is already address space qualified, reject it.
 // ISO/IEC TR 18037 S5.3 (amending C99 6.7.3): "No type shall be qualified
 // by qualifiers for two or more different address spaces."
-if (T.getAddressSpace()) {
+if (T.getAddressSpace() != LangAS::Default) {
   Diag(AttrLoc, diag::err_attribute_address_multiple_qualifiers);
   return QualType();
 }
@@ -5656,15 +5656,16 @@
 }
 
 llvm::APSInt max(addrSpace.getBitWidth());
-max = Qualifiers::MaxAddressSpace - LangAS::FirstTargetAddressSpace;
+max =
+Qualifiers::MaxAddressSpace - (unsigned)LangAS::FirstTargetAddressSpace;
 if (addrSpace > max) {
   Diag(AttrLoc, diag::err_attribute_address_space_too_high)
   << (unsigned)max.getZExtValue() << AddrSpace->getSourceRange();
   return QualType();
 }
 
-unsigned ASIdx = static_cast(addrSpace.getZExtValue()) +
- LangAS::FirstTargetAddressSpace;
+LangAS ASIdx = LanguageAS::fromTargetAS(
+static_cast(addrSpace.getZExtValue()));
 
 return Context.getAddrSpaceQualType(T, ASIdx);
   }
@@ -5690,7 +5691,7 @@
   // If this type is already address space qualified, reject it.
   // ISO/IEC TR 18

[libunwind] r315498 - Support DWARF unwinding on i386 windows

2017-10-11 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Wed Oct 11 13:06:18 2017
New Revision: 315498

URL: http://llvm.org/viewvc/llvm-project?rev=315498&view=rev
Log:
Support DWARF unwinding on i386 windows

In practice, with code built with clang, there are still unresolved
issues with DW_CFA_GNU_args_size though.

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

Modified:
libunwind/trunk/src/AddressSpace.hpp
libunwind/trunk/src/UnwindRegistersRestore.S
libunwind/trunk/src/assembly.h
libunwind/trunk/src/config.h

Modified: libunwind/trunk/src/AddressSpace.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/AddressSpace.hpp?rev=315498&r1=315497&r2=315498&view=diff
==
--- libunwind/trunk/src/AddressSpace.hpp (original)
+++ libunwind/trunk/src/AddressSpace.hpp Wed Oct 11 13:06:18 2017
@@ -18,7 +18,7 @@
 #include 
 #include 
 
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
 #include 
 #endif
 
@@ -97,7 +97,12 @@ extern char __exidx_end;
 // independent ELF header traversal is not provided by  on some
 // systems (e.g., FreeBSD). On these systems the data structures are
 // just called Elf_XXX. Define ElfW() locally.
+#ifndef _WIN32
 #include 
+#else
+#include 
+#include 
+#endif
 #if !defined(ElfW)
 #define ElfW(type) Elf_##type
 #endif
@@ -356,6 +361,43 @@ inline bool LocalAddressSpace::findUnwin
  info.arm_section, info.arm_section_length);
   if (info.arm_section && info.arm_section_length)
 return true;
+#elif defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) && defined(_WIN32)
+  HMODULE mods[1024];
+  HANDLE process = GetCurrentProcess();
+  DWORD needed;
+
+  if (!EnumProcessModules(process, mods, sizeof(mods), &needed))
+return false;
+
+  for (unsigned i = 0; i < (needed / sizeof(HMODULE)); i++) {
+PIMAGE_DOS_HEADER pidh = (PIMAGE_DOS_HEADER)mods[i];
+PIMAGE_NT_HEADERS pinh = (PIMAGE_NT_HEADERS)((BYTE *)pidh + 
pidh->e_lfanew);
+PIMAGE_FILE_HEADER pifh = (PIMAGE_FILE_HEADER)&pinh->FileHeader;
+PIMAGE_SECTION_HEADER pish = IMAGE_FIRST_SECTION(pinh);
+bool found_obj = false;
+bool found_hdr = false;
+
+info.dso_base = (uintptr_t)mods[i];
+for (unsigned j = 0; j < pifh->NumberOfSections; j++, pish++) {
+  uintptr_t begin = pish->VirtualAddress + (uintptr_t)mods[i];
+  uintptr_t end = begin + pish->Misc.VirtualSize;
+  if (!strncmp((const char *)pish->Name, ".text",
+   IMAGE_SIZEOF_SHORT_NAME)) {
+if (targetAddr >= begin && targetAddr < end)
+  found_obj = true;
+  } else if (!strncmp((const char *)pish->Name, ".eh_frame",
+  IMAGE_SIZEOF_SHORT_NAME)) {
+// FIXME: This section name actually is truncated, ideally we
+// should locate and check the full long name instead.
+info.dwarf_section = begin;
+info.dwarf_section_length = pish->Misc.VirtualSize;
+found_hdr = true;
+  }
+  if (found_obj && found_hdr)
+return true;
+}
+  }
+  return false;
 #elif defined(_LIBUNWIND_ARM_EHABI) || defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
   struct dl_iterate_cb_data {
 LocalAddressSpace *addressSpace;
@@ -478,7 +520,7 @@ inline bool LocalAddressSpace::findOther
 inline bool LocalAddressSpace::findFunctionName(pint_t addr, char *buf,
 size_t bufLen,
 unw_word_t *offset) {
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
   Dl_info dyldInfo;
   if (dladdr((void *)addr, &dyldInfo)) {
 if (dyldInfo.dli_sname != NULL) {

Modified: libunwind/trunk/src/UnwindRegistersRestore.S
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindRegistersRestore.S?rev=315498&r1=315497&r2=315498&view=diff
==
--- libunwind/trunk/src/UnwindRegistersRestore.S (original)
+++ libunwind/trunk/src/UnwindRegistersRestore.S Wed Oct 11 13:06:18 2017
@@ -18,6 +18,10 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9li
 #
 # void libunwind::Registers_x86::jumpto()
 #
+#if defined(_WIN32)
+# On windows, the 'this' pointer is passed in ecx instead of on the stack
+  movl   %ecx, %eax
+#else
 # On entry:
 #  +   +
 #  +---+
@@ -27,6 +31,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9li
 #  +---+   <-- SP
 #  +   +
   movl   4(%esp), %eax
+#endif
   # set up eax and ret on new stack location
   movl  28(%eax), %edx # edx holds new stack pointer
   subl  $8,%edx

Modified: libunwind/trunk/src/assembly.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/assembly.h?rev=315498&r1=315497&r2=315498&view=diff
==
--- libunwind/trunk/src/assembly.h (original)
+++ libunwi

[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-11 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315498: Support DWARF unwinding on i386 windows (authored by 
mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D38679?vs=118263&id=118673#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38679

Files:
  libunwind/trunk/src/AddressSpace.hpp
  libunwind/trunk/src/UnwindRegistersRestore.S
  libunwind/trunk/src/assembly.h
  libunwind/trunk/src/config.h

Index: libunwind/trunk/src/UnwindRegistersRestore.S
===
--- libunwind/trunk/src/UnwindRegistersRestore.S
+++ libunwind/trunk/src/UnwindRegistersRestore.S
@@ -18,6 +18,10 @@
 #
 # void libunwind::Registers_x86::jumpto()
 #
+#if defined(_WIN32)
+# On windows, the 'this' pointer is passed in ecx instead of on the stack
+  movl   %ecx, %eax
+#else
 # On entry:
 #  +   +
 #  +---+
@@ -27,6 +31,7 @@
 #  +---+   <-- SP
 #  +   +
   movl   4(%esp), %eax
+#endif
   # set up eax and ret on new stack location
   movl  28(%eax), %edx # edx holds new stack pointer
   subl  $8,%edx
Index: libunwind/trunk/src/config.h
===
--- libunwind/trunk/src/config.h
+++ libunwind/trunk/src/config.h
@@ -37,6 +37,8 @@
 #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND
 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND   1
   #endif
+#elif defined(_WIN32)
+  #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
 #else
   #if defined(__ARM_DWARF_EH__) || !defined(__arm__)
 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
Index: libunwind/trunk/src/AddressSpace.hpp
===
--- libunwind/trunk/src/AddressSpace.hpp
+++ libunwind/trunk/src/AddressSpace.hpp
@@ -18,7 +18,7 @@
 #include 
 #include 
 
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
 #include 
 #endif
 
@@ -97,7 +97,12 @@
 // independent ELF header traversal is not provided by  on some
 // systems (e.g., FreeBSD). On these systems the data structures are
 // just called Elf_XXX. Define ElfW() locally.
+#ifndef _WIN32
 #include 
+#else
+#include 
+#include 
+#endif
 #if !defined(ElfW)
 #define ElfW(type) Elf_##type
 #endif
@@ -356,6 +361,43 @@
  info.arm_section, info.arm_section_length);
   if (info.arm_section && info.arm_section_length)
 return true;
+#elif defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) && defined(_WIN32)
+  HMODULE mods[1024];
+  HANDLE process = GetCurrentProcess();
+  DWORD needed;
+
+  if (!EnumProcessModules(process, mods, sizeof(mods), &needed))
+return false;
+
+  for (unsigned i = 0; i < (needed / sizeof(HMODULE)); i++) {
+PIMAGE_DOS_HEADER pidh = (PIMAGE_DOS_HEADER)mods[i];
+PIMAGE_NT_HEADERS pinh = (PIMAGE_NT_HEADERS)((BYTE *)pidh + pidh->e_lfanew);
+PIMAGE_FILE_HEADER pifh = (PIMAGE_FILE_HEADER)&pinh->FileHeader;
+PIMAGE_SECTION_HEADER pish = IMAGE_FIRST_SECTION(pinh);
+bool found_obj = false;
+bool found_hdr = false;
+
+info.dso_base = (uintptr_t)mods[i];
+for (unsigned j = 0; j < pifh->NumberOfSections; j++, pish++) {
+  uintptr_t begin = pish->VirtualAddress + (uintptr_t)mods[i];
+  uintptr_t end = begin + pish->Misc.VirtualSize;
+  if (!strncmp((const char *)pish->Name, ".text",
+   IMAGE_SIZEOF_SHORT_NAME)) {
+if (targetAddr >= begin && targetAddr < end)
+  found_obj = true;
+  } else if (!strncmp((const char *)pish->Name, ".eh_frame",
+  IMAGE_SIZEOF_SHORT_NAME)) {
+// FIXME: This section name actually is truncated, ideally we
+// should locate and check the full long name instead.
+info.dwarf_section = begin;
+info.dwarf_section_length = pish->Misc.VirtualSize;
+found_hdr = true;
+  }
+  if (found_obj && found_hdr)
+return true;
+}
+  }
+  return false;
 #elif defined(_LIBUNWIND_ARM_EHABI) || defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
   struct dl_iterate_cb_data {
 LocalAddressSpace *addressSpace;
@@ -478,7 +520,7 @@
 inline bool LocalAddressSpace::findFunctionName(pint_t addr, char *buf,
 size_t bufLen,
 unw_word_t *offset) {
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
   Dl_info dyldInfo;
   if (dladdr((void *)addr, &dyldInfo)) {
 if (dyldInfo.dli_sname != NULL) {
Index: libunwind/trunk/src/assembly.h
===
--- libunwind/trunk/src/assembly.h
+++ libunwind/trunk/src/assembly.h
@@ -26,6 +26,14 @@
 
 #if defined(__APPLE__)
 #define HIDDEN_DIRECTIVE .private_extern
+#elif defined(_WIN32)
+// In the COFF object file format, there's no attributes for a global,
+// non-static symbol to make it somehow hidden. S

[PATCH] D38134: [OpenCL] Emit enqueued block as kernel

2017-10-11 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 118677.
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

Revised by Anastasia's comments. Get block invoke function by API instead of 
iterate through IR's. Pass the block kernel directly to `__enqueu_kernel 
functions`.


https://reviews.llvm.org/D38134

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CGOpenCLRuntime.h
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenTypes.h
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl
  test/CodeGenOpenCL/cl20-device-side-enqueue.cl

Index: test/CodeGenOpenCL/cl20-device-side-enqueue.cl
===
--- test/CodeGenOpenCL/cl20-device-side-enqueue.cl
+++ test/CodeGenOpenCL/cl20-device-side-enqueue.cl
@@ -6,10 +6,30 @@
 typedef void (^bl_t)(local void *);
 typedef struct {int a;} ndrange_t;
 
-// N.B. The check here only exists to set BL_GLOBAL
-// COMMON: @block_G =  addrspace(1) constant void (i8 addrspace(3)*) addrspace(4)* addrspacecast (void (i8 addrspace(3)*) addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BL_GLOBAL:@__block_literal_global(\.[0-9]+)?]] to void (i8 addrspace(3)*) addrspace(1)*) to void (i8 addrspace(3)*) addrspace(4)*)
+// COMMON: %struct.__opencl_block_literal_generic = type { i32, i32, i8 addrspace(4)* }
+
+// For a block global variable, first emit the block literal as a global variable, then emit the block variable itself.
+// COMMON: [[BL_GLOBAL:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* [[INV_G:@[^ ]+]] to i8*) to i8 addrspace(4)*) }
+// COMMON: @block_G =  addrspace(1) constant void (i8 addrspace(3)*) addrspace(4)* addrspacecast (void (i8 addrspace(3)*) addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BL_GLOBAL]] to void (i8 addrspace(3)*) addrspace(1)*) to void (i8 addrspace(3)*) addrspace(4)*)
+
+// For anonymous blocks without captures, emit block literals as global variable.
+// COMMON: [[BLG1:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* {{@[^ ]+}} to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG2:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* {{@[^ ]+}} to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG3:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* {{@[^ ]+}} to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG4:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* {{@[^ ]+}} to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG5:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* {{@[^ ]+}} to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG6:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*, i8 addrspace(3)*, i8 addrspace(3)*)* {{@[^ ]+}} to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG7:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* {{@[^ ]+}} to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG8:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*)* [[INVG8:@[^ ]+]] to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG9:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* [[INVG9:@[^ ]+]] to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG10:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*)* {{@[^ ]+}} to i8*) to i8 add

[PATCH] D38819: [libunwind] Add support for dwarf unwinding on windows on x86_64

2017-10-11 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
Herald added a subscriber: aprantl.

Clang doesn't currently support building for windows/x86_64 with dwarf by 
setting command line parameters, but if manually modified to use dwarf, we can 
make libunwind work in this configuration as well.

Even if support for this is deemed pointless, I guess one could omit the 
assembly changes, but the fixes for the generic code probably are worthwhile at 
least.


https://reviews.llvm.org/D38819

Files:
  docs/index.rst
  include/unwind.h
  src/AddressSpace.hpp
  src/UnwindLevel1.c
  src/UnwindRegistersRestore.S
  src/UnwindRegistersSave.S

Index: src/UnwindRegistersSave.S
===
--- src/UnwindRegistersSave.S
+++ src/UnwindRegistersSave.S
@@ -63,6 +63,27 @@
 #  thread_state pointer is in rdi
 #
 DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
+#if defined(_WIN32)
+  movq  %rax,   (%rcx)
+  movq  %rbx,  8(%rcx)
+  movq  %rcx, 16(%rcx)
+  movq  %rdx, 24(%rcx)
+  movq  %rdi, 32(%rcx)
+  movq  %rsi, 40(%rcx)
+  movq  %rbp, 48(%rcx)
+  movq  %rsp, 56(%rcx)
+  addq  $8,   56(%rcx)
+  movq  %r8,  64(%rcx)
+  movq  %r9,  72(%rcx)
+  movq  %r10, 80(%rcx)
+  movq  %r11, 88(%rcx)
+  movq  %r12, 96(%rcx)
+  movq  %r13,104(%rcx)
+  movq  %r14,112(%rcx)
+  movq  %r15,120(%rcx)
+  movq  (%rsp),%rdx
+  movq  %rdx,128(%rcx) # store return address as rip
+#else
   movq  %rax,   (%rdi)
   movq  %rbx,  8(%rdi)
   movq  %rcx, 16(%rdi)
@@ -82,6 +103,7 @@
   movq  %r15,120(%rdi)
   movq  (%rsp),%rsi
   movq  %rsi,128(%rdi) # store return address as rip
+#endif
   # skip rflags
   # skip cs
   # skip fs
Index: src/UnwindRegistersRestore.S
===
--- src/UnwindRegistersRestore.S
+++ src/UnwindRegistersRestore.S
@@ -65,6 +65,40 @@
 #
 # void libunwind::Registers_x86_64::jumpto()
 #
+#if defined(_WIN32)
+# On entry, thread_state pointer is in rcx
+
+  movq  56(%rcx), %rax # rax holds new stack pointer
+  subq  $16, %rax
+  movq  %rax, 56(%rcx)
+  movq  16(%rcx), %rdx  # store new rcx on new stack
+  movq  %rdx, 0(%rax)
+  movq  128(%rcx), %rdx # store new rip on new stack
+  movq  %rdx, 8(%rax)
+  # restore all registers
+  movq0(%rcx), %rax
+  movq8(%rcx), %rbx
+  # restore rcx later
+  movq   24(%rcx), %rdx
+  movq   32(%rcx), %rdi
+  movq   40(%rcx), %rsi
+  movq   48(%rcx), %rbp
+  # restore rsp later
+  movq   64(%rcx), %r8
+  movq   72(%rcx), %r9
+  movq   80(%rcx), %r10
+  movq   88(%rcx), %r11
+  movq   96(%rcx), %r12
+  movq  104(%rcx), %r13
+  movq  112(%rcx), %r14
+  movq  120(%rcx), %r15
+  # skip rflags
+  # skip cs
+  # skip fs
+  # skip gs
+  movq  56(%rcx), %rsp  # cut back rsp to new location
+  pop%rcx  # rcx was saved here earlier
+#else
 # On entry, thread_state pointer is in rdi
 
   movq  56(%rdi), %rax # rax holds new stack pointer
@@ -97,6 +131,7 @@
   # skip gs
   movq  56(%rdi), %rsp  # cut back rsp to new location
   pop%rdi  # rdi was saved here earlier
+#endif
   ret# rip was saved here
 
 
Index: src/UnwindLevel1.c
===
--- src/UnwindLevel1.c
+++ src/UnwindLevel1.c
@@ -86,7 +86,7 @@
 // this frame.
 if (frameInfo.handler != 0) {
   __personality_routine p =
-  (__personality_routine)(long)(frameInfo.handler);
+  (__personality_routine)(uintptr_t)(frameInfo.handler);
   _LIBUNWIND_TRACE_UNWINDING(
   "unwind_phase1(ex_ojb=%p): calling personality function %p",
   (void *)exception_object, (void *)(uintptr_t)p);
@@ -181,7 +181,7 @@
 // If there is a personality routine, tell it we are unwinding.
 if (frameInfo.handler != 0) {
   __personality_routine p =
-  (__personality_routine)(long)(frameInfo.handler);
+  (__personality_routine)(uintptr_t)(frameInfo.handler);
   _Unwind_Action action = _UA_CLEANUP_PHASE;
   if (sp == exception_object->private_2) {
 // Tell personality this was the frame it marked in phase 1.
Index: src/AddressSpace.hpp
===
--- src/AddressSpace.hpp
+++ src/AddressSpace.hpp
@@ -142,7 +142,7 @@
 /// making local unwinds fast.
 class __attribute__((visibility("hidden"))) LocalAddressSpace {
 public:
-#ifdef __LP64__
+#if defined(__LP64__) || defined(_WIN64)
   typedef uint64_t pint_t;
   typedef int64_t  sint_t;
 #else
@@ -194,7 +194,7 @@
 };
 
 inline uintptr_t LocalAddressSpace::getP(pint_t addr) {
-#ifdef __LP64__
+#if defined(__LP64__) || defined(_WIN64)
   return get64(addr);
 #else
   return get32(addr);
Index: include/unwind.h
===
--- include/unwind.h
+++ include/unwind.h
@@ -122,7 +122,7 @@
 _Unwind_Exception *exc);
   uintptr_t private_1; // non-zero means forced unwind
   uintptr_t private_2; // holds sp that phase1 found for phase2 to use
-#ifndef __LP

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

2017-10-11 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

If there is no other issues. May I commit this patch now? Thanks.


https://reviews.llvm.org/D35082



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


[PATCH] D38820: [CGExprScalar] Add missing types in function GetIntrinsic

2017-10-11 Thread Guozhi Wei via Phabricator via cfe-commits
Carrot created this revision.

In function GetIntrinsic, not all types are covered. Types double and long long 
are missed, type long is wrongly treated same as int, it should be same as long 
long. These problems cause compiler crashes when compiling code in PR31161. 
This patch fixed the problem.


https://reviews.llvm.org/D38820

Files:
  lib/CodeGen/CGExprScalar.cpp
  test/CodeGen/ppc-vector-compare.cc


Index: test/CodeGen/ppc-vector-compare.cc
===
--- test/CodeGen/ppc-vector-compare.cc
+++ test/CodeGen/ppc-vector-compare.cc
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown 
-emit-llvm %s \
+// RUN: %clang_cc1 -target-feature +vsx -triple powerpc64-unknown-unknown 
-emit-llvm %s \
 // RUN:-o - | FileCheck %s
 
 #include 
@@ -9,3 +9,26 @@
   return v1 == v2;
 }
 
+// CHECK-LABEL: @_Z5test2Dv2_mS_Dv2_lS0_Dv2_yS1_Dv2_xS2_Dv2_dS3_
+bool test2(vector unsigned long v1, vector unsigned long v2,
+   vector long v3, vector long v4,
+   vector unsigned long long v5, vector unsigned long long v6,
+   vector long long v7, vector long long v8,
+   vector double v9, vector double v10) {
+  // CHECK: @llvm.ppc.altivec.vcmpequd.p
+  bool res = v1 == v2;
+
+  // CHECK: @llvm.ppc.altivec.vcmpequd.p
+  res |= v3 == v4;
+
+  // CHECK: @llvm.ppc.altivec.vcmpequd.p
+  res |= v5 == v6;
+
+  // CHECK: @llvm.ppc.altivec.vcmpequd.p
+  res |= v7 == v8;
+
+  // CHECK: @llvm.ppc.vsx.xvcmpeqdp.p
+  res |= v9 == v10;
+  return res;
+}
+
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -3120,16 +3120,25 @@
 return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequh_p :
 llvm::Intrinsic::ppc_altivec_vcmpgtsh_p;
   case BuiltinType::UInt:
-  case BuiltinType::ULong:
 return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequw_p :
 llvm::Intrinsic::ppc_altivec_vcmpgtuw_p;
   case BuiltinType::Int:
-  case BuiltinType::Long:
 return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequw_p :
 llvm::Intrinsic::ppc_altivec_vcmpgtsw_p;
+  case BuiltinType::ULong:
+  case BuiltinType::ULongLong:
+return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequd_p :
+llvm::Intrinsic::ppc_altivec_vcmpgtud_p;
+  case BuiltinType::Long:
+  case BuiltinType::LongLong:
+return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequd_p :
+llvm::Intrinsic::ppc_altivec_vcmpgtsd_p;
   case BuiltinType::Float:
 return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpeqfp_p :
 llvm::Intrinsic::ppc_altivec_vcmpgtfp_p;
+  case BuiltinType::Double:
+return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_vsx_xvcmpeqdp_p :
+llvm::Intrinsic::ppc_vsx_xvcmpgtdp_p;
   }
 }
 


Index: test/CodeGen/ppc-vector-compare.cc
===
--- test/CodeGen/ppc-vector-compare.cc
+++ test/CodeGen/ppc-vector-compare.cc
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown -emit-llvm %s \
+// RUN: %clang_cc1 -target-feature +vsx -triple powerpc64-unknown-unknown -emit-llvm %s \
 // RUN:-o - | FileCheck %s
 
 #include 
@@ -9,3 +9,26 @@
   return v1 == v2;
 }
 
+// CHECK-LABEL: @_Z5test2Dv2_mS_Dv2_lS0_Dv2_yS1_Dv2_xS2_Dv2_dS3_
+bool test2(vector unsigned long v1, vector unsigned long v2,
+   vector long v3, vector long v4,
+   vector unsigned long long v5, vector unsigned long long v6,
+   vector long long v7, vector long long v8,
+   vector double v9, vector double v10) {
+  // CHECK: @llvm.ppc.altivec.vcmpequd.p
+  bool res = v1 == v2;
+
+  // CHECK: @llvm.ppc.altivec.vcmpequd.p
+  res |= v3 == v4;
+
+  // CHECK: @llvm.ppc.altivec.vcmpequd.p
+  res |= v5 == v6;
+
+  // CHECK: @llvm.ppc.altivec.vcmpequd.p
+  res |= v7 == v8;
+
+  // CHECK: @llvm.ppc.vsx.xvcmpeqdp.p
+  res |= v9 == v10;
+  return res;
+}
+
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -3120,16 +3120,25 @@
 return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequh_p :
 llvm::Intrinsic::ppc_altivec_vcmpgtsh_p;
   case BuiltinType::UInt:
-  case BuiltinType::ULong:
 return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequw_p :
 llvm::Intrinsic::ppc_altivec_vcmpgtuw_p;
   case BuiltinType::Int:
-  case BuiltinType::Long:
 return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequw_p :
 llvm::Intrinsic::ppc_altivec_vcmpgtsw_p;
+  case BuiltinType::ULong:
+  case Builti

[PATCH] D38816: Convert clang::LangAS to a strongly typed enum

2017-10-11 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

My only regret is that I have but one +1 to give to this patch.




Comment at: include/clang/Basic/AddressSpaces.h:51
 
+namespace LanguageAS {
 /// The type of a lookup table which maps from language-specific address spaces

I wonder if you need this namespace?  LangAS right next to LanguageAS reads 
strangely to me -- "what's the difference?".

I guess you'd need to rename Map and fromTargetAS, but the other two members 
are probably OK?


Repository:
  rL LLVM

https://reviews.llvm.org/D38816



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


[PATCH] D38430: Enable -pie and --enable-new-dtags by default on Android.

2017-10-11 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added a comment.

ping


https://reviews.llvm.org/D38430



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


r315506 - [clang-fuzzer] Build with newer protobuf-mutator.

2017-10-11 Thread Matt Morehouse via cfe-commits
Author: morehouse
Date: Wed Oct 11 13:45:10 2017
New Revision: 315506

URL: http://llvm.org/viewvc/llvm-project?rev=315506&view=rev
Log:
[clang-fuzzer] Build with newer protobuf-mutator.

Modified:
cfe/trunk/cmake/modules/ProtobufMutator.cmake

Modified: cfe/trunk/cmake/modules/ProtobufMutator.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/ProtobufMutator.cmake?rev=315506&r1=315505&r2=315506&view=diff
==
--- cfe/trunk/cmake/modules/ProtobufMutator.cmake (original)
+++ cfe/trunk/cmake/modules/ProtobufMutator.cmake Wed Oct 11 13:45:10 2017
@@ -6,7 +6,7 @@ set(PBM_FUZZ_LIB_PATH ${PBM_PATH}/src/li
 ExternalProject_Add(${PBM_PREFIX}
   PREFIX ${PBM_PREFIX}
   GIT_REPOSITORY https://github.com/google/libprotobuf-mutator.git
-  GIT_TAG 17789d1
+  GIT_TAG e4eae60
   CONFIGURE_COMMAND ${CMAKE_COMMAND} -G${CMAKE_GENERATOR}
 -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
 -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}


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


[PATCH] D38819: [libunwind] Add support for dwarf unwinding on windows on x86_64

2017-10-11 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

As further explanation/justification - libcxxabi and libunwind don't support 
SEH exceptions yet.


https://reviews.llvm.org/D38819



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


[PATCH] D38810: [Analyzer] Support bodyfarming std::call_once for libstdc++

2017-10-11 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315508: [Analyzer] Support bodyfarming libstdc++ 
implementation of std::call_once. (authored by george.karpenkov).

Changed prior to commit:
  https://reviews.llvm.org/D38810?vs=118644&id=118686#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38810

Files:
  cfe/trunk/lib/Analysis/BodyFarm.cpp
  cfe/trunk/test/Analysis/call_once.cpp

Index: cfe/trunk/test/Analysis/call_once.cpp
===
--- cfe/trunk/test/Analysis/call_once.cpp
+++ cfe/trunk/test/Analysis/call_once.cpp
@@ -1,15 +1,24 @@
-// RUN: %clang_analyze_cc1 -std=c++11 -fblocks -analyzer-checker=core,debug.ExprInspection -w -verify %s
+// RUN: %clang_analyze_cc1 -std=c++11 -fblocks -analyzer-checker=core,debug.ExprInspection -verify %s
+// RUN: %clang_analyze_cc1 -std=c++11 -fblocks -analyzer-checker=core,debug.ExprInspection -DEMULATE_LIBSTDCPP -verify %s
 
 void clang_analyzer_eval(bool);
 
 // Faking std::std::call_once implementation.
 namespace std {
+
+#ifndef EMULATE_LIBSTDCPP
 typedef struct once_flag_s {
   unsigned long __state_ = 0;
 } once_flag;
+#else
+typedef struct once_flag_s {
+  int _M_once = 0;
+} once_flag;
+#endif
 
 template 
 void call_once(once_flag &o, Callable func, Args... args) {};
+
 } // namespace std
 
 // Check with Lambdas.
Index: cfe/trunk/lib/Analysis/BodyFarm.cpp
===
--- cfe/trunk/lib/Analysis/BodyFarm.cpp
+++ cfe/trunk/lib/Analysis/BodyFarm.cpp
@@ -108,7 +108,7 @@
 
   /// Returns a *first* member field of a record declaration with a given name.
   /// \return an nullptr if no member with such a name exists.
-  NamedDecl *findMemberField(const CXXRecordDecl *RD, StringRef Name);
+  ValueDecl *findMemberField(const RecordDecl *RD, StringRef Name);
 
 private:
   ASTContext &C;
@@ -234,7 +234,7 @@
   OK_Ordinary);
 }
 
-NamedDecl *ASTMaker::findMemberField(const CXXRecordDecl *RD, StringRef Name) {
+ValueDecl *ASTMaker::findMemberField(const RecordDecl *RD, StringRef Name) {
 
   CXXBasePaths Paths(
   /* FindAmbiguities=*/false,
@@ -246,7 +246,7 @@
   DeclContextLookupResult Decls = RD->lookup(DeclName);
   for (NamedDecl *FoundDecl : Decls)
 if (!FoundDecl->getDeclContext()->isFunctionOrMethod())
-  return FoundDecl;
+  return cast(FoundDecl);
 
   return nullptr;
 }
@@ -328,25 +328,31 @@
   const ParmVarDecl *Callback = D->getParamDecl(1);
   QualType CallbackType = Callback->getType().getNonReferenceType();
   QualType FlagType = Flag->getType().getNonReferenceType();
-  CXXRecordDecl *FlagCXXDecl = FlagType->getAsCXXRecordDecl();
-  if (!FlagCXXDecl) {
-DEBUG(llvm::dbgs() << "Flag field is not a CXX record: "
-   << "unknown std::call_once implementation."
-   << "Ignoring the call.\n");
+  auto *FlagRecordDecl = dyn_cast_or_null(FlagType->getAsTagDecl());
+
+  if (!FlagRecordDecl) {
+DEBUG(llvm::dbgs() << "Flag field is not a record: "
+   << "unknown std::call_once implementation, "
+   << "ignoring the call.\n");
 return nullptr;
   }
 
-  // Note: here we are assuming libc++ implementation of call_once,
-  // which has a struct with a field `__state_`.
-  // Body farming might not work for other `call_once` implementations.
-  NamedDecl *FoundDecl = M.findMemberField(FlagCXXDecl, "__state_");
-  ValueDecl *FieldDecl;
-  if (FoundDecl) {
-FieldDecl = dyn_cast(FoundDecl);
-  } else {
+  // We initially assume libc++ implementation of call_once,
+  // where the once_flag struct has a field `__state_`.
+  ValueDecl *FlagFieldDecl = M.findMemberField(FlagRecordDecl, "__state_");
+
+  // Otherwise, try libstdc++ implementation, with a field
+  // `_M_once`
+  if (!FlagFieldDecl) {
 DEBUG(llvm::dbgs() << "No field __state_ found on std::once_flag struct, "
-   << "unable to synthesize call_once body, ignoring "
-   << "the call.\n");
+   << "assuming libstdc++ implementation\n");
+FlagFieldDecl = M.findMemberField(FlagRecordDecl, "_M_once");
+  }
+
+  if (!FlagFieldDecl) {
+DEBUG(llvm::dbgs() << "No field _M_once found on std::once flag struct: "
+   << "unknown std::call_once implementation, "
+   << "ignoring the call");
 return nullptr;
   }
 
@@ -383,7 +389,7 @@
 /* GetNonReferenceType=*/true);
 
 
-  MemberExpr *Deref = M.makeMemberExpression(FlagDecl, FieldDecl);
+  MemberExpr *Deref = M.makeMemberExpression(FlagDecl, FlagFieldDecl);
   assert(Deref->isLValue());
   QualType DerefType = Deref->getType();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r315508 - [Analyzer] Support bodyfarming libstdc++ implementation of std::call_once.

2017-10-11 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed Oct 11 13:53:01 2017
New Revision: 315508

URL: http://llvm.org/viewvc/llvm-project?rev=315508&view=rev
Log:
[Analyzer] Support bodyfarming libstdc++ implementation of std::call_once.

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

Modified:
cfe/trunk/lib/Analysis/BodyFarm.cpp
cfe/trunk/test/Analysis/call_once.cpp

Modified: cfe/trunk/lib/Analysis/BodyFarm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BodyFarm.cpp?rev=315508&r1=315507&r2=315508&view=diff
==
--- cfe/trunk/lib/Analysis/BodyFarm.cpp (original)
+++ cfe/trunk/lib/Analysis/BodyFarm.cpp Wed Oct 11 13:53:01 2017
@@ -108,7 +108,7 @@ public:
 
   /// Returns a *first* member field of a record declaration with a given name.
   /// \return an nullptr if no member with such a name exists.
-  NamedDecl *findMemberField(const CXXRecordDecl *RD, StringRef Name);
+  ValueDecl *findMemberField(const RecordDecl *RD, StringRef Name);
 
 private:
   ASTContext &C;
@@ -234,7 +234,7 @@ MemberExpr *ASTMaker::makeMemberExpressi
   OK_Ordinary);
 }
 
-NamedDecl *ASTMaker::findMemberField(const CXXRecordDecl *RD, StringRef Name) {
+ValueDecl *ASTMaker::findMemberField(const RecordDecl *RD, StringRef Name) {
 
   CXXBasePaths Paths(
   /* FindAmbiguities=*/false,
@@ -246,7 +246,7 @@ NamedDecl *ASTMaker::findMemberField(con
   DeclContextLookupResult Decls = RD->lookup(DeclName);
   for (NamedDecl *FoundDecl : Decls)
 if (!FoundDecl->getDeclContext()->isFunctionOrMethod())
-  return FoundDecl;
+  return cast(FoundDecl);
 
   return nullptr;
 }
@@ -328,25 +328,31 @@ static Stmt *create_call_once(ASTContext
   const ParmVarDecl *Callback = D->getParamDecl(1);
   QualType CallbackType = Callback->getType().getNonReferenceType();
   QualType FlagType = Flag->getType().getNonReferenceType();
-  CXXRecordDecl *FlagCXXDecl = FlagType->getAsCXXRecordDecl();
-  if (!FlagCXXDecl) {
-DEBUG(llvm::dbgs() << "Flag field is not a CXX record: "
-   << "unknown std::call_once implementation."
-   << "Ignoring the call.\n");
+  auto *FlagRecordDecl = 
dyn_cast_or_null(FlagType->getAsTagDecl());
+
+  if (!FlagRecordDecl) {
+DEBUG(llvm::dbgs() << "Flag field is not a record: "
+   << "unknown std::call_once implementation, "
+   << "ignoring the call.\n");
 return nullptr;
   }
 
-  // Note: here we are assuming libc++ implementation of call_once,
-  // which has a struct with a field `__state_`.
-  // Body farming might not work for other `call_once` implementations.
-  NamedDecl *FoundDecl = M.findMemberField(FlagCXXDecl, "__state_");
-  ValueDecl *FieldDecl;
-  if (FoundDecl) {
-FieldDecl = dyn_cast(FoundDecl);
-  } else {
+  // We initially assume libc++ implementation of call_once,
+  // where the once_flag struct has a field `__state_`.
+  ValueDecl *FlagFieldDecl = M.findMemberField(FlagRecordDecl, "__state_");
+
+  // Otherwise, try libstdc++ implementation, with a field
+  // `_M_once`
+  if (!FlagFieldDecl) {
 DEBUG(llvm::dbgs() << "No field __state_ found on std::once_flag struct, "
-   << "unable to synthesize call_once body, ignoring "
-   << "the call.\n");
+   << "assuming libstdc++ implementation\n");
+FlagFieldDecl = M.findMemberField(FlagRecordDecl, "_M_once");
+  }
+
+  if (!FlagFieldDecl) {
+DEBUG(llvm::dbgs() << "No field _M_once found on std::once flag struct: "
+   << "unknown std::call_once implementation, "
+   << "ignoring the call");
 return nullptr;
   }
 
@@ -383,7 +389,7 @@ static Stmt *create_call_once(ASTContext
 /* GetNonReferenceType=*/true);
 
 
-  MemberExpr *Deref = M.makeMemberExpression(FlagDecl, FieldDecl);
+  MemberExpr *Deref = M.makeMemberExpression(FlagDecl, FlagFieldDecl);
   assert(Deref->isLValue());
   QualType DerefType = Deref->getType();
 

Modified: cfe/trunk/test/Analysis/call_once.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/call_once.cpp?rev=315508&r1=315507&r2=315508&view=diff
==
--- cfe/trunk/test/Analysis/call_once.cpp (original)
+++ cfe/trunk/test/Analysis/call_once.cpp Wed Oct 11 13:53:01 2017
@@ -1,15 +1,24 @@
-// RUN: %clang_analyze_cc1 -std=c++11 -fblocks 
-analyzer-checker=core,debug.ExprInspection -w -verify %s
+// RUN: %clang_analyze_cc1 -std=c++11 -fblocks 
-analyzer-checker=core,debug.ExprInspection -verify %s
+// RUN: %clang_analyze_cc1 -std=c++11 -fblocks 
-analyzer-checker=core,debug.ExprInspection -DEMULATE_LIBSTDCPP -verify %s
 
 void clang_analyzer_eval(bool);
 
 // Faking std::std::call_once implementation.
 namespace std {
+
+#ifndef EMULATE_LIBSTDCPP
 typedef struct once_flag_s {
   unsigned long __state_ = 0;
 } 

[PATCH] D38425: [clangd] Document highlights for clangd

2017-10-11 Thread William Enright via Phabricator via cfe-commits
Nebiroth marked an inline comment as done.
Nebiroth added inline comments.



Comment at: clangd/ClangdUnit.cpp:784
+/// Finds declarations locations that a given source location refers to.
+class TargetDeclarationFinder : public index::IndexDataConsumer {
+  std::vector DeclarationLocations;

ilya-biryukov wrote:
> This `IndexDataConsumer` effectively does the same thing as 
> `DeclarationLocationsFinder`.
> We should reuse the code between those two.
> 
> To do that we could:
> 1. Change `DeclarationLocationsFinder` to return a list of `Decl*`s and 
> `MacroDef*`s that are under caret.
> 2. In `findDefinition` we should return locations of found `Decl` and 
> `MacroDef`.
> 3. In `documentHighlights` we would rerun `DocumentHighlightsFinder`to 
> capture locations of `Decls` referenced in step 1.
> 
> Do you think this approach would work?
I have something similar to this implemented. Will upstream it soon.


https://reviews.llvm.org/D38425



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


[PATCH] D38821: [COFF, ARM64] Add MS builtins __dmb, __dsb, __isb

2017-10-11 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
Herald added subscribers: kristof.beyls, javed.absar, aemerson.

This is an update to https://reviews.llvm.org/D36111 by @mgrang, taking over 
finishing of this patch. Compared to his version, this makes the intrinsics 
conditional to ALL_MS_LANGUAGES.


https://reviews.llvm.org/D38821

Files:
  include/clang/Basic/BuiltinsAArch64.def
  lib/Basic/Targets/AArch64.cpp
  test/CodeGen/arm64-microsoft-intrinsics.c


Index: test/CodeGen/arm64-microsoft-intrinsics.c
===
--- /dev/null
+++ test/CodeGen/arm64-microsoft-intrinsics.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple arm64-windows -fms-compatibility -emit-llvm -o - %s 
\
+// RUN:| FileCheck %s -check-prefix CHECK-MSVC
+
+// RUN: not %clang_cc1 -triple arm64-linux -Werror -S -o /dev/null %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-LINUX
+
+void check__dmb(void) {
+  __dmb(0);
+}
+
+// CHECK-MSVC: @llvm.aarch64.dmb(i32 0)
+// CHECK-LINUX: error: implicit declaration of function '__dmb'
+
+void check__dsb(void) {
+  __dsb(0);
+}
+
+// CHECK-MSVC: @llvm.aarch64.dsb(i32 0)
+// CHECK-LINUX: error: implicit declaration of function '__dsb'
+
+void check__isb(void) {
+  __isb(0);
+}
+
+// CHECK-MSVC: @llvm.aarch64.isb(i32 0)
+// CHECK-LINUX: error: implicit declaration of function '__isb'
Index: lib/Basic/Targets/AArch64.cpp
===
--- lib/Basic/Targets/AArch64.cpp
+++ lib/Basic/Targets/AArch64.cpp
@@ -27,6 +27,8 @@
 
 #define BUILTIN(ID, TYPE, ATTRS)   
\
{#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#define LANGBUILTIN(ID, TYPE, ATTRS, LANG) 
\
+  {#ID, TYPE, ATTRS, nullptr, LANG, nullptr},
 #include "clang/Basic/BuiltinsAArch64.def"
 };
 
Index: include/clang/Basic/BuiltinsAArch64.def
===
--- include/clang/Basic/BuiltinsAArch64.def
+++ include/clang/Basic/BuiltinsAArch64.def
@@ -14,6 +14,10 @@
 
 // The format of this database matches clang/Basic/Builtins.def.
 
+#if defined(BUILTIN) && !defined(LANGBUILTIN)
+#   define LANGBUILTIN(ID, TYPE, ATTRS, BUILTIN_LANG) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
 // In libgcc
 BUILTIN(__clear_cache, "vv*v*", "i")
 
@@ -61,4 +65,9 @@
 BUILTIN(__builtin_arm_wsr64, "vcC*LUi", "nc")
 BUILTIN(__builtin_arm_wsrp, "vcC*vC*", "nc")
 
+LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES)
+LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES)
+LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES)
+
 #undef BUILTIN
+#undef LANGBUILTIN


Index: test/CodeGen/arm64-microsoft-intrinsics.c
===
--- /dev/null
+++ test/CodeGen/arm64-microsoft-intrinsics.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple arm64-windows -fms-compatibility -emit-llvm -o - %s \
+// RUN:| FileCheck %s -check-prefix CHECK-MSVC
+
+// RUN: not %clang_cc1 -triple arm64-linux -Werror -S -o /dev/null %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-LINUX
+
+void check__dmb(void) {
+  __dmb(0);
+}
+
+// CHECK-MSVC: @llvm.aarch64.dmb(i32 0)
+// CHECK-LINUX: error: implicit declaration of function '__dmb'
+
+void check__dsb(void) {
+  __dsb(0);
+}
+
+// CHECK-MSVC: @llvm.aarch64.dsb(i32 0)
+// CHECK-LINUX: error: implicit declaration of function '__dsb'
+
+void check__isb(void) {
+  __isb(0);
+}
+
+// CHECK-MSVC: @llvm.aarch64.isb(i32 0)
+// CHECK-LINUX: error: implicit declaration of function '__isb'
Index: lib/Basic/Targets/AArch64.cpp
===
--- lib/Basic/Targets/AArch64.cpp
+++ lib/Basic/Targets/AArch64.cpp
@@ -27,6 +27,8 @@
 
 #define BUILTIN(ID, TYPE, ATTRS)   \
{#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#define LANGBUILTIN(ID, TYPE, ATTRS, LANG) \
+  {#ID, TYPE, ATTRS, nullptr, LANG, nullptr},
 #include "clang/Basic/BuiltinsAArch64.def"
 };
 
Index: include/clang/Basic/BuiltinsAArch64.def
===
--- include/clang/Basic/BuiltinsAArch64.def
+++ include/clang/Basic/BuiltinsAArch64.def
@@ -14,6 +14,10 @@
 
 // The format of this database matches clang/Basic/Builtins.def.
 
+#if defined(BUILTIN) && !defined(LANGBUILTIN)
+#   define LANGBUILTIN(ID, TYPE, ATTRS, BUILTIN_LANG) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
 // In libgcc
 BUILTIN(__clear_cache, "vv*v*", "i")
 
@@ -61,4 +65,9 @@
 BUILTIN(__builtin_arm_wsr64, "vcC*LUi", "nc")
 BUILTIN(__builtin_arm_wsrp, "vcC*vC*", "nc")
 
+LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES)
+LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES)
+LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES)
+
 #undef BUILTIN
+#undef LANGBUILTIN
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/c

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

2017-10-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

It sounds like there's agreement about the basic technical direction of 
introducing LangAS::opencl_private.  Please introduce isAddressSpaceImplicit() 
in a different patch and make this patch just about the introduction of 
LangAS::opencl_private.  You can have the pretty-printer just ignore __private 
for now, which should avoid gratuitous diagnostic changes.

I would like you to investigate using AttributedType for the pretty-printing 
and address-space semantic checks before adding isAddressSpaceImplicit().




Comment at: include/clang/AST/Type.h:562
+  static const uint32_t IMask = 0x200;
+  static const uint32_t IShift = 9;
   static const uint32_t AddressSpaceMask =

"I" is not an appropriate abbreviation for "AddressSpaceImplicit".



Comment at: include/clang/Basic/AddressSpaces.h:34
 
   // OpenCL specific address spaces.
   opencl_global,

I think you need a real comment about the design of OpenCL address spaces here. 
 Specifically, it is important to note that OpenCL no longer uses 
LangAS::Default for anything except r-values.


https://reviews.llvm.org/D35082



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


[PATCH] D38824: [X86] Synchronize the CPU predefined macros with gcc

2017-10-11 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
Herald added a subscriber: krytarowski.

We were using corei7 for a large swatch of Intel CPUs. gcc has a different 
defines that more closely match the march flags. This updates to match.  It 
also fixes skylake-avx512 and adds silvermont in addition to slm.


https://reviews.llvm.org/D38824

Files:
  lib/Basic/Targets/X86.cpp
  test/Preprocessor/predefined-arch-macros.c

Index: test/Preprocessor/predefined-arch-macros.c
===
--- test/Preprocessor/predefined-arch-macros.c
+++ test/Preprocessor/predefined-arch-macros.c
@@ -427,11 +427,14 @@
 // CHECK_COREI7_AVX_M32: #define __SSSE3__ 1
 // CHECK_COREI7_AVX_M32: #define __XSAVEOPT__ 1
 // CHECK_COREI7_AVX_M32: #define __XSAVE__ 1
-// CHECK_COREI7_AVX_M32: #define __corei7 1
-// CHECK_COREI7_AVX_M32: #define __corei7__ 1
+// CHECK_COREI7_AVX_M32: #define __corei7_avx 1
+// CHECK_COREI7_AVX_M32: #define __corei7_avx__ 1
 // CHECK_COREI7_AVX_M32: #define __i386 1
 // CHECK_COREI7_AVX_M32: #define __i386__ 1
-// CHECK_COREI7_AVX_M32: #define __tune_corei7__ 1
+// CHECK_COREI7_AVX_M32: #define __sandybridge 1
+// CHECK_COREI7_AVX_M32: #define __sandybridge__ 1
+// CHECK_COREI7_AVX_M32: #define __tune_corei7_avx__ 1
+// CHECK_COREI7_AVX_M32: #define __tune_sandybridge__ 1
 // CHECK_COREI7_AVX_M32: #define i386 1
 // RUN: %clang -march=corei7-avx -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
@@ -454,9 +457,12 @@
 // CHECK_COREI7_AVX_M64: #define __XSAVE__ 1
 // CHECK_COREI7_AVX_M64: #define __amd64 1
 // CHECK_COREI7_AVX_M64: #define __amd64__ 1
-// CHECK_COREI7_AVX_M64: #define __corei7 1
-// CHECK_COREI7_AVX_M64: #define __corei7__ 1
-// CHECK_COREI7_AVX_M64: #define __tune_corei7__ 1
+// CHECK_COREI7_AVX_M64: #define __corei7_avx 1
+// CHECK_COREI7_AVX_M64: #define __corei7_avx__ 1
+// CHECK_COREI7_AVX_M64: #define __sandybridge 1
+// CHECK_COREI7_AVX_M64: #define __sandybridge__ 1
+// CHECK_COREI7_AVX_M64: #define __tune_corei7_avx__ 1
+// CHECK_COREI7_AVX_M64: #define __tune_sandybridge__ 1
 // CHECK_COREI7_AVX_M64: #define __x86_64 1
 // CHECK_COREI7_AVX_M64: #define __x86_64__ 1
 //
@@ -477,11 +483,14 @@
 // CHECK_CORE_AVX_I_M32: #define __SSSE3__ 1
 // CHECK_CORE_AVX_I_M32: #define __XSAVEOPT__ 1
 // CHECK_CORE_AVX_I_M32: #define __XSAVE__ 1
-// CHECK_CORE_AVX_I_M32: #define __corei7 1
-// CHECK_CORE_AVX_I_M32: #define __corei7__ 1
+// CHECK_CORE_AVX_I_M32: #define __corei7_avx 1
+// CHECK_CORE_AVX_I_M32: #define __corei7_avx__ 1
 // CHECK_CORE_AVX_I_M32: #define __i386 1
 // CHECK_CORE_AVX_I_M32: #define __i386__ 1
-// CHECK_CORE_AVX_I_M32: #define __tune_corei7__ 1
+// CHECK_CORE_AVX_I_M32: #define __sandybridge 1
+// CHECK_CORE_AVX_I_M32: #define __sandybridge__ 1
+// CHECK_CORE_AVX_I_M32: #define __tune_corei7_avx__ 1
+// CHECK_CORE_AVX_I_M32: #define __tune_sandybridge__ 1
 // CHECK_CORE_AVX_I_M32: #define i386 1
 // RUN: %clang -march=core-avx-i -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
@@ -504,9 +513,12 @@
 // CHECK_CORE_AVX_I_M64: #define __XSAVE__ 1
 // CHECK_CORE_AVX_I_M64: #define __amd64 1
 // CHECK_CORE_AVX_I_M64: #define __amd64__ 1
-// CHECK_CORE_AVX_I_M64: #define __corei7 1
-// CHECK_CORE_AVX_I_M64: #define __corei7__ 1
-// CHECK_CORE_AVX_I_M64: #define __tune_corei7__ 1
+// CHECK_CORE_AVX_I_M64: #define __corei7_avx 1
+// CHECK_CORE_AVX_I_M64: #define __corei7_avx__ 1
+// CHECK_CORE_AVX_I_M64: #define __sandybridge 1
+// CHECK_CORE_AVX_I_M64: #define __sandybridge__ 1
+// CHECK_CORE_AVX_I_M64: #define __tune_corei7_avx__ 1
+// CHECK_CORE_AVX_I_M64: #define __tune_sandybridge__ 1
 // CHECK_CORE_AVX_I_M64: #define __x86_64 1
 // CHECK_CORE_AVX_I_M64: #define __x86_64__ 1
 //
@@ -533,11 +545,14 @@
 // CHECK_CORE_AVX2_M32: #define __SSSE3__ 1
 // CHECK_CORE_AVX2_M32: #define __XSAVEOPT__ 1
 // CHECK_CORE_AVX2_M32: #define __XSAVE__ 1
-// CHECK_CORE_AVX2_M32: #define __corei7 1
-// CHECK_CORE_AVX2_M32: #define __corei7__ 1
+// CHECK_CORE_AVX2_M32: #define __core_avx2 1
+// CHECK_CORE_AVX2_M32: #define __core_avx2__ 1
+// CHECK_CORE_AVX2_M32: #define __haswell 1
+// CHECK_CORE_AVX2_M32: #define __haswell__ 1
 // CHECK_CORE_AVX2_M32: #define __i386 1
 // CHECK_CORE_AVX2_M32: #define __i386__ 1
-// CHECK_CORE_AVX2_M32: #define __tune_corei7__ 1
+// CHECK_CORE_AVX2_M32: #define __tune_core_avx2__ 1
+// CHECK_CORE_AVX2_M32: #define __tune_haswell__ 1
 // CHECK_CORE_AVX2_M32: #define i386 1
 // RUN: %clang -march=core-avx2 -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
@@ -566,9 +581,12 @@
 // CHECK_CORE_AVX2_M64: #define __XSAVE__ 1
 // CHECK_CORE_AVX2_M64: #define __amd64 1
 // CHECK_CORE_AVX2_M64: #define __amd64__ 1
-// CHECK_CORE_AVX2_M64: #define __corei7 1
-// CHECK_CORE_AVX2_M64: #define __corei7__ 1
-// CHECK_CORE_AVX2_M64: #define __tune_corei7__ 1
+// CHECK_CORE_AVX2_M64: #define __core_avx2 1
+// CHECK_CORE_AVX2_M64: #define __core_avx2__ 1
+// CHECK_CORE_AVX2_M64: #def

[PATCH] D38772: [refactor] allow the use of refactoring diagnostics

2017-10-11 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Basic/DiagnosticIDs.cpp:46
   unsigned WarnShowInSystemHeader : 1;
-  unsigned Category : 5;
+  unsigned Category : 6;
 

hokein wrote:
> just curious: is this change needed?
I get a build warning without this change as the bitfield becomes too narrow 
with the new category, so yeah.



Comment at: tools/clang-refactor/ToolRefactoringResultConsumer.h:19
+
+/// A subclass of \c RefactoringResultConsumer that stores the reference to the
+/// TU-specific diagnostics engine.

hokein wrote:
> I'd name it "interface", because it has unimplemented virtual function 
> (`handleError`), clients can't create an instance of it. 
> 
> or alternatively,  does it make more sense to just add these methods and 
> `DiagnosticsEngine` variable to the `tooling::RefactoringResultConsumer` 
> interface? I see you have replaced "RefactoringResultConsumer" with this new 
> interface in many places. 
Right now I don't think having the diagnostics engine will be useful for 
clients outside of tool, so I'd prefer to keep it here. We can reconsider this 
decision in the future if we need to.


Repository:
  rL LLVM

https://reviews.llvm.org/D38772



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


[PATCH] D38772: [refactor] allow the use of refactoring diagnostics

2017-10-11 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 118701.
arphaman marked 2 inline comments as done.
arphaman added a comment.

- rename the common consumer class.


Repository:
  rL LLVM

https://reviews.llvm.org/D38772

Files:
  include/clang/Basic/AllDiagnostics.h
  include/clang/Basic/CMakeLists.txt
  include/clang/Basic/Diagnostic.td
  include/clang/Basic/DiagnosticIDs.h
  include/clang/Basic/DiagnosticRefactoringKinds.td
  include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h
  include/clang/Tooling/Refactoring/RefactoringDiagnostic.h
  include/clang/Tooling/Refactoring/RefactoringRuleContext.h
  lib/Basic/DiagnosticIDs.cpp
  lib/Tooling/Refactoring/Rename/RenamingAction.cpp
  test/Refactor/LocalRename/NoSymbolSelectedError.cpp
  tools/clang-refactor/ClangRefactor.cpp
  tools/clang-refactor/TestSupport.cpp
  tools/clang-refactor/TestSupport.h
  tools/clang-refactor/ToolRefactoringResultConsumer.h
  tools/diagtool/DiagnosticNames.cpp

Index: tools/diagtool/DiagnosticNames.cpp
===
--- tools/diagtool/DiagnosticNames.cpp
+++ tools/diagtool/DiagnosticNames.cpp
@@ -42,6 +42,7 @@
 #include "clang/Basic/DiagnosticCommentKinds.inc"
 #include "clang/Basic/DiagnosticSemaKinds.inc"
 #include "clang/Basic/DiagnosticAnalysisKinds.inc"
+#include "clang/Basic/DiagnosticRefactoringKinds.inc"
 #undef DIAG
 };
 
Index: tools/clang-refactor/ToolRefactoringResultConsumer.h
===
--- /dev/null
+++ tools/clang-refactor/ToolRefactoringResultConsumer.h
@@ -0,0 +1,48 @@
+//===--- ToolRefactoringResultConsumer.h - --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_CLANG_REFACTOR_TOOL_REFACTORING_RESULT_CONSUMER_H
+#define LLVM_CLANG_TOOLS_CLANG_REFACTOR_TOOL_REFACTORING_RESULT_CONSUMER_H
+
+#include "clang/AST/ASTContext.h"
+#include "clang/Tooling/Refactoring/RefactoringResultConsumer.h"
+
+namespace clang {
+namespace refactor {
+
+/// An interface that subclasses the \c RefactoringResultConsumer interface
+/// that stores the reference to the TU-specific diagnostics engine.
+class ClangRefactorToolConsumerInterface
+: public tooling::RefactoringResultConsumer {
+public:
+  /// Called when a TU is entered.
+  void beginTU(ASTContext &Context) {
+assert(!Diags && "Diags has been set");
+Diags = &Context.getDiagnostics();
+  }
+
+  /// Called when the tool is done with a TU.
+  void endTU() {
+assert(Diags && "Diags unset");
+Diags = nullptr;
+  }
+
+  DiagnosticsEngine &getDiags() const {
+assert(Diags && "no diags");
+return *Diags;
+  }
+
+private:
+  DiagnosticsEngine *Diags = nullptr;
+};
+
+} // end namespace refactor
+} // end namespace clang
+
+#endif // LLVM_CLANG_TOOLS_CLANG_REFACTOR_TOOL_REFACTORING_RESULT_CONSUMER_H
Index: tools/clang-refactor/TestSupport.h
===
--- tools/clang-refactor/TestSupport.h
+++ tools/clang-refactor/TestSupport.h
@@ -16,9 +16,9 @@
 #ifndef LLVM_CLANG_TOOLS_CLANG_REFACTOR_TEST_SUPPORT_H
 #define LLVM_CLANG_TOOLS_CLANG_REFACTOR_TEST_SUPPORT_H
 
+#include "ToolRefactoringResultConsumer.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
-#include "clang/Tooling/Refactoring/RefactoringResultConsumer.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Error.h"
@@ -65,7 +65,7 @@
   bool foreachRange(const SourceManager &SM,
 llvm::function_ref Callback) const;
 
-  std::unique_ptr createConsumer() const;
+  std::unique_ptr createConsumer() const;
 
   void dump(llvm::raw_ostream &OS) const;
 };
Index: tools/clang-refactor/TestSupport.cpp
===
--- tools/clang-refactor/TestSupport.cpp
+++ tools/clang-refactor/TestSupport.cpp
@@ -14,6 +14,7 @@
 //===--===//
 
 #include "TestSupport.h"
+#include "clang/Basic/DiagnosticError.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/STLExtras.h"
@@ -106,7 +107,7 @@
 }
 
 class TestRefactoringResultConsumer final
-: public tooling::RefactoringResultConsumer {
+: public ClangRefactorToolConsumerInterface {
 public:
   TestRefactoringResultConsumer(const TestSelectionRangesInFile &TestRanges)
   : TestRanges(TestRanges) {
@@ -182,10 +183,15 @@
   std::string ErrorMessage;
   bool HasResult = !!Result;
   if (!HasResult) {
-// FIXME: Handle diagnostic error as well.
-handleAllErrors(Result.takeError(), [&](StringError &Err) {
-  ErrorMessage = Err.getMessage();
- 

[PATCH] D38816: Convert clang::LangAS to a strongly typed enum

2017-10-11 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added inline comments.



Comment at: include/clang/Basic/AddressSpaces.h:51
 
+namespace LanguageAS {
 /// The type of a lookup table which maps from language-specific address spaces

jlebar wrote:
> I wonder if you need this namespace?  LangAS right next to LanguageAS reads 
> strangely to me -- "what's the difference?".
> 
> I guess you'd need to rename Map and fromTargetAS, but the other two members 
> are probably OK?
The only reason I added this namespace is that I wasn't sure whether having 
those functions in the clang namespace is acceptable.

Not quite sure what to call the functions though. `langASFromTargetAS`?


Repository:
  rL LLVM

https://reviews.llvm.org/D38816



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


[PATCH] D38816: Convert clang::LangAS to a strongly typed enum

2017-10-11 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

> The only reason I added this namespace is that I wasn't sure whether having 
> those functions in the clang namespace is acceptable.

Maybe someone else will object, or suggest an existing namespace they should be 
in.  FWIW I think it's fine.

> Not quite sure what to call the functions though. langASFromTargetAS?

sgtm!


Repository:
  rL LLVM

https://reviews.llvm.org/D38816



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


r315517 - [X86] Add support for 'amdfam17h' to __builtin_cpu_is to match gcc.

2017-10-11 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Oct 11 14:42:02 2017
New Revision: 315517

URL: http://llvm.org/viewvc/llvm-project?rev=315517&view=rev
Log:
[X86] Add support for 'amdfam17h' to __builtin_cpu_is to match gcc.

The compiler-rt implementation already supported it, it just wasn't exposed.

Modified:
cfe/trunk/lib/Basic/Targets/X86.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/target-builtin-noerror.c

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=315517&r1=315516&r2=315517&view=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Wed Oct 11 14:42:02 2017
@@ -1293,6 +1293,7 @@ bool X86TargetInfo::validateCpuIs(String
   .Case("amd", true)
   .Case("amdfam10h", true)
   .Case("amdfam15h", true)
+  .Case("amdfam17h", true)
   .Case("atom", true)
   .Case("barcelona", true)
   .Case("bdver1", true)

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=315517&r1=315516&r2=315517&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Oct 11 14:42:02 2017
@@ -7501,6 +7501,7 @@ Value *CodeGenFunction::EmitX86CpuIs(Str
 INTEL_KNL,
 AMD_BTVER1,
 AMD_BTVER2,
+AMDFAM17H,
 CPU_SUBTYPE_START,
 INTEL_COREI7_NEHALEM,
 INTEL_COREI7_WESTMERE,
@@ -7527,6 +7528,7 @@ Value *CodeGenFunction::EmitX86CpuIs(Str
   .Case("amdfam10", AMDFAM10H)
   .Case("amdfam15h", AMDFAM15H)
   .Case("amdfam15", AMDFAM15H)
+  .Case("amdfam17h", AMDFAM17H)
   .Case("atom", INTEL_BONNELL)
   .Case("barcelona", AMDFAM10H_BARCELONA)
   .Case("bdver1", AMDFAM15H_BDVER1)

Modified: cfe/trunk/test/CodeGen/target-builtin-noerror.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/target-builtin-noerror.c?rev=315517&r1=315516&r2=315517&view=diff
==
--- cfe/trunk/test/CodeGen/target-builtin-noerror.c (original)
+++ cfe/trunk/test/CodeGen/target-builtin-noerror.c Wed Oct 11 14:42:02 2017
@@ -81,6 +81,7 @@ void verifycpustrings() {
   (void)__builtin_cpu_is("amd");
   (void)__builtin_cpu_is("amdfam10h");
   (void)__builtin_cpu_is("amdfam15h");
+  (void)__builtin_cpu_is("amdfam17h");
   (void)__builtin_cpu_is("atom");
   (void)__builtin_cpu_is("barcelona");
   (void)__builtin_cpu_is("bdver1");


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


[PATCH] D38680: [libunwind] Fix handling of DW_CFA_GNU_args_size

2017-10-11 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: src/libunwind.cpp:188
+  co->getInfo(&info);
+  pint_t orgArgSize = (pint_t)info.gp;
+  uint64_t orgFuncStart = info.start_ip;

I think it makes sense to have this here: the contract is that if the 
personality sets the IP when the cursor pointed to a PC with a non-zero arg 
size, we should adjust SP for the personality.

However, it's not clear to me that we don't need the same adjustment when 
stepping across frames that use arg size without a frame pointer.


https://reviews.llvm.org/D38680



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


r315518 - [Driver] Export symbols needed to use profile runtime

2017-10-11 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Wed Oct 11 14:54:09 2017
New Revision: 315518

URL: http://llvm.org/viewvc/llvm-project?rev=315518&view=rev
Log:
[Driver] Export symbols needed to use profile runtime

Apple's API verification tool (tapi) checks that the symbols exported
from a program match a whitelist. When the program uses the profile
runtime, some additional symbols which are typically not part of the
regular whitelist must be exported.

If we're using symbol export directives along with the profile runtime
on Darwin, the driver needs to export the additional symbols to avoid
verification failures.

rdar://problem/30067753

Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/test/Driver/darwin-ld.c

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=315518&r1=315517&r2=315518&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Wed Oct 11 14:54:09 2017
@@ -986,6 +986,25 @@ StringRef Darwin::getOSLibraryNameSuffix
   llvm_unreachable("Unsupported platform");
 }
 
+/// Check if the link command contains a symbol export directive.
+static bool hasExportSymbolDirective(const ArgList &Args) {
+  for (Arg *A : Args) {
+if (!A->getOption().matches(options::OPT_Wl_COMMA) &&
+!A->getOption().matches(options::OPT_Xlinker))
+  continue;
+if (A->containsValue("-exported_symbols_list") ||
+A->containsValue("-exported_symbol"))
+  return true;
+  }
+  return false;
+}
+
+/// Add an export directive for \p Symbol to the link command.
+static void addExportedSymbol(ArgStringList &CmdArgs, const char *Symbol) {
+  CmdArgs.push_back("-exported_symbol");
+  CmdArgs.push_back(Symbol);
+}
+
 void Darwin::addProfileRTLibs(const ArgList &Args,
   ArgStringList &CmdArgs) const {
   if (!needsProfileRT(Args)) return;
@@ -994,6 +1013,16 @@ void Darwin::addProfileRTLibs(const ArgL
   Args, CmdArgs,
   (Twine("libclang_rt.profile_") + getOSLibraryNameSuffix() + ".a").str(),
   RuntimeLinkOptions(RLO_AlwaysLink | RLO_FirstLink));
+
+  // If we have a symbol export directive and we're linking in the profile
+  // runtime, automatically export symbols necessary to implement some of the
+  // runtime's functionality.
+  if (hasExportSymbolDirective(Args)) {
+addExportedSymbol(CmdArgs, "_VPMergeHook");
+addExportedSymbol(CmdArgs, "___llvm_profile_filename");
+addExportedSymbol(CmdArgs, "___llvm_profile_raw_version");
+addExportedSymbol(CmdArgs, "_lprofCurFilename");
+  }
 }
 
 void DarwinClang::AddLinkSanitizerLibArgs(const ArgList &Args,

Modified: cfe/trunk/test/Driver/darwin-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-ld.c?rev=315518&r1=315517&r2=315518&view=diff
==
--- cfe/trunk/test/Driver/darwin-ld.c (original)
+++ cfe/trunk/test/Driver/darwin-ld.c Wed Oct 11 14:54:09 2017
@@ -351,3 +351,17 @@
 // RUN: %clang -target arm64-apple-ios5.0 -miphoneos-version-min=5.0 
-fprofile-instr-generate -### %t.o 2> %t.log
 // RUN: FileCheck -check-prefix=LINK_PROFILE_FIRST %s < %t.log
 // LINK_PROFILE_FIRST: {{ld(.exe)?"}} 
"{{[^"]+}}libclang_rt.profile_{{[a-z]+}}.a"
+
+// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate 
-Wl,-exported_symbols_list,/dev/null -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
+// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate 
-Wl,-exported_symbol,foo -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
+// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate -Xlinker 
-exported_symbol -Xlinker foo -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
+// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate -Xlinker 
-exported_symbols_list -Xlinker /dev/null -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
+// PROFILE_EXPORT: "-exported_symbol" "_VPMergeHook" "-exported_symbol" 
"___llvm_profile_filename" "-exported_symbol" "___llvm_profile_raw_version" 
"-exported_symbol" "_lprofCurFilename"
+//
+// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate -### 
%t.o 2> %t.log
+// RUN: FileCheck -check-prefix=NO_PROFILE_EXPORT %s < %t.log
+// NO_PROFILE_EXPORT-NOT: "-exported_symbol"


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


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

2017-10-11 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

In https://reviews.llvm.org/D35082#895230, @rjmccall wrote:

> It sounds like there's agreement about the basic technical direction of 
> introducing LangAS::opencl_private.  Please introduce 
> isAddressSpaceImplicit() in a different patch and make this patch just about 
> the introduction of LangAS::opencl_private.  You can have the pretty-printer 
> just ignore __private for now, which should avoid gratuitous diagnostic 
> changes.
>
> I would like you to investigate using AttributedType for the pretty-printing 
> and address-space semantic checks before adding isAddressSpaceImplicit().


Thanks. I will separate the implicit addr space flag to another patch.




Comment at: include/clang/AST/Type.h:562
+  static const uint32_t IMask = 0x200;
+  static const uint32_t IShift = 9;
   static const uint32_t AddressSpaceMask =

rjmccall wrote:
> "I" is not an appropriate abbreviation for "AddressSpaceImplicit".
Will change it to ImplictAddrSpace.



Comment at: include/clang/Basic/AddressSpaces.h:34
 
   // OpenCL specific address spaces.
   opencl_global,

rjmccall wrote:
> I think you need a real comment about the design of OpenCL address spaces 
> here.  Specifically, it is important to note that OpenCL no longer uses 
> LangAS::Default for anything except r-values.
Will do.


https://reviews.llvm.org/D35082



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


[PATCH] D38821: [COFF, ARM64] Add MS builtins __dmb, __dsb, __isb

2017-10-11 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

LGTM.


https://reviews.llvm.org/D38821



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


[PATCH] D38824: [X86] Synchronize the CPU predefined macros with gcc

2017-10-11 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc added inline comments.



Comment at: lib/Basic/Targets/X86.cpp:844-845
-// FIXME: Historically, we defined this legacy name, it would be nice to
-// remove it at some point. We've never exposed fine-grained names for
-// recent primary x86 CPUs, and we should keep it that way.
-defineCPUMacros(Builder, "corei7");

This seems to undo the idea that we should keep avoiding exposing fine-grained 
CPU names? What's new that changes this?



Comment at: lib/Basic/Targets/X86.cpp:852
+defineCPUMacros(Builder, "core_avx2");
+defineCPUMacros(Builder, "haswell");
 break;

I find calling a Westmere CPU `nehalem` a little odd. Calling IvyBridge a 
`sandybridge' CPU seems quite confusing. But calling Skylake (client) and 
Cannonlake (all? client?) `haswell` seems  deeply weird.


https://reviews.llvm.org/D38824



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


  1   2   >