[PATCH] D39640: [lit] Set shlibpath_var on Solaris

2017-11-27 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

It's been another two weeks, so: could someone please commit this for me?  
Thanks.


https://reviews.llvm.org/D39640



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


r319012 - [CodeGen] Collect information about sizes of accesses and access types for TBAA

2017-11-27 Thread Ivan A. Kosarev via cfe-commits
Author: kosarev
Date: Mon Nov 27 01:39:29 2017
New Revision: 319012

URL: http://llvm.org/viewvc/llvm-project?rev=319012&view=rev
Log:
[CodeGen] Collect information about sizes of accesses and access types for TBAA

The information about access and type sizes is necessary for
producing TBAA metadata in the new size-aware format. With this
patch, D39955 and D39956 in place we should be able to change
CodeGenTBAA::createScalarTypeNode() and
CodeGenTBAA::getBaseTypeInfo() to generate metadata in the new
format under the -new-struct-path-tbaa command-line option. For
now, this new information remains unused.

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

Modified:
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
cfe/trunk/lib/CodeGen/CodeGenTBAA.h

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=319012&r1=319011&r2=319012&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Mon Nov 27 01:39:29 2017
@@ -2423,7 +2423,8 @@ void CodeGenFunction::InitializeVTablePo
   VTableAddressPoint = Builder.CreateBitCast(VTableAddressPoint, VTablePtrTy);
 
   llvm::StoreInst *Store = Builder.CreateStore(VTableAddressPoint, 
VTableField);
-  CGM.DecorateInstructionWithTBAA(Store, CGM.getTBAAVTablePtrAccessInfo());
+  TBAAAccessInfo TBAAInfo = CGM.getTBAAVTablePtrAccessInfo(VTablePtrTy);
+  CGM.DecorateInstructionWithTBAA(Store, TBAAInfo);
   if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
   CGM.getCodeGenOpts().StrictVTablePointers)
 CGM.DecorateInstructionWithInvariantGroup(Store, Vptr.VTableClass);
@@ -2517,7 +2518,8 @@ llvm::Value *CodeGenFunction::GetVTableP
const CXXRecordDecl *RD) {
   Address VTablePtrSrc = Builder.CreateElementBitCast(This, VTableTy);
   llvm::Instruction *VTable = Builder.CreateLoad(VTablePtrSrc, "vtable");
-  CGM.DecorateInstructionWithTBAA(VTable, CGM.getTBAAVTablePtrAccessInfo());
+  TBAAAccessInfo TBAAInfo = CGM.getTBAAVTablePtrAccessInfo(VTableTy);
+  CGM.DecorateInstructionWithTBAA(VTable, TBAAInfo);
 
   if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
   CGM.getCodeGenOpts().StrictVTablePointers)

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=319012&r1=319011&r2=319012&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Nov 27 01:39:29 2017
@@ -136,7 +136,7 @@ CodeGenModule::CodeGenModule(ASTContext
   // Enable TBAA unless it's suppressed. ThreadSanitizer needs TBAA even at O0.
   if (LangOpts.Sanitize.has(SanitizerKind::Thread) ||
   (!CodeGenOpts.RelaxedAliasing && CodeGenOpts.OptimizationLevel > 0))
-TBAA.reset(new CodeGenTBAA(Context, VMContext, CodeGenOpts, getLangOpts(),
+TBAA.reset(new CodeGenTBAA(Context, TheModule, CodeGenOpts, getLangOpts(),
getCXXABI().getMangleContext()));
 
   // If debug info or coverage generation is enabled, create the CGDebugInfo
@@ -579,13 +579,20 @@ llvm::MDNode *CodeGenModule::getTBAAType
 }
 
 TBAAAccessInfo CodeGenModule::getTBAAAccessInfo(QualType AccessType) {
-  return TBAAAccessInfo(getTBAATypeInfo(AccessType));
+  // Pointee values may have incomplete types, but they shall never be
+  // dereferenced.
+  if (AccessType->isIncompleteType())
+return TBAAAccessInfo::getIncompleteInfo();
+
+  uint64_t Size = Context.getTypeSizeInChars(AccessType).getQuantity();
+  return TBAAAccessInfo(getTBAATypeInfo(AccessType), Size);
 }
 
-TBAAAccessInfo CodeGenModule::getTBAAVTablePtrAccessInfo() {
+TBAAAccessInfo
+CodeGenModule::getTBAAVTablePtrAccessInfo(llvm::Type *VTablePtrType) {
   if (!TBAA)
 return TBAAAccessInfo();
-  return TBAA->getVTablePtrAccessInfo();
+  return TBAA->getVTablePtrAccessInfo(VTablePtrType);
 }
 
 llvm::MDNode *CodeGenModule::getTBAAStructInfo(QualType QTy) {

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=319012&r1=319011&r2=319012&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Mon Nov 27 01:39:29 2017
@@ -664,7 +664,7 @@ public:
 
   /// getTBAAVTablePtrAccessInfo - Get the TBAA information that describes an
   /// access to a virtual table pointer.
-  TBAAAccessInfo getTBAAVTablePtrAccessInfo();
+  TBAAAccessInfo getTBAAVTablePtrAccessInfo(llvm::Type *VTablePtrType);
 
   llvm::MDNode *getTBAAStructInfo(QualType QTy);
 

Modified: cfe/trunk/lib/CodeGen/CodeG

[PATCH] D40176: [CodeGen] Collect information about sizes of accesses and access types for TBAA

2017-11-27 Thread Ivan Kosarev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319012: [CodeGen] Collect information about sizes of 
accesses and access types for TBAA (authored by kosarev).

Changed prior to commit:
  https://reviews.llvm.org/D40176?vs=124084&id=124332#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40176

Files:
  cfe/trunk/lib/CodeGen/CGClass.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.h
  cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
  cfe/trunk/lib/CodeGen/CodeGenTBAA.h

Index: cfe/trunk/lib/CodeGen/CodeGenTBAA.h
===
--- cfe/trunk/lib/CodeGen/CodeGenTBAA.h
+++ cfe/trunk/lib/CodeGen/CodeGenTBAA.h
@@ -36,40 +36,53 @@
 enum class TBAAAccessKind : unsigned {
   Ordinary,
   MayAlias,
+  Incomplete,
 };
 
 // TBAAAccessInfo - Describes a memory access in terms of TBAA.
 struct TBAAAccessInfo {
   TBAAAccessInfo(TBAAAccessKind Kind, llvm::MDNode *BaseType,
- llvm::MDNode *AccessType, uint64_t Offset)
-: Kind(Kind), BaseType(BaseType), AccessType(AccessType), Offset(Offset)
+ llvm::MDNode *AccessType, uint64_t Offset, uint64_t Size)
+: Kind(Kind), BaseType(BaseType), AccessType(AccessType),
+  Offset(Offset), Size(Size)
   {}
 
   TBAAAccessInfo(llvm::MDNode *BaseType, llvm::MDNode *AccessType,
- uint64_t Offset)
-: TBAAAccessInfo(TBAAAccessKind::Ordinary, BaseType, AccessType, Offset)
+ uint64_t Offset, uint64_t Size)
+: TBAAAccessInfo(TBAAAccessKind::Ordinary, BaseType, AccessType,
+ Offset, Size)
   {}
 
-  explicit TBAAAccessInfo(llvm::MDNode *AccessType)
-: TBAAAccessInfo(/* BaseType= */ nullptr, AccessType, /* Offset= */ 0)
+  explicit TBAAAccessInfo(llvm::MDNode *AccessType, uint64_t Size)
+: TBAAAccessInfo(/* BaseType= */ nullptr, AccessType, /* Offset= */ 0, Size)
   {}
 
   TBAAAccessInfo()
-: TBAAAccessInfo(/* AccessType= */ nullptr)
+: TBAAAccessInfo(/* AccessType= */ nullptr, /* Size= */ 0)
   {}
 
   static TBAAAccessInfo getMayAliasInfo() {
-return TBAAAccessInfo(TBAAAccessKind::MayAlias, /* BaseType= */ nullptr,
-  /* AccessType= */ nullptr, /* Offset= */ 0);
+return TBAAAccessInfo(TBAAAccessKind::MayAlias,
+  /* BaseType= */ nullptr, /* AccessType= */ nullptr,
+  /* Offset= */ 0, /* Size= */ 0);
   }
 
   bool isMayAlias() const { return Kind == TBAAAccessKind::MayAlias; }
 
+  static TBAAAccessInfo getIncompleteInfo() {
+return TBAAAccessInfo(TBAAAccessKind::Incomplete,
+  /* BaseType= */ nullptr, /* AccessType= */ nullptr,
+  /* Offset= */ 0, /* Size= */ 0);
+  }
+
+  bool isIncomplete() const { return Kind == TBAAAccessKind::Incomplete; }
+
   bool operator==(const TBAAAccessInfo &Other) const {
 return Kind == Other.Kind &&
BaseType == Other.BaseType &&
AccessType == Other.AccessType &&
-   Offset == Other.Offset;
+   Offset == Other.Offset &&
+   Size == Other.Size;
   }
 
   bool operator!=(const TBAAAccessInfo &Other) const {
@@ -95,12 +108,16 @@
   /// Offset - The byte offset of the final access within the base one. Must be
   /// zero if the base access type is not specified.
   uint64_t Offset;
+
+  /// Size - The size of access, in bytes.
+  uint64_t Size;
 };
 
 /// CodeGenTBAA - This class organizes the cross-module state that is used
 /// while lowering AST types to LLVM types.
 class CodeGenTBAA {
   ASTContext &Context;
+  llvm::Module &Module;
   const CodeGenOptions &CodeGenOpts;
   const LangOptions &Features;
   MangleContext &MContext;
@@ -138,10 +155,10 @@
  SmallVectorImpl &Fields,
  bool MayAlias);
 
-  /// A wrapper function to create a scalar type. For struct-path aware TBAA,
-  /// the scalar type has the same format as the struct type: name, offset,
-  /// pointer to another node in the type DAG.
-  llvm::MDNode *createTBAAScalarType(StringRef Name, llvm::MDNode *Parent);
+  /// createScalarTypeNode - A wrapper function to create a metadata node
+  /// describing a scalar type.
+  llvm::MDNode *createScalarTypeNode(StringRef Name, llvm::MDNode *Parent,
+ uint64_t Size);
 
   /// getTypeInfoHelper - An internal helper function to generate metadata used
   /// to describe accesses to objects of the given type.
@@ -152,19 +169,17 @@
   llvm::MDNode *getBaseTypeInfoHelper(const Type *Ty);
 
 public:
-  CodeGenTBAA(ASTContext &Ctx, llvm::LLVMContext &VMContext,
-  const CodeGenOptions &CGO,
-  const LangOptions &Features,
-  MangleContext &MContext);
+  CodeGenTBAA(ASTContext &Ctx, llvm::Module &M, const CodeGenOptions &CGO,
+  const LangOptions &Features, MangleContext &MContext);
   ~CodeGenTBAA();
 
   /// getTypeI

[PATCH] D40415: [libcxx] Define istream_iterator equality comparison operators out-of-line

2017-11-27 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

In https://reviews.llvm.org/D40415#934939, @EricWF wrote:

> LGTM. Thanks.


I don't have write access. Please commit the patch on my behalf.


https://reviews.llvm.org/D40415



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


[PATCH] D40450: [clangd] Refactoring of GlobalCompilationDatabase

2017-11-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdLSPServer.cpp:254
+  std::move(Primary), llvm::make_unique(
+  ".", ArrayRef{}));
+}

Clangd still changes working directory when running the parsing, so  `"."` 
might end up being a different dir on multiple runs over the same file.
Maybe use file's parent for now?




Comment at: clangd/ClangdServer.cpp:178
+  // Create an owned version of CDB to use ArgumentsAdjustingCompilations.
+  struct OwnedCDB : public tooling::CompilationDatabase {
+OwnedCDB(const tooling::CompilationDatabase &Ref) : Ref(Ref) {}

Maybe move this code out of `ClangdServer`? Arguably, it should be less 
confusing for clients of `ClangdServer` if they get exactly the compile 
commands returned by `CDB`.

This would also allow to get rid of `ResourceDir` parameter, which seems to be 
handled by `CompilationDatabase` now.



Comment at: clangd/ClangdServer.h:208
   /// Various messages are logged using \p Logger.
-  ClangdServer(GlobalCompilationDatabase &CDB,
+  ClangdServer(const tooling::CompilationDatabase &CDB,
DiagnosticsConsumer &DiagConsumer,

Are there any mutating methods in `CompilataionDatabase`? Why do we use `const 
&`  instead of `&`?



Comment at: clangd/GlobalCompilationDatabase.cpp:57
+  for (auto &Cmd : Commands) {
+assert(Cmd.CommandLine.size() >= 2 &&
+   "Expected at least the command and the filename");

IIRC, `Cmd` could come directly from `compile_commands.json`.
We should avoid crashing `clangd` if contents of `compile_commands.json` are 
invalid. Could we log the error instead and continue with other commands 
instead?



Comment at: clangd/GlobalCompilationDatabase.h:34
+  std::vector
+  getCompileCommands(PathRef File) const override;
 

It seems that this `const` means more trouble for implementations (i.e. using 
`mutable`, etc.) without providing any value.
Maybe we should consider removing it from the interface?
Am I missing the upsides of using `const` here?




Comment at: clangd/GlobalCompilationDatabase.h:61
+  llvm::StringMap> ExtraFlags;
+  std::unique_ptr Inner;
+};

Maybe we should consider using non-owning reference here?
It gives more flexibility, e.g. allowing to allocate on stack or store `CDB` 
directly inside the class fields, albeit it requires a bit more code to setup.
I'd say upsides of non-owning semantics outweigh a bit of added complexity


https://reviews.llvm.org/D40450



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


[PATCH] D40068: Implement more accurate penalty & trade-offs while breaking protruding tokens.

2017-11-27 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.

Self-accepting and closing, as the underlying change has landed, and this diff 
is incorrect now.
I also have an idea to solve the problem Typz has brought up.


https://reviews.llvm.org/D40068



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


r319015 - [ASTImporter] Support importing CXXPseudoDestructorExpr

2017-11-27 Thread Aleksei Sidorin via cfe-commits
Author: a.sidorin
Date: Mon Nov 27 02:30:00 2017
New Revision: 319015

URL: http://llvm.org/viewvc/llvm-project?rev=319015&view=rev
Log:
[ASTImporter] Support importing CXXPseudoDestructorExpr

Patch by Peter Szecsi!

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


Modified:
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=319015&r1=319014&r2=319015&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Mon Nov 27 02:30:00 2017
@@ -283,6 +283,7 @@ namespace clang {
 Expr *VisitExprWithCleanups(ExprWithCleanups *EWC);
 Expr *VisitCXXThisExpr(CXXThisExpr *E);
 Expr *VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E);
+Expr *VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E);
 Expr *VisitMemberExpr(MemberExpr *E);
 Expr *VisitCallExpr(CallExpr *E);
 Expr *VisitInitListExpr(InitListExpr *E);
@@ -5725,6 +5726,39 @@ Expr *ASTNodeImporter::VisitMemberExpr(M
 E->getObjectKind());
 }
 
+Expr *ASTNodeImporter::VisitCXXPseudoDestructorExpr(
+CXXPseudoDestructorExpr *E) {
+
+  Expr *BaseE = Importer.Import(E->getBase());
+  if (!BaseE)
+return nullptr;
+
+  TypeSourceInfo *ScopeInfo = Importer.Import(E->getScopeTypeInfo());
+  if (!ScopeInfo && E->getScopeTypeInfo())
+return nullptr;
+
+  PseudoDestructorTypeStorage Storage;
+  if (IdentifierInfo *FromII = E->getDestroyedTypeIdentifier()) {
+IdentifierInfo *ToII = Importer.Import(FromII);
+if (!ToII)
+  return nullptr;
+Storage = PseudoDestructorTypeStorage(
+  ToII, Importer.Import(E->getDestroyedTypeLoc()));
+  } else {
+TypeSourceInfo *TI = Importer.Import(E->getDestroyedTypeInfo());
+if (!TI)
+  return nullptr;
+Storage = PseudoDestructorTypeStorage(TI);
+  }
+
+  return new (Importer.getToContext()) CXXPseudoDestructorExpr(
+Importer.getToContext(), BaseE, E->isArrow(),
+Importer.Import(E->getOperatorLoc()),
+Importer.Import(E->getQualifierLoc()),
+ScopeInfo, Importer.Import(E->getColonColonLoc()),
+Importer.Import(E->getTildeLoc()), Storage);
+}
+
 Expr *ASTNodeImporter::VisitCallExpr(CallExpr *E) {
   QualType T = Importer.Import(E->getType());
   if (T.isNull())

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=319015&r1=319014&r2=319015&view=diff
==
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Mon Nov 27 02:30:00 2017
@@ -567,5 +567,21 @@ TEST(ImportExpr, ImportTypeTraitExprValD
)));
 }
 
+const internal::VariadicDynCastAllOfMatcher
+cxxPseudoDestructorExpr;
+
+TEST(ImportExpr, ImportCXXPseudoDestructorExpr) {
+  MatchVerifier Verifier;
+  EXPECT_TRUE(
+  testImport("typedef int T;"
+ "void declToImport(int *p) {"
+ "  T t;"
+ "  p->T::~T();"
+ "}",
+ Lang_CXX, "", Lang_CXX, Verifier,
+ functionDecl(has(compoundStmt(has(
+ callExpr(has(cxxPseudoDestructorExpr();
+}
+
 } // end namespace ast_matchers
 } // end namespace clang


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


[PATCH] D38843: [ASTImporter] Support importing CXXPseudoDestructorExpr

2017-11-27 Thread Aleksei Sidorin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319015: [ASTImporter] Support importing 
CXXPseudoDestructorExpr (authored by a.sidorin).

Changed prior to commit:
  https://reviews.llvm.org/D38843?vs=124173&id=124338#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38843

Files:
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/unittests/AST/ASTImporterTest.cpp


Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp
===
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp
@@ -567,5 +567,21 @@
)));
 }
 
+const internal::VariadicDynCastAllOfMatcher
+cxxPseudoDestructorExpr;
+
+TEST(ImportExpr, ImportCXXPseudoDestructorExpr) {
+  MatchVerifier Verifier;
+  EXPECT_TRUE(
+  testImport("typedef int T;"
+ "void declToImport(int *p) {"
+ "  T t;"
+ "  p->T::~T();"
+ "}",
+ Lang_CXX, "", Lang_CXX, Verifier,
+ functionDecl(has(compoundStmt(has(
+ callExpr(has(cxxPseudoDestructorExpr();
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: cfe/trunk/lib/AST/ASTImporter.cpp
===
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -283,6 +283,7 @@
 Expr *VisitExprWithCleanups(ExprWithCleanups *EWC);
 Expr *VisitCXXThisExpr(CXXThisExpr *E);
 Expr *VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E);
+Expr *VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E);
 Expr *VisitMemberExpr(MemberExpr *E);
 Expr *VisitCallExpr(CallExpr *E);
 Expr *VisitInitListExpr(InitListExpr *E);
@@ -5725,6 +5726,39 @@
 E->getObjectKind());
 }
 
+Expr *ASTNodeImporter::VisitCXXPseudoDestructorExpr(
+CXXPseudoDestructorExpr *E) {
+
+  Expr *BaseE = Importer.Import(E->getBase());
+  if (!BaseE)
+return nullptr;
+
+  TypeSourceInfo *ScopeInfo = Importer.Import(E->getScopeTypeInfo());
+  if (!ScopeInfo && E->getScopeTypeInfo())
+return nullptr;
+
+  PseudoDestructorTypeStorage Storage;
+  if (IdentifierInfo *FromII = E->getDestroyedTypeIdentifier()) {
+IdentifierInfo *ToII = Importer.Import(FromII);
+if (!ToII)
+  return nullptr;
+Storage = PseudoDestructorTypeStorage(
+  ToII, Importer.Import(E->getDestroyedTypeLoc()));
+  } else {
+TypeSourceInfo *TI = Importer.Import(E->getDestroyedTypeInfo());
+if (!TI)
+  return nullptr;
+Storage = PseudoDestructorTypeStorage(TI);
+  }
+
+  return new (Importer.getToContext()) CXXPseudoDestructorExpr(
+Importer.getToContext(), BaseE, E->isArrow(),
+Importer.Import(E->getOperatorLoc()),
+Importer.Import(E->getQualifierLoc()),
+ScopeInfo, Importer.Import(E->getColonColonLoc()),
+Importer.Import(E->getTildeLoc()), Storage);
+}
+
 Expr *ASTNodeImporter::VisitCallExpr(CallExpr *E) {
   QualType T = Importer.Import(E->getType());
   if (T.isNull())


Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp
===
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp
@@ -567,5 +567,21 @@
)));
 }
 
+const internal::VariadicDynCastAllOfMatcher
+cxxPseudoDestructorExpr;
+
+TEST(ImportExpr, ImportCXXPseudoDestructorExpr) {
+  MatchVerifier Verifier;
+  EXPECT_TRUE(
+  testImport("typedef int T;"
+ "void declToImport(int *p) {"
+ "  T t;"
+ "  p->T::~T();"
+ "}",
+ Lang_CXX, "", Lang_CXX, Verifier,
+ functionDecl(has(compoundStmt(has(
+ callExpr(has(cxxPseudoDestructorExpr();
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: cfe/trunk/lib/AST/ASTImporter.cpp
===
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -283,6 +283,7 @@
 Expr *VisitExprWithCleanups(ExprWithCleanups *EWC);
 Expr *VisitCXXThisExpr(CXXThisExpr *E);
 Expr *VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E);
+Expr *VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E);
 Expr *VisitMemberExpr(MemberExpr *E);
 Expr *VisitCallExpr(CallExpr *E);
 Expr *VisitInitListExpr(InitListExpr *E);
@@ -5725,6 +5726,39 @@
 E->getObjectKind());
 }
 
+Expr *ASTNodeImporter::VisitCXXPseudoDestructorExpr(
+CXXPseudoDestructorExpr *E) {
+
+  Expr *BaseE = Importer.Import(E->getBase());
+  if (!BaseE)
+return nullptr;
+
+  TypeSourceInfo *ScopeInfo = Importer.Import(E->getScopeTypeInfo());
+  if (!ScopeInfo && E->getScopeTypeInfo())
+retur

[PATCH] D40481: [libclang] Fix cursors for arguments of Subscript and Call operators

2017-11-27 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik created this revision.

The DeclRefExpr of CXXOperatorCallExpr refering to the custom operator
is visited before the arguments to the operator call. For the Call and
Subscript operator the range of this DeclRefExpr includes the whole call
expression, so that all tokens in that range were mapped to the operator
function, even the tokens of the arguments.

Fix this by ensuring that this particular DeclRefExpr is visited last.

Fixes PR25775.


https://reviews.llvm.org/D40481

Files:
  test/Index/annotate-operator-call-expr.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -6441,11 +6441,18 @@
   SourceManager &SrcMgr;
   bool HasContextSensitiveKeywords;
 
+  struct PostChildrenAction {
+  CXCursor cursor;
+  enum Action { Invalid, Ignore, Postpone } action;
+  };
+  using PostChildrenActions = SmallVector;
+
   struct PostChildrenInfo {
 CXCursor Cursor;
 SourceRange CursorRange;
 unsigned BeforeReachingCursorIdx;
 unsigned BeforeChildrenTokenIdx;
+PostChildrenActions ChildActions;
   };
   SmallVector PostChildrenInfos;
 
@@ -6491,7 +6498,13 @@
 
   void VisitChildren(CXCursor C) { AnnotateVis.VisitChildren(C); }
   enum CXChildVisitResult Visit(CXCursor cursor, CXCursor parent);
+  bool IsIgnoredChildCursor(CXCursor cursor) const;
+  PostChildrenActions DetermineChildActions(CXCursor Cursor) const;
+
   bool postVisitChildren(CXCursor cursor);
+  void HandlePostPonedChildCursors(const PostChildrenInfo &Info);
+  void HandlePostPonedChildCursor(CXCursor Cursor, unsigned StartTokenIndex);
+
   void AnnotateTokens();
   
   /// \brief Determine whether the annotator saw any cursors that have 
@@ -6509,7 +6522,67 @@
 void AnnotateTokensWorker::AnnotateTokens() {
   // Walk the AST within the region of interest, annotating tokens
   // along the way.
-  AnnotateVis.visitFileRegion();
+AnnotateVis.visitFileRegion();
+}
+
+bool AnnotateTokensWorker::IsIgnoredChildCursor(CXCursor cursor) const {
+  if (PostChildrenInfos.empty())
+return false;
+
+  for (const auto &ChildAction : PostChildrenInfos.back().ChildActions) {
+if (ChildAction.cursor == cursor &&
+ChildAction.action == PostChildrenAction::Ignore)
+  return true;
+  }
+
+  return false;
+}
+
+const CXXOperatorCallExpr *GetSubscriptOrCallOperator(CXCursor Cursor) {
+  if (!clang_isExpression(Cursor.kind))
+return nullptr;
+
+  const Expr *E = getCursorExpr(Cursor);
+  if (const auto *OCE = dyn_cast(E)) {
+const OverloadedOperatorKind Kind = OCE->getOperator();
+if (Kind == OO_Call || Kind == OO_Subscript)
+  return OCE;
+  }
+
+  return nullptr;
+}
+
+AnnotateTokensWorker::PostChildrenActions
+AnnotateTokensWorker::DetermineChildActions(CXCursor Cursor) const {
+  PostChildrenActions actions;
+
+  // The DeclRefExpr of CXXOperatorCallExpr refering to the custom operator is
+  // visited before the arguments to the operator call. For the Call and
+  // Subscript operator the range of this DeclRefExpr includes the whole call
+  // expression, so that all tokens in that range would be mapped to the
+  // operator function, including the tokens of the arguments. To avoid that,
+  // ensure to visit this DeclRefExpr as last node.
+  if (const auto *OCE = GetSubscriptOrCallOperator(Cursor)) {
+const Expr *Callee = OCE->getCallee();
+if (const ImplicitCastExpr *ICE = dyn_cast(Callee)) {
+  const Expr *SubExpr = ICE->getSubExpr();
+  if (const DeclRefExpr *DRE = dyn_cast(SubExpr)) {
+const Decl *parentDecl = getCursorParentDecl(Cursor);
+CXTranslationUnit TU = clang_Cursor_getTranslationUnit(Cursor);
+
+// Visit the DeclRefExpr as last.
+CXCursor cxChild = MakeCXCursor(DRE, parentDecl, TU);
+actions.push_back({cxChild, PostChildrenAction::Postpone});
+
+// The parent of the DeclRefExpr, an ImplicitCastExpr, has an equally
+// wide range as the DeclRefExpr. We can skip visiting this entirely.
+cxChild = MakeCXCursor(ICE, parentDecl, TU);
+actions.push_back({cxChild, PostChildrenAction::Ignore});
+  }
+}
+  }
+
+  return actions;
 }
 
 static inline void updateCursorAnnotation(CXCursor &Cursor,
@@ -6588,7 +6661,10 @@
   SourceRange cursorRange = getRawCursorExtent(cursor);
   if (cursorRange.isInvalid())
 return CXChildVisit_Recurse;
-  
+
+  if (IsIgnoredChildCursor(cursor))
+  return CXChildVisit_Continue;
+
   if (!HasContextSensitiveKeywords) {
 // Objective-C properties can have context-sensitive keywords.
 if (cursor.kind == CXCursor_ObjCPropertyDecl) {
@@ -6736,6 +6812,7 @@
   Info.CursorRange = cursorRange;
   Info.BeforeReachingCursorIdx = BeforeReachingCursorIdx;
   Info.BeforeChildrenTokenIdx = NextToken();
+  Info.ChildActions = DetermineChildActions(cursor);
   PostChildrenInfos.push_back(Info);
 
   return CXChildVisit_Recu

[PATCH] D40481: [libclang] Fix cursors for arguments of Subscript and Call operators

2017-11-27 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added inline comments.



Comment at: tools/libclang/CIndex.cpp:6445
+  struct PostChildrenAction {
+  CXCursor cursor;
+  enum Action { Invalid, Ignore, Postpone } action;

4 spaces instead of 2



Comment at: tools/libclang/CIndex.cpp:6535
+ChildAction.action == PostChildrenAction::Ignore)
+  return true;
+  }

missing {}



Comment at: tools/libclang/CIndex.cpp:
+  if (IsIgnoredChildCursor(cursor))
+  return CXChildVisit_Continue;
+

4 spaces indentation instead of 2



Comment at: tools/libclang/CIndex.cpp:6860
+if (ChildAction.action == PostChildrenAction::Postpone)
+  HandlePostPonedChildCursor(ChildAction.cursor,
+ Info.BeforeChildrenTokenIdx);

cover with {}



Comment at: tools/libclang/CIndex.cpp:6888
+  const SourceLocation fixedEnd =
+  RefNameRange.getEnd().getLocWithOffset(-1);
+  RefNameRange = SourceRange(RefNameRange.getBegin(), fixedEnd);

4 spaces indentation instead of 2



Comment at: tools/libclang/CIndex.cpp:6892
+  const RangeComparisonResult ComparisonResult =
+  LocationCompare(SrcMgr, TokenLocation, RefNameRange);
+

same


https://reviews.llvm.org/D40481



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


[PATCH] D40310: Restructure how we break tokens.

2017-11-27 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: lib/Format/ContinuationIndenter.cpp:1518
+  unsigned RemainingTokenColumns = 0;
+  // The column number we're currently at.
+  unsigned ContentStartColumn = 0;

krasimir wrote:
> Could you please spell out the invariants that we maintain about 
> `TailOffset`, `RemainingTokenColumns` and `ContentStartColumn` (at least) at 
> the beginning of every main loop iteration below? That would surely make it 
> easier to review.
I'm not sure what you mean - I would literally write what I already wrote in 
the comment. Can you formulate questions so I can make sure I answer them?



Comment at: lib/Format/ContinuationIndenter.cpp:1533
+  // ContentStartColumn is either
+  // - at the start of the line, directly after a break
+  // - the end of the last line +1, when continuing a reflow over multiple

krasimir wrote:
> If the previous iteration requested that we try to reflow, how can 
> `ContentStartColumn` be at the start of the (current) line?
After a line break (that was already in the original text), ContentStartColumn 
is set to where we want the first character of the broken line to start.


https://reviews.llvm.org/D40310



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


[PATCH] D40481: [libclang] Fix cursors for arguments of Subscript and Call operators

2017-11-27 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik updated this revision to Diff 124341.
nik added a comment.

Addressed coding style issues.


https://reviews.llvm.org/D40481

Files:
  test/Index/annotate-operator-call-expr.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -6441,11 +6441,18 @@
   SourceManager &SrcMgr;
   bool HasContextSensitiveKeywords;
 
+  struct PostChildrenAction {
+CXCursor cursor;
+enum Action { Invalid, Ignore, Postpone } action;
+  };
+  using PostChildrenActions = SmallVector;
+
   struct PostChildrenInfo {
 CXCursor Cursor;
 SourceRange CursorRange;
 unsigned BeforeReachingCursorIdx;
 unsigned BeforeChildrenTokenIdx;
+PostChildrenActions ChildActions;
   };
   SmallVector PostChildrenInfos;
 
@@ -6491,7 +6498,13 @@
 
   void VisitChildren(CXCursor C) { AnnotateVis.VisitChildren(C); }
   enum CXChildVisitResult Visit(CXCursor cursor, CXCursor parent);
+  bool IsIgnoredChildCursor(CXCursor cursor) const;
+  PostChildrenActions DetermineChildActions(CXCursor Cursor) const;
+
   bool postVisitChildren(CXCursor cursor);
+  void HandlePostPonedChildCursors(const PostChildrenInfo &Info);
+  void HandlePostPonedChildCursor(CXCursor Cursor, unsigned StartTokenIndex);
+
   void AnnotateTokens();
   
   /// \brief Determine whether the annotator saw any cursors that have 
@@ -6509,7 +6522,68 @@
 void AnnotateTokensWorker::AnnotateTokens() {
   // Walk the AST within the region of interest, annotating tokens
   // along the way.
-  AnnotateVis.visitFileRegion();
+AnnotateVis.visitFileRegion();
+}
+
+bool AnnotateTokensWorker::IsIgnoredChildCursor(CXCursor cursor) const {
+  if (PostChildrenInfos.empty())
+return false;
+
+  for (const auto &ChildAction : PostChildrenInfos.back().ChildActions) {
+if (ChildAction.cursor == cursor &&
+ChildAction.action == PostChildrenAction::Ignore) {
+  return true;
+}
+  }
+
+  return false;
+}
+
+const CXXOperatorCallExpr *GetSubscriptOrCallOperator(CXCursor Cursor) {
+  if (!clang_isExpression(Cursor.kind))
+return nullptr;
+
+  const Expr *E = getCursorExpr(Cursor);
+  if (const auto *OCE = dyn_cast(E)) {
+const OverloadedOperatorKind Kind = OCE->getOperator();
+if (Kind == OO_Call || Kind == OO_Subscript)
+  return OCE;
+  }
+
+  return nullptr;
+}
+
+AnnotateTokensWorker::PostChildrenActions
+AnnotateTokensWorker::DetermineChildActions(CXCursor Cursor) const {
+  PostChildrenActions actions;
+
+  // The DeclRefExpr of CXXOperatorCallExpr refering to the custom operator is
+  // visited before the arguments to the operator call. For the Call and
+  // Subscript operator the range of this DeclRefExpr includes the whole call
+  // expression, so that all tokens in that range would be mapped to the
+  // operator function, including the tokens of the arguments. To avoid that,
+  // ensure to visit this DeclRefExpr as last node.
+  if (const auto *OCE = GetSubscriptOrCallOperator(Cursor)) {
+const Expr *Callee = OCE->getCallee();
+if (const ImplicitCastExpr *ICE = dyn_cast(Callee)) {
+  const Expr *SubExpr = ICE->getSubExpr();
+  if (const DeclRefExpr *DRE = dyn_cast(SubExpr)) {
+const Decl *parentDecl = getCursorParentDecl(Cursor);
+CXTranslationUnit TU = clang_Cursor_getTranslationUnit(Cursor);
+
+// Visit the DeclRefExpr as last.
+CXCursor cxChild = MakeCXCursor(DRE, parentDecl, TU);
+actions.push_back({cxChild, PostChildrenAction::Postpone});
+
+// The parent of the DeclRefExpr, an ImplicitCastExpr, has an equally
+// wide range as the DeclRefExpr. We can skip visiting this entirely.
+cxChild = MakeCXCursor(ICE, parentDecl, TU);
+actions.push_back({cxChild, PostChildrenAction::Ignore});
+  }
+}
+  }
+
+  return actions;
 }
 
 static inline void updateCursorAnnotation(CXCursor &Cursor,
@@ -6588,7 +6662,10 @@
   SourceRange cursorRange = getRawCursorExtent(cursor);
   if (cursorRange.isInvalid())
 return CXChildVisit_Recurse;
-  
+
+  if (IsIgnoredChildCursor(cursor))
+return CXChildVisit_Continue;
+
   if (!HasContextSensitiveKeywords) {
 // Objective-C properties can have context-sensitive keywords.
 if (cursor.kind == CXCursor_ObjCPropertyDecl) {
@@ -6736,6 +6813,7 @@
   Info.CursorRange = cursorRange;
   Info.BeforeReachingCursorIdx = BeforeReachingCursorIdx;
   Info.BeforeChildrenTokenIdx = NextToken();
+  Info.ChildActions = DetermineChildActions(cursor);
   PostChildrenInfos.push_back(Info);
 
   return CXChildVisit_Recurse;
@@ -6748,6 +6826,8 @@
   if (!clang_equalCursors(Info.Cursor, cursor))
 return false;
 
+  HandlePostPonedChildCursors(Info);
+
   const unsigned BeforeChildren = Info.BeforeChildrenTokenIdx;
   const unsigned AfterChildren = NextToken();
   SourceRange cursorRange = Info.CursorRange;
@@ -6774,6 +6854,56 @@
   return false;
 }
 
+void Anno

[PATCH] D40481: [libclang] Fix cursors for arguments of Subscript and Call operators

2017-11-27 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik marked 4 inline comments as done.
nik added inline comments.



Comment at: tools/libclang/CIndex.cpp:6888
+  const SourceLocation fixedEnd =
+  RefNameRange.getEnd().getLocWithOffset(-1);
+  RefNameRange = SourceRange(RefNameRange.getBegin(), fixedEnd);

yvvan wrote:
> 4 spaces indentation instead of 2
That's not me, but clang-format, so I guess it's fine as is.



Comment at: tools/libclang/CIndex.cpp:6892
+  const RangeComparisonResult ComparisonResult =
+  LocationCompare(SrcMgr, TokenLocation, RefNameRange);
+

yvvan wrote:
> same
That's not me, but clang-format, so I guess it's fine as is.


https://reviews.llvm.org/D40481



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


[PATCH] D40481: [libclang] Fix cursors for arguments of Subscript and Call operators

2017-11-27 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added inline comments.



Comment at: tools/libclang/CIndex.cpp:6888
+  const SourceLocation fixedEnd =
+  RefNameRange.getEnd().getLocWithOffset(-1);
+  RefNameRange = SourceRange(RefNameRange.getBegin(), fixedEnd);

nik wrote:
> yvvan wrote:
> > 4 spaces indentation instead of 2
> That's not me, but clang-format, so I guess it's fine as is.
oh, you're right. it's ok here and in the next one


https://reviews.llvm.org/D40481



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


[PATCH] D39706: [refactor][extract] Initial implementation of variable captures

2017-11-27 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

Lg

(Sorry for losing track of this and the delay!)


Repository:
  rL LLVM

https://reviews.llvm.org/D39706



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


[PATCH] D40439: [Tooling] Remove file/command enumeration from CompilationDatabase.

2017-11-27 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer added a comment.

There are a few users of the C++ API out there, do we have migration path for 
them?


https://reviews.llvm.org/D40439



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


[clang-tools-extra] r319021 - [clang-tidy] readability-non-const-parameter fixes should update all declarations

2017-11-27 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon Nov 27 04:42:04 2017
New Revision: 319021

URL: http://llvm.org/viewvc/llvm-project?rev=319021&view=rev
Log:
[clang-tidy] readability-non-const-parameter fixes should update all 
declarations

Fixes http://llvm.org/PR34410.

Modified:
clang-tools-extra/trunk/clang-tidy/readability/NonConstParameterCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-non-const-parameter.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/NonConstParameterCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/NonConstParameterCheck.cpp?rev=319021&r1=319020&r2=319021&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/NonConstParameterCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/NonConstParameterCheck.cpp 
Mon Nov 27 04:42:04 2017
@@ -138,9 +138,18 @@ void NonConstParameterCheck::diagnoseNon
 if (!ParamInfo.CanBeConst)
   continue;
 
+SmallVector Fixes;
+auto *Function =
+dyn_cast_or_null(Par->getParentFunctionOrMethod());
+if (!Function)
+  continue;
+unsigned Index = Par->getFunctionScopeIndex();
+for (FunctionDecl *FnDecl : Function->redecls())
+  Fixes.push_back(FixItHint::CreateInsertion(
+  FnDecl->getParamDecl(Index)->getLocStart(), "const "));
+
 diag(Par->getLocation(), "pointer parameter '%0' can be pointer to const")
-<< Par->getName()
-<< FixItHint::CreateInsertion(Par->getLocStart(), "const ");
+<< Par->getName() << Fixes;
   }
 }
 

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-non-const-parameter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-non-const-parameter.cpp?rev=319021&r1=319020&r2=319021&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/readability-non-const-parameter.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-non-const-parameter.cpp 
Mon Nov 27 04:42:04 2017
@@ -277,3 +277,13 @@ public:
 int x = *p;
   }
 };
+
+extern char foo(char *s); // 1
+// CHECK-FIXES: {{^}}extern char foo(const char *s); // 1{{$}}
+// CHECK-MESSAGES: :[[@LINE+1]]:16: warning: pointer parameter 's' can be
+char foo(char *s) {
+  // CHECK-FIXES: {{^}}char foo(const char *s) {{{$}}
+  return *s;
+}
+char foo(char *s); // 2
+// CHECK-FIXES: {{^}}char foo(const char *s); // 2{{$}}


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


[PATCH] D37482: run-clang-tidy: Use check_call instead of check_output

2017-11-27 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG, if this still works under Python 2.


https://reviews.llvm.org/D37482



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


[clang-tools-extra] r319022 - Make helper function static. NFC.

2017-11-27 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Nov 27 04:48:26 2017
New Revision: 319022

URL: http://llvm.org/viewvc/llvm-project?rev=319022&view=rev
Log:
Make helper function static. NFC.

Modified:
clang-tools-extra/trunk/clangd/Protocol.cpp

Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=319022&r1=319021&r2=319022&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.cpp (original)
+++ clang-tools-extra/trunk/clangd/Protocol.cpp Mon Nov 27 04:48:26 2017
@@ -843,7 +843,7 @@ CodeActionParams::parse(llvm::yaml::Mapp
   return Result;
 }
 
-llvm::Optional>>
+static llvm::Optional>>
 parseWorkspaceEditChange(llvm::yaml::MappingNode *Params,
  clangd::Logger &Logger) {
   std::map> Result;


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


[PATCH] D40485: [clangd] Introduced a Context that stores implicit data

2017-11-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
Herald added a subscriber: mgorny.

It will be used to pass around things like Logger and Tracer throughout
clangd classes.


https://reviews.llvm.org/D40485

Files:
  clangd/CMakeLists.txt
  clangd/Context.cpp
  clangd/Context.h
  clangd/TypedValueMap.h
  unittests/clangd/CMakeLists.txt
  unittests/clangd/ContextTests.cpp

Index: unittests/clangd/ContextTests.cpp
===
--- /dev/null
+++ unittests/clangd/ContextTests.cpp
@@ -0,0 +1,88 @@
+//===-- ContextTests.cpp - Context tests *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "Context.h"
+
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+
+TEST(TypedValueMapTests, Simple) {
+  Key IntParam;
+  Key ExtraIntParam;
+
+  clangd::TypedValueMap Ctx;
+
+  ASSERT_TRUE(Ctx.emplace(IntParam, 10));
+  ASSERT_TRUE(Ctx.emplace(ExtraIntParam, 20));
+
+  EXPECT_EQ(*Ctx.get(IntParam), 10);
+  EXPECT_EQ(*Ctx.get(ExtraIntParam), 20);
+
+  ASSERT_FALSE(Ctx.emplace(IntParam, 30));
+
+  ASSERT_TRUE(Ctx.remove(IntParam));
+  EXPECT_EQ(Ctx.get(IntParam), nullptr);
+  EXPECT_EQ(*Ctx.get(ExtraIntParam), 20);
+
+  ASSERT_TRUE(Ctx.emplace(IntParam, 30));
+  EXPECT_EQ(*Ctx.get(IntParam), 30);
+  EXPECT_EQ(*Ctx.get(ExtraIntParam), 20);
+}
+
+TEST(TypedValueMapTests, MoveOps) {
+  Key> Param;
+
+  clangd::TypedValueMap Ctx;
+  Ctx.emplace(Param, llvm::make_unique(10));
+  EXPECT_EQ(**Ctx.get(Param), 10);
+
+  clangd::TypedValueMap NewCtx = std::move(Ctx);
+  EXPECT_EQ(**NewCtx.get(Param), 10);
+}
+
+TEST(TypedValueMapTests, PtrKey) {
+  int Value = 10;
+  PtrKey Param;
+
+  clangd::TypedValueMap Ctx;
+  EXPECT_EQ(Ctx.get(Param), nullptr);
+
+  Ctx.emplace(Param, &Value);
+  EXPECT_EQ(*Ctx.get(Param), 10);
+
+  Ctx.remove(Param);
+  EXPECT_EQ(Ctx.get(Param), nullptr);
+
+  Ctx.emplace(Param, nullptr);
+  EXPECT_EQ(Ctx.get(Param), nullptr);
+}
+
+TEST(ContextTests, Builders) {
+  Key ParentParam;
+  Key ParentAndChildParam;
+  Key ChildParam;
+
+  Context ParentCtx =
+  buildCtx().add(ParentParam, 10).add(ParentAndChildParam, 20);
+  Context ChildCtx =
+  buildCtx(&ParentCtx).add(ParentAndChildParam, 30).add(ChildParam, 40);
+
+  EXPECT_EQ(*ParentCtx.get(ParentParam), 10);
+  EXPECT_EQ(*ParentCtx.get(ParentAndChildParam), 20);
+  EXPECT_EQ(ParentCtx.get(ChildParam), nullptr);
+
+  EXPECT_EQ(*ChildCtx.get(ParentParam), 10);
+  EXPECT_EQ(*ChildCtx.get(ParentAndChildParam), 30);
+  EXPECT_EQ(*ChildCtx.get(ChildParam), 40);
+}
+
+} // namespace clangd
+} // namespace clang
Index: unittests/clangd/CMakeLists.txt
===
--- unittests/clangd/CMakeLists.txt
+++ unittests/clangd/CMakeLists.txt
@@ -10,6 +10,7 @@
 
 add_extra_unittest(ClangdTests
   ClangdTests.cpp
+  ContextTests.cpp
   JSONExprTests.cpp
   TraceTests.cpp
   )
Index: clangd/TypedValueMap.h
===
--- /dev/null
+++ clangd/TypedValueMap.h
@@ -0,0 +1,123 @@
+//===--- TypedValueMap.h - Type-safe heterogenous key-value map -*- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Type-safe heterogenous map.
+//
+//===--===//
+
+#include "llvm/ADT/DenseMap.h"
+#include 
+
+namespace clang {
+namespace clangd {
+
+/// Used as identity for map values. Non-movable and non-copyable. Address of
+/// this object is used internally to as keys in a map.
+template  class Key {
+public:
+  static_assert(!std::is_reference::value,
+"Reference arguments to Key<> are not allowed");
+
+  Key() = default;
+
+  Key(Key const &) = delete;
+  Key &operator=(Key const &) = delete;
+  Key(Key &&) = delete;
+  Key &operator=(Key &&) = delete;
+};
+
+/// Similar to a Key with a slightly easier to use semantics.
+/// While get(Key) returns T**, get(PtrKey) returns T*.
+/// Therefore PtrKey<> does not distinguish values missing from the map and
+/// values equal to null.
+template  class PtrKey {
+public:
+  Key UnderlyingKey;
+};
+
+/// A type-safe map from Key to T.
+class TypedValueMap {
+public:
+  TypedValueMap() = default;
+  TypedValueMap(const TypedValueMap &) = delete;
+  TypedValueMap(TypedValueMap &&) = default;
+
+  template  Type *get(Key &Key) const {
+auto It = Map.find(&Key);
+if (It == Map.end())
+  return nullptr;
+return static_cast(It->second->getValuePtr());
+  }
+
+  template 
+  bool emplace(Key &Key, 

[PATCH] D40486: [clangd] Implemented logging using Context

2017-11-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.

https://reviews.llvm.org/D40486

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/ClangdUnitStore.cpp
  clangd/ClangdUnitStore.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/JSONRPCDispatcher.cpp
  clangd/JSONRPCDispatcher.h
  clangd/Logger.cpp
  clangd/Logger.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/tool/ClangdMain.cpp
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -9,7 +9,7 @@
 
 #include "ClangdLSPServer.h"
 #include "ClangdServer.h"
-#include "Logger.h"
+#include "Context.h"
 #include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Config/config.h"
 #include "llvm/ADT/SmallVector.h"
@@ -133,8 +133,11 @@
 } // namespace vfs
 
 namespace clangd {
+
 namespace {
 
+Context emptyCtx() { return buildCtx(); }
+
 struct StringWithPos {
   std::string Text;
   clangd::Position MarkerPos;
@@ -333,8 +336,7 @@
 MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
 /*StorePreamblesInMemory=*/true,
-clangd::CodeCompleteOptions(),
-EmptyLogger::getInstance());
+clangd::CodeCompleteOptions());
 for (const auto &FileWithContents : ExtraFiles)
   FS.Files[getVirtualTestFilePath(FileWithContents.first)] =
   FileWithContents.second;
@@ -345,7 +347,8 @@
 
 // Have to sync reparses because requests are processed on the calling
 // thread.
-auto AddDocFuture = Server.addDocument(SourceFilename, SourceContents);
+auto AddDocFuture =
+Server.addDocument(SourceFilename, SourceContents, emptyCtx());
 
 auto Result = dumpASTWithoutMemoryLocs(Server, SourceFilename);
 
@@ -398,8 +401,7 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
   /*StorePreamblesInMemory=*/true,
-  clangd::CodeCompleteOptions(),
-  EmptyLogger::getInstance());
+  clangd::CodeCompleteOptions());
 
   const auto SourceContents = R"cpp(
 #include "foo.h"
@@ -416,19 +418,19 @@
   // To sync reparses before checking for errors.
   std::future ParseFuture;
 
-  ParseFuture = Server.addDocument(FooCpp, SourceContents);
+  ParseFuture = Server.addDocument(FooCpp, SourceContents, emptyCtx());
   auto DumpParse1 = dumpASTWithoutMemoryLocs(Server, FooCpp);
   ASSERT_EQ(ParseFuture.wait_for(DefaultFutureTimeout),
 std::future_status::ready);
   EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
 
-  ParseFuture = Server.addDocument(FooCpp, "");
+  ParseFuture = Server.addDocument(FooCpp, "", emptyCtx());
   auto DumpParseEmpty = dumpASTWithoutMemoryLocs(Server, FooCpp);
   ASSERT_EQ(ParseFuture.wait_for(DefaultFutureTimeout),
 std::future_status::ready);
   EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
 
-  ParseFuture = Server.addDocument(FooCpp, SourceContents);
+  ParseFuture = Server.addDocument(FooCpp, SourceContents, emptyCtx());
   auto DumpParse2 = dumpASTWithoutMemoryLocs(Server, FooCpp);
   ASSERT_EQ(ParseFuture.wait_for(DefaultFutureTimeout),
 std::future_status::ready);
@@ -445,8 +447,7 @@
 
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
   /*StorePreamblesInMemory=*/true,
-  clangd::CodeCompleteOptions(),
-  EmptyLogger::getInstance());
+  clangd::CodeCompleteOptions());
 
   const auto SourceContents = R"cpp(
 #include "foo.h"
@@ -463,21 +464,21 @@
   // To sync reparses before checking for errors.
   std::future ParseFuture;
 
-  ParseFuture = Server.addDocument(FooCpp, SourceContents);
+  ParseFuture = Server.addDocument(FooCpp, SourceContents, emptyCtx());
   auto DumpParse1 = dumpASTWithoutMemoryLocs(Server, FooCpp);
   ASSERT_EQ(ParseFuture.wait_for(DefaultFutureTimeout),
 std::future_status::ready);
   EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
 
   FS.Files[FooH] = "";
-  ParseFuture = Server.forceReparse(FooCpp);
+  ParseFuture = Server.forceReparse(FooCpp, emptyCtx());
   auto DumpParseDifferent = dumpASTWithoutMemoryLocs(Server, FooCpp);
   ASSERT_EQ(ParseFuture.wait_for(DefaultFutureTimeout),
 std::future_status::ready);
   EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
 
   FS.Files[FooH] = "int a;";
-  ParseFuture = Server.forceReparse(FooCpp);
+  ParseFuture = Server.forceReparse(FooCpp, emptyCtx());
   auto DumpParse2 = dumpASTWithoutMemoryLocs(Server, FooCpp);
   EXPECT_EQ(ParseFutur

[PATCH] D40488: [clangd] Implemented tracing using Context

2017-11-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.

https://reviews.llvm.org/D40488

Files:
  clangd/ClangdUnit.cpp
  clangd/JSONRPCDispatcher.cpp
  clangd/JSONRPCDispatcher.h
  clangd/ProtocolHandlers.cpp
  clangd/Trace.cpp
  clangd/Trace.h
  clangd/tool/ClangdMain.cpp
  unittests/clangd/TraceTests.cpp

Index: unittests/clangd/TraceTests.cpp
===
--- unittests/clangd/TraceTests.cpp
+++ unittests/clangd/TraceTests.cpp
@@ -7,6 +7,7 @@
 //
 //===--===//
 
+#include "Context.h"
 #include "Trace.h"
 
 #include "llvm/ADT/DenseMap.h"
@@ -74,10 +75,12 @@
   std::string JSON;
   {
 raw_string_ostream OS(JSON);
-auto Session = trace::Session::create(OS);
+auto JSONTracer = trace::createJSONTracer(OS);
+Context TraceCtx =
+buildCtx().add(trace::EventTracer::CtxKey, JSONTracer.get());
 {
-  trace::Span S("A");
-  trace::log("B");
+  trace::Span S(TraceCtx, "A");
+  trace::log(TraceCtx, "B");
 }
   }
 
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -116,15 +116,15 @@
 }
   }
   llvm::Optional TraceStream;
-  std::unique_ptr TraceSession;
+  std::unique_ptr TraceSession;
   if (!TraceFile.empty()) {
 std::error_code EC;
 TraceStream.emplace(TraceFile, /*ref*/ EC, llvm::sys::fs::F_RW);
 if (EC) {
   TraceFile.reset();
   llvm::errs() << "Error while opening trace file: " << EC.message();
 } else {
-  TraceSession = trace::Session::create(*TraceStream, PrettyPrint);
+  TraceSession = trace::createJSONTracer(*TraceStream, PrettyPrint);
 }
   }
 
@@ -134,7 +134,11 @@
  InputMirrorStream ? InputMirrorStream.getPointer() : nullptr,
  PrettyPrint);
 
-  GlobalSession Session(buildCtx().add(Logger::CtxKey, &Out));
+  TypedValueMap ContextMap;
+  ContextMap.emplace(Logger::CtxKey, &Out);
+  if (TraceSession)
+ContextMap.emplace(trace::EventTracer::CtxKey, TraceSession.get());
+  GlobalSession Session(Context(/*Parent=*/nullptr, std::move(ContextMap)));
 
   // If --compile-commands-dir arg was invoked, check value and override default
   // path.
Index: clangd/Trace.h
===
--- clangd/Trace.h
+++ clangd/Trace.h
@@ -8,60 +8,64 @@
 //===--===//
 //
 // Supports writing performance traces describing clangd's behavior.
-// Traces are written in the Trace Event format supported by chrome's trace
-// viewer (chrome://tracing).
+// Traces are consumed by implementations of the EventTracer interface.
 //
-// The format is documented here:
-// https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview
 //
 // All APIs are no-ops unless a Session is active (created by ClangdMain).
 //
 //===--===//
 
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_TRACE_H_
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_TRACE_H_
 
+#include "Context.h"
 #include "JSONExpr.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/raw_ostream.h"
 
 namespace clang {
 namespace clangd {
 namespace trace {
 
-// A session directs the output of trace events. Only one Session can exist.
-// It should be created before clangd threads are spawned, and destroyed after
-// they exit.
-// TODO: we may want to add pluggable support for other tracing backends.
-class Session {
+class EventTracer {
 public:
-  // Starts a sessions capturing trace events and writing Trace Event JSON.
-  static std::unique_ptr create(llvm::raw_ostream &OS,
- bool Pretty = false);
-  ~Session();
+  static PtrKey CtxKey;
 
-private:
-  Session() = default;
+  virtual ~EventTracer() = default;
+  virtual void event(llvm::StringRef Phase, json::obj &&Contents) = 0;
 };
 
-// Records a single instant event, associated with the current thread.
-void log(const llvm::Twine &Name);
+/// Create an instance of EventTracer that produces an output in the Trace Event
+/// format supported by Chrome's trace viewer (chrome://tracing).
+///
+/// The format is documented here:
+/// https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview
+///
+/// The implementation supports concurrent calls and can be used as a global
+/// tracer (i.e., can be put into a global Context).
+std::unique_ptr createJSONTracer(llvm::raw_ostream &OS,
+  bool Pretty = false);
 
-// Records an event whose duration is the lifetime of the Span object.
-//
-// Arbitrary JSON metadata can be attached while this span is active:
-//   SPAN_ATTACH(MySpan, "Payload", SomeJSONExpr);
-// SomeJSONExpr is evaluated and copied only if actually needed.
+/// Records a singl

[PATCH] D40487: [clang-tidy] Move checks from misc- to performance-

2017-11-27 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh created this revision.
Herald added subscribers: xazax.hun, mgorny.

rename_check.py misc-move-constructor-init performance-move-constructor-init
rename_check.py misc-inefficient-algorithm performance-inefficient-algorithm


https://reviews.llvm.org/D40487

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/InefficientAlgorithmCheck.cpp
  clang-tidy/misc/InefficientAlgorithmCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/MoveConstructorInitCheck.cpp
  clang-tidy/misc/MoveConstructorInitCheck.h
  clang-tidy/performance/CMakeLists.txt
  clang-tidy/performance/InefficientAlgorithmCheck.cpp
  clang-tidy/performance/InefficientAlgorithmCheck.h
  clang-tidy/performance/MoveConstructorInitCheck.cpp
  clang-tidy/performance/MoveConstructorInitCheck.h
  clang-tidy/performance/PerformanceTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cert-oop11-cpp.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-inefficient-algorithm.rst
  docs/clang-tidy/checks/misc-move-constructor-init.rst
  docs/clang-tidy/checks/performance-inefficient-algorithm.rst
  docs/clang-tidy/checks/performance-move-constructor-init.rst
  test/clang-tidy/cert-oop11-cpp.cpp
  test/clang-tidy/misc-inefficient-algorithm.cpp
  test/clang-tidy/misc-move-constructor-init.cpp
  test/clang-tidy/performance-inefficient-algorithm.cpp
  test/clang-tidy/performance-move-constructor-init.cpp

Index: test/clang-tidy/performance-move-constructor-init.cpp
===
--- test/clang-tidy/performance-move-constructor-init.cpp
+++ test/clang-tidy/performance-move-constructor-init.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-move-constructor-init,modernize-pass-by-value %t -- \
+// RUN: %check_clang_tidy %s performance-move-constructor-init,modernize-pass-by-value %t -- \
 // RUN: -config='{CheckOptions: \
 // RUN:  [{key: modernize-pass-by-value.ValuesOnly, value: 1}]}' \
 // RUN: -- -std=c++11 -isystem %S/Inputs/Headers
@@ -30,7 +30,7 @@
 struct D : B {
   D() : B() {}
   D(const D &RHS) : B(RHS) {}
-  // CHECK-MESSAGES: :[[@LINE+3]]:16: warning: move constructor initializes base class by calling a copy constructor [misc-move-constructor-init]
+  // CHECK-MESSAGES: :[[@LINE+3]]:16: warning: move constructor initializes base class by calling a copy constructor [performance-move-constructor-init]
   // CHECK-MESSAGES: 26:3: note: copy constructor being called
   // CHECK-MESSAGES: 27:3: note: candidate move constructor here
   D(D &&RHS) : B(RHS) {}
@@ -75,7 +75,7 @@
 
 struct M {
   B Mem;
-  // CHECK-MESSAGES: :[[@LINE+1]]:16: warning: move constructor initializes class member by calling a copy constructor [misc-move-constructor-init]
+  // CHECK-MESSAGES: :[[@LINE+1]]:16: warning: move constructor initializes class member by calling a copy constructor [performance-move-constructor-init]
   M(M &&RHS) : Mem(RHS.Mem) {}
 };
 
Index: test/clang-tidy/performance-inefficient-algorithm.cpp
===
--- test/clang-tidy/performance-inefficient-algorithm.cpp
+++ test/clang-tidy/performance-inefficient-algorithm.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-inefficient-algorithm %t
+// RUN: %check_clang_tidy %s performance-inefficient-algorithm %t
 
 namespace std {
 template  struct less {
@@ -78,7 +78,7 @@
 int main() {
   std::set s;
   auto it = std::find(s.begin(), s.end(), 43);
-  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: this STL algorithm call should be replaced with a container method [misc-inefficient-algorithm]
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: this STL algorithm call should be replaced with a container method [performance-inefficient-algorithm]
   // CHECK-FIXES: {{^  }}auto it = s.find(43);{{$}}
   auto c = count(s.begin(), s.end(), 43);
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: this STL algorithm call should be
@@ -107,7 +107,7 @@
   // CHECK-FIXES: {{^  }}msptr->find(46);{{$}}
 
   it = std::find(s.begin(), s.end(), 43, std::greater());
-  // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: different comparers used in the algorithm and the container [misc-inefficient-algorithm]
+  // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: different comparers used in the algorithm and the container [performance-inefficient-algorithm]
 
   FIND_IN_SET(s);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
Index: test/clang-tidy/cert-oop11-cpp.cpp
===
--- test/clang-tidy/cert-oop11-cpp.cpp
+++ test/clang-tidy/cert-oop11-cpp.cpp
@@ -16,6 +16,6 @@
 
   // This should not produce a diagnostic because it is not covered under
   // the CERT guideline for OOP11-CPP. However, this will produce a diagnostic
-  // under misc-move-constructor-init.
+  // under performance-move-constructor-init.
   D(B b) : b(b) {}
 };
Index: docs/clang-tidy/checks/per

[PATCH] D40489: [clangd] Changed tracing interfaces

2017-11-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.

Introduced begin_event, end_event and instant_event instead of a
string phase name.


https://reviews.llvm.org/D40489

Files:
  clangd/Trace.cpp
  clangd/Trace.h

Index: clangd/Trace.h
===
--- clangd/Trace.h
+++ clangd/Trace.h
@@ -27,12 +27,29 @@
 namespace clangd {
 namespace trace {
 
+/// A sink for consuming tracing events. Calls to begin_event and end_event with
+/// the same name are always properly nested by using a RAII object (Span).
+/// However, global tracers (i.e., returned from the global Context object) may
+/// be called concurrently and have to be properly synchronized. For per-request
+/// EventTracers (i.e., returned from the request-specific Context objects) the
+/// calls to begin_event and end_event must be properly synchronized and must
+/// never be called concurrently.
 class EventTracer {
 public:
+  /// A key used by trace::Span and trace::log to find EventTracer in a \p
+  /// Context.
   static PtrKey CtxKey;
 
   virtual ~EventTracer() = default;
-  virtual void event(llvm::StringRef Phase, json::obj &&Contents) = 0;
+
+  /// Called when event with \p Name stars.
+  virtual void begin_event(Context &Ctx, llvm::StringRef Name) = 0;
+  /// Called when event with \p Name ends.
+  virtual void end_event(Context &Ctx, llvm::StringRef Name,
+ json::obj &&Args) = 0;
+  /// Called for instant events.
+  virtual void instant_event(Context &Ctx, llvm::StringRef Name,
+ json::obj &&Args) = 0;
 };
 
 /// Create an instance of EventTracer that produces an output in the Trace Event
@@ -66,6 +83,7 @@
 
 private:
   Context &Ctx;
+  std::string Name;
   std::unique_ptr Args;
 };
 
Index: clangd/Trace.cpp
===
--- clangd/Trace.cpp
+++ clangd/Trace.cpp
@@ -45,9 +45,23 @@
 Out.flush();
   }
 
+  void begin_event(Context &Ctx, llvm::StringRef Name) override {
+jsonEvent("B", json::obj{{"name", Name}});
+  }
+
+  void end_event(Context &Ctx, llvm::StringRef Name,
+ json::obj &&Args) override {
+jsonEvent("E", json::obj{{"name", Name}, {"args", std::move(Args)}});
+  }
+
+  void instant_event(Context &Ctx, llvm::StringRef Name,
+ json::obj &&Args) override {
+jsonEvent("i", json::obj{{"name", Name}, {"args", std::move(Args)}});
+  }
+
   // Record an event on the current thread. ph, pid, tid, ts are set.
   // Contents must be a list of the other JSON key/values.
-  void event(StringRef Phase, json::obj &&Contents) override {
+  void jsonEvent(StringRef Phase, json::obj &&Contents) {
 uint64_t TID = get_threadid();
 std::lock_guard Lock(Mu);
 // If we haven't already, emit metadata describing this thread.
@@ -103,27 +117,23 @@
   EventTracer *T = Ctx.get(EventTracer::CtxKey);
   if (!T)
 return;
-  T->event("i", json::obj{
-{"name", "Log"},
-{"args", json::obj{{"Message", Message.str()}}},
-});
+  T->instant_event("Log", json::obj{{"Message", Message.str()}});
 }
 
-Span::Span(Context &Ctx, std::string Name) : Ctx(Ctx) {
-  EventTracer* T = Ctx.get(EventTracer::CtxKey);
+Span::Span(Context &Ctx, std::string Name) : Ctx(Ctx), Name(std::move(Name)) {
+  EventTracer *T = Ctx.get(EventTracer::CtxKey);
   if (!T)
 return;
-  T->event("B", json::obj{{"name", std::move(Name)}});
+  T->begin_event(this->Name);
   Args = llvm::make_unique();
 }
 
 Span::~Span() {
   auto T = Ctx.get(EventTracer::CtxKey);
   if (!T)
 return;
-  if (!Args)
-Args = llvm::make_unique();
-  T->event("E", Args ? json::obj{{"args", std::move(*Args)}} : json::obj{});
+  assert(Args && "Args can't be null at this point");
+  T->end_event(Name, std::move(*Args));
 }
 
 } // namespace trace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40487: [clang-tidy] Move checks from misc- to performance-

2017-11-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D40487



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


[PATCH] D40487: [clang-tidy] Move checks from misc- to performance-

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

LGTM.


https://reviews.llvm.org/D40487



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


[PATCH] D40488: [clangd] Implemented tracing using Context

2017-11-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov planned changes to this revision.
ilya-biryukov added inline comments.



Comment at: clangd/JSONRPCDispatcher.h:80
+  // Ctx must be before Tracer!
   Context Ctx;
   JSONOutput &Out;

This is still wrong, `Context` is used by `Tracer` internally and should not be 
moved.


https://reviews.llvm.org/D40488



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


[PATCH] D40485: [clangd] Introduced a Context that stores implicit data

2017-11-27 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer requested changes to this revision.
bkramer added inline comments.
This revision now requires changes to proceed.



Comment at: clangd/Context.h:79
+/// Otherwise returns an empty Context.
+Context &globalCtx();
+

This is a giant code smell. If we want the context route, please pass contexts 
everywhere. I really don't want this kind of technical debt in clangd now.


https://reviews.llvm.org/D40485



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


[libclc] r319017 - configure.py: Add gfx900 (Vega, Raven)

2017-11-27 Thread Vedran Miletic via cfe-commits
Author: vedranm
Date: Mon Nov 27 03:14:06 2017
New Revision: 319017

URL: http://llvm.org/viewvc/llvm-project?rev=319017&view=rev
Log:
configure.py: Add gfx900 (Vega, Raven)

Sort amdgcn-- and amdgcn--amdhsa in a consistent way.

Modified:
libclc/trunk/configure.py

Modified: libclc/trunk/configure.py
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/configure.py?rev=319017&r1=319016&r2=319017&view=diff
==
--- libclc/trunk/configure.py (original)
+++ libclc/trunk/configure.py Mon Nov 27 03:14:06 2017
@@ -100,9 +100,9 @@ available_targets = {
 {'gpu' : 'barts',   'aliases' : ['turks', 'caicos'] },
 {'gpu' : 'cayman',  'aliases' : ['aruba']} ]},
   'amdgcn--': { 'devices' :
-[{'gpu' : 'tahiti', 'aliases' : ['pitcairn', 'verde', 'oland', 
'hainan', 'bonaire', 'kabini', 'kaveri', 
'hawaii','mullins','tonga','carrizo','iceland','fiji','stoney','polaris10','polaris11']}
 ]},
+[{'gpu' : 'tahiti', 'aliases' : ['pitcairn', 'verde', 'oland', 
'hainan', 'bonaire', 'kabini', 'kaveri', 'hawaii', 'mullins', 'tonga', 
'iceland', 'carrizo', 'fiji', 'stoney', 'polaris10', 'polaris11', 'gfx900']} ]},
   'amdgcn--amdhsa': { 'devices' :
-  [{'gpu' : '', 'aliases' : ['bonaire', 'hawaii', 
'kabini', 'kaveri', 'mullins', 'carrizo', 'stoney', 'fiji', 'iceland', 
'tonga','polaris10','polaris11']} ]},
+  [{'gpu' : '', 'aliases' : ['bonaire', 'kabini', 
'kaveri', 'hawaii', 'mullins', 'tonga', 'iceland', 'carrizo', 'fiji', 'stoney', 
'polaris10', 'polaris11', 'gfx900']} ]},
   'nvptx--'   : { 'devices' : [{'gpu' : '', 'aliases' : []} ]},
   'nvptx64--' : { 'devices' : [{'gpu' : '', 'aliases' : []} ]},
   'nvptx--nvidiacl'   : { 'devices' : [{'gpu' : '', 'aliases' : []} ]},


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


r319011 - [OpenCL] Add extensions cl_intel_subgroups and cl_intel_subgroups_short

2017-11-27 Thread via cfe-commits
Author: AlexeySotkin
Date: Mon Nov 27 01:14:17 2017
New Revision: 319011

URL: http://llvm.org/viewvc/llvm-project?rev=319011&view=rev
Log:
[OpenCL] Add extensions cl_intel_subgroups and cl_intel_subgroups_short

Reviewers: yaxunl, Anastasia, bader

Reviewed By: Anastasia, bader

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Basic/OpenCLExtensions.def
cfe/trunk/lib/Headers/opencl-c.h
cfe/trunk/test/SemaOpenCL/extension-version.cl

Modified: cfe/trunk/include/clang/Basic/OpenCLExtensions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenCLExtensions.def?rev=319011&r1=319010&r2=319011&view=diff
==
--- cfe/trunk/include/clang/Basic/OpenCLExtensions.def (original)
+++ cfe/trunk/include/clang/Basic/OpenCLExtensions.def Mon Nov 27 01:14:17 2017
@@ -79,6 +79,10 @@ OPENCLEXT_INTERNAL(cl_clang_storage_clas
 OPENCLEXT_INTERNAL(cl_amd_media_ops, 100, ~0U)
 OPENCLEXT_INTERNAL(cl_amd_media_ops2, 100, ~0U)
 
+// Intel OpenCL extensions
+OPENCLEXT_INTERNAL(cl_intel_subgroups, 120, ~0U)
+OPENCLEXT_INTERNAL(cl_intel_subgroups_short, 120, ~0U)
+
 #undef OPENCLEXT_INTERNAL
 
 #ifdef OPENCLEXT

Modified: cfe/trunk/lib/Headers/opencl-c.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/opencl-c.h?rev=319011&r1=319010&r2=319011&view=diff
==
--- cfe/trunk/lib/Headers/opencl-c.h (original)
+++ cfe/trunk/lib/Headers/opencl-c.h Mon Nov 27 01:14:17 2017
@@ -15886,6 +15886,313 @@ double  __ovld __conv sub_group_scan_inc
 
 #endif //cl_khr_subgroups cl_intel_subgroups
 
+#if defined(cl_intel_subgroups)
+// Intel-Specific Sub Group Functions
+float   __ovld __conv intel_sub_group_shuffle( float  x, uint c );
+float2  __ovld __conv intel_sub_group_shuffle( float2 x, uint c );
+float3  __ovld __conv intel_sub_group_shuffle( float3 x, uint c );
+float4  __ovld __conv intel_sub_group_shuffle( float4 x, uint c );
+float8  __ovld __conv intel_sub_group_shuffle( float8 x, uint c );
+float16 __ovld __conv intel_sub_group_shuffle( float16 x, uint c );
+
+int __ovld __conv intel_sub_group_shuffle( int  x, uint c );
+int2__ovld __conv intel_sub_group_shuffle( int2 x, uint c );
+int3__ovld __conv intel_sub_group_shuffle( int3 x, uint c );
+int4__ovld __conv intel_sub_group_shuffle( int4 x, uint c );
+int8__ovld __conv intel_sub_group_shuffle( int8 x, uint c );
+int16   __ovld __conv intel_sub_group_shuffle( int16 x, uint c );
+
+uint__ovld __conv intel_sub_group_shuffle( uint  x, uint c );
+uint2   __ovld __conv intel_sub_group_shuffle( uint2 x, uint c );
+uint3   __ovld __conv intel_sub_group_shuffle( uint3 x, uint c );
+uint4   __ovld __conv intel_sub_group_shuffle( uint4 x, uint c );
+uint8   __ovld __conv intel_sub_group_shuffle( uint8 x, uint c );
+uint16  __ovld __conv intel_sub_group_shuffle( uint16 x, uint c );
+
+long__ovld __conv intel_sub_group_shuffle( long x, uint c );
+ulong   __ovld __conv intel_sub_group_shuffle( ulong x, uint c );
+
+float   __ovld __conv intel_sub_group_shuffle_down( float  cur, float  next, 
uint c );
+float2  __ovld __conv intel_sub_group_shuffle_down( float2 cur, float2 next, 
uint c );
+float3  __ovld __conv intel_sub_group_shuffle_down( float3 cur, float3 next, 
uint c );
+float4  __ovld __conv intel_sub_group_shuffle_down( float4 cur, float4 next, 
uint c );
+float8  __ovld __conv intel_sub_group_shuffle_down( float8 cur, float8 next, 
uint c );
+float16 __ovld __conv intel_sub_group_shuffle_down( float16 cur, float16 next, 
uint c );
+
+int __ovld __conv intel_sub_group_shuffle_down( int  cur, int  next, uint 
c );
+int2__ovld __conv intel_sub_group_shuffle_down( int2 cur, int2 next, uint 
c );
+int3__ovld __conv intel_sub_group_shuffle_down( int3 cur, int3 next, uint 
c );
+int4__ovld __conv intel_sub_group_shuffle_down( int4 cur, int4 next, uint 
c );
+int8__ovld __conv intel_sub_group_shuffle_down( int8 cur, int8 next, uint 
c );
+int16   __ovld __conv intel_sub_group_shuffle_down( int16 cur, int16 next, 
uint c );
+
+uint__ovld __conv intel_sub_group_shuffle_down( uint  cur, uint  next, 
uint c );
+uint2   __ovld __conv intel_sub_group_shuffle_down( uint2 cur, uint2 next, 
uint c );
+uint3   __ovld __conv intel_sub_group_shuffle_down( uint3 cur, uint3 next, 
uint c );
+uint4   __ovld __conv intel_sub_group_shuffle_down( uint4 cur, uint4 next, 
uint c );
+uint8   __ovld __conv intel_sub_group_shuffle_down( uint8 cur, uint8 next, 
uint c );
+uint16  __ovld __conv intel_sub_group_shuffle_down( uint16 cur, uint16 next, 
uint c );
+
+long__ovld __conv intel_sub_group_shuffle_down( long prev, long cur, uint 
c );
+ulong   __ovld __conv intel_sub_group_shuffle_down( ulong prev, ulong cur, 
uint c );
+
+float   __ovld __conv intel_sub_group_shuffle_up( float  prev, float  cur, 
uin

[clang-tools-extra] r319023 - [clang-tidy] Move checks from misc- to performance-

2017-11-27 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon Nov 27 05:06:28 2017
New Revision: 319023

URL: http://llvm.org/viewvc/llvm-project?rev=319023&view=rev
Log:
[clang-tidy] Move checks from misc- to performance-

Summary:
rename_check.py misc-move-constructor-init performance-move-constructor-init
rename_check.py misc-inefficient-algorithm performance-inefficient-algorithm

Reviewers: hokein, aaron.ballman

Reviewed By: hokein, aaron.ballman

Subscribers: aaron.ballman, mgorny, xazax.hun, cfe-commits

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

Added:
clang-tools-extra/trunk/clang-tidy/performance/InefficientAlgorithmCheck.cpp
  - copied, changed from r319021, 
clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp
clang-tools-extra/trunk/clang-tidy/performance/InefficientAlgorithmCheck.h
  - copied, changed from r319021, 
clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.h
clang-tools-extra/trunk/clang-tidy/performance/MoveConstructorInitCheck.cpp
  - copied, changed from r319021, 
clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp
clang-tools-extra/trunk/clang-tidy/performance/MoveConstructorInitCheck.h
  - copied, changed from r319021, 
clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/performance-inefficient-algorithm.rst
  - copied, changed from r319021, 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-inefficient-algorithm.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/performance-move-constructor-init.rst
  - copied, changed from r319021, 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-constructor-init.rst

clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-algorithm.cpp
  - copied, changed from r319021, 
clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp

clang-tools-extra/trunk/test/clang-tidy/performance-move-constructor-init.cpp
  - copied, changed from r319021, 
clang-tools-extra/trunk/test/clang-tidy/misc-move-constructor-init.cpp
Removed:
clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.h
clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-inefficient-algorithm.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-constructor-init.rst
clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-move-constructor-init.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/performance/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/performance/PerformanceTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-oop11-cpp.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
clang-tools-extra/trunk/test/clang-tidy/cert-oop11-cpp.cpp

Modified: clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp?rev=319023&r1=319022&r2=319023&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp Mon Nov 27 
05:06:28 2017
@@ -11,11 +11,11 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 #include "../google/UnnamedNamespaceInHeaderCheck.h"
-#include "../misc/MoveConstructorInitCheck.h"
 #include "../misc/NewDeleteOverloadsCheck.h"
 #include "../misc/NonCopyableObjects.h"
 #include "../misc/StaticAssertCheck.h"
 #include "../misc/ThrowByValueCatchByReferenceCheck.h"
+#include "../performance/MoveConstructorInitCheck.h"
 #include "CommandProcessorCheck.h"
 #include "DontModifyStdNamespaceCheck.h"
 #include "FloatLoopCounter.h"
@@ -46,7 +46,7 @@ public:
 CheckFactories.registerCheck(
 "cert-dcl59-cpp");
 // OOP
-CheckFactories.registerCheck(
+CheckFactories.registerCheck(
 "cert-oop11-cpp");
 // ERR
 CheckFactories.registerCheck(

Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=319023&r1=319022&r2=319023&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Mon Nov 27 05:06:28 
2017
@@ -7,13 +7,11 @@ add_clang_libr

[PATCH] D40487: [clang-tidy] Move checks from misc- to performance-

2017-11-27 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE319023: [clang-tidy] Move checks from misc- to 
performance- (authored by alexfh).

Changed prior to commit:
  https://reviews.llvm.org/D40487?vs=124356&id=124359#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40487

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/InefficientAlgorithmCheck.cpp
  clang-tidy/misc/InefficientAlgorithmCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/MoveConstructorInitCheck.cpp
  clang-tidy/misc/MoveConstructorInitCheck.h
  clang-tidy/performance/CMakeLists.txt
  clang-tidy/performance/InefficientAlgorithmCheck.cpp
  clang-tidy/performance/InefficientAlgorithmCheck.h
  clang-tidy/performance/MoveConstructorInitCheck.cpp
  clang-tidy/performance/MoveConstructorInitCheck.h
  clang-tidy/performance/PerformanceTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cert-oop11-cpp.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-inefficient-algorithm.rst
  docs/clang-tidy/checks/misc-move-constructor-init.rst
  docs/clang-tidy/checks/performance-inefficient-algorithm.rst
  docs/clang-tidy/checks/performance-move-constructor-init.rst
  test/clang-tidy/cert-oop11-cpp.cpp
  test/clang-tidy/misc-inefficient-algorithm.cpp
  test/clang-tidy/misc-move-constructor-init.cpp
  test/clang-tidy/performance-inefficient-algorithm.cpp
  test/clang-tidy/performance-move-constructor-init.cpp

Index: clang-tidy/performance/MoveConstructorInitCheck.h
===
--- clang-tidy/performance/MoveConstructorInitCheck.h
+++ clang-tidy/performance/MoveConstructorInitCheck.h
@@ -0,0 +1,44 @@
+//===--- MoveConstructorInitCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_MOVECONSTRUCTORINITCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_MOVECONSTRUCTORINITCHECK_H
+
+#include "../ClangTidy.h"
+#include "../utils/IncludeInserter.h"
+
+#include 
+
+namespace clang {
+namespace tidy {
+namespace performance {
+
+/// The check flags user-defined move constructors that have a ctor-initializer
+/// initializing a member or base class through a copy constructor instead of a
+/// move constructor.
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/performance-move-constructor-init.html
+class MoveConstructorInitCheck : public ClangTidyCheck {
+public:
+  MoveConstructorInitCheck(StringRef Name, ClangTidyContext *Context);
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void registerPPCallbacks(clang::CompilerInstance &Compiler) override;
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+
+private:
+  std::unique_ptr Inserter;
+  const utils::IncludeSorter::IncludeStyle IncludeStyle;
+};
+
+} // namespace performance
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_MOVECONSTRUCTORINITCHECK_H
Index: clang-tidy/performance/PerformanceTidyModule.cpp
===
--- clang-tidy/performance/PerformanceTidyModule.cpp
+++ clang-tidy/performance/PerformanceTidyModule.cpp
@@ -13,8 +13,10 @@
 #include "FasterStringFindCheck.h"
 #include "ForRangeCopyCheck.h"
 #include "ImplicitConversionInLoopCheck.h"
+#include "InefficientAlgorithmCheck.h"
 #include "InefficientStringConcatenationCheck.h"
 #include "InefficientVectorOperationCheck.h"
+#include "MoveConstructorInitCheck.h"
 #include "TypePromotionInMathFnCheck.h"
 #include "UnnecessaryCopyInitialization.h"
 #include "UnnecessaryValueParamCheck.h"
@@ -32,10 +34,14 @@
 "performance-for-range-copy");
 CheckFactories.registerCheck(
 "performance-implicit-conversion-in-loop");
+CheckFactories.registerCheck(
+"performance-inefficient-algorithm");
 CheckFactories.registerCheck(
 "performance-inefficient-string-concatenation");
 CheckFactories.registerCheck(
 "performance-inefficient-vector-operation");
+CheckFactories.registerCheck(
+"performance-move-constructor-init");
 CheckFactories.registerCheck(
 "performance-type-promotion-in-math-fn");
 CheckFactories.registerCheck(
Index: clang-tidy/performance/MoveConstructorInitCheck.cpp
===
--- clang-tidy/performance/MoveConstructorInitCheck.cpp
+++ clang-tidy/performance/MoveConstructorInitCheck.cpp
@@ -0,0 +1,110 @@
+//===--- MoveConst

[PATCH] D40485: [clangd] Introduced a Context that stores implicit data

2017-11-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/Context.h:79
+/// Otherwise returns an empty Context.
+Context &globalCtx();
+

bkramer wrote:
> This is a giant code smell. If we want the context route, please pass 
> contexts everywhere. I really don't want this kind of technical debt in 
> clangd now.
I'm with you on this one, but I think @sammccall was keen on having the global 
context. The main reason was to always have access to **some** loggers and 
tracers, even when it's hard to pass the Context into the function.
It's perfectly easy to remove all usages of `globalCtx()`, currently only 8 
usages to get rid of. However, I'd wait for Sam's comment before doing that.


https://reviews.llvm.org/D40485



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


r319024 - [clang-format] Add option to group multiple #include blocks when sorting includes

2017-11-27 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Mon Nov 27 05:23:45 2017
New Revision: 319024

URL: http://llvm.org/viewvc/llvm-project?rev=319024&view=rev
Log:
[clang-format] Add option to group multiple #include blocks when sorting 
includes

Summary:
This patch allows grouping multiple #include blocks together and sort all 
includes as one big block.
Additionally, sorted includes can be regrouped after sorting based on 
configured categories.

Contributed by @KrzysztofKapusta!

Reviewers: krasimir

Reviewed By: krasimir

Subscribers: cfe-commits, klimek

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

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/SortIncludesTest.cpp

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=319024&r1=319023&r2=319024&view=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Mon Nov 27 05:23:45 2017
@@ -1173,6 +1173,45 @@ the configuration (without a prefix: ``A
 
   For example: BOOST_FOREACH.
 
+**IncludeBlocks** (``IncludeBlocksStyle``)
+  Dependent on the value, multiple ``#include`` blocks can be sorted
+  as one and divided based on category.
+
+  Possible values:
+
+  * ``IBS_Preserve`` (in configuration: ``Preserve``)
+Sort each ``#include`` block separately.
+
+.. code-block:: c++
+
+   #include "b.h"   into  #include "b.h"
+
+   #include   #include "a.h"
+   #include "a.h" #include 
+
+  * ``IBS_Merge`` (in configuration: ``Merge``)
+Merge multiple ``#include`` blocks together and sort as one.
+
+.. code-block:: c++
+
+   #include "b.h"   into  #include "a.h"
+  #include "b.h"
+   #include   #include 
+   #include "a.h"
+
+  * ``IBS_Regroup`` (in configuration: ``Regroup``)
+Merge multiple ``#include`` blocks together and sort as one.
+Then split into groups based on category priority. See 
``IncludeCategories``.
+
+.. code-block:: c++
+
+   #include "b.h"   into  #include "a.h"
+  #include "b.h"
+   #include 
+   #include "a.h" #include 
+
+
+
 **IncludeCategories** (``std::vector``)
   Regular expressions denoting the different ``#include`` categories
   used for ordering ``#includes``.

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=319024&r1=319023&r2=319024&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Mon Nov 27 05:23:45 2017
@@ -985,6 +985,40 @@ struct FormatStyle {
   /// For example: BOOST_FOREACH.
   std::vector ForEachMacros;
 
+  /// \brief Styles for sorting multiple ``#include`` blocks.
+  enum IncludeBlocksStyle {
+/// \brief Sort each ``#include`` block separately.
+/// \code
+///#include "b.h"   into  #include "b.h"
+///
+///#include   #include "a.h"
+///#include "a.h" #include 
+/// \endcode
+IBS_Preserve,
+/// \brief Merge multiple ``#include`` blocks together and sort as one.
+/// \code
+///#include "b.h"   into  #include "a.h"
+///   #include "b.h"
+///#include   #include 
+///#include "a.h"
+/// \endcode
+IBS_Merge,
+/// \brief Merge multiple ``#include`` blocks together and sort as one.
+/// Then split into groups based on category priority. See
+/// ``IncludeCategories``.
+/// \code
+///#include "b.h"   into  #include "a.h"
+///   #include "b.h"
+///#include 
+///#include "a.h" #include 
+/// \endcode
+IBS_Regroup,
+  };
+
+  /// \brief Dependent on the value, multiple ``#include`` blocks can be sorted
+  /// as one and divided based on category.
+  IncludeBlocksStyle IncludeBlocks;
+
   /// \brief See documentation of ``IncludeCategories``.
   struct IncludeCategory {
 /// \brief The regular expression that this category matches.
@@ -1609,6 +1643,7 @@ struct FormatStyle {
R.ExperimentalAutoDetectBinPacking &&
FixNamespaceComments == R.FixNamespaceComments &&
ForEachMacros == R.ForEachMacros &&
+   IncludeBlocks == R.IncludeBlocks &&
IncludeCategories == R.IncludeCategories &&
IndentCaseLabels == R.In

[PATCH] D40288: [clang-format] Add option to group multiple #include blocks when sorting includes

2017-11-27 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319024: [clang-format] Add option to group multiple #include 
blocks when sorting… (authored by krasimir).

Changed prior to commit:
  https://reviews.llvm.org/D40288?vs=123924&id=124361#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40288

Files:
  cfe/trunk/docs/ClangFormatStyleOptions.rst
  cfe/trunk/include/clang/Format/Format.h
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/unittests/Format/SortIncludesTest.cpp

Index: cfe/trunk/unittests/Format/SortIncludesTest.cpp
===
--- cfe/trunk/unittests/Format/SortIncludesTest.cpp
+++ cfe/trunk/unittests/Format/SortIncludesTest.cpp
@@ -77,6 +77,28 @@
   EXPECT_TRUE(sortIncludes(Style, Code, GetCodeRange(Code), "a.cc").empty());
 }
 
+TEST_F(SortIncludesTest, SortedIncludesInMultipleBlocksAreMerged) {
+  Style.IncludeBlocks = FormatStyle::IBS_Merge;
+  EXPECT_EQ("#include \"a.h\"\n"
+"#include \"b.h\"\n"
+"#include \"c.h\"\n",
+sort("#include \"a.h\"\n"
+ "#include \"c.h\"\n"
+ "\n"
+ "\n"
+ "#include \"b.h\"\n"));
+
+  Style.IncludeBlocks = FormatStyle::IBS_Regroup;
+  EXPECT_EQ("#include \"a.h\"\n"
+"#include \"b.h\"\n"
+"#include \"c.h\"\n",
+sort("#include \"a.h\"\n"
+ "#include \"c.h\"\n"
+ "\n"
+ "\n"
+ "#include \"b.h\"\n"));
+}
+
 TEST_F(SortIncludesTest, SupportClangFormatOff) {
   EXPECT_EQ("#include \n"
 "#include \n"
@@ -159,6 +181,48 @@
  "#include \"b.h\"\n"));
 }
 
+TEST_F(SortIncludesTest, SortsAllBlocksWhenMerging) {
+  Style.IncludeBlocks = FormatStyle::IBS_Merge;
+  EXPECT_EQ("#include \"a.h\"\n"
+"#include \"b.h\"\n"
+"#include \"c.h\"\n",
+sort("#include \"a.h\"\n"
+ "#include \"c.h\"\n"
+ "\n"
+ "#include \"b.h\"\n"));
+}
+
+TEST_F(SortIncludesTest, CommentsAlwaysSeparateGroups) {
+  EXPECT_EQ("#include \"a.h\"\n"
+"#include \"c.h\"\n"
+"// comment\n"
+"#include \"b.h\"\n",
+sort("#include \"c.h\"\n"
+ "#include \"a.h\"\n"
+ "// comment\n"
+ "#include \"b.h\"\n"));
+
+  Style.IncludeBlocks = FormatStyle::IBS_Merge;
+  EXPECT_EQ("#include \"a.h\"\n"
+"#include \"c.h\"\n"
+"// comment\n"
+"#include \"b.h\"\n",
+sort("#include \"c.h\"\n"
+ "#include \"a.h\"\n"
+ "// comment\n"
+ "#include \"b.h\"\n"));
+
+  Style.IncludeBlocks = FormatStyle::IBS_Regroup;
+  EXPECT_EQ("#include \"a.h\"\n"
+"#include \"c.h\"\n"
+"// comment\n"
+"#include \"b.h\"\n",
+sort("#include \"c.h\"\n"
+ "#include \"a.h\"\n"
+ "// comment\n"
+ "#include \"b.h\"\n"));
+}
+
 TEST_F(SortIncludesTest, HandlesAngledIncludesAsSeparateBlocks) {
   EXPECT_EQ("#include \"a.h\"\n"
 "#include \"c.h\"\n"
@@ -180,6 +244,19 @@
  "#include \"a.h\"\n"));
 }
 
+TEST_F(SortIncludesTest, RegroupsAngledIncludesInSeparateBlocks) {
+  Style.IncludeBlocks = FormatStyle::IBS_Regroup;
+  EXPECT_EQ("#include \"a.h\"\n"
+"#include \"c.h\"\n"
+"\n"
+"#include \n"
+"#include \n",
+sort("#include \n"
+ "#include \n"
+ "#include \"c.h\"\n"
+ "#include \"a.h\"\n"));
+}
+
 TEST_F(SortIncludesTest, HandlesMultilineIncludes) {
   EXPECT_EQ("#include \"a.h\"\n"
 "#include \"b.h\"\n"
@@ -266,6 +343,35 @@
  "a.cc"));
 }
 
+TEST_F(SortIncludesTest, RecognizeMainHeaderInAllGroups) {
+  Style.IncludeIsMainRegex = "([-_](test|unittest))?$";
+  Style.IncludeBlocks = FormatStyle::IBS_Merge;
+
+  EXPECT_EQ("#include \"c.h\"\n"
+"#include \"a.h\"\n"
+"#include \"b.h\"\n",
+sort("#include \"b.h\"\n"
+ "\n"
+ "#include \"a.h\"\n"
+ "#include \"c.h\"\n",
+ "c.cc"));
+}
+
+TEST_F(SortIncludesTest, MainHeaderIsSeparatedWhenRegroupping) {
+  Style.IncludeIsMainRegex = "([-_](test|unittest))?$";
+  Style.IncludeBlocks = FormatStyle::IBS_Regroup;
+
+  EXPECT_EQ("#include \"a.h\"\n"
+"\n"
+"#include \"b.h\"\n"
+"#include \"c.h\"\n",
+sort("#include \"b.h\"\n"
+ "\n"
+ "#include \"a.h\"\n"
+ "#include \"c.h\"\n",
+ "a.cc"));
+}
+
 TEST_F(SortIncludesTest, SupportCaseInsensitiveMatching) {
   // Setup an regex for main includes so we can cover those as well.
   Style.IncludeIsMainRegex = "([-_](test|unittest))?

[PATCH] D40489: [clangd] Changed tracing interfaces

2017-11-27 Thread Pavel Sychev via Phabricator via cfe-commits
luckygeck added inline comments.



Comment at: clangd/Trace.h:41
+  /// Context.
   static PtrKey CtxKey;
 

This is a (1)static non-pod member in an (2) interface. Is it really a good 
idea? If we plan to have only one ctxkey, then maybe let's make it not bound to 
EventTracer?



Comment at: clangd/Trace.h:45
+
+  /// Called when event with \p Name stars.
+  virtual void begin_event(Context &Ctx, llvm::StringRef Name) = 0;

s/stars/starts.



Comment at: clangd/Trace.h:49
+  virtual void end_event(Context &Ctx, llvm::StringRef Name,
+ json::obj &&Args) = 0;
+  /// Called for instant events.

Maybe it is better to calculate these Args only if the tracing is enabled? This 
might be done at least this two ways:
1) Have `bool is_tracing_enabled()` method that we can check before calculating 
args.
2) Pass a function that will produce json::obj when called.


https://reviews.llvm.org/D40489



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


[PATCH] D39640: [lit] Set shlibpath_var on Solaris

2017-11-27 Thread Fedor Sergeev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319026: [lit] Set shlibpath_var on Solaris (authored by 
fedor.sergeev).

Changed prior to commit:
  https://reviews.llvm.org/D39640?vs=121626&id=124363#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39640

Files:
  cfe/trunk/test/Unit/lit.cfg.py


Index: cfe/trunk/test/Unit/lit.cfg.py
===
--- cfe/trunk/test/Unit/lit.cfg.py
+++ cfe/trunk/test/Unit/lit.cfg.py
@@ -36,7 +36,7 @@
 config.environment[symbolizer] = os.environ[symbolizer]
 
 def find_shlibpath_var():
-if platform.system() in ['Linux', 'FreeBSD', 'NetBSD']:
+if platform.system() in ['Linux', 'FreeBSD', 'NetBSD', 'SunOS']:
 yield 'LD_LIBRARY_PATH'
 elif platform.system() == 'Darwin':
 yield 'DYLD_LIBRARY_PATH'


Index: cfe/trunk/test/Unit/lit.cfg.py
===
--- cfe/trunk/test/Unit/lit.cfg.py
+++ cfe/trunk/test/Unit/lit.cfg.py
@@ -36,7 +36,7 @@
 config.environment[symbolizer] = os.environ[symbolizer]
 
 def find_shlibpath_var():
-if platform.system() in ['Linux', 'FreeBSD', 'NetBSD']:
+if platform.system() in ['Linux', 'FreeBSD', 'NetBSD', 'SunOS']:
 yield 'LD_LIBRARY_PATH'
 elif platform.system() == 'Darwin':
 yield 'DYLD_LIBRARY_PATH'
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r319026 - [lit] Set shlibpath_var on Solaris

2017-11-27 Thread Fedor Sergeev via cfe-commits
Author: fedor.sergeev
Date: Mon Nov 27 05:33:19 2017
New Revision: 319026

URL: http://llvm.org/viewvc/llvm-project?rev=319026&view=rev
Log:
[lit] Set shlibpath_var on Solaris

Summary:
During make check-all on Solaris, lit complains

llvm-lit: /vol/gcc/src/llvm/llvm/dist/tools/clang/test/Unit/lit.cfg.py:57: 
warning: unable to inject shared library path on 'SunOS'

The following patch avoids this: Solaris uses LD_LIBRARY_PATH like several 
other targets.

In theory, one could also handle LD_LIBRARY_PATH_{32,64} which take precedence 
over
LD_LIBRARY_PATH if set, but let's cross that bridge when we get there.

Patch by Rainer Orth.

Reviewers: rsmith, lichray
Reviewed By: lichray

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

Modified:
cfe/trunk/test/Unit/lit.cfg.py

Modified: cfe/trunk/test/Unit/lit.cfg.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Unit/lit.cfg.py?rev=319026&r1=319025&r2=319026&view=diff
==
--- cfe/trunk/test/Unit/lit.cfg.py (original)
+++ cfe/trunk/test/Unit/lit.cfg.py Mon Nov 27 05:33:19 2017
@@ -36,7 +36,7 @@ for symbolizer in ['ASAN_SYMBOLIZER_PATH
 config.environment[symbolizer] = os.environ[symbolizer]
 
 def find_shlibpath_var():
-if platform.system() in ['Linux', 'FreeBSD', 'NetBSD']:
+if platform.system() in ['Linux', 'FreeBSD', 'NetBSD', 'SunOS']:
 yield 'LD_LIBRARY_PATH'
 elif platform.system() == 'Darwin':
 yield 'DYLD_LIBRARY_PATH'


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


[PATCH] D39857: [AMDGPU] Late parsed / dependent arguments for AMDGPU kernel attributes

2017-11-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added a comment.
This revision now requires changes to proceed.

Please add test cases for this new functionality.




Comment at: lib/CodeGen/TargetInfo.cpp:7665
+static llvm::APSInt getConstexprInt(const Expr *E, const ASTContext& Ctx) {
+  assert(E);
+

You should add a message to your assertion in case it is triggered. e.g., 
`assert(E && "attempting to get a constexpr int out of a null Expr");` or 
something along those lines.



Comment at: lib/CodeGen/TargetInfo.cpp:7665
+static llvm::APSInt getConstexprInt(const Expr *E, const ASTContext& Ctx)
+{
+  assert(E);

aaron.ballman wrote:
> The curly brace should bind to the end of the function parameter list. I'd 
> just run the whole patch through clang-format and then fix up anything that 
> goes wrong in the .td files.
This is still a bit off -- the `&` should bind to `Ctx`.



Comment at: lib/CodeGen/TargetInfo.cpp:7669
+  llvm::APSInt Tmp{32, 0};
+  E->EvaluateAsInt(Tmp, Ctx);
+

aaron.ballman wrote:
> Are you expecting this to always succeed, or are you relying on the 
> initialized value in the case where this fails?
This question still applies.



Comment at: lib/Sema/SemaDeclAttr.cpp:5473
+static bool checkAllAreIntegral(Sema &S, const AttributeList &Attr) {
+  for (auto i = 0u; i != Attr.getNumArgs(); ++i) {
+Expr* E = Attr.getArgAsExpr(i);

aaron.ballman wrote:
> Don't use `auto` here either, just use `unsigned`. Also `i` doesn't match our 
> coding standard.
Only partially fixed; the naming convention is still not being followed.


https://reviews.llvm.org/D39857



___
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-11-27 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle requested changes to this revision.
malaperle added a comment.
This revision now requires changes to proceed.

There were some things I missed, sorry about that!




Comment at: clangd/main.cpp:1
+#define MACRO 1
+namespace ns1 {

This files needs to be removed



Comment at: test/clangd/documenthighlight.test:10
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"#define
 MACRO 1\nnamespace ns1 {\nstruct MyClass {\nint xasd;\nvoid anotherOperation() 
{\n}\nstatic int foo(MyClass*) {\nreturn 0;\n}\n\n};\nstruct Foo {\nint 
xasd;\n};\n}\nint main() {\nint bonjour;\nbonjour = 2;\nns1::Foo bar = { xasd : 
1};\nbar.xasd = 3;\nns1::MyClass* Params;\nParams->anotherOperation();}\n"}}}
+

I think we should cover "kind":2 as well. It's probably not a big change.



Comment at: test/clangd/documenthighlight.test:15
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":17,"character":2}}}
+# Go to local variable
+# CHECK: 
{"id":1,"jsonrpc":"2.0","result":[{"kind":1,"range":{"end":{"character":12,"line":16},"start":{"character":4,"line":16}}},{"kind":3,"range":{"end":{"character":7,"line":17},"start":{"character":0,"line":17}}}]}

This comment should be updated, it was copy/pasted probably?



Comment at: test/clangd/documenthighlight.test:22
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":18,"character":17}}}
+# Go to local variable
+# CHECK: 
{"id":1,"jsonrpc":"2.0","result":[{"kind":1,"range":{"end":{"character":9,"line":12},"start":{"character":4,"line":12}}},{"kind":1,"range":{"end":{"character":21,"line":18},"start":{"character":17,"line":18}}},{"kind":3,"range":{"end":{"character":8,"line":19},"start":{"character":4,"line":19}}}]}

This comment should be updated, it was copy/pasted probably?



Comment at: test/clangd/documenthighlight.test:29
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":21,"character":10}}}
+# Go to local variable
+# CHECK: 
{"id":1,"jsonrpc":"2.0","result":[{"kind":1,"range":{"end":{"character":22,"line":4},"start":{"character":5,"line":4}}},{"kind":1,"range":{"end":{"character":25,"line":21},"start":{"character":8,"line":21}}}]}

This comment should be updated, it was copy/pasted probably?


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] D40230: Add -mprefer-vector-width driver option and attribute during CodeGen.

2017-11-27 Thread Sanjay Patel via Phabricator via cfe-commits
spatel accepted this revision.
spatel added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D40230



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


[PATCH] D40450: [clangd] Refactoring of GlobalCompilationDatabase

2017-11-27 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

@Nebiroth , Will this be compatible with your patch to change 
CompilationDatabase at runtime? https://reviews.llvm.org/D39571


https://reviews.llvm.org/D40450



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


[PATCH] D40453: Add the nvidia-cuda-toolkit Debian package path to search path

2017-11-27 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added reviewers: tra, jlebar.
Hahnfeld added a comment.

The change looks good in general and is small enough and last in the candidates 
list to not break working setups.

What concerns me is that we have to do the same for every distribution (I know 
that Arch Linux for example has CUDA installed in `/opt/cuda`, see 
https://www.archlinux.org/packages/community/x86_64/cuda/). In addition many 
HPC systems use the modules system to install multiple versions in parallel. As 
such we should make the installation detection smarter:

1. We could have an environment variable that systems can set to the 
appropriate directory.
2. We could try to automatically deduce the install path: If we find `ptxas` in 
the `PATH` and it is in a directory `bin`, its parent is a good candidate to 
start searching.

I think 2. would work for Arch Linux which adds `/opt/cuda/bin` to `PATH` IIRC. 
I'm not sure about Debian though, @sylvestre.ledru? If that doesn't work, we 
have to add the candidate statically anyway...


https://reviews.llvm.org/D40453



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


[PATCH] D40489: [clangd] Changed tracing interfaces

2017-11-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 124371.
ilya-biryukov added a comment.

- Fixed a typo.


https://reviews.llvm.org/D40489

Files:
  clangd/Trace.cpp
  clangd/Trace.h

Index: clangd/Trace.h
===
--- clangd/Trace.h
+++ clangd/Trace.h
@@ -27,12 +27,29 @@
 namespace clangd {
 namespace trace {
 
+/// A sink for consuming tracing events. Calls to begin_event and end_event with
+/// the same name are always properly nested by using a RAII object (Span).
+/// However, global tracers (i.e., returned from the global Context object) may
+/// be called concurrently and have to be properly synchronized. For per-request
+/// EventTracers (i.e., returned from the request-specific Context objects) the
+/// calls to begin_event and end_event must be properly synchronized and must
+/// never be called concurrently.
 class EventTracer {
 public:
+  /// A key used by trace::Span and trace::log to find EventTracer in a \p
+  /// Context.
   static PtrKey CtxKey;
 
   virtual ~EventTracer() = default;
-  virtual void event(llvm::StringRef Phase, json::obj &&Contents) = 0;
+
+  /// Called when event with \p Name starts.
+  virtual void begin_event(Context &Ctx, llvm::StringRef Name) = 0;
+  /// Called when event with \p Name ends.
+  virtual void end_event(Context &Ctx, llvm::StringRef Name,
+ json::obj &&Args) = 0;
+  /// Called for instant events.
+  virtual void instant_event(Context &Ctx, llvm::StringRef Name,
+ json::obj &&Args) = 0;
 };
 
 /// Create an instance of EventTracer that produces an output in the Trace Event
@@ -66,6 +83,7 @@
 
 private:
   Context &Ctx;
+  std::string Name;
   std::unique_ptr Args;
 };
 
Index: clangd/Trace.cpp
===
--- clangd/Trace.cpp
+++ clangd/Trace.cpp
@@ -45,9 +45,23 @@
 Out.flush();
   }
 
+  void begin_event(Context &Ctx, llvm::StringRef Name) override {
+jsonEvent("B", json::obj{{"name", Name}});
+  }
+
+  void end_event(Context &Ctx, llvm::StringRef Name,
+ json::obj &&Args) override {
+jsonEvent("E", json::obj{{"name", Name}, {"args", std::move(Args)}});
+  }
+
+  void instant_event(Context &Ctx, llvm::StringRef Name,
+ json::obj &&Args) override {
+jsonEvent("i", json::obj{{"name", Name}, {"args", std::move(Args)}});
+  }
+
   // Record an event on the current thread. ph, pid, tid, ts are set.
   // Contents must be a list of the other JSON key/values.
-  void event(StringRef Phase, json::obj &&Contents) override {
+  void jsonEvent(StringRef Phase, json::obj &&Contents) {
 uint64_t TID = get_threadid();
 std::lock_guard Lock(Mu);
 // If we haven't already, emit metadata describing this thread.
@@ -103,27 +117,23 @@
   EventTracer *T = Ctx.get(EventTracer::CtxKey);
   if (!T)
 return;
-  T->event("i", json::obj{
-{"name", "Log"},
-{"args", json::obj{{"Message", Message.str()}}},
-});
+  T->instant_event("Log", json::obj{{"Message", Message.str()}});
 }
 
-Span::Span(Context &Ctx, std::string Name) : Ctx(Ctx) {
-  EventTracer* T = Ctx.get(EventTracer::CtxKey);
+Span::Span(Context &Ctx, std::string Name) : Ctx(Ctx), Name(std::move(Name)) {
+  EventTracer *T = Ctx.get(EventTracer::CtxKey);
   if (!T)
 return;
-  T->event("B", json::obj{{"name", std::move(Name)}});
+  T->begin_event(this->Name);
   Args = llvm::make_unique();
 }
 
 Span::~Span() {
   auto T = Ctx.get(EventTracer::CtxKey);
   if (!T)
 return;
-  if (!Args)
-Args = llvm::make_unique();
-  T->event("E", Args ? json::obj{{"args", std::move(*Args)}} : json::obj{});
+  assert(Args && "Args can't be null at this point");
+  T->end_event(Name, std::move(*Args));
 }
 
 } // namespace trace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40489: [clangd] Changed tracing interfaces

2017-11-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov marked an inline comment as done.
ilya-biryukov added inline comments.



Comment at: clangd/Trace.h:41
+  /// Context.
   static PtrKey CtxKey;
 

luckygeck wrote:
> This is a (1)static non-pod member in an (2) interface. Is it really a good 
> idea? If we plan to have only one ctxkey, then maybe let's make it not bound 
> to EventTracer?
It does not have any data members, has trivial default constructor and trivial 
destructor.
I don't think there are any problems we're gonna hit with this one, or am I 
missing something?

> then maybe let's make it not bound to EventTracer?
Do you propose to move it out of the `class` into the `clangd::trace` namespace 
instead?



Comment at: clangd/Trace.h:49
+  virtual void end_event(Context &Ctx, llvm::StringRef Name,
+ json::obj &&Args) = 0;
+  /// Called for instant events.

luckygeck wrote:
> Maybe it is better to calculate these Args only if the tracing is enabled? 
> This might be done at least this two ways:
> 1) Have `bool is_tracing_enabled()` method that we can check before 
> calculating args.
> 2) Pass a function that will produce json::obj when called.
The current implementation won't compute args if `EventTracer` inside a 
`Context` is null, so I think this should cover our needs for per-request 
tracing (see `SPAN_ATTACH` macro).
But `is_tracing_enabled()` makes sense if we'd like to turn the tracing off in 
a middle of a single `Context` lifetime. This would make sense for global 
tracer, is this the use-case you anticipate?



https://reviews.llvm.org/D40489



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


[clang-tools-extra] r319033 - [clang-tidy] Misc redundant expressions check updated for overloaded operators

2017-11-27 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Mon Nov 27 07:05:24 2017
New Revision: 319033

URL: http://llvm.org/viewvc/llvm-project?rev=319033&view=rev
Log:
[clang-tidy] Misc redundant expressions check updated for overloaded operators

Patch by: Lilla Barancsuk

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

Modified:
clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp?rev=319033&r1=319032&r2=319033&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp Mon 
Nov 27 07:05:24 2017
@@ -98,6 +98,9 @@ static bool areEquivalentExpr(const Expr
   case Stmt::StringLiteralClass:
 return cast(Left)->getBytes() ==
cast(Right)->getBytes();
+  case Stmt::CXXOperatorCallExprClass:
+return cast(Left)->getOperator() ==
+   cast(Right)->getOperator();
   case Stmt::DependentScopeDeclRefExprClass:
 if (cast(Left)->getDeclName() !=
 cast(Right)->getDeclName())
@@ -410,6 +413,7 @@ matchRelationalIntegerConstantExpr(Strin
   std::string CastId = (Id + "-cast").str();
   std::string SwapId = (Id + "-swap").str();
   std::string NegateId = (Id + "-negate").str();
+  std::string OverloadId = (Id + "-overload").str();
 
   const auto RelationalExpr = ignoringParenImpCasts(binaryOperator(
   isComparisonOperator(), expr().bind(Id),
@@ -437,12 +441,54 @@ matchRelationalIntegerConstantExpr(Strin
 hasOperatorName("!"),
 hasUnaryOperand(anyOf(CastExpr, RelationalExpr);
 
+  const auto OverloadedOperatorExpr =
+  cxxOperatorCallExpr(
+  anyOf(hasOverloadedOperatorName("=="),
+hasOverloadedOperatorName("!="), 
hasOverloadedOperatorName("<"),
+hasOverloadedOperatorName("<="), 
hasOverloadedOperatorName(">"),
+hasOverloadedOperatorName(">=")),
+  // Filter noisy false positives.
+  unless(isMacro()), unless(isInTemplateInstantiation()))
+  .bind(OverloadId);
+
   return anyOf(RelationalExpr, CastExpr, NegateRelationalExpr,
-   NegateNegateRelationalExpr);
+   NegateNegateRelationalExpr, OverloadedOperatorExpr);
 }
 
-// Retrieves sub-expressions matched by 'matchRelationalIntegerConstantExpr' 
with
-// name 'Id'.
+// Checks whether a function param is non constant reference type, and may
+// be modified in the function.
+static bool isNonConstReferenceType(QualType ParamType) {
+  return ParamType->isReferenceType() &&
+ !ParamType.getNonReferenceType().isConstQualified();
+}
+
+// Checks whether the arguments of an overloaded operator can be modified in 
the
+// function.
+// For operators that take an instance and a constant as arguments, only the
+// first argument (the instance) needs to be checked, since the constant itself
+// is a temporary expression. Whether the second parameter is checked is
+// controlled by the parameter `ParamsToCheckCount`.
+static bool
+canOverloadedOperatorArgsBeModified(const FunctionDecl *OperatorDecl,
+bool checkSecondParam) {
+  unsigned ParamCount = OperatorDecl->getNumParams();
+
+  // Overloaded operators declared inside a class have only one param.
+  // These functions must be declared const in order to not be able to modify
+  // the instance of the class they are called through.
+  if (ParamCount == 1 &&
+  !OperatorDecl->getType()->getAs()->isConst())
+return true;
+
+  if (isNonConstReferenceType(OperatorDecl->getParamDecl(0)->getType()))
+return true;
+
+  return checkSecondParam && ParamCount == 2 &&
+ isNonConstReferenceType(OperatorDecl->getParamDecl(1)->getType());
+}
+
+// Retrieves sub-expressions matched by 'matchRelationalIntegerConstantExpr'
+// with name 'Id'.
 static bool retrieveRelationalIntegerConstantExpr(
 const MatchFinder::MatchResult &Result, StringRef Id,
 const Expr *&OperandExpr, BinaryOperatorKind &Opcode, const Expr *&Symbol,
@@ -450,6 +496,7 @@ static bool retrieveRelationalIntegerCon
   std::string CastId = (Id + "-cast").str();
   std::string SwapId = (Id + "-swap").str();
   std::string NegateId = (Id + "-negate").str();
+  std::string OverloadId = (Id + "-overload").str();
 
   if (const auto *Bin = Result.Nodes.getNodeAs(Id)) {
 // Operand received with explicit comparator.
@@ -458,12 +505,29 @@ static bool retrieveRelationalIntegerCon
 
 if (!retrieveIntegerConstantExpr(Result, Id, Value, ConstExpr))
   return false;
-
   } else if (const auto *Cast = Result.Nodes.getNodeAs(CastId)) {
 // Operand received with implicit co

[clang-tools-extra] r319034 - [clang-tidy] Fix link error in clang-tidy after the recent check renames.

2017-11-27 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon Nov 27 07:17:13 2017
New Revision: 319034

URL: http://llvm.org/viewvc/llvm-project?rev=319034&view=rev
Log:
[clang-tidy] Fix link error in clang-tidy after the recent check renames.

Modified:
clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt

Modified: clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt?rev=319034&r1=319033&r2=319034&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt Mon Nov 27 07:17:13 
2017
@@ -22,5 +22,6 @@ add_clang_library(clangTidyCERTModule
   clangTidy
   clangTidyGoogleModule
   clangTidyMiscModule
+  clangTidyPerformanceModule
   clangTidyUtils
   )


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


[PATCH] D39800: [analyzer] pr34404: Fix a crash on pointers to members in nested anonymous structures.

2017-11-27 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Is anything holding this patch?


https://reviews.llvm.org/D39800



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


[PATCH] D39803: [analyzer] pr34766: Fix a crash on explicit construction of std::initializer_list.

2017-11-27 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Is anything holding this patch?


https://reviews.llvm.org/D39803



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


r319037 - Constify. NFC.

2017-11-27 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Mon Nov 27 07:32:00 2017
New Revision: 319037

URL: http://llvm.org/viewvc/llvm-project?rev=319037&view=rev
Log:
Constify. NFC.

Modified:
cfe/trunk/include/clang/Sema/Sema.h

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=319037&r1=319036&r2=319037&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Nov 27 07:32:00 2017
@@ -1555,7 +1555,7 @@ public:
   /// visible at the specified location.
   void makeMergedDefinitionVisible(NamedDecl *ND);
 
-  bool isModuleVisible(Module *M) { return VisibleModules.isVisible(M); }
+  bool isModuleVisible(const Module *M) { return VisibleModules.isVisible(M); }
 
   /// Determine whether a declaration is visible to name lookup.
   bool isVisible(const NamedDecl *D) {


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


[PATCH] D40489: [clangd] Changed tracing interfaces

2017-11-27 Thread Pavel Sychev via Phabricator via cfe-commits
luckygeck added inline comments.



Comment at: clangd/Trace.h:41
+  /// Context.
   static PtrKey CtxKey;
 

ilya-biryukov wrote:
> luckygeck wrote:
> > This is a (1)static non-pod member in an (2) interface. Is it really a good 
> > idea? If we plan to have only one ctxkey, then maybe let's make it not 
> > bound to EventTracer?
> It does not have any data members, has trivial default constructor and 
> trivial destructor.
> I don't think there are any problems we're gonna hit with this one, or am I 
> missing something?
> 
> > then maybe let's make it not bound to EventTracer?
> Do you propose to move it out of the `class` into the `clangd::trace` 
> namespace instead?
I've just looked through the change adding Context and Key<>\PtrKey<> thingy. 
Yes, these classes are POD, so it is fine to have them static  (as you rely 
only on their address). 

Yes, I'd prefer to move the key out of `class` into a namespace - interface 
looks better without any data IMO.



Comment at: clangd/Trace.h:49
+  virtual void end_event(Context &Ctx, llvm::StringRef Name,
+ json::obj &&Args) = 0;
+  /// Called for instant events.

ilya-biryukov wrote:
> luckygeck wrote:
> > Maybe it is better to calculate these Args only if the tracing is enabled? 
> > This might be done at least this two ways:
> > 1) Have `bool is_tracing_enabled()` method that we can check before 
> > calculating args.
> > 2) Pass a function that will produce json::obj when called.
> The current implementation won't compute args if `EventTracer` inside a 
> `Context` is null, so I think this should cover our needs for per-request 
> tracing (see `SPAN_ATTACH` macro).
> But `is_tracing_enabled()` makes sense if we'd like to turn the tracing off 
> in a middle of a single `Context` lifetime. This would make sense for global 
> tracer, is this the use-case you anticipate?
> 
Oh, ok - setting tracer in a context only when we need to looks good enough.


https://reviews.llvm.org/D40489



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


[libcxx] r319038 - Implement LWG#2948: unique_ptr does not define operator<< for stream output

2017-11-27 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Nov 27 07:51:36 2017
New Revision: 319038

URL: http://llvm.org/viewvc/llvm-project?rev=319038&view=rev
Log:
Implement LWG#2948: unique_ptr does not define operator<< for stream output

Added:

libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.fail.cpp

libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.pass.cpp
Modified:
libcxx/trunk/include/memory
libcxx/trunk/include/ostream
libcxx/trunk/www/cxx2a_status.html

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=319038&r1=319037&r2=319038&view=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Mon Nov 27 07:51:36 2017
@@ -387,6 +387,9 @@ template unique_
 templateunique_ptr make_unique(size_t n);  
 // C++14
 template unspecified   make_unique(Args&&...) = 
delete; // C++14, T == U[N]
 
+template
+basic_ostream& operator<< (basic_ostream& os, unique_ptr 
const& p);
+
 template
 class shared_ptr
 {

Modified: libcxx/trunk/include/ostream
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ostream?rev=319038&r1=319037&r2=319038&view=diff
==
--- libcxx/trunk/include/ostream (original)
+++ libcxx/trunk/include/ostream Mon Nov 27 07:51:36 2017
@@ -1071,6 +1071,18 @@ operator<<(basic_ostream<_CharT, _Traits
 return __os << __p.get();
 }
 
+template
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+is_same&>() << declval<_Yp>())>::type>::value,
+basic_ostream<_CharT, _Traits>&
+>::type
+operator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& 
__p)
+{
+return __os << __p.get();
+}
+
 template 
 basic_ostream<_CharT, _Traits>&
 operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x)

Added: 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.fail.cpp?rev=319038&view=auto
==
--- 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.fail.cpp
 (added)
+++ 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.fail.cpp
 Mon Nov 27 07:51:36 2017
@@ -0,0 +1,31 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// unique_ptr
+
+// template
+//   basic_ostream&
+//   operator<<(basic_ostream& os, const unique_ptr& p);
+
+//   -?- Remarks: This function shall not participate in overload resolution 
unless os << p.get() is a valid expression.
+
+#include 
+#include 
+#include 
+
+class A {};
+
+int main()
+{
+std::unique_ptr p(new A);
+std::ostringstream os;
+os << p;
+}

Added: 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.pass.cpp?rev=319038&view=auto
==
--- 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.pass.cpp
 (added)
+++ 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.pass.cpp
 Mon Nov 27 07:51:36 2017
@@ -0,0 +1,29 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// unique_ptr
+
+// template
+//   basic_ostream&
+//   operator<<(basic_ostream& os, const unique_ptr& p);
+
+#include 
+#include 
+#include 
+
+int main()
+{
+std::unique_ptr p(new int(3));
+std::ostringstream os;
+assert(os.str().empty());
+os << p;
+assert(!os.str().empty());
+}

Modified: libcxx/trunk/www/cxx2a_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx2a_status.html?rev=319038&r1=319037&r2=319038&view=diff
==
--- libcxx/trunk/www/cxx2a_status.html (original)
+++ libcxx/trunk/www/cxx2a_status.html Mon Nov 27 07:51:36 2017
@@ -65,7 +65,7 @@
https://wg21.link/P0439R0";>P0439R0LWGMake 
std::memory_order a scoped 
enumerationAlbuquerque
https://wg21.link/P045

[PATCH] D40310: Restructure how we break tokens.

2017-11-27 Thread Manuel Klimek via Phabricator via cfe-commits
klimek updated this revision to Diff 124381.
klimek added a comment.

Restructure based on code review feedback.


https://reviews.llvm.org/D40310

Files:
  lib/Format/BreakableToken.cpp
  lib/Format/BreakableToken.h
  lib/Format/ContinuationIndenter.cpp
  unittests/Format/FormatTest.cpp
  unittests/Format/FormatTestComments.cpp

Index: unittests/Format/FormatTestComments.cpp
===
--- unittests/Format/FormatTestComments.cpp
+++ unittests/Format/FormatTestComments.cpp
@@ -1096,11 +1096,12 @@
 }
 
 TEST_F(FormatTestComments, SplitsLongLinesInComments) {
+  // FIXME: Do we need to fix up the "  */" at the end?
+  // It doesn't look like any of our current logic triggers this.
   EXPECT_EQ("/* This is a long\n"
 " * comment that\n"
-" * doesn't\n"
-" * fit on one line.\n"
-" */",
+" * doesn't fit on\n"
+" * one line.  */",
 format("/* "
"This is a long "
"comment that "
@@ -2102,6 +2103,66 @@
   EXPECT_EQ("///", format(" ///  ", getLLVMStyleWithColumns(20)));
 }
 
+TEST_F(FormatTestComments, ReflowsCommentsPrecise) {
+  // FIXME: This assumes we do not continue compressing whitespace once we are
+  // in reflow mode. Consider compressing whitespace.
+
+  // Test that we stop reflowing precisely at the column limit.
+  // After reflowing, "// reflows into   foo" does not fit the column limit,
+  // so we compress the whitespace.
+  EXPECT_EQ("// some text that\n"
+"// reflows into foo\n",
+format("// some text that reflows\n"
+   "// into   foo\n",
+   getLLVMStyleWithColumns(20)));
+  // Given one more column, "// reflows into   foo" does fit the limit, so we
+  // do not compress the whitespace.
+  EXPECT_EQ("// some text that\n"
+"// reflows into   foo\n",
+format("// some text that reflows\n"
+   "// into   foo\n",
+   getLLVMStyleWithColumns(21)));
+}
+
+TEST_F(FormatTestComments, ReflowsCommentsWithExtraWhitespace) {
+  // Baseline.
+  EXPECT_EQ("// some text\n"
+"// that re flows\n",
+format("// some text that\n"
+   "// re flows\n",
+   getLLVMStyleWithColumns(16)));
+  EXPECT_EQ("// some text\n"
+"// that re flows\n",
+format("// some text that\n"
+   "// reflows\n",
+   getLLVMStyleWithColumns(16)));
+  EXPECT_EQ("/* some text\n"
+" * that re flows\n"
+" */\n",
+format("/* some text that\n"
+   "*  re   flows\n"
+   "*/\n",
+   getLLVMStyleWithColumns(16)));
+  // FIXME: We do not reflow if the indent of two subsequent lines differs;
+  // given that this is different behavior from block comments, do we want
+  // to keep this?
+  EXPECT_EQ("// some text\n"
+"// that\n"
+"// re flows\n",
+format("// some text that\n"
+   "// re   flows\n",
+   getLLVMStyleWithColumns(16)));
+  // Space within parts of a line that fit.
+  // FIXME: Use the earliest possible split while reflowing to compress the
+  // whitespace within the line.
+  EXPECT_EQ("// some text that\n"
+"// does re   flow\n"
+"// more  here\n",
+format("// some text that does\n"
+   "// re   flow  more  here\n",
+   getLLVMStyleWithColumns(21)));
+}
+
 TEST_F(FormatTestComments, IgnoresIf0Contents) {
   EXPECT_EQ("#if 0\n"
 "}{)(&*(^%%#%@! fsadj f;ldjs ,:;| <<<>>>][)(][\n"
@@ -2484,6 +2545,7 @@
   " long */\n"
   "  b);",
   format("a = f(a, /* long long */ b);", getLLVMStyleWithColumns(16)));
+
   EXPECT_EQ(
   "a = f(\n"
   "a,\n"
@@ -2888,16 +2950,15 @@
getLLVMStyleWithColumns(20)));
 }
 
-TEST_F(FormatTestComments, NoCrush_Bug34236) {
+TEST_F(FormatTestComments, NoCrash_Bug34236) {
   // This is a test case from a crasher reported in:
   // https://bugs.llvm.org/show_bug.cgi?id=34236
   // Temporarily disable formatting for readability.
   // clang-format off
   EXPECT_EQ(
 "/**/ /*\n"
 "  *   a\n"
-"  * b c\n"
-"  * d*/",
+"  * b c d*/",
   format(
 "/**/ /*\n"
 " *   a b\n"
Index: unittests/Format/FormatTest.cpp
===
--- u

[PATCH] D40310: Restructure how we break tokens.

2017-11-27 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

Restructured to make the invariants clearer based on a chat with Krasimir.


https://reviews.llvm.org/D40310



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


[clang-tools-extra] r319040 - [clang-tools-extra] Fix small typo in docs/ReleaseNotes.rst

2017-11-27 Thread Ben Hamilton via cfe-commits
Author: benhamilton
Date: Mon Nov 27 07:58:26 2017
New Revision: 319040

URL: http://llvm.org/viewvc/llvm-project?rev=319040&view=rev
Log:
[clang-tools-extra] Fix small typo in docs/ReleaseNotes.rst

Summary:
This is mainly a test diff to check the new Herald rule I
added in LLVM Phabricator to automatically Cc: cfe-commits on all
clang-tools-extra diffs.

Reviewers: Wizard, hokein, klimek

Reviewed By: Wizard

Subscribers: dlj, bkramer, sammccall

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

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=319040&r1=319039&r2=319040&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Mon Nov 27 07:58:26 2017
@@ -99,7 +99,7 @@ Improvements to clang-tidy
 - The 'misc-string-constructor' check was renamed to 
`bugprone-string-constructor
   
`_
 
-- New `google-avoid-throwing-objc-exception
+- New `google-objc-avoid-throwing-exception
   
`_
 check
 
   Add new check to detect throwing exceptions in Objective-C code, which 
should be avoided.


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


[clang-tools-extra] r319039 - [clang-tools-extra] Set up .arcconfig to point to new Diffusion CTE repository

2017-11-27 Thread Ben Hamilton via cfe-commits
Author: benhamilton
Date: Mon Nov 27 07:58:25 2017
New Revision: 319039

URL: http://llvm.org/viewvc/llvm-project?rev=319039&view=rev
Log:
[clang-tools-extra] Set up .arcconfig to point to new Diffusion CTE repository

Summary:
I'm testing out a new Diffusion repository `CTE`:

https://reviews.llvm.org/source/clang-tools-extra/

This explicitly updates clang-tools-extra's `.arcconfig` to point to
the new `CTE` repository in Diffusion, which will let us set up Herald
rules, etc.

Reviewers: klimek, sammccall

Reviewed By: sammccall

Subscribers: bkramer, dlj

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

Modified:
clang-tools-extra/trunk/.arcconfig

Modified: clang-tools-extra/trunk/.arcconfig
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/.arcconfig?rev=319039&r1=319038&r2=319039&view=diff
==
--- clang-tools-extra/trunk/.arcconfig (original)
+++ clang-tools-extra/trunk/.arcconfig Mon Nov 27 07:58:25 2017
@@ -1,4 +1,4 @@
 {
-  "project_id" : "clang-tools-extra",
+  "repository.callsign" : "CTE",
   "conduit_uri" : "https://reviews.llvm.org/";
 }


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


[PATCH] D40494: [clang] Set up .arcconfig to point to new Diffusion C repository

2017-11-27 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.

We want to automatically copy cfe-commits@ on review requests
to the clang repository.

Similar to https://reviews.llvm.org/D40179, I set up a new Diffusion repository 
with callsign
"C" for clang:

https://reviews.llvm.org/source/clang/

This explicitly updates clang's .arcconfig to point to the new C
repository in Diffusion, which will let us use Herald rule 
https://reviews.llvm.org/H268.


Repository:
  rC Clang

https://reviews.llvm.org/D40494

Files:
  .arcconfig


Index: .arcconfig
===
--- .arcconfig
+++ .arcconfig
@@ -1,4 +1,4 @@
 {
-  "project_id" : "clang",
+  "repository.callsign" : "C",
   "conduit_uri" : "https://reviews.llvm.org/";
 }


Index: .arcconfig
===
--- .arcconfig
+++ .arcconfig
@@ -1,4 +1,4 @@
 {
-  "project_id" : "clang",
+  "repository.callsign" : "C",
   "conduit_uri" : "https://reviews.llvm.org/";
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r319042 - Fix failure on C++03 bots

2017-11-27 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Nov 27 08:17:19 2017
New Revision: 319042

URL: http://llvm.org/viewvc/llvm-project?rev=319042&view=rev
Log:
Fix failure on C++03 bots

Modified:
libcxx/trunk/include/ostream

libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.fail.cpp

libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.pass.cpp

Modified: libcxx/trunk/include/ostream
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ostream?rev=319042&r1=319041&r2=319042&view=diff
==
--- libcxx/trunk/include/ostream (original)
+++ libcxx/trunk/include/ostream Mon Nov 27 08:17:19 2017
@@ -1071,6 +1071,7 @@ operator<<(basic_ostream<_CharT, _Traits
 return __os << __p.get();
 }
 
+#ifndef _LIBCPP_HAS_NO_DECLTYPE
 template
 inline _LIBCPP_INLINE_VISIBILITY
 typename enable_if
@@ -1082,6 +1083,7 @@ operator<<(basic_ostream<_CharT, _Traits
 {
 return __os << __p.get();
 }
+#endif
 
 template 
 basic_ostream<_CharT, _Traits>&

Modified: 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.fail.cpp?rev=319042&r1=319041&r2=319042&view=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.fail.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.fail.cpp
 Mon Nov 27 08:17:19 2017
@@ -7,6 +7,9 @@
 //
 
//===--===//
 
+// UNSUPPORTED: c++98, c++03
+//  Because we don't have a functioning decltype in C++03
+
 // 
 
 // unique_ptr

Modified: 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.pass.cpp?rev=319042&r1=319041&r2=319042&view=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.special/io.pass.cpp
 Mon Nov 27 08:17:19 2017
@@ -7,6 +7,9 @@
 //
 
//===--===//
 
+// UNSUPPORTED: c++98, c++03
+//  Because we don't have a functioning decltype in C++03
+
 // 
 
 // unique_ptr


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


[PATCH] D37187: [Analyzer] Fix Bug 25609 - Assertion UNREACHABLE: 'Unexpected ProgramPoint' with widen-loops=true

2017-11-27 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.

LGTM, but as noted inline you should update the new llvm_unreachable() to have 
a more descriptive error message.

Do you have commit access or do you need someone to commit this for you?




Comment at: lib/StaticAnalyzer/Core/PathDiagnostic.cpp:701
+}
+llvm_unreachable("Unexpected ProgramPoint");
   } else {

This assertion should probably say something like "Unexpected CFG element at 
front of block".


https://reviews.llvm.org/D37187



___
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-11-27 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 124391.
Nebiroth marked an inline comment as done.
Nebiroth added a comment.
Herald added a subscriber: klimek.

Removed temporary test file
Updated test to account for read-access symbol verification


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38425

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  test/clangd/documenthighlight.test
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test

Index: test/clangd/initialize-params.test
===
--- test/clangd/initialize-params.test
+++ test/clangd/initialize-params.test
@@ -20,6 +20,7 @@
 # CHECK-NEXT:  },
 # CHECK-NEXT:  "definitionProvider": true,
 # CHECK-NEXT:  "documentFormattingProvider": true,
+# CHECK-NEXT:	   "documentHighlightProvider": true,
 # CHECK-NEXT:  "documentOnTypeFormattingProvider": {
 # CHECK-NEXT:"firstTriggerCharacter": "}",
 # CHECK-NEXT:"moreTriggerCharacter": []
Index: test/clangd/initialize-params-invalid.test
===
--- test/clangd/initialize-params-invalid.test
+++ test/clangd/initialize-params-invalid.test
@@ -20,6 +20,7 @@
 # CHECK-NEXT:  },
 # CHECK-NEXT:  "definitionProvider": true,
 # CHECK-NEXT:  "documentFormattingProvider": true,
+# CHECK-NEXT:	   "documentHighlightProvider": true,
 # CHECK-NEXT:  "documentOnTypeFormattingProvider": {
 # CHECK-NEXT:"firstTriggerCharacter": "}",
 # CHECK-NEXT:"moreTriggerCharacter": []
Index: test/clangd/documenthighlight.test
===
--- /dev/null
+++ test/clangd/documenthighlight.test
@@ -0,0 +1,42 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 479
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"#define MACRO 1\nnamespace ns1 {\nstruct MyClass {\nint xasd;\nvoid anotherOperation() {\n}\nstatic int foo(MyClass*) {\nreturn 0;\n}\n\n};\nstruct Foo {\nint xasd;\n};\n}\nint main() {\nint bonjour;\nbonjour = 2;\nint test1 = bonjour;\nns1::Foo bar = { xasd : 1};\nbar.xasd = 3;\nns1::MyClass* Params;\nParams->anotherOperation();\n}\n"}}}
+
+Content-Length: 156
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":17,"character":2}}}
+# Verify local variable 
+# CHECK: {"id":1,"jsonrpc":"2.0","result":[{"kind":1,"range":{"end":{"character":12,"line":16},"start":{"character":4,"line":16}}},{"kind":3,"range":{"end":{"character":7,"line":17},"start":{"character":0,"line":17}}},{"kind":2,"range":{"end":{"character":20,"line":18},"start":{"character":12,"line":18}}}]}
+
+Content-Length: 157
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":18,"character":17}}}
+# Verify struct highlight
+# CHECK: {"id":1,"jsonrpc":"2.0","result":[{"kind":1,"range":{"end":{"character":12,"line":16},"start":{"character":4,"line":16}}},{"kind":3,"range":{"end":{"character":7,"line":17},"start":{"character":0,"line":17}}},{"kind":2,"range":{"end":{"character":20,"line":18},"start":{"character":12,"line":18}}}]}
+
+Content-Length: 157
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":21,"character":10}}}
+# Verify method highlight
+# CHECK: {"id":1,"jsonrpc":"2.0","result":[{"kind":1,"range":{"end":{"character":14,"line":2},"start":{"character":7,"line":2}}},{"kind":1,"range":{"end":{"character":23,"line":6},"start":{"character":15,"line":6}}},{"kind":1,"range":{"end":{"character":13,"line":21},"start":{"character":5,"line":21}}}]}
+
+Content-Length: 156
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":18,"character":14}}}
+# Verify Read-access of a symbol (kind = 2) 
+# CHECK: {"id":1,"jsonrpc":"2.0","result":[{"kind":1,"range":{"end":{"character":12,"line":16},"start":{"character":4,"line":16}}},{"kind":3,"range":{"end":{"character":7,"line":17},"start":{"character":0,"line":17}}},{"kind":2,"range":{"end":{"character":20,"line":18},"start":{"character":12,"line":18}}}]}
+
+Content-Length: 48
+
+{"jsonrpc":"2.0","id":1,"method":"shutdown"}
+
+Content-Length: 33
+
+{"jsonrpc":"2.0":"method":"exit"}		

r319046 - [OPENMP] Improve handling of cancel directives in target-based

2017-11-27 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Nov 27 08:54:08 2017
New Revision: 319046

URL: http://llvm.org/viewvc/llvm-project?rev=319046&view=rev
Log:
[OPENMP] Improve handling of cancel directives in target-based
constructs, NFC.

Improved handling of cancel|cancellation point directives inside
target-based for directives.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=319046&r1=319045&r2=319046&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Mon Nov 27 08:54:08 2017
@@ -1293,6 +1293,13 @@ static llvm::Value *emitParallelOrTeamsO
 HasCancel = OPFD->hasCancel();
   else if (auto *OPFD = dyn_cast(&D))
 HasCancel = OPFD->hasCancel();
+  else if (auto *OPFD = dyn_cast(&D))
+HasCancel = OPFD->hasCancel();
+  else if (auto *OPFD = dyn_cast(&D))
+HasCancel = OPFD->hasCancel();
+  else if (auto *OPFD =
+   dyn_cast(&D))
+HasCancel = OPFD->hasCancel();
   CGOpenMPOutlinedRegionInfo CGInfo(*CS, ThreadIDVar, CodeGen, InnermostKind,
 HasCancel, OutlinedHelperName);
   CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, &CGInfo);

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=319046&r1=319045&r2=319046&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Mon Nov 27 08:54:08 2017
@@ -2039,8 +2039,7 @@ void CodeGenFunction::EmitOMPDistributeP
   S.getDistInc());
   };
   OMPLexicalScope Scope(*this, S, /*AsInlined=*/true);
-  CGM.getOpenMPRuntime().emitInlinedDirective(*this, OMPD_distribute, CodeGen,
-  S.hasCancel());
+  CGM.getOpenMPRuntime().emitInlinedDirective(*this, OMPD_distribute, CodeGen);
 }
 
 void CodeGenFunction::EmitOMPDistributeParallelForSimdDirective(
@@ -3201,8 +3200,7 @@ void CodeGenFunction::EmitOMPDistributeD
 CGF.EmitOMPDistributeLoop(S, emitOMPLoopBodyWithStopPoint, S.getInc());
   };
   OMPLexicalScope Scope(*this, S, /*AsInlined=*/true);
-  CGM.getOpenMPRuntime().emitInlinedDirective(*this, OMPD_distribute, CodeGen,
-  false);
+  CGM.getOpenMPRuntime().emitInlinedDirective(*this, OMPD_distribute, CodeGen);
 }
 
 static llvm::Function *emitOutlinedOrderedFunction(CodeGenModule &CGM,
@@ -3915,8 +3913,8 @@ void CodeGenFunction::EmitOMPTeamsDistri
 OMPPrivateScope PrivateScope(CGF);
 CGF.EmitOMPReductionClauseInit(S, PrivateScope);
 (void)PrivateScope.Privatize();
-CGF.CGM.getOpenMPRuntime().emitInlinedDirective(
-CGF, OMPD_distribute, CodeGenDistribute, S.hasCancel());
+CGF.CGM.getOpenMPRuntime().emitInlinedDirective(CGF, OMPD_distribute,
+CodeGenDistribute);
 CGF.EmitOMPReductionClauseFinal(S, /*ReductionKind=*/OMPD_teams);
   };
   emitCommonOMPTeamsDirective(*this, S, OMPD_distribute_parallel_for, CodeGen);

Modified: cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp?rev=319046&r1=319045&r2=319046&view=diff
==
--- cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp Mon Nov 27 08:54:08 
2017
@@ -106,6 +106,7 @@ int foo(int n) {
   #pragma omp target parallel for
   for (int i = 3; i < 32; i += 5) {
 #pragma omp cancel for
+#pragma omp cancellation point for
   }
 
   // CHECK:   call void [[HVT1:@.+]](i[[SZ]] {{[^,]+}}, i{{32|64}}{{[*]*}} 
{{[^)]+}})
@@ -325,6 +326,7 @@ int foo(int n) {
 //
 // CHECK:   define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias 
%.global_tid., i32* noalias %.bound_tid.)
 // CHECK:   call i32 @__kmpc_cancel(%ident_t* @
+// CHECK:   call i32 @__kmpc_cancellationpoint(%ident_t* @
 // CHECK:   ret void
 // CHECK:   }
 


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


[PATCH] D40500: [libcxx] Set up .arcconfig to point to new Diffusion CXX repository

2017-11-27 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
Herald added a subscriber: cfe-commits.

We want to automatically copy the appropriate mailing list
for review requests to the libc++ repository.

For context, see the proposal and discussion here:

http://lists.llvm.org/pipermail/cfe-dev/2017-November/056032.html

Similar to https://reviews.llvm.org/D40179, I set up a new Diffusion repository 
with callsign
"CXX" for libc++:

https://reviews.llvm.org/source/libcxx/

This explicitly updates libcxx's .arcconfig to point to the new
CXX repository in Diffusion, which will let us use Herald rule 
https://reviews.llvm.org/H268.


Repository:
  rCXX libc++

https://reviews.llvm.org/D40500

Files:
  .arcconfig


Index: .arcconfig
===
--- .arcconfig
+++ .arcconfig
@@ -1,4 +1,4 @@
 {
-  "project_id" : "libcxx",
+  "repository.callsign" : "CXX",
   "conduit_uri" : "https://reviews.llvm.org/";
 }


Index: .arcconfig
===
--- .arcconfig
+++ .arcconfig
@@ -1,4 +1,4 @@
 {
-  "project_id" : "libcxx",
+  "repository.callsign" : "CXX",
   "conduit_uri" : "https://reviews.llvm.org/";
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40108: [clang-tidy] Adding Fuchsia checkers to clang-tidy

2017-11-27 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 124397.
juliehockett marked 7 inline comments as done.
juliehockett added a comment.

Added new tests and updated wording in warning.


https://reviews.llvm.org/D40108

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/fuchsia/CMakeLists.txt
  clang-tidy/fuchsia/DefaultArgumentsCheck.cpp
  clang-tidy/fuchsia/DefaultArgumentsCheck.h
  clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/fuchsia-default-arguments.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/fuchsia-default-arguments.cpp

Index: test/clang-tidy/fuchsia-default-arguments.cpp
===
--- /dev/null
+++ test/clang-tidy/fuchsia-default-arguments.cpp
@@ -0,0 +1,81 @@
+// RUN: %check_clang_tidy %s fuchsia-default-arguments %t
+
+int foo(int value = 5) { return value; }
+// CHECK-MESSAGES: [[@LINE-1]]:9: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+// CHECK-FIXES: int foo(int value) { return value; }
+
+int f() {
+  foo();
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments]
+  // CHECK-NEXT: note: default parameter was declared here:
+  // CHECK-NEXT: int foo(int value = 5) { return value; }
+}
+
+int bar(int value) { return value; }
+
+int n() {
+  foo(0);
+  bar(0);
+}
+
+class Baz {
+public:
+  int a(int value = 5) { return value; }
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+  // CHECK-FIXES: int a(int value) { return value; }
+
+  int b(int value) { return value; }
+};
+
+class Foo {
+  // Fix should be suggested in declaration
+  int a(int value = 53);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+  // CHECK-FIXES: int a(int value);
+};
+
+// Fix shouldn't be suggested in implementation
+int Foo::a(int value) {
+  return value;
+}
+
+// Elided functions
+void f(int = 5) {};
+// CHECK-MESSAGES: [[@LINE-1]]:8: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+// CHECK-FIXES: void f(int) {};
+
+void g(int) {};
+
+// Should not suggest fix for macro-defined parameters
+#define D(val) = val
+
+void h(int i D(5));
+// CHECK-MESSAGES: [[@LINE-1]]:8: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+// CHECK-FIXES-NOT: void h(int i);
+
+void x(int i);
+void x(int i = 12);
+// CHECK-MESSAGES: [[@LINE-1]]:8: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+// CHECK-FIXES: void x(int i);
+
+void x(int i) {}
+
+struct S {
+  void x(int i);
+};
+
+void S::x(int i = 12) {}
+// CHECK-MESSAGES: [[@LINE-1]]:11: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+// CHECK-FIXES: void S::x(int i) {}
+
+int main() {
+  S s;
+  s.x();
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments]
+  // CHECK-NEXT: note: default parameter was declared here:
+  // CHECK-NEXT: void S::x(int i = 12) {}
+  x();
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments]
+  // CHECK-NEXT: note: default parameter was declared here:
+  // CHECK-NEXT: void x(int i = 12);
+}
\ No newline at end of file
Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -61,6 +61,7 @@
 ``cert-``  Checks related to CERT Secure Coding Guidelines.
 ``cppcoreguidelines-`` Checks related to C++ Core Guidelines.
 ``clang-analyzer-``Clang Static Analyzer checks.
+``fuchsia-``   Checks related to Fuchsia coding conventions.
 ``google-``Checks related to Google coding conventions.
 ``hicpp-`` Checks related to High Integrity C++ Coding Standard.
 ``llvm-``  Checks related to the LLVM coding conventions.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -55,6 +55,7 @@
cppcoreguidelines-pro-type-vararg
cppcoreguidelines-slicing
cppcoreguidelines-special-member-functions
+   fuchsia-default-arguments
google-build-explicit-make-pair
google-build-namespaces
google-build-using-namespace
Index: docs/clang-tidy/checks/fuchsia-default-arguments.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/fuchsia-default-arguments.rst
@@ -0,0 +1,24 @@

[PATCH] D40501: [libcxxabi] Set up .arcconfig to point to new Diffusion CXXA repository

2017-11-27 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
Herald added a subscriber: cfe-commits.

We want to automatically copy the appropriate mailing list
for review requests to the libc++abi repository.

For context, see the proposal and discussion here:

http://lists.llvm.org/pipermail/cfe-dev/2017-November/056032.html

Similar to https://reviews.llvm.org/D40500, I set up a new Diffusion repository 
with callsign
"CXXA" for libc++abi:

https://reviews.llvm.org/source/libcxxabi/

This explicitly updates libcxxabi's .arcconfig to point to the new
CXX repository in Diffusion, which will let us use Herald rule 
https://reviews.llvm.org/H268.


Repository:
  rCXXA libc++abi

https://reviews.llvm.org/D40501

Files:
  .arcconfig


Index: .arcconfig
===
--- .arcconfig
+++ .arcconfig
@@ -1,4 +1,4 @@
 {
-  "project_id" : "libcxxabi",
+  "repository.callsign" : "CXXA",
   "conduit_uri" : "https://reviews.llvm.org/";
 }


Index: .arcconfig
===
--- .arcconfig
+++ .arcconfig
@@ -1,4 +1,4 @@
 {
-  "project_id" : "libcxxabi",
+  "repository.callsign" : "CXXA",
   "conduit_uri" : "https://reviews.llvm.org/";
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40060: [clangd] Fuzzy match scorer

2017-11-27 Thread Evgeny Gryaznov via Phabricator via cfe-commits
inspirer added inline comments.



Comment at: clangd/FuzzyMatch.cpp:254
+  // Penalty: matching inside a segment (and previous char wasn't matched).
+  if (WordRole[W] == Tail && P && !Matched[P - 1][W - 1])
+S -= 3;

You need a third boolean dimension in your DP table for this condition to work 
- "matches".

Consider matching "Abde" against "AbdDe". The result should be [Ab]d[De] and 
not [Abd]D[e]. While evaluating Abd against AbdD, you will have to choose 
between two ways to represent the match and no matter what you choose, scoring 
in this line will not know whether your previous char matched, since you merged 
two branches and kept only one of them.

This scoring works OK-ish since you check "if (Diag >= Left)" above and so you 
Matched table is full of trues, but you matches will gravitate towards the ends 
of the candidate string if you decide to show them in the UI.


https://reviews.llvm.org/D40060



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


r319052 - [clang] Set up .arcconfig to point to new Diffusion C repository

2017-11-27 Thread Ben Hamilton via cfe-commits
Author: benhamilton
Date: Mon Nov 27 09:21:24 2017
New Revision: 319052

URL: http://llvm.org/viewvc/llvm-project?rev=319052&view=rev
Log:
[clang] Set up .arcconfig to point to new Diffusion C repository

Summary:
We want to automatically copy cfe-commits@ on review requests
to the clang repository.

Similar to D40179, I set up a new Diffusion repository with callsign
"C" for clang:

https://reviews.llvm.org/source/clang/

This explicitly updates clang's .arcconfig to point to the new C
repository in Diffusion, which will let us use Herald rule H268.

Reviewers: klimek, sammccall

Reviewed By: klimek

Subscribers: dlj, bkramer

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

Modified:
cfe/trunk/.arcconfig

Modified: cfe/trunk/.arcconfig
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/.arcconfig?rev=319052&r1=319051&r2=319052&view=diff
==
--- cfe/trunk/.arcconfig (original)
+++ cfe/trunk/.arcconfig Mon Nov 27 09:21:24 2017
@@ -1,4 +1,4 @@
 {
-  "project_id" : "clang",
+  "repository.callsign" : "C",
   "conduit_uri" : "https://reviews.llvm.org/";
 }


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


[PATCH] D40476: Switch kryo to use -mcpu=cortex-a57 when invoking the assembler

2017-11-27 Thread Stephen Hines via Phabricator via cfe-commits
srhines added inline comments.



Comment at: lib/Driver/ToolChains/Gnu.cpp:660
+// of a cpu flag.
+Arg *A = Args.getLastArg(options::OPT_mcpu_EQ);
+if (A) {

Is it better to sink A into the if condition again?



Comment at: test/Driver/as-mcpu.c:1
+// == Check that krait is substituted by cortex-15 when 
invoking
+// the assembler

cortex-a15 - this is missing the "a".



Comment at: test/Driver/as-mcpu.c:6
+
+// == Check that kryo is substituted by cortex-57 when invoking
+// the assembler

cortex-a57


https://reviews.llvm.org/D40476



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


r319055 - [analyzer] pr34404: Fix a crash on modeling pointers to indirect members.

2017-11-27 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Nov 27 09:31:16 2017
New Revision: 319055

URL: http://llvm.org/viewvc/llvm-project?rev=319055&view=rev
Log:
[analyzer] pr34404: Fix a crash on modeling pointers to indirect members.

We were crashing whenever a C++ pointer-to-member was taken, that was pointing
to a member of an anonymous structure field within a class, eg.

  struct A {
struct {
 int x;
};
  };
  // ...
  &A::x;

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/Analysis/pointer-to-member.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=319055&r1=319054&r2=319055&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Mon Nov 27 09:31:16 2017
@@ -2108,10 +2108,12 @@ void ExprEngine::VisitCommonDeclRefExpr(
   ProgramPoint::PostLValueKind);
 return;
   }
-  if (isa(D)) {
+  if (isa(D) || isa(D)) {
 // FIXME: Compute lvalue of field pointers-to-member.
 // Right now we just use a non-null void pointer, so that it gives proper
 // results in boolean contexts.
+// FIXME: Maybe delegate this to the surrounding operator&.
+// Note how this expression is lvalue, however pointer-to-member is NonLoc.
 SVal V = svalBuilder.conjureSymbolVal(Ex, LCtx, getContext().VoidPtrTy,
   currBldrCtx->blockCount());
 state = state->assume(V.castAs(), true);

Modified: cfe/trunk/test/Analysis/pointer-to-member.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/pointer-to-member.cpp?rev=319055&r1=319054&r2=319055&view=diff
==
--- cfe/trunk/test/Analysis/pointer-to-member.cpp (original)
+++ cfe/trunk/test/Analysis/pointer-to-member.cpp Mon Nov 27 09:31:16 2017
@@ -230,3 +230,42 @@ void double_diamond() {
   clang_analyzer_eval(d2.*(static_cast(static_cast(static_cast(&B::f == 4); // expected-warning {{TRUE}}
 }
 } // end of testPointerToMemberDiamond namespace
+
+namespace testAnonymousMember {
+struct A {
+  struct {
+int x;
+  };
+  struct {
+struct {
+  int y;
+};
+  };
+  struct {
+union {
+  int z;
+};
+  };
+};
+
+void test() {
+  clang_analyzer_eval(&A::x); // expected-warning{{TRUE}}
+  clang_analyzer_eval(&A::y); // expected-warning{{TRUE}}
+  clang_analyzer_eval(&A::z); // expected-warning{{TRUE}}
+
+  // FIXME: These should be true.
+  int A::*l = &A::x, A::*m = &A::y, A::*n = &A::z;
+  clang_analyzer_eval(l); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(m); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(n); // expected-warning{{UNKNOWN}}
+
+  // FIXME: These should be true as well.
+  A a;
+  a.x = 1;
+  clang_analyzer_eval(a.*l == 1); // expected-warning{{UNKNOWN}}
+  a.y = 2;
+  clang_analyzer_eval(a.*m == 2); // expected-warning{{UNKNOWN}}
+  a.z = 3;
+  clang_analyzer_eval(a.*n == 3); // expected-warning{{UNKNOWN}}
+}
+} // end of testAnonymousMember namespace


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


[PATCH] D39800: [analyzer] pr34404: Fix a crash on pointers to members in nested anonymous structures.

2017-11-27 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319055: [analyzer] pr34404: Fix a crash on modeling pointers 
to indirect members. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D39800?vs=122087&id=124404#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39800

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
  cfe/trunk/test/Analysis/pointer-to-member.cpp


Index: cfe/trunk/test/Analysis/pointer-to-member.cpp
===
--- cfe/trunk/test/Analysis/pointer-to-member.cpp
+++ cfe/trunk/test/Analysis/pointer-to-member.cpp
@@ -230,3 +230,42 @@
   clang_analyzer_eval(d2.*(static_cast(static_cast(static_cast(&B::f == 4); // expected-warning {{TRUE}}
 }
 } // end of testPointerToMemberDiamond namespace
+
+namespace testAnonymousMember {
+struct A {
+  struct {
+int x;
+  };
+  struct {
+struct {
+  int y;
+};
+  };
+  struct {
+union {
+  int z;
+};
+  };
+};
+
+void test() {
+  clang_analyzer_eval(&A::x); // expected-warning{{TRUE}}
+  clang_analyzer_eval(&A::y); // expected-warning{{TRUE}}
+  clang_analyzer_eval(&A::z); // expected-warning{{TRUE}}
+
+  // FIXME: These should be true.
+  int A::*l = &A::x, A::*m = &A::y, A::*n = &A::z;
+  clang_analyzer_eval(l); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(m); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(n); // expected-warning{{UNKNOWN}}
+
+  // FIXME: These should be true as well.
+  A a;
+  a.x = 1;
+  clang_analyzer_eval(a.*l == 1); // expected-warning{{UNKNOWN}}
+  a.y = 2;
+  clang_analyzer_eval(a.*m == 2); // expected-warning{{UNKNOWN}}
+  a.z = 3;
+  clang_analyzer_eval(a.*n == 3); // expected-warning{{UNKNOWN}}
+}
+} // end of testAnonymousMember namespace
Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -2108,10 +2108,12 @@
   ProgramPoint::PostLValueKind);
 return;
   }
-  if (isa(D)) {
+  if (isa(D) || isa(D)) {
 // FIXME: Compute lvalue of field pointers-to-member.
 // Right now we just use a non-null void pointer, so that it gives proper
 // results in boolean contexts.
+// FIXME: Maybe delegate this to the surrounding operator&.
+// Note how this expression is lvalue, however pointer-to-member is NonLoc.
 SVal V = svalBuilder.conjureSymbolVal(Ex, LCtx, getContext().VoidPtrTy,
   currBldrCtx->blockCount());
 state = state->assume(V.castAs(), true);


Index: cfe/trunk/test/Analysis/pointer-to-member.cpp
===
--- cfe/trunk/test/Analysis/pointer-to-member.cpp
+++ cfe/trunk/test/Analysis/pointer-to-member.cpp
@@ -230,3 +230,42 @@
   clang_analyzer_eval(d2.*(static_cast(static_cast(static_cast(&B::f == 4); // expected-warning {{TRUE}}
 }
 } // end of testPointerToMemberDiamond namespace
+
+namespace testAnonymousMember {
+struct A {
+  struct {
+int x;
+  };
+  struct {
+struct {
+  int y;
+};
+  };
+  struct {
+union {
+  int z;
+};
+  };
+};
+
+void test() {
+  clang_analyzer_eval(&A::x); // expected-warning{{TRUE}}
+  clang_analyzer_eval(&A::y); // expected-warning{{TRUE}}
+  clang_analyzer_eval(&A::z); // expected-warning{{TRUE}}
+
+  // FIXME: These should be true.
+  int A::*l = &A::x, A::*m = &A::y, A::*n = &A::z;
+  clang_analyzer_eval(l); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(m); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(n); // expected-warning{{UNKNOWN}}
+
+  // FIXME: These should be true as well.
+  A a;
+  a.x = 1;
+  clang_analyzer_eval(a.*l == 1); // expected-warning{{UNKNOWN}}
+  a.y = 2;
+  clang_analyzer_eval(a.*m == 2); // expected-warning{{UNKNOWN}}
+  a.z = 3;
+  clang_analyzer_eval(a.*n == 3); // expected-warning{{UNKNOWN}}
+}
+} // end of testAnonymousMember namespace
Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -2108,10 +2108,12 @@
   ProgramPoint::PostLValueKind);
 return;
   }
-  if (isa(D)) {
+  if (isa(D) || isa(D)) {
 // FIXME: Compute lvalue of field pointers-to-member.
 // Right now we just use a non-null void pointer, so that it gives proper
 // results in boolean contexts.
+// FIXME: Maybe delegate this to the surrounding operator&.
+// Note how this expression is lvalue, however pointer-to-member is NonLoc.
 SVal V = svalBuilder.conjureSymbolVal(Ex, LCtx, getContext().VoidPtrTy,
   currBldrCtx->blockCount());
 state = state->assume(V.castAs(), true);
___

[PATCH] D39800: [analyzer] pr34404: Fix a crash on pointers to members in nested anonymous structures.

2017-11-27 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Sorry, i wanted to quickly look at why this thing is lvalue, but this didn't 
seem to be happening, so i guess i'd just commit for now.


Repository:
  rL LLVM

https://reviews.llvm.org/D39800



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


r319058 - [analyzer] pr34766: Fix a crash on explicit std::initializer_list constructor.

2017-11-27 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Nov 27 09:37:09 2017
New Revision: 319058

URL: http://llvm.org/viewvc/llvm-project?rev=319058&view=rev
Log:
[analyzer] pr34766: Fix a crash on explicit std::initializer_list constructor.

We didn't support the following syntax:

  (std::initializer_list){12}

which suddenly produces CompoundLiteralExpr that contains
CXXStdInitializerListExpr.

Lift the assertion and instead pass the value through CompoundLiteralExpr
transparently, as it doesn't add much.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
cfe/trunk/test/Analysis/initializer.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp?rev=319058&r1=319057&r2=319058&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp Mon Nov 27 09:37:09 2017
@@ -535,7 +535,7 @@ void ExprEngine::VisitCompoundLiteralExp
   const Expr *Init = CL->getInitializer();
   SVal V = State->getSVal(CL->getInitializer(), LCtx);
 
-  if (isa(Init)) {
+  if (isa(Init) || isa(Init)) {
 // No work needed. Just pass the value up to this expression.
   } else {
 assert(isa(Init));

Modified: cfe/trunk/test/Analysis/initializer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/initializer.cpp?rev=319058&r1=319057&r2=319058&view=diff
==
--- cfe/trunk/test/Analysis/initializer.cpp (original)
+++ cfe/trunk/test/Analysis/initializer.cpp Mon Nov 27 09:37:09 2017
@@ -211,7 +211,7 @@ namespace CXX_initializer_lists {
 struct C {
   C(std::initializer_list list);
 };
-void foo() {
+void testPointerEscapeIntoLists() {
   C empty{}; // no-crash
 
   // Do not warn that 'x' leaks. It might have been deleted by
@@ -219,4 +219,8 @@ void foo() {
   int *x = new int;
   C c{x}; // no-warning
 }
+
+void testPassListsWithExplicitConstructors() {
+  (void)(std::initializer_list){12}; // no-crash
+}
 }


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


[PATCH] D39803: [analyzer] pr34766: Fix a crash on explicit construction of std::initializer_list.

2017-11-27 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319058: [analyzer] pr34766: Fix a crash on explicit 
std::initializer_list constructor. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D39803?vs=122094&id=124406#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39803

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  cfe/trunk/test/Analysis/initializer.cpp


Index: cfe/trunk/test/Analysis/initializer.cpp
===
--- cfe/trunk/test/Analysis/initializer.cpp
+++ cfe/trunk/test/Analysis/initializer.cpp
@@ -211,12 +211,16 @@
 struct C {
   C(std::initializer_list list);
 };
-void foo() {
+void testPointerEscapeIntoLists() {
   C empty{}; // no-crash
 
   // Do not warn that 'x' leaks. It might have been deleted by
   // the destructor of 'c'.
   int *x = new int;
   C c{x}; // no-warning
 }
+
+void testPassListsWithExplicitConstructors() {
+  (void)(std::initializer_list){12}; // no-crash
+}
 }
Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -535,7 +535,7 @@
   const Expr *Init = CL->getInitializer();
   SVal V = State->getSVal(CL->getInitializer(), LCtx);
 
-  if (isa(Init)) {
+  if (isa(Init) || isa(Init)) {
 // No work needed. Just pass the value up to this expression.
   } else {
 assert(isa(Init));


Index: cfe/trunk/test/Analysis/initializer.cpp
===
--- cfe/trunk/test/Analysis/initializer.cpp
+++ cfe/trunk/test/Analysis/initializer.cpp
@@ -211,12 +211,16 @@
 struct C {
   C(std::initializer_list list);
 };
-void foo() {
+void testPointerEscapeIntoLists() {
   C empty{}; // no-crash
 
   // Do not warn that 'x' leaks. It might have been deleted by
   // the destructor of 'c'.
   int *x = new int;
   C c{x}; // no-warning
 }
+
+void testPassListsWithExplicitConstructors() {
+  (void)(std::initializer_list){12}; // no-crash
+}
 }
Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -535,7 +535,7 @@
   const Expr *Init = CL->getInitializer();
   SVal V = State->getSVal(CL->getInitializer(), LCtx);
 
-  if (isa(Init)) {
+  if (isa(Init) || isa(Init)) {
 // No work needed. Just pass the value up to this expression.
   } else {
 assert(isa(Init));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40505: [clang-tidy] Ignore ExprWithCleanups when looking for else-after-throw

2017-11-27 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons created this revision.
Herald added subscribers: cfe-commits, xazax.hun, klimek.

The readability-else-after-return check was not warning about
an else after a throw of an exception that had arguments that needed
to be cleaned up.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40505

Files:
  clang-tidy/readability/ElseAfterReturnCheck.cpp
  test/clang-tidy/readability-else-after-return.cpp


Index: test/clang-tidy/readability-else-after-return.cpp
===
--- test/clang-tidy/readability-else-after-return.cpp
+++ test/clang-tidy/readability-else-after-return.cpp
@@ -1,5 +1,16 @@
 // RUN: %check_clang_tidy %s readability-else-after-return %t -- -- -std=c++11 
-fexceptions
 
+namespace std {
+struct string {
+  string(const char *);
+  ~string();
+};
+}
+
+struct my_exception {
+  my_exception(const std::string &s);
+};
+
 void f(int a) {
   if (a > 0)
 return;
@@ -85,5 +96,12 @@
 // CHECK-FIXES: {{^}}} // comment-9
   x++;
 }
+if (x) {
+  throw my_exception("foo");
+} else { // comment-10
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not use 'else' after 'throw'
+// CHECK-FIXES: {{^}}} // comment-10
+  x++;
+}
   }
 }
Index: clang-tidy/readability/ElseAfterReturnCheck.cpp
===
--- clang-tidy/readability/ElseAfterReturnCheck.cpp
+++ clang-tidy/readability/ElseAfterReturnCheck.cpp
@@ -21,7 +21,8 @@
 void ElseAfterReturnCheck::registerMatchers(MatchFinder *Finder) {
   const auto ControlFlowInterruptorMatcher =
   stmt(anyOf(returnStmt().bind("return"), continueStmt().bind("continue"),
- breakStmt().bind("break"), cxxThrowExpr().bind("throw")));
+ breakStmt().bind("break"),
+ expr(ignoringImplicit(cxxThrowExpr().bind("throw");
   Finder->addMatcher(
   compoundStmt(forEach(
   ifStmt(hasThen(stmt(


Index: test/clang-tidy/readability-else-after-return.cpp
===
--- test/clang-tidy/readability-else-after-return.cpp
+++ test/clang-tidy/readability-else-after-return.cpp
@@ -1,5 +1,16 @@
 // RUN: %check_clang_tidy %s readability-else-after-return %t -- -- -std=c++11 -fexceptions
 
+namespace std {
+struct string {
+  string(const char *);
+  ~string();
+};
+}
+
+struct my_exception {
+  my_exception(const std::string &s);
+};
+
 void f(int a) {
   if (a > 0)
 return;
@@ -85,5 +96,12 @@
 // CHECK-FIXES: {{^}}} // comment-9
   x++;
 }
+if (x) {
+  throw my_exception("foo");
+} else { // comment-10
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not use 'else' after 'throw'
+// CHECK-FIXES: {{^}}} // comment-10
+  x++;
+}
   }
 }
Index: clang-tidy/readability/ElseAfterReturnCheck.cpp
===
--- clang-tidy/readability/ElseAfterReturnCheck.cpp
+++ clang-tidy/readability/ElseAfterReturnCheck.cpp
@@ -21,7 +21,8 @@
 void ElseAfterReturnCheck::registerMatchers(MatchFinder *Finder) {
   const auto ControlFlowInterruptorMatcher =
   stmt(anyOf(returnStmt().bind("return"), continueStmt().bind("continue"),
- breakStmt().bind("break"), cxxThrowExpr().bind("throw")));
+ breakStmt().bind("break"),
+ expr(ignoringImplicit(cxxThrowExpr().bind("throw");
   Finder->addMatcher(
   compoundStmt(forEach(
   ifStmt(hasThen(stmt(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40453: Add the nvidia-cuda-toolkit Debian package path to search path

2017-11-27 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

Debian packages don't update the PATH and we are aiming at providing packages 
working out of the box.

In general, yeah, we have to do that for every distros... :/


https://reviews.llvm.org/D40453



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


[PATCH] D39930: [CMake] Use libc++ and compiler-rt as default libraries in Fuchsia toolchain

2017-11-27 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

@phosek, I would love to see compiler-rt fully refactored so that we target one 
triple at a time always. I'd also love to see the clang driver refactored so 
that the code to resolve paths to runtime libraries was shared so we follow the 
same conventions across all driver implementations.

These are both large projects with a lot of stakeholders, and I don't expect 
that I'll be much use on it anytime soon.


Repository:
  rL LLVM

https://reviews.llvm.org/D39930



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


[PATCH] D40258: [CMake] Support side-by-side checkouts in multi-stage build

2017-11-27 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rL LLVM

https://reviews.llvm.org/D40258



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


[PATCH] D40280: [CMake][libcxx] Include AddLLVM needed for tests in the right context

2017-11-27 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rL LLVM

https://reviews.llvm.org/D40280



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


[PATCH] D40325: add new check to find OSSpinlock usage

2017-11-27 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added inline comments.



Comment at: clang-tidy/objc/AvoidSpinlockCheck.cpp:22-24
+  if (!getLangOpts().ObjC1 && !getLangOpts().ObjC2) {
+return;
+  }

Why? `OSSpinLock()` calls should also be avoided in C++.

I think you should remove this.




Comment at: clang-tidy/objc/AvoidSpinlockCheck.cpp:27
+  callExpr(
+  callee((functionDecl(matchesName("::OSSpinlock(Lock|Unlock|Try)")
+  .bind("spinlock"),

`matchesName()` uses a regular expression, and is many orders of magnitude 
slower than `hasAnyName(A, B, C)`.

Can you change to `hasAnyName()`, please?




Comment at: clang-tidy/objc/CMakeLists.txt:4
 add_clang_library(clangTidyObjCModule
+  AvoidSpinlockCheck.cpp
   ForbiddenSubclassingCheck.cpp

IMHO this is really a check which should apply to products built on Apple SDKs, 
not for Objective-C.

I don't know if that means we should move this to an `apple` submodule or if 
there is a better solution.

You don't have to move it in this review, but let's open up a discussion to 
figure out where non-ObjC checks should go.



Comment at: docs/clang-tidy/checks/objc-avoid-spinlock.rst:13
+- `OSSpinlockTry`
+- `OSSpinlockUnlcok`
+

Typo: Unlcok -> Unlock



https://reviews.llvm.org/D40325



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


[PATCH] D40453: Add the nvidia-cuda-toolkit Debian package path to search path

2017-11-27 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

In that case I don't see a way to be "clever", so we have to add the static 
candidate. I'll let @tra or @jlebar have a final look.


https://reviews.llvm.org/D40453



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


[PATCH] D40507: [clang-tidy] Move more checks from misc- to performance-

2017-11-27 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh created this revision.
Herald added subscribers: xazax.hun, mgorny.

rename_check.py misc-move-const-arg performance-move-const-arg
rename_check.py misc-noexcept-move-constructor 
performance-noexcept-move-constructor


https://reviews.llvm.org/D40507

Files:
  clang-tidy/hicpp/HICPPTidyModule.cpp
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/MoveConstantArgumentCheck.cpp
  clang-tidy/misc/MoveConstantArgumentCheck.h
  clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
  clang-tidy/misc/NoexceptMoveConstructorCheck.h
  clang-tidy/modernize/PassByValueCheck.cpp
  clang-tidy/performance/CMakeLists.txt
  clang-tidy/performance/MoveConstArgCheck.cpp
  clang-tidy/performance/MoveConstArgCheck.h
  clang-tidy/performance/NoexceptMoveConstructorCheck.cpp
  clang-tidy/performance/NoexceptMoveConstructorCheck.h
  clang-tidy/performance/PerformanceTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/hicpp-move-const-arg.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-move-const-arg.rst
  docs/clang-tidy/checks/misc-noexcept-move-constructor.rst
  docs/clang-tidy/checks/performance-move-const-arg.rst
  docs/clang-tidy/checks/performance-noexcept-move-constructor.rst
  test/clang-tidy/misc-move-const-arg.cpp
  test/clang-tidy/misc-noexcept-move-constructor.cpp
  test/clang-tidy/modernize-pass-by-value.cpp
  test/clang-tidy/performance-move-const-arg.cpp
  test/clang-tidy/performance-noexcept-move-constructor.cpp

Index: test/clang-tidy/performance-noexcept-move-constructor.cpp
===
--- test/clang-tidy/performance-noexcept-move-constructor.cpp
+++ test/clang-tidy/performance-noexcept-move-constructor.cpp
@@ -1,16 +1,18 @@
-// RUN: %check_clang_tidy %s misc-noexcept-move-constructor %t
+// RUN: %check_clang_tidy %s performance-noexcept-move-constructor %t
 
 class A {
   A(A &&);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: move constructors should be marked noexcept [misc-noexcept-move-constructor]
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: move constructors should be marked
+  // noexcept [performance-noexcept-move-constructor]
   A &operator=(A &&);
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: move assignment operators should
 };
 
 struct B {
   static constexpr bool kFalse = false;
   B(B &&) noexcept(kFalse);
-  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: noexcept specifier on the move constructor evaluates to 'false' [misc-noexcept-move-constructor]
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: noexcept specifier on the move
+  // constructor evaluates to 'false' [performance-noexcept-move-constructor]
 };
 
 class OK {};
@@ -24,16 +26,16 @@
  public:
   OK1();
   OK1(const OK1 &);
-  OK1(OK1&&) noexcept;
+  OK1(OK1 &&) noexcept;
   OK1 &operator=(OK1 &&) noexcept;
   void f();
   void g() noexcept;
 };
 
 class OK2 {
   static constexpr bool kTrue = true;
 
-public:
+ public:
   OK2(OK2 &&) noexcept(true) {}
   OK2 &operator=(OK2 &&) noexcept(kTrue) { return *this; }
 };
Index: test/clang-tidy/performance-move-const-arg.cpp
===
--- test/clang-tidy/performance-move-const-arg.cpp
+++ test/clang-tidy/performance-move-const-arg.cpp
@@ -1,73 +1,91 @@
-// RUN: %check_clang_tidy %s misc-move-const-arg %t
+// RUN: %check_clang_tidy %s performance-move-const-arg %t
 
 namespace std {
-template  struct remove_reference;
+template 
+struct remove_reference;
 
-template  struct remove_reference { typedef _Tp type; };
+template 
+struct remove_reference {
+  typedef _Tp type;
+};
 
-template  struct remove_reference<_Tp &> { typedef _Tp type; };
+template 
+struct remove_reference<_Tp &> {
+  typedef _Tp type;
+};
 
-template  struct remove_reference<_Tp &&> { typedef _Tp type; };
+template 
+struct remove_reference<_Tp &&> {
+  typedef _Tp type;
+};
 
 template 
 constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) {
   return static_cast::type &&>(__t);
 }
 
-} // namespace std
+}  // namespace std
 
 class A {
-public:
+ public:
   A() {}
   A(const A &rhs) {}
   A(A &&rhs) {}
 };
 
 int f1() {
   return std::move(42);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the expression of the trivially-copyable type 'int' has no effect; remove std::move() [misc-move-const-arg]
-  // CHECK-FIXES: return 42;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the expression of
+  // the trivially-copyable type 'int' has no effect; remove std::move()
+  // [performance-move-const-arg] CHECK-FIXES: return 42;
 }
 
 int f2(int x2) {
   return std::move(x2);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the variable 'x2' of the trivially-copyable type 'int'
-  // CHECK-FIXES: return x2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the variable 'x2' of
+  // the trivially-copyable type 'int' CHECK-FIXES: return x2;
 }
 
 int *f3(int *x3) {
   return std:

[PATCH] D40476: Switch kryo to use -mcpu=cortex-a57 when invoking the assembler

2017-11-27 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 124410.
pirama added a comment.

Address review comments.


https://reviews.llvm.org/D40476

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/as-mcpu.c


Index: test/Driver/as-mcpu.c
===
--- /dev/null
+++ test/Driver/as-mcpu.c
@@ -0,0 +1,10 @@
+// == Check that krait is substituted by cortex-a15 when 
invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=krait -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A15 %s
+// CHECK-CORTEX-A15: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a15
+
+// == Check that kryo is substituted by cortex-a57 when 
invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=kryo -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// CHECK-CORTEX-A57: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a57
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -653,22 +653,36 @@
 
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
 
-// FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -mcpu=cortex-a15 to avoid a lower
-// march from being picked in the absence of a cpu flag.
+// FIXME: remove krait and kryo checks when GNU tools support them.  For 
now
+// use -mcpu=cortex-a15 for krait and -mcpu=cortex-a57 for kryo
+// -mcpu=cortex-a57 to avoid a lower march from being picked in the absence
+// of a cpu flag.
 Arg *A;
-if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
-StringRef(A->getValue()).equals_lower("krait"))
-  CmdArgs.push_back("-mcpu=cortex-a15");
-else
-  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+if ((A= Args.getLastArg(options::OPT_mcpu_EQ))) {
+  StringRef CPUArg(A->getValue());
+  if(CPUArg.equals_lower("krait"))
+CmdArgs.push_back("-mcpu=cortex-a15");
+  else if(CPUArg.equals_lower("kryo"))
+CmdArgs.push_back("-mcpu=cortex-a57");
+  else
+Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+}
 Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ);
 break;
   }
   case llvm::Triple::aarch64:
   case llvm::Triple::aarch64_be: {
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
-Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+
+// FIXME: remove kryo check when GNU tools support them.  For now use
+// -mcpu=cortex-a57 to avoid a lower march from being picked in the absence
+// of a cpu flag.
+Arg *A;
+if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
+(StringRef(A->getValue()).equals_lower("kryo")))
+  CmdArgs.push_back("-mcpu=cortex-a57");
+else
+  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
 break;
   }
   case llvm::Triple::mips:


Index: test/Driver/as-mcpu.c
===
--- /dev/null
+++ test/Driver/as-mcpu.c
@@ -0,0 +1,10 @@
+// == Check that krait is substituted by cortex-a15 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=krait -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A15 %s
+// CHECK-CORTEX-A15: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a15
+
+// == Check that kryo is substituted by cortex-a57 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// CHECK-CORTEX-A57: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a57
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -653,22 +653,36 @@
 
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
 
-// FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -mcpu=cortex-a15 to avoid a lower
-// march from being picked in the absence of a cpu flag.
+// FIXME: remove krait and kryo checks when GNU tools support them.  For now
+// use -mcpu=cortex-a15 for krait and -mcpu=cortex-a57 for kryo
+// -mcpu=cortex-a57 to avoid a lower march from being picked in the absence
+// of a cpu flag.
 Arg *A;
-if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
-StringRef(A->getValue()).equals_lower("krait"))
-  CmdArgs.push_back("-mcpu=cortex-a15");
-else
-  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+if ((A= Args.getLastArg(options::OPT_mcpu_EQ))) {
+  StringRef CPUArg(A->getValue());
+  if(CPUArg.equ

[PATCH] D40505: [clang-tidy] Ignore ExprWithCleanups when looking for else-after-throw

2017-11-27 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

How about also matching on call to functions with no-return attribute?
i.e.

  [[noreturn]] my_die();
  void do_stuff();
  
  void fn(int x) {
if(!x)
  my_die();
else // <- since `my_die()` will never return, `else` is not really needed.
  do_stuff();
  }


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40505



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


[PATCH] D40476: Switch kryo to use -mcpu=cortex-a57 when invoking the assembler

2017-11-27 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 124412.
pirama added a comment.

Add missing space.


https://reviews.llvm.org/D40476

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/as-mcpu.c


Index: test/Driver/as-mcpu.c
===
--- /dev/null
+++ test/Driver/as-mcpu.c
@@ -0,0 +1,10 @@
+// == Check that krait is substituted by cortex-a15 when 
invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=krait -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A15 %s
+// CHECK-CORTEX-A15: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a15
+
+// == Check that kryo is substituted by cortex-a57 when 
invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=kryo -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// CHECK-CORTEX-A57: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a57
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -653,22 +653,36 @@
 
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
 
-// FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -mcpu=cortex-a15 to avoid a lower
-// march from being picked in the absence of a cpu flag.
+// FIXME: remove krait and kryo checks when GNU tools support them.  For 
now
+// use -mcpu=cortex-a15 for krait and -mcpu=cortex-a57 for kryo
+// -mcpu=cortex-a57 to avoid a lower march from being picked in the absence
+// of a cpu flag.
 Arg *A;
-if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
-StringRef(A->getValue()).equals_lower("krait"))
-  CmdArgs.push_back("-mcpu=cortex-a15");
-else
-  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+if ((A = Args.getLastArg(options::OPT_mcpu_EQ))) {
+  StringRef CPUArg(A->getValue());
+  if(CPUArg.equals_lower("krait"))
+CmdArgs.push_back("-mcpu=cortex-a15");
+  else if(CPUArg.equals_lower("kryo"))
+CmdArgs.push_back("-mcpu=cortex-a57");
+  else
+Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+}
 Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ);
 break;
   }
   case llvm::Triple::aarch64:
   case llvm::Triple::aarch64_be: {
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
-Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+
+// FIXME: remove kryo check when GNU tools support them.  For now use
+// -mcpu=cortex-a57 to avoid a lower march from being picked in the absence
+// of a cpu flag.
+Arg *A;
+if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
+(StringRef(A->getValue()).equals_lower("kryo")))
+  CmdArgs.push_back("-mcpu=cortex-a57");
+else
+  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
 break;
   }
   case llvm::Triple::mips:


Index: test/Driver/as-mcpu.c
===
--- /dev/null
+++ test/Driver/as-mcpu.c
@@ -0,0 +1,10 @@
+// == Check that krait is substituted by cortex-a15 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=krait -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A15 %s
+// CHECK-CORTEX-A15: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a15
+
+// == Check that kryo is substituted by cortex-a57 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// CHECK-CORTEX-A57: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a57
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -653,22 +653,36 @@
 
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
 
-// FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -mcpu=cortex-a15 to avoid a lower
-// march from being picked in the absence of a cpu flag.
+// FIXME: remove krait and kryo checks when GNU tools support them.  For now
+// use -mcpu=cortex-a15 for krait and -mcpu=cortex-a57 for kryo
+// -mcpu=cortex-a57 to avoid a lower march from being picked in the absence
+// of a cpu flag.
 Arg *A;
-if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
-StringRef(A->getValue()).equals_lower("krait"))
-  CmdArgs.push_back("-mcpu=cortex-a15");
-else
-  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+if ((A = Args.getLastArg(options::OPT_mcpu_EQ))) {
+  StringRef CPUArg(A->getValue());
+  if(CPUArg.equals_

[clang-tools-extra] r319062 - [clang-tidy] Rename qualified references to check class + support inconsistent names

2017-11-27 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon Nov 27 09:59:26 2017
New Revision: 319062

URL: http://llvm.org/viewvc/llvm-project?rev=319062&view=rev
Log:
[clang-tidy] Rename qualified references to check class + support inconsistent 
names

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

Modified: clang-tools-extra/trunk/clang-tidy/rename_check.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/rename_check.py?rev=319062&r1=319061&r2=319062&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/rename_check.py (original)
+++ clang-tools-extra/trunk/clang-tidy/rename_check.py Mon Nov 27 09:59:26 2017
@@ -184,12 +184,19 @@ def main():
   help='Old check name.')
   parser.add_argument('new_check_name', type=str,
   help='New check name.')
+  parser.add_argument('--check_class_name', type=str,
+  help='Old name of the class implementing the check.')
   args = parser.parse_args()
 
   old_module = args.old_check_name.split('-')[0]
   new_module = args.new_check_name.split('-')[0]
-  check_name_camel = ''.join(map(lambda elem: elem.capitalize(),
- args.old_check_name.split('-')[1:])) + 'Check'
+  if args.check_class_name:
+check_name_camel = args.check_class_name
+  else:
+check_name_camel = (''.join(map(lambda elem: elem.capitalize(),
+args.old_check_name.split('-')[1:])) +
+'Check')
+
   new_check_name_camel = (''.join(map(lambda elem: elem.capitalize(),
   args.new_check_name.split('-')[1:])) +
   'Check')
@@ -237,6 +244,10 @@ def main():
   args.new_check_name + '\n' + '=' * len(args.new_check_name) + '\n')
 
 replaceInFile(filename, args.old_check_name, args.new_check_name)
+replaceInFile(filename, old_module + '::' + check_name_camel,
+  new_module + '::' + new_check_name_camel)
+replaceInFile(filename, old_module + '/' + check_name_camel,
+  new_module + '/' + new_check_name_camel)
 replaceInFile(filename, check_name_camel, new_check_name_camel)
 
   if old_module != new_module:


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


[PATCH] D40508: Replace long type names in IR with hashes

2017-11-27 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff created this revision.
Herald added a subscriber: JDevlieghere.

If a source file extensively uses templates, resulting LLVM IR may have
types with huge names. It may occur if a record type is defined in a class.
In this case its type name contains all declaration contexts and, if a
declaration context is a class specialization, it is specified with
template parameters.

This change implements transformation of long IR type names. If name length
exceeds some limit, it is truncated and SHA1 hash of its full name is
appended to the obtained abbreviated name. Such solution could reduce memory
footprint and still keep names usable for identification.

To implement this algorithm functions PrintTemplateArgumentList were changed.
They try to make their output a valid C++ code. For this purpose they ensure
that digraph '<:' and tokens '>>' are not formed by inserting space between
characters. The implementation prints template arguments into a separate
stream and then put its content into 'uplevel' stream adding space before
and/or after the text if necessary. Such implementation prevents from using
special stream implementations because the intermediate stream is always of
the same type. To cope with this problem, a new flag in PrintingPolicy is
introduced, which turns off checks for undesirable character sequences. In
this case the intermediate stream becomes unneeded and printing occurs into
the same stream.


https://reviews.llvm.org/D40508

Files:
  include/clang/AST/PrettyPrinter.h
  include/clang/AST/Type.h
  lib/AST/ASTContext.cpp
  lib/AST/Decl.cpp
  lib/AST/DeclTemplate.cpp
  lib/AST/NestedNameSpecifier.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/TypePrinter.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  test/CodeGenCXX/template-types.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -4718,12 +4718,12 @@
 // If the type was explicitly written, use that.
 if (TypeSourceInfo *TSInfo = ClassSpec->getTypeAsWritten())
   return cxstring::createDup(TSInfo->getType().getAsString(Policy));
-
+
 SmallString<128> Str;
 llvm::raw_svector_ostream OS(Str);
 OS << *ClassSpec;
-TemplateSpecializationType::PrintTemplateArgumentList(
-OS, ClassSpec->getTemplateArgs().asArray(), Policy);
+printTemplateArgumentList(OS, ClassSpec->getTemplateArgs().asArray(),
+  Policy);
 return cxstring::createDup(OS.str());
   }
   
Index: test/CodeGenCXX/template-types.cpp
===
--- /dev/null
+++ test/CodeGenCXX/template-types.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++11 -triple i686-linux-gnu -S -emit-llvm %s -o - | FileCheck %s
+
+// Taken from the test pr29160.cpp
+template 
+struct Foo {
+  template 
+  static void ignore() {}
+  Foo() { ignore(); }
+  struct Inner {};
+};
+
+struct Base {
+  Base();
+  ~Base();
+};
+
+#define STAMP(thiz, prev) using thiz = Foo< \
+  prev, prev, prev, prev, prev, prev, prev, prev, prev, prev, prev, prev, \
+  prev, prev, prev, prev, prev, prev, prev, prev, prev, prev, prev, prev, \
+  prev, prev, prev, prev, prev, prev, prev, prev, prev, prev, prev, prev \
+  >;
+STAMP(A, Base);
+STAMP(B, A);
+STAMP(C, B);
+
+int main() {
+  C::Inner val_1;
+}
+
+// CHECK: %"struct.Foo TemplateArgsStr;
   llvm::raw_svector_ostream OS(TemplateArgsStr);
   Template->printName(OS);
-  TemplateSpecializationType::PrintTemplateArgumentList(
-  OS, Active->template_arguments(), getPrintingPolicy());
+  printTemplateArgumentList(OS, Active->template_arguments(),
+getPrintingPolicy());
   Diags.Report(Active->PointOfInstantiation,
diag::note_default_arg_instantiation_here)
 << OS.str()
@@ -562,8 +562,8 @@
   SmallVector TemplateArgsStr;
   llvm::raw_svector_ostream OS(TemplateArgsStr);
   FD->printName(OS);
-  TemplateSpecializationType::PrintTemplateArgumentList(
-  OS, Active->template_arguments(), getPrintingPolicy());
+  printTemplateArgumentList(OS, Active->template_arguments(),
+getPrintingPolicy());
   Diags.Report(Active->PointOfInstantiation,
diag::note_default_function_arg_instantiation_here)
 << OS.str()
Index: lib/CodeGen/CodeGenTypes.cpp
===
--- lib/CodeGen/CodeGenTypes.cpp
+++ lib/CodeGen/CodeGenTypes.cpp
@@ -26,6 +26,7 @@
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/Module.h"
+#include "llvm/Support/raw_abbrev_ostream.h"
 using namespace clang;
 using namespace CodeGen;
 
@@ -51,28 +52,38 @@
 void CodeGenTypes::addRecordTypeName(const RecordDecl *RD,

[PATCH] D40476: Switch kryo to use -mcpu=cortex-a57 when invoking the assembler

2017-11-27 Thread Stephen Hines via Phabricator via cfe-commits
srhines added inline comments.



Comment at: lib/Driver/ToolChains/Gnu.cpp:661
 Arg *A;
-if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
-StringRef(A->getValue()).equals_lower("krait"))
-  CmdArgs.push_back("-mcpu=cortex-a15");
-else
-  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+if ((A = Args.getLastArg(options::OPT_mcpu_EQ))) {
+  StringRef CPUArg(A->getValue());

Arg *A can also get moved here.


https://reviews.llvm.org/D40476



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


[PATCH] D40476: Switch kryo to use -mcpu=cortex-a57 when invoking the assembler

2017-11-27 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 124415.
pirama added a comment.

Sink 'Arg *' declaration.


https://reviews.llvm.org/D40476

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/as-mcpu.c


Index: test/Driver/as-mcpu.c
===
--- /dev/null
+++ test/Driver/as-mcpu.c
@@ -0,0 +1,10 @@
+// == Check that krait is substituted by cortex-a15 when 
invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=krait -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A15 %s
+// CHECK-CORTEX-A15: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a15
+
+// == Check that kryo is substituted by cortex-a57 when 
invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=kryo -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// CHECK-CORTEX-A57: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a57
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -653,22 +653,35 @@
 
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
 
-// FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -mcpu=cortex-a15 to avoid a lower
-// march from being picked in the absence of a cpu flag.
-Arg *A;
-if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
-StringRef(A->getValue()).equals_lower("krait"))
-  CmdArgs.push_back("-mcpu=cortex-a15");
-else
-  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+// FIXME: remove krait and kryo checks when GNU tools support them.  For 
now
+// use -mcpu=cortex-a15 for krait and -mcpu=cortex-a57 for kryo
+// -mcpu=cortex-a57 to avoid a lower march from being picked in the absence
+// of a cpu flag.
+if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
+  StringRef CPUArg(A->getValue());
+  if(CPUArg.equals_lower("krait"))
+CmdArgs.push_back("-mcpu=cortex-a15");
+  else if(CPUArg.equals_lower("kryo"))
+CmdArgs.push_back("-mcpu=cortex-a57");
+  else
+Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+}
 Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ);
 break;
   }
   case llvm::Triple::aarch64:
   case llvm::Triple::aarch64_be: {
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
-Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+
+// FIXME: remove kryo check when GNU tools support them.  For now use
+// -mcpu=cortex-a57 to avoid a lower march from being picked in the absence
+// of a cpu flag.
+Arg *A;
+if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
+(StringRef(A->getValue()).equals_lower("kryo")))
+  CmdArgs.push_back("-mcpu=cortex-a57");
+else
+  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
 break;
   }
   case llvm::Triple::mips:


Index: test/Driver/as-mcpu.c
===
--- /dev/null
+++ test/Driver/as-mcpu.c
@@ -0,0 +1,10 @@
+// == Check that krait is substituted by cortex-a15 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=krait -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A15 %s
+// CHECK-CORTEX-A15: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a15
+
+// == Check that kryo is substituted by cortex-a57 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// CHECK-CORTEX-A57: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a57
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -653,22 +653,35 @@
 
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
 
-// FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -mcpu=cortex-a15 to avoid a lower
-// march from being picked in the absence of a cpu flag.
-Arg *A;
-if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
-StringRef(A->getValue()).equals_lower("krait"))
-  CmdArgs.push_back("-mcpu=cortex-a15");
-else
-  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+// FIXME: remove krait and kryo checks when GNU tools support them.  For now
+// use -mcpu=cortex-a15 for krait and -mcpu=cortex-a57 for kryo
+// -mcpu=cortex-a57 to avoid a lower march from being picked in the absence
+// of a cpu flag.
+if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
+  StringRef CPUArg(A->getValue());
+  if(C

[PATCH] D40476: Switch kryo to use -mcpu=cortex-a57 when invoking the assembler

2017-11-27 Thread Chad Rosier via Phabricator via cfe-commits
mcrosier added a comment.

Am I correct in assuming this is going to be a problem for Falkor and Saphira 
as well?  If so, can you add solutions for those as well?  Cortex-a57 should be 
good enough for those targets as well.


https://reviews.llvm.org/D40476



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


[PATCH] D40108: [clang-tidy] Adding Fuchsia checkers to clang-tidy

2017-11-27 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/clang-tidy/checks/fuchsia-default-arguments.rst:6
+
+Warns if a function is declared or called with default arguments.
+

Please synchronize with text in Release Notes.


https://reviews.llvm.org/D40108



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


[PATCH] D40505: [clang-tidy] Ignore ExprWithCleanups when looking for else-after-throw

2017-11-27 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D40505#936170, @lebedev.ri wrote:

> How about also matching on call to functions with no-return attribute?


Great idea!

But I'll keep this patch for just the throw bugfix.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40505



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


[PATCH] D39571: [clangd] DidChangeConfiguration Notification

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



Comment at: test/clangd/did-change-configuration.test:33
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///compile_commands.json","languageId":"json","version":1,"text":"[\n{\n"directory":"/",\n"command":"/usr/bin/c++-DGTEST_HAS_RTTI=0-D_GNU_SOURCE-D__STDC_CONSTANT_MACROS-D__STDC_FORMAT_MACROS-D__STDC_LIMIT_MACROS-Ilib/Demangle-I../lib/Demangle-I/usr/include/libxml2-Iinclude-I../include-fPIC-fvisibility-inlines-hidden-Werror=date-time-std=c++11-Wall-W-Wno-unused-parameter-Wwrite-strings-Wcast-qual-Wno-missing-field-initializers-pedantic-Wno-long-long-Wno-maybe-uninitialized-Wdelete-non-virtual-dtor-Wno-comment-O0-g-fno-exceptions-fno-rtti-o/foo.c.o-c/foo.c",\n"file":"/foo.c"\n},"}}}
+

ilya-biryukov wrote:
> clangd won't see this file. `didOpen` only sets contents for diagnostics, not 
> any other features.
> You would rather want to add more `# RUN:` directives at the top of the file 
> to create `compile_commands.json`, etc.
> 
> Writing it under root ('/') is obviously not an option. Lit tests allow you 
> to use temporary paths, this is probably an approach you could take. See [[ 
> https://llvm.org/docs/TestingGuide.html#substitutions | lit docs ]] for more 
> details.
Are there examples available on how to use this? I have to use a # RUN: to 
create a file and then use it's path in a workspace/didChangeConfiguration 
notification?


https://reviews.llvm.org/D39571



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


[PATCH] D40476: Switch kryo to use -mcpu=cortex-a57 when invoking the assembler

2017-11-27 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 124417.
pirama added a comment.

Normalize falkor and saphira as well.


https://reviews.llvm.org/D40476

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/as-mcpu.c


Index: test/Driver/as-mcpu.c
===
--- /dev/null
+++ test/Driver/as-mcpu.c
@@ -0,0 +1,17 @@
+// == Check that krait is substituted by cortex-a15 when 
invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=krait -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A15 %s
+// CHECK-CORTEX-A15: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a15
+
+// == Check that kryo is substituted by cortex-a57 when 
invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=kryo -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+
+// RUN: %clang -target arm-linux -mcpu=falkor -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=falkor -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+
+// RUN: %clang -target arm-linux -mcpu=saphira -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=saphira -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+
+// CHECK-CORTEX-A57: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a57
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -42,6 +42,24 @@
  !O.hasFlag(options::DriverOption) && !O.hasFlag(options::LinkerInput);
 }
 
+// Switch CPU names not recognized by GNU assembler to a close CPU that it does
+// recognize, instead of a lower march from being picked in the absence of a 
cpu
+// flag.
+static void normalizeCPUNamesForAssembler(const ArgList &Args,
+  ArgStringList &CmdArgs) {
+  if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
+StringRef CPUArg(A->getValue());
+if (CPUArg.equals_lower("krait"))
+  CmdArgs.push_back("-mcpu=cortex-a15");
+else if(CPUArg.equals_lower("kryo") ||
+CPUArg.equals_lower("falkor") ||
+CPUArg.equals_lower("saphira"))
+  CmdArgs.push_back("-mcpu=cortex-a57");
+else
+  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+  }
+}
+
 void tools::gcc::Common::ConstructJob(Compilation &C, const JobAction &JA,
   const InputInfo &Output,
   const InputInfoList &Inputs,
@@ -652,23 +670,16 @@
 }
 
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
+normalizeCPUNamesForAssembler(Args, CmdArgs);
 
-// FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -mcpu=cortex-a15 to avoid a lower
-// march from being picked in the absence of a cpu flag.
-Arg *A;
-if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
-StringRef(A->getValue()).equals_lower("krait"))
-  CmdArgs.push_back("-mcpu=cortex-a15");
-else
-  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
 Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ);
 break;
   }
   case llvm::Triple::aarch64:
   case llvm::Triple::aarch64_be: {
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
-Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+normalizeCPUNamesForAssembler(Args, CmdArgs);
+
 break;
   }
   case llvm::Triple::mips:


Index: test/Driver/as-mcpu.c
===
--- /dev/null
+++ test/Driver/as-mcpu.c
@@ -0,0 +1,17 @@
+// == Check that krait is substituted by cortex-a15 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=krait -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A15 %s
+// CHECK-CORTEX-A15: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a15
+
+// == Check that kryo is substituted by cortex-a57 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+
+// RUN: %clang -target arm-linux -mcpu=falkor -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=falkor -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+
+// RUN: %clang -target arm-linux -mcpu=saphira -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang 

[PATCH] D40108: [clang-tidy] Adding Fuchsia checkers to clang-tidy

2017-11-27 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 124421.
juliehockett marked an inline comment as done.
juliehockett added a comment.

Updating docs


https://reviews.llvm.org/D40108

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/fuchsia/CMakeLists.txt
  clang-tidy/fuchsia/DefaultArgumentsCheck.cpp
  clang-tidy/fuchsia/DefaultArgumentsCheck.h
  clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/fuchsia-default-arguments.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/fuchsia-default-arguments.cpp

Index: test/clang-tidy/fuchsia-default-arguments.cpp
===
--- /dev/null
+++ test/clang-tidy/fuchsia-default-arguments.cpp
@@ -0,0 +1,81 @@
+// RUN: %check_clang_tidy %s fuchsia-default-arguments %t
+
+int foo(int value = 5) { return value; }
+// CHECK-MESSAGES: [[@LINE-1]]:9: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+// CHECK-FIXES: int foo(int value) { return value; }
+
+int f() {
+  foo();
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments]
+  // CHECK-NEXT: note: default parameter was declared here:
+  // CHECK-NEXT: int foo(int value = 5) { return value; }
+}
+
+int bar(int value) { return value; }
+
+int n() {
+  foo(0);
+  bar(0);
+}
+
+class Baz {
+public:
+  int a(int value = 5) { return value; }
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+  // CHECK-FIXES: int a(int value) { return value; }
+
+  int b(int value) { return value; }
+};
+
+class Foo {
+  // Fix should be suggested in declaration
+  int a(int value = 53);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+  // CHECK-FIXES: int a(int value);
+};
+
+// Fix shouldn't be suggested in implementation
+int Foo::a(int value) {
+  return value;
+}
+
+// Elided functions
+void f(int = 5) {};
+// CHECK-MESSAGES: [[@LINE-1]]:8: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+// CHECK-FIXES: void f(int) {};
+
+void g(int) {};
+
+// Should not suggest fix for macro-defined parameters
+#define D(val) = val
+
+void h(int i D(5));
+// CHECK-MESSAGES: [[@LINE-1]]:8: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+// CHECK-FIXES-NOT: void h(int i);
+
+void x(int i);
+void x(int i = 12);
+// CHECK-MESSAGES: [[@LINE-1]]:8: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+// CHECK-FIXES: void x(int i);
+
+void x(int i) {}
+
+struct S {
+  void x(int i);
+};
+
+void S::x(int i = 12) {}
+// CHECK-MESSAGES: [[@LINE-1]]:11: warning: declaring a parameter with a default argument is disallowed [fuchsia-default-arguments]
+// CHECK-FIXES: void S::x(int i) {}
+
+int main() {
+  S s;
+  s.x();
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments]
+  // CHECK-NEXT: note: default parameter was declared here:
+  // CHECK-NEXT: void S::x(int i = 12) {}
+  x();
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments]
+  // CHECK-NEXT: note: default parameter was declared here:
+  // CHECK-NEXT: void x(int i = 12);
+}
\ No newline at end of file
Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -61,6 +61,7 @@
 ``cert-``  Checks related to CERT Secure Coding Guidelines.
 ``cppcoreguidelines-`` Checks related to C++ Core Guidelines.
 ``clang-analyzer-``Clang Static Analyzer checks.
+``fuchsia-``   Checks related to Fuchsia coding conventions.
 ``google-``Checks related to Google coding conventions.
 ``hicpp-`` Checks related to High Integrity C++ Coding Standard.
 ``llvm-``  Checks related to the LLVM coding conventions.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -55,6 +55,7 @@
cppcoreguidelines-pro-type-vararg
cppcoreguidelines-slicing
cppcoreguidelines-special-member-functions
+   fuchsia-default-arguments
google-build-explicit-make-pair
google-build-namespaces
google-build-using-namespace
Index: docs/clang-tidy/checks/fuchsia-default-arguments.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/fuchsia-default-arguments.rst
@@ -0,0 +1,24 @@
+.. title:: clang-tidy - fuchsia-d

[PATCH] D39627: Fix vtable not receiving hidden visibility when using push(visibility)

2017-11-27 Thread Jake Ehrlich via Phabricator via cfe-commits
jakehehrlich updated this revision to Diff 124422.
jakehehrlich added a comment.

This test was failing on windows machines. I'm hoping this change (adding 
"_cc1" to "%clang") will resolve this because %clang_cc1 shouldn't behave any 
differently on windows.


Repository:
  rC Clang

https://reviews.llvm.org/D39627

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGVTT.cpp
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGen/push-hidden-visibility-subclass.cpp

Index: test/CodeGen/push-hidden-visibility-subclass.cpp
===
--- /dev/null
+++ test/CodeGen/push-hidden-visibility-subclass.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+#pragma GCC visibility push(hidden)
+
+struct Base {
+  virtual ~Base() = default;
+  virtual void* Alloc() = 0;
+};
+
+class Child : public Base {
+public:
+  Child() = default;
+  void* Alloc();
+};
+
+void test() {
+  Child x;
+}
+
+// CHECK: @_ZTV5Child = external hidden unnamed_addr constant
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -1527,7 +1527,7 @@
 VTable->setComdat(CGM.getModule().getOrInsertComdat(VTable->getName()));
 
   // Set the right visibility.
-  CGM.setGlobalVisibility(VTable, RD);
+  CGM.setGlobalVisibility(VTable, RD, ForDefinition);
 
   // Use pointer alignment for the vtable. Otherwise we would align them based
   // on the size of the initializer which doesn't make sense as only single
@@ -1637,6 +1637,7 @@
   VTable = CGM.CreateOrReplaceCXXRuntimeVariable(
   Name, VTableType, llvm::GlobalValue::ExternalLinkage);
   VTable->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
+  CGM.setGlobalVisibility(VTable, RD, NotForDefinition);
 
   if (RD->hasAttr())
 VTable->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -710,7 +710,8 @@
   llvm::ConstantInt *getSize(CharUnits numChars);
 
   /// Set the visibility for the given LLVM GlobalValue.
-  void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D) const;
+  void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D,
+   ForDefinition_t IsForDefinition) const;
 
   /// Set the TLS mode for the given LLVM GlobalValue for the thread-local
   /// variable declaration D.
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -662,16 +662,18 @@
 }
 
 void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV,
-const NamedDecl *D) const {
+const NamedDecl *D,
+ForDefinition_t IsForDefinition) const {
   // Internal definitions always have default visibility.
   if (GV->hasLocalLinkage()) {
 GV->setVisibility(llvm::GlobalValue::DefaultVisibility);
 return;
   }
 
   // Set visibility for definitions.
   LinkageInfo LV = D->getLinkageAndVisibility();
-  if (LV.isVisibilityExplicit() || !GV->hasAvailableExternallyLinkage())
+  if (LV.isVisibilityExplicit() ||
+  (IsForDefinition && !GV->hasAvailableExternallyLinkage()))
 GV->setVisibility(GetLLVMVisibility(LV.getVisibility()));
 }
 
@@ -1052,7 +1054,7 @@
 void CodeGenModule::SetCommonAttributes(const Decl *D,
 llvm::GlobalValue *GV) {
   if (const auto *ND = dyn_cast_or_null(D))
-setGlobalVisibility(GV, ND);
+setGlobalVisibility(GV, ND, ForDefinition);
   else
 GV->setVisibility(llvm::GlobalValue::DefaultVisibility);
 
@@ -1108,8 +1110,8 @@
   setNonAliasAttributes(D, F);
 }
 
-static void setLinkageAndVisibilityForGV(llvm::GlobalValue *GV,
- const NamedDecl *ND) {
+static void setLinkageForGV(llvm::GlobalValue *GV,
+const NamedDecl *ND) {
   // Set linkage and visibility in case we never see a definition.
   LinkageInfo LV = ND->getLinkageAndVisibility();
   if (!isExternallyVisible(LV.getLinkage())) {
@@ -1125,10 +1127,6 @@
   // separate linkage types for this.
   GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage);
 }
-
-// Set visibility on a declaration only if it's explicit.
-if (LV.isVisibilityExplicit())
-  GV->setVisibility(CodeGenModule::GetLLVMVisibility(LV.getVisibility()));
   }
 }
 
@@ -1197,7 +1195,8 @@
   // Only a few attributes are set on declarations; these may later be
   // overridden by a definition.
 
-  setLinkageAndVisibilityForGV(F, FD);
+  setLinkageForGV(F, FD);
+  setGlobalVisibility(F, FD, NotF

[libcxx] r319074 - Fix PR#35438 - bitset constructor does not zero unused bits

2017-11-27 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Nov 27 11:03:30 2017
New Revision: 319074

URL: http://llvm.org/viewvc/llvm-project?rev=319074&view=rev
Log:
Fix PR#35438 - bitset constructor does not zero unused bits

Modified:
libcxx/trunk/include/bitset

libcxx/trunk/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp

libcxx/trunk/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp

Modified: libcxx/trunk/include/bitset
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/bitset?rev=319074&r1=319073&r2=319074&view=diff
==
--- libcxx/trunk/include/bitset (original)
+++ libcxx/trunk/include/bitset Mon Nov 27 11:03:30 2017
@@ -503,7 +503,10 @@ template 
 inline
 _LIBCPP_CONSTEXPR
 __bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
-: __first_(static_cast<__storage_type>(__v))
+: __first_(
+_Size == __bits_per_word ? static_cast<__storage_type>(__v)
+ : static_cast<__storage_type>(__v) & 
((__storage_type(1) << _Size) - 1)
+)
 {
 }
 

Modified: 
libcxx/trunk/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp?rev=319074&r1=319073&r2=319074&view=diff
==
--- 
libcxx/trunk/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp
 Mon Nov 27 11:03:30 2017
@@ -36,11 +36,18 @@ void test_to_ullong()
 std::bitset v(j);
 assert(j == v.to_ullong());
 }
+{ // test values bigger than can fit into the bitset
+const unsigned long long val = 0xULL;
+const bool canFit = N < sizeof(unsigned long long) * CHAR_BIT;
+const unsigned long long mask = canFit ? (1ULL << N) - 1 : (unsigned long 
long)(-1);
+std::bitset v(val);
+assert(v.to_ullong() == (val & mask)); // we shouldn't return bit patterns 
from outside the limits of the bitset.
+}
 }
 
 int main()
 {
-test_to_ullong<0>();
+// test_to_ullong<0>();
 test_to_ullong<1>();
 test_to_ullong<31>();
 test_to_ullong<32>();

Modified: 
libcxx/trunk/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp?rev=319074&r1=319073&r2=319074&view=diff
==
--- 
libcxx/trunk/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp
 Mon Nov 27 11:03:30 2017
@@ -16,9 +16,12 @@
 #include 
 #include 
 
+#include 
+
 template 
 void test_to_ulong()
 {
+std::cout << "Testing size = " << N << std::endl;
 const std::size_t M = sizeof(unsigned long) * CHAR_BIT < N ? 
sizeof(unsigned long) * CHAR_BIT : N;
 const bool is_M_zero = std::integral_constant::value; // 
avoid compiler warnings
 const std::size_t X = is_M_zero ? sizeof(unsigned long) * CHAR_BIT - 1 : 
sizeof(unsigned long) * CHAR_BIT - M;
@@ -34,9 +37,18 @@ void test_to_ulong()
 for (std::size_t i = 0; i < sizeof(tests)/sizeof(tests[0]); ++i)
 {
 std::size_t j = tests[i];
+std::cout << "  Testing value = " << j << std::endl;
 std::bitset v(j);
 assert(j == v.to_ulong());
 }
+
+{ // test values bigger than can fit into the bitset
+const unsigned long val = 0xULL;
+const bool canFit = N < sizeof(unsigned long) * CHAR_BIT;
+const unsigned long mask = canFit ? (1ULL << N) - 1 : (unsigned long)(-1);
+std::bitset v(val);
+assert(v.to_ulong() == (val & mask)); // we shouldn't return bit patterns 
from outside the limits of the bitset.
+}
 }
 
 int main()


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


[PATCH] D40257: [CMake] Use LIST_SEPARATOR rather than escaping in ExternalProject_Add

2017-11-27 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

Can you please take a look at this one as well (this one is Clang, the other 
one was LLVM)?


Repository:
  rL LLVM

https://reviews.llvm.org/D40257



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


[PATCH] D40257: [CMake] Use LIST_SEPARATOR rather than escaping in ExternalProject_Add

2017-11-27 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rL LLVM

https://reviews.llvm.org/D40257



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


r319077 - Switch CPU names not recognized by GNU assembler

2017-11-27 Thread Pirama Arumuga Nainar via cfe-commits
Author: pirama
Date: Mon Nov 27 11:18:39 2017
New Revision: 319077

URL: http://llvm.org/viewvc/llvm-project?rev=319077&view=rev
Log:
Switch CPU names not recognized by GNU assembler

Summary:
Switch CPU names not recognized by GNU assembler to a close CPU that it
does recognize.  In this patch, kryo, falkor and saphira all get
replaced by cortex-a57 when invoking the assembler.  In addition, krait
was already being replaced by cortex-a15.

Reviewers: weimingz

Subscribers: srhines, cfe-commits

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

Added:
cfe/trunk/test/Driver/as-mcpu.c
Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=319077&r1=319076&r2=319077&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Mon Nov 27 11:18:39 2017
@@ -42,6 +42,24 @@ static bool forwardToGCC(const Option &O
  !O.hasFlag(options::DriverOption) && !O.hasFlag(options::LinkerInput);
 }
 
+// Switch CPU names not recognized by GNU assembler to a close CPU that it does
+// recognize, instead of a lower march from being picked in the absence of a 
cpu
+// flag.
+static void normalizeCPUNamesForAssembler(const ArgList &Args,
+  ArgStringList &CmdArgs) {
+  if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
+StringRef CPUArg(A->getValue());
+if (CPUArg.equals_lower("krait"))
+  CmdArgs.push_back("-mcpu=cortex-a15");
+else if(CPUArg.equals_lower("kryo") ||
+CPUArg.equals_lower("falkor") ||
+CPUArg.equals_lower("saphira"))
+  CmdArgs.push_back("-mcpu=cortex-a57");
+else
+  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+  }
+}
+
 void tools::gcc::Common::ConstructJob(Compilation &C, const JobAction &JA,
   const InputInfo &Output,
   const InputInfoList &Inputs,
@@ -652,23 +670,16 @@ void tools::gnutools::Assembler::Constru
 }
 
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
+normalizeCPUNamesForAssembler(Args, CmdArgs);
 
-// FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -mcpu=cortex-a15 to avoid a lower
-// march from being picked in the absence of a cpu flag.
-Arg *A;
-if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
-StringRef(A->getValue()).equals_lower("krait"))
-  CmdArgs.push_back("-mcpu=cortex-a15");
-else
-  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
 Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ);
 break;
   }
   case llvm::Triple::aarch64:
   case llvm::Triple::aarch64_be: {
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
-Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+normalizeCPUNamesForAssembler(Args, CmdArgs);
+
 break;
   }
   case llvm::Triple::mips:

Added: cfe/trunk/test/Driver/as-mcpu.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/as-mcpu.c?rev=319077&view=auto
==
--- cfe/trunk/test/Driver/as-mcpu.c (added)
+++ cfe/trunk/test/Driver/as-mcpu.c Mon Nov 27 11:18:39 2017
@@ -0,0 +1,17 @@
+// == Check that krait is substituted by cortex-a15 when 
invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=krait -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A15 %s
+// CHECK-CORTEX-A15: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a15
+
+// == Check that kryo is substituted by cortex-a57 when 
invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=kryo -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+
+// RUN: %clang -target arm-linux -mcpu=falkor -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=falkor -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+
+// RUN: %clang -target arm-linux -mcpu=saphira -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=saphira -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+
+// CHECK-CORTEX-A57: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a57


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


[PATCH] D40476: Switch kryo to use -mcpu=cortex-a57 when invoking the assembler

2017-11-27 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319077: Switch CPU names not recognized by GNU assembler 
(authored by pirama).

Repository:
  rL LLVM

https://reviews.llvm.org/D40476

Files:
  cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
  cfe/trunk/test/Driver/as-mcpu.c


Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
@@ -42,6 +42,24 @@
  !O.hasFlag(options::DriverOption) && !O.hasFlag(options::LinkerInput);
 }
 
+// Switch CPU names not recognized by GNU assembler to a close CPU that it does
+// recognize, instead of a lower march from being picked in the absence of a 
cpu
+// flag.
+static void normalizeCPUNamesForAssembler(const ArgList &Args,
+  ArgStringList &CmdArgs) {
+  if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
+StringRef CPUArg(A->getValue());
+if (CPUArg.equals_lower("krait"))
+  CmdArgs.push_back("-mcpu=cortex-a15");
+else if(CPUArg.equals_lower("kryo") ||
+CPUArg.equals_lower("falkor") ||
+CPUArg.equals_lower("saphira"))
+  CmdArgs.push_back("-mcpu=cortex-a57");
+else
+  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+  }
+}
+
 void tools::gcc::Common::ConstructJob(Compilation &C, const JobAction &JA,
   const InputInfo &Output,
   const InputInfoList &Inputs,
@@ -652,23 +670,16 @@
 }
 
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
+normalizeCPUNamesForAssembler(Args, CmdArgs);
 
-// FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -mcpu=cortex-a15 to avoid a lower
-// march from being picked in the absence of a cpu flag.
-Arg *A;
-if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
-StringRef(A->getValue()).equals_lower("krait"))
-  CmdArgs.push_back("-mcpu=cortex-a15");
-else
-  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
 Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ);
 break;
   }
   case llvm::Triple::aarch64:
   case llvm::Triple::aarch64_be: {
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
-Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+normalizeCPUNamesForAssembler(Args, CmdArgs);
+
 break;
   }
   case llvm::Triple::mips:
Index: cfe/trunk/test/Driver/as-mcpu.c
===
--- cfe/trunk/test/Driver/as-mcpu.c
+++ cfe/trunk/test/Driver/as-mcpu.c
@@ -0,0 +1,17 @@
+// == Check that krait is substituted by cortex-a15 when 
invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=krait -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A15 %s
+// CHECK-CORTEX-A15: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a15
+
+// == Check that kryo is substituted by cortex-a57 when 
invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=kryo -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+
+// RUN: %clang -target arm-linux -mcpu=falkor -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=falkor -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+
+// RUN: %clang -target arm-linux -mcpu=saphira -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=saphira -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+
+// CHECK-CORTEX-A57: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a57


Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
@@ -42,6 +42,24 @@
  !O.hasFlag(options::DriverOption) && !O.hasFlag(options::LinkerInput);
 }
 
+// Switch CPU names not recognized by GNU assembler to a close CPU that it does
+// recognize, instead of a lower march from being picked in the absence of a cpu
+// flag.
+static void normalizeCPUNamesForAssembler(const ArgList &Args,
+  ArgStringList &CmdArgs) {
+  if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
+StringRef CPUArg(A->getValue());
+if (CPUArg.equals_lower("krait"))
+  CmdArgs.push_back("-mcpu=cortex-a15");
+else if(CPUArg.equals_lower("kryo") ||
+CPUArg.equals_lower("falkor") ||
+CPUArg.equals_lower("saphira"))
+  CmdArgs.push_back("-mcpu=cortex-a57");
+else
+  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+  }
+}
+

[PATCH] D40476: Switch kryo to use -mcpu=cortex-a57 when invoking the assembler

2017-11-27 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

Thanks for the review.  Now let's just hope the windows bots stay happy :)


Repository:
  rL LLVM

https://reviews.llvm.org/D40476



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


  1   2   >