r262205 - [index] Use ',' to separate symbol roles when printing.

2016-02-29 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Mon Feb 29 01:55:51 2016
New Revision: 262205

URL: http://llvm.org/viewvc/llvm-project?rev=262205&view=rev
Log:
[index] Use ',' to separate symbol roles when printing.

Modified:
cfe/trunk/lib/Index/IndexSymbol.cpp
cfe/trunk/test/Index/Core/index-source.cpp
cfe/trunk/test/Index/Core/index-source.m

Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=262205&r1=262204&r2=262205&view=diff
==
--- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
+++ cfe/trunk/lib/Index/IndexSymbol.cpp Mon Feb 29 01:55:51 2016
@@ -214,7 +214,7 @@ void index::printSymbolRoles(SymbolRoleS
   bool VisitedOnce = false;
   applyForEachSymbolRole(Roles, [&](SymbolRole Role) {
 if (VisitedOnce)
-  OS << '/';
+  OS << ',';
 else
   VisitedOnce = true;
 switch (Role) {

Modified: cfe/trunk/test/Index/Core/index-source.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.cpp?rev=262205&r1=262204&r2=262205&view=diff
==
--- cfe/trunk/test/Index/Core/index-source.cpp (original)
+++ cfe/trunk/test/Index/Core/index-source.cpp Mon Feb 29 01:55:51 2016
@@ -4,6 +4,6 @@ template 
 class TemplCls {
 // CHECK: [[@LINE-1]]:7 | c++-class/C++ | TemplCls | c:@ST>1#T@TemplCls | 
 | Def | rel: 0
   TemplCls(int x);
-  // CHECK: [[@LINE-1]]:3 | constructor/C++ | TemplCls | 
c:@ST>1#T@TemplCls@F@TemplCls#I# |  | Decl/RelChild | rel: 1
+  // CHECK: [[@LINE-1]]:3 | constructor/C++ | TemplCls | 
c:@ST>1#T@TemplCls@F@TemplCls#I# |  | Decl,RelChild | rel: 1
   // CHECK-NEXT: RelChild | TemplCls | c:@ST>1#T@TemplCls
 };

Modified: cfe/trunk/test/Index/Core/index-source.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.m?rev=262205&r1=262204&r2=262205&view=diff
==
--- cfe/trunk/test/Index/Core/index-source.m (original)
+++ cfe/trunk/test/Index/Core/index-source.m Mon Feb 29 01:55:51 2016
@@ -3,6 +3,6 @@
 @interface Base
 // CHECK: [[@LINE-1]]:12 | objc-class/ObjC | Base | c:objc(cs)Base | 
_OBJC_CLASS_$_Base | Decl | rel: 0
 -(void)meth;
-// CHECK: [[@LINE-1]]:1 | objc-instance-method/ObjC | meth | 
c:objc(cs)Base(im)meth | -[Base meth] | Decl/Dyn/RelChild | rel: 1
+// CHECK: [[@LINE-1]]:1 | objc-instance-method/ObjC | meth | 
c:objc(cs)Base(im)meth | -[Base meth] | Decl,Dyn,RelChild | rel: 1
 // CHECK-NEXT: RelChild | Base | c:objc(cs)Base
 @end


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


r262208 - [index] Print and test module import references.

2016-02-29 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Mon Feb 29 01:56:07 2016
New Revision: 262208

URL: http://llvm.org/viewvc/llvm-project?rev=262208&view=rev
Log:
[index] Print and test module import references.

Added:
cfe/trunk/test/Index/Core/Inputs/
cfe/trunk/test/Index/Core/Inputs/module/
cfe/trunk/test/Index/Core/Inputs/module/ModA.h
cfe/trunk/test/Index/Core/Inputs/module/module.modulemap
cfe/trunk/test/Index/Core/index-with-module.m
Modified:
cfe/trunk/lib/Index/IndexSymbol.cpp
cfe/trunk/lib/Index/IndexingContext.cpp
cfe/trunk/tools/c-index-test/core_main.cpp

Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=262208&r1=262207&r2=262208&view=diff
==
--- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
+++ cfe/trunk/lib/Index/IndexSymbol.cpp Mon Feb 29 01:56:07 2016
@@ -53,6 +53,9 @@ SymbolInfo index::getSymbolInfo(const De
 
   } else {
 switch (D->getKind()) {
+case Decl::Import:
+  Info.Kind = SymbolKind::Module;
+  break;
 case Decl::Typedef:
   Info.Kind = SymbolKind::Typedef; break;
 case Decl::Function:

Modified: cfe/trunk/lib/Index/IndexingContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexingContext.cpp?rev=262208&r1=262207&r2=262208&view=diff
==
--- cfe/trunk/lib/Index/IndexingContext.cpp (original)
+++ cfe/trunk/lib/Index/IndexingContext.cpp Mon Feb 29 01:56:07 2016
@@ -58,7 +58,12 @@ bool IndexingContext::handleReference(co
 }
 
 bool IndexingContext::importedModule(const ImportDecl *ImportD) {
-  SourceLocation Loc = ImportD->getLocation();
+  SourceLocation Loc;
+  auto IdLocs = ImportD->getIdentifierLocs();
+  if (!IdLocs.empty())
+Loc = IdLocs.front();
+  else
+Loc = ImportD->getLocation();
   SourceManager &SM = Ctx->getSourceManager();
   Loc = SM.getFileLoc(Loc);
   if (Loc.isInvalid())
@@ -85,7 +90,7 @@ bool IndexingContext::importedModule(con
 }
   }
 
-  SymbolRoleSet Roles{};
+  SymbolRoleSet Roles = (unsigned)SymbolRole::Reference;
   if (ImportD->isImplicit())
 Roles |= (unsigned)SymbolRole::Implicit;
 

Added: cfe/trunk/test/Index/Core/Inputs/module/ModA.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/Inputs/module/ModA.h?rev=262208&view=auto
==
--- cfe/trunk/test/Index/Core/Inputs/module/ModA.h (added)
+++ cfe/trunk/test/Index/Core/Inputs/module/ModA.h Mon Feb 29 01:56:07 2016
@@ -0,0 +1,2 @@
+
+void ModA_func(void);

Added: cfe/trunk/test/Index/Core/Inputs/module/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/Inputs/module/module.modulemap?rev=262208&view=auto
==
--- cfe/trunk/test/Index/Core/Inputs/module/module.modulemap (added)
+++ cfe/trunk/test/Index/Core/Inputs/module/module.modulemap Mon Feb 29 
01:56:07 2016
@@ -0,0 +1 @@
+module ModA { header "ModA.h" export * }

Added: cfe/trunk/test/Index/Core/index-with-module.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-with-module.m?rev=262208&view=auto
==
--- cfe/trunk/test/Index/Core/index-with-module.m (added)
+++ cfe/trunk/test/Index/Core/index-with-module.m Mon Feb 29 01:56:07 2016
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t.mcp
+// RUN: c-index-test core -print-source-symbols -- %s -I %S/Inputs/module 
-fmodules -fmodules-cache-path=%t.mcp | FileCheck %s
+
+// CHECK: [[@LINE+1]]:9 | module/C | ModA | Ref |
+@import ModA;
+// CHECK: [[@LINE+1]]:1 | module/C | ModA | Ref,Impl |
+#include "ModA.h"
+
+void foo() {
+  // CHECK: [[@LINE+1]]:3 | function/C | ModA_func | c:@F@ModA_func | {{.*}} | 
Ref,Call,RelCall | rel: 1
+  ModA_func();
+}
\ No newline at end of file

Modified: cfe/trunk/tools/c-index-test/core_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/core_main.cpp?rev=262208&r1=262207&r2=262208&view=diff
==
--- cfe/trunk/tools/c-index-test/core_main.cpp (original)
+++ cfe/trunk/tools/c-index-test/core_main.cpp Mon Feb 29 01:56:07 2016
@@ -107,6 +107,26 @@ public:
 
 return true;
   }
+
+  bool handleModuleOccurence(const ImportDecl *ImportD, SymbolRoleSet Roles,
+ FileID FID, unsigned Offset) override {
+ASTContext &Ctx = ImportD->getASTContext();
+SourceManager &SM = Ctx.getSourceManager();
+
+unsigned Line = SM.getLineNumber(FID, Offset);
+unsigned Col = SM.getColumnNumber(FID, Offset);
+OS << Line << ':' << Col << " | ";
+
+printSymbolInfo(getSymbolInfo(ImportD), OS);
+OS << " | ";
+
+OS << ImportD->getImportedModule()->getFullModuleName()

r262206 - [AST/RecursiveASTVisitor] Correction so that dataTraverseStmtPost will get called after the statement has been visited.

2016-02-29 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Mon Feb 29 01:55:55 2016
New Revision: 262206

URL: http://llvm.org/viewvc/llvm-project?rev=262206&view=rev
Log:
[AST/RecursiveASTVisitor] Correction so that dataTraverseStmtPost will get 
called after the statement has been visited.

Fixes the indexing client of this.

Modified:
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/test/Index/Core/index-source.m

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=262206&r1=262205&r2=262206&view=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Mon Feb 29 01:55:55 2016
@@ -139,7 +139,9 @@ public:
   /// Parameters involving this type are used to implement data
   /// recursion over Stmts and Exprs within this class, and should
   /// typically not be explicitly specified by derived classes.
-  typedef SmallVectorImpl DataRecursionQueue;
+  /// The bool bit indicates whether the statement has been traversed or not.
+  typedef SmallVectorImpl>
+DataRecursionQueue;
 
   /// \brief Return a reference to the derived class.
   Derived &getDerived() { return *static_cast(this); }
@@ -561,23 +563,32 @@ bool RecursiveASTVisitor::Trave
 return true;
 
   if (Queue) {
-Queue->push_back(S);
+Queue->push_back({S, false});
 return true;
   }
 
-  SmallVector LocalQueue;
-  LocalQueue.push_back(S);
+  SmallVector, 8> LocalQueue;
+  LocalQueue.push_back({S, false});
 
   while (!LocalQueue.empty()) {
-Stmt *CurrS = LocalQueue.pop_back_val();
+auto &CurrSAndVisited = LocalQueue.back();
+Stmt *CurrS = CurrSAndVisited.getPointer();
+bool Visited = CurrSAndVisited.getInt();
+if (Visited) {
+  LocalQueue.pop_back();
+  TRY_TO(dataTraverseStmtPost(CurrS));
+  continue;
+}
 
-size_t N = LocalQueue.size();
 if (getDerived().dataTraverseStmtPre(CurrS)) {
+  CurrSAndVisited.setInt(true);
+  size_t N = LocalQueue.size();
   TRY_TO(dataTraverseNode(CurrS, &LocalQueue));
-  TRY_TO(dataTraverseStmtPost(CurrS));
+  // Process new children in the order they were added.
+  std::reverse(LocalQueue.begin() + N, LocalQueue.end());
+} else {
+  LocalQueue.pop_back();
 }
-// Process new children in the order they were added.
-std::reverse(LocalQueue.begin() + N, LocalQueue.end());
   }
 
   return true;

Modified: cfe/trunk/test/Index/Core/index-source.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.m?rev=262206&r1=262205&r2=262206&view=diff
==
--- cfe/trunk/test/Index/Core/index-source.m (original)
+++ cfe/trunk/test/Index/Core/index-source.m Mon Feb 29 01:55:55 2016
@@ -6,3 +6,13 @@
 // CHECK: [[@LINE-1]]:1 | objc-instance-method/ObjC | meth | 
c:objc(cs)Base(im)meth | -[Base meth] | Decl,Dyn,RelChild | rel: 1
 // CHECK-NEXT: RelChild | Base | c:objc(cs)Base
 @end
+
+void foo();
+// CHECK: [[@LINE+1]]:6 | function/C | goo | c:@F@goo | _goo | Def | rel: 0
+void goo(Base *b) {
+  // CHECK: [[@LINE+1]]:3 | function/C | foo | c:@F@foo | _foo | Ref,Call | 
rel: 0
+  foo();
+  // CHECK: [[@LINE+2]]:6 | objc-instance-method/ObjC | meth | 
c:objc(cs)Base(im)meth | -[Base meth] | Ref,Call,Dyn,RelRec | rel: 1
+  // CHECK-NEXT: RelRec | Base | c:objc(cs)Base
+  [b meth];
+}


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


r262207 - [index] Add a caller relation for a call reference.

2016-02-29 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Mon Feb 29 01:56:00 2016
New Revision: 262207

URL: http://llvm.org/viewvc/llvm-project?rev=262207&view=rev
Log:
[index] Add a caller relation for a call reference.

Modified:
cfe/trunk/include/clang/Index/IndexSymbol.h
cfe/trunk/lib/Index/IndexBody.cpp
cfe/trunk/lib/Index/IndexSymbol.cpp
cfe/trunk/test/Index/Core/index-source.m

Modified: cfe/trunk/include/clang/Index/IndexSymbol.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/IndexSymbol.h?rev=262207&r1=262206&r2=262207&view=diff
==
--- cfe/trunk/include/clang/Index/IndexSymbol.h (original)
+++ cfe/trunk/include/clang/Index/IndexSymbol.h Mon Feb 29 01:56:00 2016
@@ -88,8 +88,9 @@ enum class SymbolRole : uint16_t {
   RelationBaseOf  = 1 << 10,
   RelationOverrideOf  = 1 << 11,
   RelationReceivedBy  = 1 << 12,
+  RelationCalledBy= 1 << 13,
 };
-static const unsigned SymbolRoleBitNum = 13;
+static const unsigned SymbolRoleBitNum = 14;
 typedef unsigned SymbolRoleSet;
 
 /// Represents a relation to another symbol for a symbol occurrence.

Modified: cfe/trunk/lib/Index/IndexBody.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexBody.cpp?rev=262207&r1=262206&r2=262207&view=diff
==
--- cfe/trunk/lib/Index/IndexBody.cpp (original)
+++ cfe/trunk/lib/Index/IndexBody.cpp Mon Feb 29 01:56:00 2016
@@ -88,7 +88,7 @@ public:
 
 } else if (auto CE = dyn_cast(Parent)) {
   if (CE->getCallee()->IgnoreParenCasts() == E) {
-Roles |= (unsigned)SymbolRole::Call;
+addCallRole(Roles, Relations);
 if (auto *ME = dyn_cast(E)) {
   if (auto *CXXMD = 
dyn_cast_or_null(ME->getMemberDecl()))
 if (CXXMD->isVirtual() && !ME->hasQualifier()) {
@@ -120,6 +120,15 @@ public:
 return Roles;
   }
 
+  void addCallRole(SymbolRoleSet &Roles,
+   SmallVectorImpl &Relations) {
+Roles |= (unsigned)SymbolRole::Call;
+if (auto *FD = dyn_cast(ParentDC))
+  Relations.emplace_back((unsigned)SymbolRole::RelationCalledBy, FD);
+else if (auto *MD = dyn_cast(ParentDC))
+  Relations.emplace_back((unsigned)SymbolRole::RelationCalledBy, MD);
+  }
+
   bool VisitDeclRefExpr(DeclRefExpr *E) {
 SmallVector Relations;
 SymbolRoleSet Roles = getRolesForRef(E, Relations);
@@ -169,11 +178,12 @@ public:
 };
 
 if (ObjCMethodDecl *MD = E->getMethodDecl()) {
-  SymbolRoleSet Roles = (unsigned)SymbolRole::Call;
+  SymbolRoleSet Roles{};
+  SmallVector Relations;
+  addCallRole(Roles, Relations);
   if (E->isImplicit())
 Roles |= (unsigned)SymbolRole::Implicit;
 
-  SmallVector Relations;
   if (isDynamic(E)) {
 Roles |= (unsigned)SymbolRole::Dynamic;
 if (auto *RecD = E->getReceiverInterface())
@@ -206,39 +216,42 @@ public:
 Parent, ParentDC, SymbolRoleSet(), {}, E);
   }
 
+  bool passObjCLiteralMethodCall(const ObjCMethodDecl *MD, const Expr *E) {
+SymbolRoleSet Roles{};
+SmallVector Relations;
+addCallRole(Roles, Relations);
+Roles |= (unsigned)SymbolRole::Implicit;
+return IndexCtx.handleReference(MD, E->getLocStart(),
+Parent, ParentDC, Roles, Relations, E);
+  }
+
   bool VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
 if (ObjCMethodDecl *MD = E->getBoxingMethod()) {
-  SymbolRoleSet Roles = (unsigned)SymbolRole::Call;
-  Roles |= (unsigned)SymbolRole::Implicit;
-  return IndexCtx.handleReference(MD, E->getLocStart(),
-  Parent, ParentDC, Roles, {}, E);
+  return passObjCLiteralMethodCall(MD, E);
 }
 return true;
   }
   
   bool VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
 if (ObjCMethodDecl *MD = E->getDictWithObjectsMethod()) {
-  SymbolRoleSet Roles = (unsigned)SymbolRole::Call;
-  Roles |= (unsigned)SymbolRole::Implicit;
-  return IndexCtx.handleReference(MD, E->getLocStart(),
-  Parent, ParentDC, Roles, {}, E);
+  return passObjCLiteralMethodCall(MD, E);
 }
 return true;
   }
 
   bool VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
 if (ObjCMethodDecl *MD = E->getArrayWithObjectsMethod()) {
-  SymbolRoleSet Roles = (unsigned)SymbolRole::Call;
-  Roles |= (unsigned)SymbolRole::Implicit;
-  return IndexCtx.handleReference(MD, E->getLocStart(),
-  Parent, ParentDC, Roles, {}, E);
+  return passObjCLiteralMethodCall(MD, E);
 }
 return true;
   }
 
   bool VisitCXXConstructExpr(CXXConstructExpr *E) {
+SymbolRoleSet Roles{};
+SmallVector Relations;
+addCallRole(Roles, Relations);
 return IndexCtx.handleReference(E->getConstructor(), E->getLocation(),
-Parent, ParentDC, 
(unsigned

Re: [PATCH] D14286: ASTImporter: expressions, pt.1

2016-02-29 Thread Aleksei Sidorin via cfe-commits
a.sidorin added a comment.

Serge: Sorry, that's because I forgot to add a dependence. There should be a 
patch implementing these matchers.


Repository:
  rL LLVM

http://reviews.llvm.org/D14286



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


Re: [PATCH] D17704: Added interfaces for code-formatting while applying replacements.

2016-02-29 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: include/clang/Tooling/Core/Replacement.h:227-232
@@ -222,1 +226,8 @@
 
+/// \brief Applies all replacements in \p Replaces to \p Code.
+///
+/// This completely ignores the path stored in each replacement. If one or more
+/// replacements cannot be applied, this returns an empty \c string.
+std::string applyAllReplacements(StringRef Code,
+ const std::vector &Replaces);
+

I think we'll need to mainly call out the differences to the function above in 
the comment.


Comment at: include/clang/Tooling/Core/Replacement.h:241-243
@@ +240,5 @@
+/// replacements.
+tooling::Replacements formatReplacements(const format::FormatStyle &Style,
+ StringRef Code,
+ const tooling::Replacements 
&Replaces);
+

I'd probably put the Style parameter last.


Comment at: lib/Tooling/Core/Replacement.cpp:14-16
@@ -13,3 +13,5 @@
 
+#include "clang/Tooling/Core/Replacement.h"
+#include 
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticIDs.h"

Nit: I'd put newlines between the #include groups here.


Comment at: lib/Tooling/Core/Replacement.cpp:292
@@ +291,3 @@
+  std::vector ChangedRanges = calculateChangedRanges(Replaces);
+  StringRef FileName = Replaces.begin()->getFilePath();
+  tooling::Replacements FormatReplaces =

We'll either want to assert that !Replaces.empty() (and document that in the 
function comment), or do an early exit if that's the case.


Comment at: lib/Tooling/Core/Replacement.cpp:304
@@ +303,3 @@
+
+  // Generate the new ranges from the replacements.
+  int Shift = 0;

This comment doesn't carry it's weight, I think. I'd delete it.


Comment at: lib/Tooling/Core/Replacement.cpp:315-317
@@ +314,5 @@
+
+bool applyAllReplacementsAndFormat(const format::FormatStyle &Style,
+  const Replacements &Replaces,
+  Rewriter &Rewrite) {
+  SourceManager &SM = Rewrite.getSourceMgr();

I think we'll want to cut that out for now and implement it so that it works 
for arbitrary sets of replacements in a follow-up cl.


Comment at: lib/Tooling/Core/Replacement.cpp:337
@@ +336,3 @@
+  const Replacements &Replaces) {
+  if (Replaces.empty()) return Code;
+

If the inner functions handle this case correctly, we don't need to handle it 
here.


Comment at: unittests/Tooling/RefactoringTest.cpp:171-177
@@ +170,9 @@
+TEST_F(ReplacementTest, FormatCodeAfterReplacements) {
+  std::string Code = "MyType012345678901234567890123456789 *a =\n"
+ "new MyType012345678901234567890123456789();\n"
+ "g(iii, 0, "
+ "jjj,\n"
+ "  0, kkk, 0, "
+ "mmm);\n"
+ "int  bad = format   ;";
+  std::string Expected =

If you want to test that breaks happen, it's often better to use a 
configuration with a smaller column limit.


http://reviews.llvm.org/D17704



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


Re: [PATCH] D17286: Make FreeBSD and NetBSD use CLANG_DEFAULT_CXX_STDLIB

2016-02-29 Thread Jonas Hahnfeld via cfe-commits
Hahnfeld added a comment.

Gentle ping


http://reviews.llvm.org/D17286



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


[PATCH] D17709: [MSVC Compat] Support for '__unaligned' attribute in function declaration

2016-02-29 Thread Olga Chupina via cfe-commits
olga.a.chupina created this revision.
olga.a.chupina added a reviewer: rnk.
olga.a.chupina added a subscriber: cfe-commits.

This patch supports using '__unaligned' attribute in function declaration:

struct UnalignedS {
  void foo(double) __unaligned { ; }
};

void bar(void (UnalignedS::*pf)(double)__unaligned);

http://reviews.llvm.org/D17709

Files:
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseTentative.cpp
  test/SemaCXX/MicrosoftExtensions.cpp

Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -4808,7 +4808,9 @@
 case tok::kw___thiscall:
 case tok::kw___vectorcall:
 case tok::kw___unaligned:
-  if (AttrReqs & AR_DeclspecAttributesParsed) {
+  // Allow __unaligned in function definition after a parameter list
+  if ((AttrReqs & AR_DeclspecAttributesParsed) ||
+  (Tok.getKind() == tok::kw___unaligned)) {
 ParseMicrosoftTypeAttributes(DS.getAttributes());
 continue;
   }
Index: lib/Parse/ParseTentative.cpp
===
--- lib/Parse/ParseTentative.cpp
+++ lib/Parse/ParseTentative.cpp
@@ -1782,7 +1782,8 @@
 return TPResult::Error;
 
   // cv-qualifier-seq
-  while (Tok.isOneOf(tok::kw_const, tok::kw_volatile, tok::kw_restrict))
+  while (Tok.isOneOf(tok::kw_const, tok::kw_volatile, tok::kw_restrict,
+ tok::kw___unaligned))
 ConsumeToken();
 
   // ref-qualifier[opt]
Index: test/SemaCXX/MicrosoftExtensions.cpp
===
--- test/SemaCXX/MicrosoftExtensions.cpp
+++ test/SemaCXX/MicrosoftExtensions.cpp
@@ -80,6 +80,10 @@
 // __unaligned handling
 typedef char __unaligned *aligned_type;
 typedef struct UnalignedTag { int f; } __unaligned *aligned_type2;
+struct UnalignedS {
+  void foo(double) __unaligned { ; }
+};
+void bar(void (UnalignedS::*pf)(double)__unaligned);
 
 
 template void h1(T (__stdcall M::* const )()) { }


Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -4808,7 +4808,9 @@
 case tok::kw___thiscall:
 case tok::kw___vectorcall:
 case tok::kw___unaligned:
-  if (AttrReqs & AR_DeclspecAttributesParsed) {
+  // Allow __unaligned in function definition after a parameter list
+  if ((AttrReqs & AR_DeclspecAttributesParsed) ||
+  (Tok.getKind() == tok::kw___unaligned)) {
 ParseMicrosoftTypeAttributes(DS.getAttributes());
 continue;
   }
Index: lib/Parse/ParseTentative.cpp
===
--- lib/Parse/ParseTentative.cpp
+++ lib/Parse/ParseTentative.cpp
@@ -1782,7 +1782,8 @@
 return TPResult::Error;
 
   // cv-qualifier-seq
-  while (Tok.isOneOf(tok::kw_const, tok::kw_volatile, tok::kw_restrict))
+  while (Tok.isOneOf(tok::kw_const, tok::kw_volatile, tok::kw_restrict,
+ tok::kw___unaligned))
 ConsumeToken();
 
   // ref-qualifier[opt]
Index: test/SemaCXX/MicrosoftExtensions.cpp
===
--- test/SemaCXX/MicrosoftExtensions.cpp
+++ test/SemaCXX/MicrosoftExtensions.cpp
@@ -80,6 +80,10 @@
 // __unaligned handling
 typedef char __unaligned *aligned_type;
 typedef struct UnalignedTag { int f; } __unaligned *aligned_type2;
+struct UnalignedS {
+  void foo(double) __unaligned { ; }
+};
+void bar(void (UnalignedS::*pf)(double)__unaligned);
 
 
 template void h1(T (__stdcall M::* const )()) { }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17704: Added interfaces for code-formatting while applying replacements.

2016-02-29 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

LG



Comment at: lib/Tooling/Core/Replacement.cpp:290
@@ +289,3 @@
+ const format::FormatStyle &Style) {
+  if (Replaces.empty()) return Replaces;
+

I'd return a default constructed Replacements() instead - I think that requires 
a bit less reasoning (as written currently, I'll need to reason that a copy is 
made to convince myself that this is correct).


http://reviews.llvm.org/D17704



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


Re: r262200 - [X86] Enabling xsave should not enable AVX. I seem to have done this, but I don't know why.

2016-02-29 Thread Joerg Sonnenberger via cfe-commits
On Mon, Feb 29, 2016 at 06:51:34AM -, Craig Topper via cfe-commits wrote:
> Author: ctopper
> Date: Mon Feb 29 00:51:34 2016
> New Revision: 262200
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=262200&view=rev
> Log:
> [X86] Enabling xsave should not enable AVX. I seem to have done this, but I 
> don't know why.

Does this apply to 3.8?

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


r262216 - clang-format: Don't format unrelated nested blocks.

2016-02-29 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Feb 29 06:26:20 2016
New Revision: 262216

URL: http://llvm.org/viewvc/llvm-project?rev=262216&view=rev
Log:
clang-format: Don't format unrelated nested blocks.

With this change:

  SomeFunction(
  [] {
int i;
 return i;  // Format this line.
  },
  [] {
 return 2;  // Don't "fix" this.
  });

Modified:
cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
cfe/trunk/unittests/Format/FormatTestSelective.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp?rev=262216&r1=262215&r2=262216&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp Mon Feb 29 06:26:20 2016
@@ -863,7 +863,9 @@ UnwrappedLineFormatter::format(const Sma
   // If no token in the current line is affected, we still need to format
   // affected children.
   if (TheLine.ChildrenAffected)
-format(TheLine.Children, DryRun);
+for (const FormatToken *Tok = TheLine.First; Tok; Tok = Tok->Next)
+  if (!Tok->Children.empty())
+format(Tok->Children, DryRun);
 
   // Adapt following lines on the current indent level to the same level
   // unless the current \c AnnotatedLine is not at the beginning of a line.

Modified: cfe/trunk/unittests/Format/FormatTestSelective.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestSelective.cpp?rev=262216&r1=262215&r2=262216&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestSelective.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestSelective.cpp Mon Feb 29 06:26:20 2016
@@ -278,6 +278,23 @@ TEST_F(FormatTestSelective, IndividualSt
"  };\n"
"});",
0, 0));
+  EXPECT_EQ("SomeFunction(\n"
+"[] {\n"
+"  int i;\n"
+"  return i;\n" // Format this line.
+"},\n"
+"[] {\n"
+"   return 2;\n" // Don't fix this.
+"});",
+format("SomeFunction(\n"
+   "[] {\n"
+   "  int i;\n"
+   "   return i;\n" // Format this line.
+   "},\n"
+   "[] {\n"
+   "   return 2;\n" // Don't fix this.
+   "});",
+   40, 0));
 }
 
 TEST_F(FormatTestSelective, WrongIndent) {


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


[RecursiveASTVisitor] fix skipping template specialization definition details

2016-02-29 Thread greye via cfe-commits
As described in [1] RecursiveASTVisitor skips definition of class
template specializations. This patch fixes it in the same way as is done
for partial specializations.

1. https://llvm.org/bugs/show_bug.cgi?id=12640
Index: include/clang/AST/RecursiveASTVisitor.h
===
--- include/clang/AST/RecursiveASTVisitor.h	(revision 262213)
+++ include/clang/AST/RecursiveASTVisitor.h	(working copy)
@@ -1675,7 +1675,7 @@
 
 DEF_TRAVERSE_DECL(CXXRecordDecl, { TRY_TO(TraverseCXXRecordHelper(D)); })
 
-#define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND)  \
+#define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND, DECLKIND)\
   DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateSpecializationDecl, {\
 /* For implicit instantiations ("set x;"), we don't want to   \
recurse at all, since the instatiated template isn't written in \
@@ -1695,10 +1695,12 @@
  (embedded in the DEF_TRAVERSE_DECL() macro)   \
  which contains the instantiated members of the template. */   \
   return true; \
+   \
+TRY_TO(Traverse##DECLKIND##Helper(D)); \
   })
 
-DEF_TRAVERSE_TMPL_SPEC_DECL(Class)
-DEF_TRAVERSE_TMPL_SPEC_DECL(Var)
+DEF_TRAVERSE_TMPL_SPEC_DECL(Class, CXXRecord)
+DEF_TRAVERSE_TMPL_SPEC_DECL(Var, Var)
 
 template 
 bool RecursiveASTVisitor::TraverseTemplateArgumentLocsHelper(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17704: Added interfaces for code-formatting while applying replacements.

2016-02-29 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 49355.
ioeric marked 8 inline comments as done.
ioeric added a comment.

- removed applyAllReplacementsAndFormat with Rewritter interface. reduced the 
column limit in test case; some formatting.


http://reviews.llvm.org/D17704

Files:
  include/clang/Tooling/Core/Replacement.h
  lib/Tooling/Core/Replacement.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -18,6 +18,7 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
@@ -166,6 +167,35 @@
   EXPECT_EQ("z", Context.getRewrittenText(IDz));
 }
 
+TEST_F(ReplacementTest, FormatCodeAfterReplacements) {
+  // Column limit is 20.
+  std::string Code = "Type *a =\n"
+ "new Type();\n"
+ "g(i, 0, j,\n"
+ "  0, k, 0, mm);\n"
+ "int  bad = format   ;";
+  std::string Expected = "auto a = new Type();\n"
+ "g(i, nullptr,\n"
+ "  j, nullptr,\n"
+ "  k, nullptr,\n"
+ "  mm);\n"
+ "int  bad = format   ;";
+  FileID ID = Context.createInMemoryFile("format.cpp", Code);
+  Replacements Replaces;
+  Replaces.insert(
+  Replacement(Context.Sources, Context.getLocation(ID, 1, 1), 6, "auto "));
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 3, 10),
+  1, "nullptr"));
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 4, 3), 1,
+  "nullptr"));
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 4, 13),
+  1, "nullptr"));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  Style.ColumnLimit = 20; // Set column limit to 20 to increase readibility.
+  EXPECT_EQ(Expected, applyAllReplacementsAndFormat(Code, Replaces, Style));
+}
+
 TEST(ShiftedCodePositionTest, FindsNewCodePosition) {
   Replacements Replaces;
   Replaces.insert(Replacement("", 0, 1, ""));
@@ -418,6 +448,25 @@
   EXPECT_FALSE(Range(0, 10).contains(Range(0, 11)));
 }
 
+TEST(Range, CalculateRangesOfReplacements) {
+  // Before: bbz
+  // After : bbzz
+  Replacements Replaces;
+  Replaces.insert(Replacement("foo", 0, 4, ""));
+  Replaces.insert(Replacement("foo", 10, 1, "zz"));
+  Replaces.insert(Replacement("foo", 11, 0, ""));
+
+  std::vector Ranges = calculateChangedRangesInFile(Replaces);
+
+  EXPECT_EQ(3, Ranges.size());
+  EXPECT_TRUE(Ranges[0].getOffset() == 0);
+  EXPECT_TRUE(Ranges[0].getLength() == 0);
+  EXPECT_TRUE(Ranges[1].getOffset() == 6);
+  EXPECT_TRUE(Ranges[1].getLength() == 6);
+  EXPECT_TRUE(Ranges[2].getOffset() == 12);
+  EXPECT_TRUE(Ranges[2].getLength() == 16);
+}
+
 TEST(DeduplicateTest, removesDuplicates) {
   std::vector Input;
   Input.push_back(Replacement("fileA", 50, 0, " foo "));
Index: unittests/Tooling/CMakeLists.txt
===
--- unittests/Tooling/CMakeLists.txt
+++ unittests/Tooling/CMakeLists.txt
@@ -24,6 +24,7 @@
   clangAST
   clangASTMatchers
   clangBasic
+  clangFormat
   clangFrontend
   clangLex
   clangRewrite
Index: lib/Tooling/Core/Replacement.cpp
===
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -11,17 +11,20 @@
 //
 //===--===//
 
+#include "clang/Tooling/Core/Replacement.h"
+
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticIDs.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Rewrite/Core/Rewriter.h"
-#include "clang/Tooling/Core/Replacement.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_os_ostream.h"
+#include 
 
 namespace clang {
 namespace tooling {
@@ -281,6 +284,44 @@
   return Result;
 }
 
+tooling::Replacements formatReplacements(StringRef Code,
+ const tooling::Replacements &Replaces,
+ const format::FormatStyle &Style) {
+  if (Replaces.empty()) return Replaces;
+
+  std::string NewCode = applyAllReplacements(Code, Replaces);
+  std::vector ChangedRanges =
+  calculateChangedRangesInFile(R

[PATCH] D17704: Added interfaces for code-formatting while applying replacements.

2016-02-29 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added a reviewer: klimek.
ioeric added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Merge branch 'master' of http://llvm.org/git/clang

http://reviews.llvm.org/D17704

Files:
  include/clang/Tooling/Core/Replacement.h
  lib/Tooling/Core/Replacement.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -18,6 +18,7 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
@@ -166,6 +167,37 @@
   EXPECT_EQ("z", Context.getRewrittenText(IDz));
 }
 
+TEST_F(ReplacementTest, FormatCodeAfterReplacements) {
+  std::string Code = "MyType012345678901234567890123456789 *a =\n"
+ "new MyType012345678901234567890123456789();\n"
+ "g(iii, 0, "
+ "jjj,\n"
+ "  0, kkk, 0, "
+ "mmm);\n"
+ "int  bad = format   ;";
+  std::string Expected =
+  "auto a = new MyType012345678901234567890123456789();\n"
+  "g(iii, nullptr,\n"
+  "  jjj, nullptr,\n"
+  "  kkk, nullptr,\n"
+  "  mmm);\n"
+  "int  bad = format   ;";
+  FileID ID = Context.createInMemoryFile("format.cpp", Code);
+  Replacements Replaces;
+  Replaces.insert(
+  Replacement(Context.Sources, Context.getLocation(ID, 1, 1), 38, "auto "));
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 3, 40),
+  1, "nullptr"));
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 4, 3), 1,
+  "nullptr"));
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 4, 43),
+  1, "nullptr"));
+
+  EXPECT_TRUE(applyAllReplacementsAndFormat(format::getLLVMStyle(), Replaces,
+Context.Rewrite));
+  EXPECT_EQ(Expected, Context.getRewrittenText(ID));
+}
+
 TEST(ShiftedCodePositionTest, FindsNewCodePosition) {
   Replacements Replaces;
   Replaces.insert(Replacement("", 0, 1, ""));
@@ -418,6 +450,23 @@
   EXPECT_FALSE(Range(0, 10).contains(Range(0, 11)));
 }
 
+TEST(Range, CalculateRangesOfReplacements) {
+  // Before: bbz
+  // After : bbzz
+  Replacements Replaces;
+  Replaces.insert(Replacement("foo", 0, 4, ""));
+  Replaces.insert(Replacement("foo", 10, 1, "zz"));
+  Replaces.insert(Replacement("foo", 11, 0, ""));
+  std::vector Ranges = calculateChangedRanges(Replaces);
+  EXPECT_EQ(3, Ranges.size());
+  EXPECT_TRUE(Ranges[0].getOffset() == 0);
+  EXPECT_TRUE(Ranges[0].getLength() == 0);
+  EXPECT_TRUE(Ranges[1].getOffset() == 6);
+  EXPECT_TRUE(Ranges[1].getLength() == 6);
+  EXPECT_TRUE(Ranges[2].getOffset() == 12);
+  EXPECT_TRUE(Ranges[2].getLength() == 16);
+}
+
 TEST(DeduplicateTest, removesDuplicates) {
   std::vector Input;
   Input.push_back(Replacement("fileA", 50, 0, " foo "));
Index: unittests/Tooling/CMakeLists.txt
===
--- unittests/Tooling/CMakeLists.txt
+++ unittests/Tooling/CMakeLists.txt
@@ -24,6 +24,7 @@
   clangAST
   clangASTMatchers
   clangBasic
+  clangFormat
   clangFrontend
   clangLex
   clangRewrite
Index: lib/Tooling/Core/Replacement.cpp
===
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -11,14 +11,16 @@
 //
 //===--===//
 
+#include "clang/Tooling/Core/Replacement.h"
+#include 
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticIDs.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Rewrite/Core/Rewriter.h"
-#include "clang/Tooling/Core/Replacement.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_os_ostream.h"
@@ -281,6 +283,63 @@
   return Result;
 }
 
+tooling::Replacements
+formatReplacements(const format::FormatStyle &Style, StringRef Code,
+   const tooling::Replacements &Replaces) {
+  std::string NewCode = applyAllReplacements(Code, Replaces);
+
+  std::vector

Re: [PATCH] D17704: Added interfaces for code-formatting while applying replacements.

2016-02-29 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 49359.
ioeric marked an inline comment as done.
ioeric added a comment.

- return Replacements() instead of the empty Replaces.


http://reviews.llvm.org/D17704

Files:
  include/clang/Tooling/Core/Replacement.h
  lib/Tooling/Core/Replacement.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -18,6 +18,7 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
@@ -166,6 +167,35 @@
   EXPECT_EQ("z", Context.getRewrittenText(IDz));
 }
 
+TEST_F(ReplacementTest, FormatCodeAfterReplacements) {
+  // Column limit is 20.
+  std::string Code = "Type *a =\n"
+ "new Type();\n"
+ "g(i, 0, j,\n"
+ "  0, k, 0, mm);\n"
+ "int  bad = format   ;";
+  std::string Expected = "auto a = new Type();\n"
+ "g(i, nullptr,\n"
+ "  j, nullptr,\n"
+ "  k, nullptr,\n"
+ "  mm);\n"
+ "int  bad = format   ;";
+  FileID ID = Context.createInMemoryFile("format.cpp", Code);
+  Replacements Replaces;
+  Replaces.insert(
+  Replacement(Context.Sources, Context.getLocation(ID, 1, 1), 6, "auto "));
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 3, 10),
+  1, "nullptr"));
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 4, 3), 1,
+  "nullptr"));
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 4, 13),
+  1, "nullptr"));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  Style.ColumnLimit = 20; // Set column limit to 20 to increase readibility.
+  EXPECT_EQ(Expected, applyAllReplacementsAndFormat(Code, Replaces, Style));
+}
+
 TEST(ShiftedCodePositionTest, FindsNewCodePosition) {
   Replacements Replaces;
   Replaces.insert(Replacement("", 0, 1, ""));
@@ -418,6 +448,25 @@
   EXPECT_FALSE(Range(0, 10).contains(Range(0, 11)));
 }
 
+TEST(Range, CalculateRangesOfReplacements) {
+  // Before: bbz
+  // After : bbzz
+  Replacements Replaces;
+  Replaces.insert(Replacement("foo", 0, 4, ""));
+  Replaces.insert(Replacement("foo", 10, 1, "zz"));
+  Replaces.insert(Replacement("foo", 11, 0, ""));
+
+  std::vector Ranges = calculateChangedRangesInFile(Replaces);
+
+  EXPECT_EQ(3, Ranges.size());
+  EXPECT_TRUE(Ranges[0].getOffset() == 0);
+  EXPECT_TRUE(Ranges[0].getLength() == 0);
+  EXPECT_TRUE(Ranges[1].getOffset() == 6);
+  EXPECT_TRUE(Ranges[1].getLength() == 6);
+  EXPECT_TRUE(Ranges[2].getOffset() == 12);
+  EXPECT_TRUE(Ranges[2].getLength() == 16);
+}
+
 TEST(DeduplicateTest, removesDuplicates) {
   std::vector Input;
   Input.push_back(Replacement("fileA", 50, 0, " foo "));
Index: unittests/Tooling/CMakeLists.txt
===
--- unittests/Tooling/CMakeLists.txt
+++ unittests/Tooling/CMakeLists.txt
@@ -24,6 +24,7 @@
   clangAST
   clangASTMatchers
   clangBasic
+  clangFormat
   clangFrontend
   clangLex
   clangRewrite
Index: lib/Tooling/Core/Replacement.cpp
===
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -11,17 +11,20 @@
 //
 //===--===//
 
+#include "clang/Tooling/Core/Replacement.h"
+
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticIDs.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Rewrite/Core/Rewriter.h"
-#include "clang/Tooling/Core/Replacement.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_os_ostream.h"
+#include 
 
 namespace clang {
 namespace tooling {
@@ -281,6 +284,44 @@
   return Result;
 }
 
+tooling::Replacements formatReplacements(StringRef Code,
+ const tooling::Replacements &Replaces,
+ const format::FormatStyle &Style) {
+  if (Replaces.empty()) return Replacements();
+
+  std::string NewCode = applyAllReplacements(Code, Replaces);
+  std::vector ChangedRanges =
+  calculateChangedRangesInFile(Replaces);
+  StringRef FileName = Replaces.begin()->getFilePat

Re: [PATCH] D17637: [PPC64][VSX] Add short, char, and bool data type for vec_vsx_ld and vec_vsx_st intrinsics

2016-02-29 Thread Chuang-Yu Cheng via cfe-commits
cycheng updated this revision to Diff 49335.
cycheng added a comment.

Fix clang testing failure.
Thanks Kit!

I have checked the result by: make check-all
Testing result:

  Testing Time: 33.36s
Expected Passes: 24505
Expected Failures  : 152
Unsupported Tests  : 365
  [100%] Built target check-all


http://reviews.llvm.org/D17637

Files:
  lib/Headers/altivec.h
  test/CodeGen/builtins-ppc-vsx.c

Index: test/CodeGen/builtins-ppc-vsx.c
===
--- test/CodeGen/builtins-ppc-vsx.c
+++ test/CodeGen/builtins-ppc-vsx.c
@@ -2,16 +2,26 @@
 // RUN: %clang_cc1 -faltivec -target-feature +vsx -triple powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -faltivec -target-feature +vsx -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-LE
 
+vector signed char vsc = { -8,  9, -10, 11, -12, 13, -14, 15,
+   -0,  1,  -2,  3,  -4,  5,  -6,  7};
 vector unsigned char vuc = { 8,  9, 10, 11, 12, 13, 14, 15,
  0,  1,  2,  3,  4,  5,  6,  7};
+vector bool char vbc = { 0, 1, 0, 1, 0, 1, 0, 1,
+ 0, 1, 0, 1, 0, 1, 0, 1 };
 vector float vf = { -1.5, 2.5, -3.5, 4.5 };
 vector double vd = { 3.5, -7.5 };
 vector signed int vsi = { -1, 2, -3, 4 };
 vector unsigned int vui = { 0, 1, 2, 3 };
 vector bool long long vbll = { 1, 0 };
 vector signed long long vsll = { 255LL, -937LL };
 vector unsigned long long vull = { 1447LL, 2894LL };
+vector signed short vss = { -1, 2, -3, 4, -5, 6, -7, 8 };
+vector unsigned short vus = { 0, 1, 2, 3, 4, 5, 6, 7 };
 double d = 23.4;
+signed char sc = -128;
+unsigned char uc = 1;
+signed short ss = -32768;
+unsigned short us = 1;
 
 vector float res_vf;
 vector double res_vd;
@@ -21,7 +31,19 @@
 vector bool long long res_vbll;
 vector signed long long res_vsll;
 vector unsigned long long res_vull;
+vector signed short res_vss;
+vector unsigned short res_vus;
+vector bool char res_vbc;
+vector signed char res_vsc;
+vector unsigned char res_vuc;
+
 double res_d;
+signed int res_si;
+unsigned int res_ui;
+signed char res_sc;
+unsigned char res_uc;
+signed short res_ss;
+unsigned short res_us;
 
 void dummy() { }
 
@@ -316,16 +338,68 @@
 // CHECK: @llvm.ppc.vsx.lxvd2x
 // CHECK-LE: @llvm.ppc.vsx.lxvd2x
 
+  res_vull = vec_vsx_ld(0, &vull);
+// CHECK: @llvm.ppc.vsx.lxvd2x
+// CHECK-LE: @llvm.ppc.vsx.lxvd2x
+
+  res_vd = vec_vsx_ld(0, &vd);
+// CHECK: @llvm.ppc.vsx.lxvd2x
+// CHECK-LE: @llvm.ppc.vsx.lxvd2x
+
+  res_vss = vec_vsx_ld(0, &vss);
+// CHECK: @llvm.ppc.vsx.lxvw4x
+// CHECK-LE: @llvm.ppc.vsx.lxvw4x
+
+  res_vss = vec_vsx_ld(0, &ss);
+// CHECK: @llvm.ppc.vsx.lxvw4x
+// CHECK-LE: @llvm.ppc.vsx.lxvw4x
+
+  res_vus = vec_vsx_ld(0, &vus);
+// CHECK: @llvm.ppc.vsx.lxvw4x
+// CHECK-LE: @llvm.ppc.vsx.lxvw4x
+
+  res_vus = vec_vsx_ld(0, &us);
+// CHECK: @llvm.ppc.vsx.lxvw4x
+// CHECK-LE: @llvm.ppc.vsx.lxvw4x
+
+  res_vbc = vec_vsx_ld(0, &vbc);
+// CHECK: @llvm.ppc.vsx.lxvw4x
+// CHECK-LE: @llvm.ppc.vsx.lxvw4x
+
+  res_vsc = vec_vsx_ld(0, &vsc);
+// CHECK: @llvm.ppc.vsx.lxvw4x
+// CHECK-LE: @llvm.ppc.vsx.lxvw4x
+
+  res_vuc = vec_vsx_ld(0, &vuc);
+// CHECK: @llvm.ppc.vsx.lxvw4x
+// CHECK-LE: @llvm.ppc.vsx.lxvw4x
+
+  res_vsc = vec_vsx_ld(0, &sc);
+// CHECK: @llvm.ppc.vsx.lxvw4x
+// CHECK-LE: @llvm.ppc.vsx.lxvw4x
+
+  res_vuc = vec_vsx_ld(0, &uc);
+// CHECK: @llvm.ppc.vsx.lxvw4x
+// CHECK-LE: @llvm.ppc.vsx.lxvw4x
+
   /* vec_vsx_st */
 
   vec_vsx_st(vsi, 0, &res_vsi);
 // CHECK: @llvm.ppc.vsx.stxvw4x
 // CHECK-LE: @llvm.ppc.vsx.stxvw4x
 
+  vec_vsx_st(vsi, 0, &res_si);
+// CHECK: @llvm.ppc.vsx.stxvw4x
+// CHECK-LE: @llvm.ppc.vsx.stxvw4x
+
   vec_vsx_st(vui, 0, &res_vui);
 // CHECK: @llvm.ppc.vsx.stxvw4x
 // CHECK-LE: @llvm.ppc.vsx.stxvw4x
 
+  vec_vsx_st(vui, 0, &res_ui);
+// CHECK: @llvm.ppc.vsx.stxvw4x
+// CHECK-LE: @llvm.ppc.vsx.stxvw4x
+
   vec_vsx_st(vf, 0, &res_vf);
 // CHECK: @llvm.ppc.vsx.stxvw4x
 // CHECK-LE: @llvm.ppc.vsx.stxvw4x
@@ -342,6 +416,50 @@
 // CHECK: @llvm.ppc.vsx.stxvd2x
 // CHECK-LE: @llvm.ppc.vsx.stxvd2x
 
+  vec_vsx_st(vss, 0, &res_vss);
+// CHECK: @llvm.ppc.vsx.stxvw4x
+// CHECK-LE: @llvm.ppc.vsx.stxvw4x
+
+  vec_vsx_st(vss, 0, &res_ss);
+// CHECK: @llvm.ppc.vsx.stxvw4x
+// CHECK-LE: @llvm.ppc.vsx.stxvw4x
+
+  vec_vsx_st(vus, 0, &res_vus);
+// CHECK: @llvm.ppc.vsx.stxvw4x
+// CHECK-LE: @llvm.ppc.vsx.stxvw4x
+
+  vec_vsx_st(vus, 0, &res_us);
+// CHECK: @llvm.ppc.vsx.stxvw4x
+// CHECK-LE: @llvm.ppc.vsx.stxvw4x
+
+  vec_vsx_st(vsc, 0, &res_vsc);
+// CHECK: @llvm.ppc.vsx.stxvw4x
+// CHECK-LE: @llvm.ppc.vsx.stxvw4x
+
+  vec_vsx_st(vsc, 0, &res_sc);
+// CHECK: @llvm.ppc.vsx.stxvw4x
+// CHECK-LE: @llvm.ppc.vsx.stxvw4x
+
+  vec_vsx_st(vuc, 0, &res_vuc);
+// CHECK: @llvm.ppc.vsx.stxvw4x
+// CHECK-LE: @llvm.ppc.vsx.stxvw4x
+
+  vec_vsx_st(vuc, 0, &res_uc);
+// CHECK: @llvm.ppc.vsx.stxvw4x
+// CHECK-LE: @llvm.ppc.vsx.stxvw4x
+
+  vec_vsx_st(vbc, 0, &res_vbc);
+// CHECK: @llvm.ppc.vsx.

r262228 - AMDGPU: Add missing Volcanic Islands targets

2016-02-29 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Mon Feb 29 09:08:56 2016
New Revision: 262228

URL: http://llvm.org/viewvc/llvm-project?rev=262228&view=rev
Log:
AMDGPU: Add missing Volcanic Islands targets

Reviewers: arsenm

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Driver/r600-mcpu.cl

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=262228&r1=262227&r2=262228&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Feb 29 09:08:56 2016
@@ -1931,6 +1931,8 @@ public:
   .Case("tonga",GK_VOLCANIC_ISLANDS)
   .Case("iceland",  GK_VOLCANIC_ISLANDS)
   .Case("carrizo",  GK_VOLCANIC_ISLANDS)
+  .Case("fiji", GK_VOLCANIC_ISLANDS)
+  .Case("stoney",   GK_VOLCANIC_ISLANDS)
   .Default(GK_NONE);
 
 if (GPU == GK_NONE) {

Modified: cfe/trunk/test/Driver/r600-mcpu.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/r600-mcpu.cl?rev=262228&r1=262227&r2=262228&view=diff
==
--- cfe/trunk/test/Driver/r600-mcpu.cl (original)
+++ cfe/trunk/test/Driver/r600-mcpu.cl Mon Feb 29 09:08:56 2016
@@ -38,6 +38,8 @@ t// Check that -mcpu works for all suppo
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=tonga %s -o - 
2>&1 | FileCheck --check-prefix=TONGA-CHECK %s
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=iceland %s -o - 
2>&1 | FileCheck --check-prefix=ICELAND-CHECK %s
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=carrizo %s -o - 
2>&1 | FileCheck --check-prefix=CARRIZO-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=fiji %s -o - 2>&1 
| FileCheck --check-prefix=FIJI-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=stoney %s -o - 
2>&1 | FileCheck --check-prefix=STONEY-CHECK %s
 
 // R600-CHECK:  "-target-cpu" "r600"
 // RS880-CHECK: "-target-cpu" "rs880"
@@ -66,3 +68,5 @@ t// Check that -mcpu works for all suppo
 // TONGA-CHECK: "-target-cpu" "tonga"
 // ICELAND-CHECK: "-target-cpu" "iceland"
 // CARRIZO-CHECK: "-target-cpu" "carrizo"
+// FIJI-CHECK: "-target-cpu" "fiji"
+// STONEY-CHECK: "-target-cpu" "stoney"


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


Re: [PATCH] D17645: AMDGPU: Add missing Volcanic Islands targets

2016-02-29 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL262228: AMDGPU: Add missing Volcanic Islands targets 
(authored by tstellar).

Changed prior to commit:
  http://reviews.llvm.org/D17645?vs=49184&id=49372#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17645

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/Driver/r600-mcpu.cl

Index: cfe/trunk/test/Driver/r600-mcpu.cl
===
--- cfe/trunk/test/Driver/r600-mcpu.cl
+++ cfe/trunk/test/Driver/r600-mcpu.cl
@@ -38,6 +38,8 @@
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=tonga %s -o - 
2>&1 | FileCheck --check-prefix=TONGA-CHECK %s
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=iceland %s -o - 
2>&1 | FileCheck --check-prefix=ICELAND-CHECK %s
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=carrizo %s -o - 
2>&1 | FileCheck --check-prefix=CARRIZO-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=fiji %s -o - 2>&1 
| FileCheck --check-prefix=FIJI-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=stoney %s -o - 
2>&1 | FileCheck --check-prefix=STONEY-CHECK %s
 
 // R600-CHECK:  "-target-cpu" "r600"
 // RS880-CHECK: "-target-cpu" "rs880"
@@ -66,3 +68,5 @@
 // TONGA-CHECK: "-target-cpu" "tonga"
 // ICELAND-CHECK: "-target-cpu" "iceland"
 // CARRIZO-CHECK: "-target-cpu" "carrizo"
+// FIJI-CHECK: "-target-cpu" "fiji"
+// STONEY-CHECK: "-target-cpu" "stoney"
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -1931,6 +1931,8 @@
   .Case("tonga",GK_VOLCANIC_ISLANDS)
   .Case("iceland",  GK_VOLCANIC_ISLANDS)
   .Case("carrizo",  GK_VOLCANIC_ISLANDS)
+  .Case("fiji", GK_VOLCANIC_ISLANDS)
+  .Case("stoney",   GK_VOLCANIC_ISLANDS)
   .Default(GK_NONE);
 
 if (GPU == GK_NONE) {


Index: cfe/trunk/test/Driver/r600-mcpu.cl
===
--- cfe/trunk/test/Driver/r600-mcpu.cl
+++ cfe/trunk/test/Driver/r600-mcpu.cl
@@ -38,6 +38,8 @@
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=tonga %s -o - 2>&1 | FileCheck --check-prefix=TONGA-CHECK %s
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=iceland %s -o - 2>&1 | FileCheck --check-prefix=ICELAND-CHECK %s
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=carrizo %s -o - 2>&1 | FileCheck --check-prefix=CARRIZO-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=fiji %s -o - 2>&1 | FileCheck --check-prefix=FIJI-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=stoney %s -o - 2>&1 | FileCheck --check-prefix=STONEY-CHECK %s
 
 // R600-CHECK:  "-target-cpu" "r600"
 // RS880-CHECK: "-target-cpu" "rs880"
@@ -66,3 +68,5 @@
 // TONGA-CHECK: "-target-cpu" "tonga"
 // ICELAND-CHECK: "-target-cpu" "iceland"
 // CARRIZO-CHECK: "-target-cpu" "carrizo"
+// FIJI-CHECK: "-target-cpu" "fiji"
+// STONEY-CHECK: "-target-cpu" "stoney"
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -1931,6 +1931,8 @@
   .Case("tonga",GK_VOLCANIC_ISLANDS)
   .Case("iceland",  GK_VOLCANIC_ISLANDS)
   .Case("carrizo",  GK_VOLCANIC_ISLANDS)
+  .Case("fiji", GK_VOLCANIC_ISLANDS)
+  .Case("stoney",   GK_VOLCANIC_ISLANDS)
   .Default(GK_NONE);
 
 if (GPU == GK_NONE) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct

2016-02-29 Thread Michael Matz via cfe-commits
Hi,

On Fri, 26 Feb 2016, H.J. Lu wrote:

> >> It is clear to me now.  Let's go with
> >>
> >> ---
> >> An empty type is a type where it and all of its subobjects (recursively)
> >> are of class, structure, union, or array type.  No memory slot nor
> >> register should be used to pass or return an object of empty type that's
> >> trivially copyable.
> >> ---
> >>
> >> Any comments?
> >
> > Yes. "trivially copyable" is the wrong restriction. See
> > http://mentorembedded.github.io/cxx-abi/abi.html#normal-call for the
> > actual Itanium C++ ABI rule.
> 
> I looked it up.  " trivially copyable" is covered by C++ ABI.
> 
> > It's also completely nonsensical to mention this as a special case in
> > relation to empty types. The special case applies to all function
> > parameters, irrespective of whether they're empty -- this rule applies
> > *long* before you consider whether the type is empty. For instance, in
> > the x86-64 psABI, this should go right at the start of section 2.2.3
> > ("Parameter Passing and Returning Values"). But please don't add it
> > there -- it's completely redundant, as section 5.1 already says that
> > the Itanium C++ ABI is used, so it's not necessary to duplicate rules
> > from there.
> 
> Here is the final wording:
> 
> An empty type is a type where it and all of its subobjects (recursively)
> are of class, structure, union, or array type.  No memory slot nor register
> should be used to pass or return an object of empty type.
> 
> Footnote: Array of empty type can only passed by reference in C and C++.
> 
> Michael, can you put it in x86-64 psABI?  I will update i386 and IA MCU
> psABIs.

Not without further discussion, sorry.  If we want to invoke the C++ ABI 
to not have to worry about trivially copyable (and yeah, of course it  
would be placed better at the beginning for the whole argument passing 
section), then we need to also look at its other rules.  In particular at:


3.1.3 Empty Parameters 
* Empty classes will be passed no differently from ordinary classes. If 
  passed in registers the NaT bit must not be set on all registers that 
  make up the class. 
* The contents of the single byte parameter slot are unspecified, and the 
  callee may not depend on any particular value. On Itanium, the 
  associated NaT bit must not be set if the parameter slot is associated 
  with a register.


So, in C++, empty classes will be passed as above, not as no registers.  
The new rule would create a conflict between "no registers/slots" and "the 
single byte parameter slot".

Have you thought about this?

(I'll also note that putting in this rule might interact with "2.2 POD 
Data Types / If the base ABI does not specify rules for empty classes, 
then an empty class has size and alignment 1." because we now do specify 
rules for empty classes, though not for size and alignment explicitely).

Also this insistence that all of "trivially copyable" is 
already quite nicely specified in the C++ ABI is still not really relevant 
because C++ _is not the only language out there_.  I'm not sure how often 
I have to repeat this until people get it.


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


r262232 - Implement new interfaces for code-formatting when applying replacements.

2016-02-29 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Mon Feb 29 10:27:41 2016
New Revision: 262232

URL: http://llvm.org/viewvc/llvm-project?rev=262232&view=rev
Log:
Implement new interfaces for code-formatting when applying replacements.

Patch by Eric Liu.

Modified:
cfe/trunk/include/clang/Tooling/Core/Replacement.h
cfe/trunk/lib/Tooling/Core/Replacement.cpp
cfe/trunk/unittests/Tooling/CMakeLists.txt
cfe/trunk/unittests/Tooling/RefactoringTest.cpp

Modified: cfe/trunk/include/clang/Tooling/Core/Replacement.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/Replacement.h?rev=262232&r1=262231&r2=262232&view=diff
==
--- cfe/trunk/include/clang/Tooling/Core/Replacement.h (original)
+++ cfe/trunk/include/clang/Tooling/Core/Replacement.h Mon Feb 29 10:27:41 2016
@@ -30,6 +30,10 @@ namespace clang {
 
 class Rewriter;
 
+namespace format {
+struct FormatStyle;
+} // namespace format
+
 namespace tooling {
 
 /// \brief A source range independent of the \c SourceManager.
@@ -220,6 +224,41 @@ bool applyAllReplacements(const std::vec
 /// replacements cannot be applied, this returns an empty \c string.
 std::string applyAllReplacements(StringRef Code, const Replacements &Replaces);
 
+/// \brief Applies all replacements in \p Replaces to \p Code.
+///
+/// This completely ignores the path stored in each replacement. If one or more
+/// replacements cannot be applied, this returns an empty \c string.
+std::string applyAllReplacements(StringRef Code,
+ const std::vector &Replaces);
+
+/// \brief Calculate the ranges in a single file that are affected by the
+/// Replacements.
+///
+/// \pre Replacements must be for the same file.
+std::vector
+calculateChangedRangesInFile(const tooling::Replacements &Replaces);
+
+/// \brief Return replacements that are merged from orginal replacements
+/// and the replacements for formatting the code after applying the orginal
+/// replacements.
+tooling::Replacements formatReplacements(StringRef Code,
+ const tooling::Replacements &Replaces,
+ const format::FormatStyle &Style);
+
+/// \brief In addition to applying replacements as in `applyAllReplacements`,
+/// this function also reformats the changed code after applying replacements.
+///
+/// \pre Replacements must be for the same file and conflict-free.
+///
+/// Replacement applications happen independently of the success of
+/// other applications.
+///
+/// \returns the changed code if all replacements apply and code is fixed.
+/// empty string otherwise.
+std::string applyAllReplacementsAndFormat(StringRef Code,
+  const Replacements &Replaces,
+  const format::FormatStyle &Style);
+
 /// \brief Merges two sets of replacements with the second set referring to the
 /// code after applying the first set. Within both 'First' and 'Second',
 /// replacements must not overlap.

Modified: cfe/trunk/lib/Tooling/Core/Replacement.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/Replacement.cpp?rev=262232&r1=262231&r2=262232&view=diff
==
--- cfe/trunk/lib/Tooling/Core/Replacement.cpp (original)
+++ cfe/trunk/lib/Tooling/Core/Replacement.cpp Mon Feb 29 10:27:41 2016
@@ -11,17 +11,20 @@
 //
 
//===--===//
 
+#include "clang/Tooling/Core/Replacement.h"
+
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticIDs.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Rewrite/Core/Rewriter.h"
-#include "clang/Tooling/Core/Replacement.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_os_ostream.h"
+#include 
 
 namespace clang {
 namespace tooling {
@@ -281,6 +284,44 @@ std::string applyAllReplacements(StringR
   return Result;
 }
 
+tooling::Replacements formatReplacements(StringRef Code,
+ const tooling::Replacements &Replaces,
+ const format::FormatStyle &Style) {
+  if (Replaces.empty()) return Replacements();
+
+  std::string NewCode = applyAllReplacements(Code, Replaces);
+  std::vector ChangedRanges =
+  calculateChangedRangesInFile(Replaces);
+  StringRef FileName = Replaces.begin()->getFilePath();
+  tooling::Replacements FormatReplaces =
+  format::reformat(Style, NewCode, ChangedRanges, FileName);
+
+  tooling::Replacements MergedReplacements =
+  mergeReplacements(Replaces, FormatReplaces);
+  return MergedReplacements;
+}
+
+std::vector calculateChangedRangesInFile(const Replacemen

Re: [PATCH] D17704: Added interfaces for code-formatting while applying replacements.

2016-02-29 Thread Manuel Klimek via cfe-commits
klimek closed this revision.
klimek added a comment.

Submitted as r262232


http://reviews.llvm.org/D17704



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


Re: r262232 - Implement new interfaces for code-formatting when applying replacements.

2016-02-29 Thread Chandler Carruth via cfe-commits
On Mon, Feb 29, 2016 at 11:32 AM Manuel Klimek via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: klimek
> Date: Mon Feb 29 10:27:41 2016
> New Revision: 262232
>
> URL: http://llvm.org/viewvc/llvm-project?rev=262232&view=rev
> Log:
> Implement new interfaces for code-formatting when applying replacements.
>

Random request: provide more context in commit logs. =D

When I randomly end up staring at patches for some reason, its really
useful to know what the background is, or at least a bit of a clue.

For example, here, why does applying replacements need new interfaces?

Specifically context for those not 100% actively following along with the
detailed discussion are super useful in the commit log where others end up
reading about changes.


>
> Patch by Eric Liu.
>
> Modified:
> cfe/trunk/include/clang/Tooling/Core/Replacement.h
> cfe/trunk/lib/Tooling/Core/Replacement.cpp
> cfe/trunk/unittests/Tooling/CMakeLists.txt
> cfe/trunk/unittests/Tooling/RefactoringTest.cpp
>
> Modified: cfe/trunk/include/clang/Tooling/Core/Replacement.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/Replacement.h?rev=262232&r1=262231&r2=262232&view=diff
>
> ==
> --- cfe/trunk/include/clang/Tooling/Core/Replacement.h (original)
> +++ cfe/trunk/include/clang/Tooling/Core/Replacement.h Mon Feb 29 10:27:41
> 2016
> @@ -30,6 +30,10 @@ namespace clang {
>
>  class Rewriter;
>
> +namespace format {
> +struct FormatStyle;
> +} // namespace format
> +
>  namespace tooling {
>
>  /// \brief A source range independent of the \c SourceManager.
> @@ -220,6 +224,41 @@ bool applyAllReplacements(const std::vec
>  /// replacements cannot be applied, this returns an empty \c string.
>  std::string applyAllReplacements(StringRef Code, const Replacements
> &Replaces);
>
> +/// \brief Applies all replacements in \p Replaces to \p Code.
> +///
> +/// This completely ignores the path stored in each replacement. If one
> or more
> +/// replacements cannot be applied, this returns an empty \c string.
> +std::string applyAllReplacements(StringRef Code,
> + const std::vector
> &Replaces);
> +
> +/// \brief Calculate the ranges in a single file that are affected by the
> +/// Replacements.
> +///
> +/// \pre Replacements must be for the same file.
> +std::vector
> +calculateChangedRangesInFile(const tooling::Replacements &Replaces);
> +
> +/// \brief Return replacements that are merged from orginal replacements
> +/// and the replacements for formatting the code after applying the
> orginal
> +/// replacements.
> +tooling::Replacements formatReplacements(StringRef Code,
> + const tooling::Replacements
> &Replaces,
> + const format::FormatStyle
> &Style);
> +
> +/// \brief In addition to applying replacements as in
> `applyAllReplacements`,
> +/// this function also reformats the changed code after applying
> replacements.
> +///
> +/// \pre Replacements must be for the same file and conflict-free.
> +///
> +/// Replacement applications happen independently of the success of
> +/// other applications.
> +///
> +/// \returns the changed code if all replacements apply and code is fixed.
> +/// empty string otherwise.
> +std::string applyAllReplacementsAndFormat(StringRef Code,
> +  const Replacements &Replaces,
> +  const format::FormatStyle
> &Style);
> +
>  /// \brief Merges two sets of replacements with the second set referring
> to the
>  /// code after applying the first set. Within both 'First' and 'Second',
>  /// replacements must not overlap.
>
> Modified: cfe/trunk/lib/Tooling/Core/Replacement.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/Replacement.cpp?rev=262232&r1=262231&r2=262232&view=diff
>
> ==
> --- cfe/trunk/lib/Tooling/Core/Replacement.cpp (original)
> +++ cfe/trunk/lib/Tooling/Core/Replacement.cpp Mon Feb 29 10:27:41 2016
> @@ -11,17 +11,20 @@
>  //
>
>  
> //===--===//
>
> +#include "clang/Tooling/Core/Replacement.h"
> +
>  #include "clang/Basic/Diagnostic.h"
>  #include "clang/Basic/DiagnosticIDs.h"
>  #include "clang/Basic/DiagnosticOptions.h"
>  #include "clang/Basic/FileManager.h"
>  #include "clang/Basic/SourceManager.h"
> +#include "clang/Format/Format.h"
>  #include "clang/Lex/Lexer.h"
>  #include "clang/Rewrite/Core/Rewriter.h"
> -#include "clang/Tooling/Core/Replacement.h"
>  #include "llvm/Support/FileSystem.h"
>  #include "llvm/Support/Path.h"
>  #include "llvm/Support/raw_os_ostream.h"
> +#include 
>
>  namespace clang {
>  namespace tooling {
> @@ -281,6 +284,44 @@ std::string applyAllReplacements(StringR
>return Result;
> 

Re: [PATCH] D17286: Make FreeBSD and NetBSD use CLANG_DEFAULT_CXX_STDLIB

2016-02-29 Thread Dimitry Andric via cfe-commits
dim added subscribers: joerg, dim.
dim added a comment.

LGTM, at least. @emaste, @joerg, OK with you too?


http://reviews.llvm.org/D17286



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


r262234 - Revert "Implement new interfaces for code-formatting when applying replacements."

2016-02-29 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Mon Feb 29 10:44:16 2016
New Revision: 262234

URL: http://llvm.org/viewvc/llvm-project?rev=262234&view=rev
Log:
Revert "Implement new interfaces for code-formatting when applying 
replacements."

This reverts commit r262232.

Modified:
cfe/trunk/include/clang/Tooling/Core/Replacement.h
cfe/trunk/lib/Tooling/Core/Replacement.cpp
cfe/trunk/unittests/Tooling/CMakeLists.txt
cfe/trunk/unittests/Tooling/RefactoringTest.cpp

Modified: cfe/trunk/include/clang/Tooling/Core/Replacement.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/Replacement.h?rev=262234&r1=262233&r2=262234&view=diff
==
--- cfe/trunk/include/clang/Tooling/Core/Replacement.h (original)
+++ cfe/trunk/include/clang/Tooling/Core/Replacement.h Mon Feb 29 10:44:16 2016
@@ -30,10 +30,6 @@ namespace clang {
 
 class Rewriter;
 
-namespace format {
-struct FormatStyle;
-} // namespace format
-
 namespace tooling {
 
 /// \brief A source range independent of the \c SourceManager.
@@ -224,41 +220,6 @@ bool applyAllReplacements(const std::vec
 /// replacements cannot be applied, this returns an empty \c string.
 std::string applyAllReplacements(StringRef Code, const Replacements &Replaces);
 
-/// \brief Applies all replacements in \p Replaces to \p Code.
-///
-/// This completely ignores the path stored in each replacement. If one or more
-/// replacements cannot be applied, this returns an empty \c string.
-std::string applyAllReplacements(StringRef Code,
- const std::vector &Replaces);
-
-/// \brief Calculate the ranges in a single file that are affected by the
-/// Replacements.
-///
-/// \pre Replacements must be for the same file.
-std::vector
-calculateChangedRangesInFile(const tooling::Replacements &Replaces);
-
-/// \brief Return replacements that are merged from orginal replacements
-/// and the replacements for formatting the code after applying the orginal
-/// replacements.
-tooling::Replacements formatReplacements(StringRef Code,
- const tooling::Replacements &Replaces,
- const format::FormatStyle &Style);
-
-/// \brief In addition to applying replacements as in `applyAllReplacements`,
-/// this function also reformats the changed code after applying replacements.
-///
-/// \pre Replacements must be for the same file and conflict-free.
-///
-/// Replacement applications happen independently of the success of
-/// other applications.
-///
-/// \returns the changed code if all replacements apply and code is fixed.
-/// empty string otherwise.
-std::string applyAllReplacementsAndFormat(StringRef Code,
-  const Replacements &Replaces,
-  const format::FormatStyle &Style);
-
 /// \brief Merges two sets of replacements with the second set referring to the
 /// code after applying the first set. Within both 'First' and 'Second',
 /// replacements must not overlap.

Modified: cfe/trunk/lib/Tooling/Core/Replacement.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/Replacement.cpp?rev=262234&r1=262233&r2=262234&view=diff
==
--- cfe/trunk/lib/Tooling/Core/Replacement.cpp (original)
+++ cfe/trunk/lib/Tooling/Core/Replacement.cpp Mon Feb 29 10:44:16 2016
@@ -11,20 +11,17 @@
 //
 
//===--===//
 
-#include "clang/Tooling/Core/Replacement.h"
-
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticIDs.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
-#include "clang/Format/Format.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Rewrite/Core/Rewriter.h"
+#include "clang/Tooling/Core/Replacement.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_os_ostream.h"
-#include 
 
 namespace clang {
 namespace tooling {
@@ -284,44 +281,6 @@ std::string applyAllReplacements(StringR
   return Result;
 }
 
-tooling::Replacements formatReplacements(StringRef Code,
- const tooling::Replacements &Replaces,
- const format::FormatStyle &Style) {
-  if (Replaces.empty()) return Replacements();
-
-  std::string NewCode = applyAllReplacements(Code, Replaces);
-  std::vector ChangedRanges =
-  calculateChangedRangesInFile(Replaces);
-  StringRef FileName = Replaces.begin()->getFilePath();
-  tooling::Replacements FormatReplaces =
-  format::reformat(Style, NewCode, ChangedRanges, FileName);
-
-  tooling::Replacements MergedReplacements =
-  mergeReplacements(Replaces, FormatReplaces);
-  return MergedReplacements;
-}
-
-std::vector calculateChangedRangesInF

Re: r262232 - Implement new interfaces for code-formatting when applying replacements.

2016-02-29 Thread Manuel Klimek via cfe-commits
On Mon, Feb 29, 2016 at 5:39 PM Chandler Carruth 
wrote:

> On Mon, Feb 29, 2016 at 11:32 AM Manuel Klimek via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: klimek
>> Date: Mon Feb 29 10:27:41 2016
>> New Revision: 262232
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=262232&view=rev
>> Log:
>> Implement new interfaces for code-formatting when applying replacements.
>>
>
> Random request: provide more context in commit logs. =D
>
> When I randomly end up staring at patches for some reason, its really
> useful to know what the background is, or at least a bit of a clue.
>
> For example, here, why does applying replacements need new interfaces?
>
> Specifically context for those not 100% actively following along with the
> detailed discussion are super useful in the commit log where others end up
> reading about changes.
>

Thanks. Btw, this particular change has been rolled back because it
violates layering (that I completely missed).


>
>
>>
>> Patch by Eric Liu.
>>
>> Modified:
>> cfe/trunk/include/clang/Tooling/Core/Replacement.h
>> cfe/trunk/lib/Tooling/Core/Replacement.cpp
>> cfe/trunk/unittests/Tooling/CMakeLists.txt
>> cfe/trunk/unittests/Tooling/RefactoringTest.cpp
>>
>> Modified: cfe/trunk/include/clang/Tooling/Core/Replacement.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/Replacement.h?rev=262232&r1=262231&r2=262232&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Tooling/Core/Replacement.h (original)
>> +++ cfe/trunk/include/clang/Tooling/Core/Replacement.h Mon Feb 29
>> 10:27:41 2016
>> @@ -30,6 +30,10 @@ namespace clang {
>>
>>  class Rewriter;
>>
>> +namespace format {
>> +struct FormatStyle;
>> +} // namespace format
>> +
>>  namespace tooling {
>>
>>  /// \brief A source range independent of the \c SourceManager.
>> @@ -220,6 +224,41 @@ bool applyAllReplacements(const std::vec
>>  /// replacements cannot be applied, this returns an empty \c string.
>>  std::string applyAllReplacements(StringRef Code, const Replacements
>> &Replaces);
>>
>> +/// \brief Applies all replacements in \p Replaces to \p Code.
>> +///
>> +/// This completely ignores the path stored in each replacement. If one
>> or more
>> +/// replacements cannot be applied, this returns an empty \c string.
>> +std::string applyAllReplacements(StringRef Code,
>> + const std::vector
>> &Replaces);
>> +
>> +/// \brief Calculate the ranges in a single file that are affected by the
>> +/// Replacements.
>> +///
>> +/// \pre Replacements must be for the same file.
>> +std::vector
>> +calculateChangedRangesInFile(const tooling::Replacements &Replaces);
>> +
>> +/// \brief Return replacements that are merged from orginal replacements
>> +/// and the replacements for formatting the code after applying the
>> orginal
>> +/// replacements.
>> +tooling::Replacements formatReplacements(StringRef Code,
>> + const tooling::Replacements
>> &Replaces,
>> + const format::FormatStyle
>> &Style);
>> +
>> +/// \brief In addition to applying replacements as in
>> `applyAllReplacements`,
>> +/// this function also reformats the changed code after applying
>> replacements.
>> +///
>> +/// \pre Replacements must be for the same file and conflict-free.
>> +///
>> +/// Replacement applications happen independently of the success of
>> +/// other applications.
>> +///
>> +/// \returns the changed code if all replacements apply and code is
>> fixed.
>> +/// empty string otherwise.
>> +std::string applyAllReplacementsAndFormat(StringRef Code,
>> +  const Replacements &Replaces,
>> +  const format::FormatStyle
>> &Style);
>> +
>>  /// \brief Merges two sets of replacements with the second set referring
>> to the
>>  /// code after applying the first set. Within both 'First' and 'Second',
>>  /// replacements must not overlap.
>>
>> Modified: cfe/trunk/lib/Tooling/Core/Replacement.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/Replacement.cpp?rev=262232&r1=262231&r2=262232&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Tooling/Core/Replacement.cpp (original)
>> +++ cfe/trunk/lib/Tooling/Core/Replacement.cpp Mon Feb 29 10:27:41 2016
>> @@ -11,17 +11,20 @@
>>  //
>>
>>  
>> //===--===//
>>
>> +#include "clang/Tooling/Core/Replacement.h"
>> +
>>  #include "clang/Basic/Diagnostic.h"
>>  #include "clang/Basic/DiagnosticIDs.h"
>>  #include "clang/Basic/DiagnosticOptions.h"
>>  #include "clang/Basic/FileManager.h"
>>  #include "clang/Basic/SourceManager.h"
>> +#include "clang/Format/Format.h"
>>  #include "clang/Lex/Lexer.h"
>>  #include "clang/Rewrite/Core/Rewri

Re: [PATCH] D17286: Make FreeBSD and NetBSD use CLANG_DEFAULT_CXX_STDLIB

2016-02-29 Thread Joerg Sonnenberger via cfe-commits
joerg added a comment.

I dislike the value `default`, since with `CLANG_DEFAULT_CXX_STDLIB` it is not. 
Otherwise, it should be fine.


http://reviews.llvm.org/D17286



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


Re: [PATCH] D16396: Warn if variable cannot be implicitly instantiated

2016-02-29 Thread Serge Pavlov via cfe-commits
Any feedback?

Thanks,
--Serge

2016-01-21 14:33 GMT+06:00 Serge Pavlov :

> sepavloff created this revision.
> sepavloff added a reviewer: rsmith.
> sepavloff added subscribers: cfe-commits, silvas.
>
> Instantiation of static class members may be a source of user
> misunderstanding,
> especially in the case of using modules, PR24425 describes one of such
> examples.
> This patch implements warning if compiler tried to make implicit
> instantiation
> but could not find template definition. The implementation follows
> discussion
> of http://reviews.llvm.org/D12326.
>
> http://reviews.llvm.org/D16396
>
> Files:
>   include/clang/Basic/DiagnosticGroups.td
>   include/clang/Basic/DiagnosticSemaKinds.td
>   include/clang/Sema/Sema.h
>   lib/Sema/SemaTemplateInstantiateDecl.cpp
>   test/CXX/temp/temp.decls/temp.mem/p1.cpp
>   test/OpenMP/parallel_ast_print.cpp
>   test/OpenMP/parallel_sections_ast_print.cpp
>   test/OpenMP/task_ast_print.cpp
>   test/OpenMP/teams_ast_print.cpp
>   test/OpenMP/threadprivate_ast_print.cpp
>   test/SemaCXX/PR10177.cpp
>   test/SemaCXX/undefined-internal.cpp
>   test/SemaTemplate/unavailable-var-template.cpp
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16396: Warn if variable cannot be implicitly instantiated

2016-02-29 Thread Serge Pavlov via cfe-commits
sepavloff added a subscriber: sepavloff.
sepavloff added a comment.

Any feedback?

Thanks,
--Serge


http://reviews.llvm.org/D16396



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


Re: r261774 - Bail on compilation as soon as a job fails.

2016-02-29 Thread Nico Weber via cfe-commits
On Sun, Feb 28, 2016 at 3:40 PM, Justin Lebar  wrote:

> On Sun, Feb 28, 2016 at 1:46 PM, Nico Weber  wrote:
> > Do you think something like the implicit inputs thing in
> > http://reviews.llvm.org/D17695 could work for you as well, instead of
> this
> > patch?
>
> Having read just the patch description, I think it would be workable,
> although it might not be particularly clean.  I think you'd have to
> make most (all?) of the intermediate actions associated with a
> compilation be implicit inputs to all later actions in all other
> compilations.  Otherwise things like saving vs. not saving temps would
> give you different behavior.
>

Can you expand on this? The idea is that those implicit deps are in
addition to regular dependencies, not a replacement.


> It seems like kind of a fragile way to get this behavior.
>
> > Then we don't have to forever promise to compile all .cc input files
> > serially.
>
> I've thought about this some, since we don't really want this even for
> CUDA.  With CUDA, you commonly want to compile the device code for
> different architectures, and it would be reasonable to do those
> compilations in parallel.
>
> What I think may be a reasonable promise, at least for CUDA, is that
> we will behave *as if* we're compiling in series.  Which just means
> not interleaving diagnostics from different compilations, and not
> showing diagnostics from other subcompilations after we hit an error.
>
> I think basically nobody wants randomly-interleaved diagnostics.
> Whether or there's a good use-case where we continue after we hit an
> error is a harder question, I'm not sure.  But in any case, stopping
> after an error shouldn't mean we're forced to serialize, I think.
>

One problem I have with this change is that it breaks part of my patch ;-)
I'd like to run two commands, one to build a pch, and another to compile a
source file using the just-built pch, and if the first fails I don't want
to run the second: `make_pch && compile`. This part still works after your
patch. But we also have a flag /fallback that says "if compilation falls,
try again with this other compiler. Ideally I want `(make_pch && compile)
|| fallback_compile`, but since it's a bit of a corner case and arguably
good enough, my patch did `make_pch ; compile || fallback`. Your change
makes it impossible to run commands after one another if one fails, so now
this is `make_pch && (compile || fallback)`, i.e. if compilation of the pch
fails the fallback compiler won't be invoked.

I can try looking at maybe making FallbackCommand a FallbackAction instead
or something. But since CUDA seems to not fit the internal model of the
driver super well (lots of isCUDA() calls in many places), maybe it'd make
sense to discuss what your requirements are and if it's possible to extend
the Action / Job / Command abstractions in a way that support CUDA without
as many special cases. I happen to be in Mountain View – if you're in the
office tomorrow, maybe we could discuss this for half an hour or so in
person?


>
> -Justin
>
> > On Wed, Feb 24, 2016 at 4:49 PM, Justin Lebar via cfe-commits
> >  wrote:
> >>
> >> Author: jlebar
> >> Date: Wed Feb 24 15:49:28 2016
> >> New Revision: 261774
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=261774&view=rev
> >> Log:
> >> Bail on compilation as soon as a job fails.
> >>
> >> Summary:
> >> (Re-land of r260448, which was reverted in r260522 due to a test failure
> >> in Driver/output-file-cleanup.c that only showed up in fresh builds.)
> >>
> >> Previously we attempted to be smart; if one job failed, we'd run all
> >> jobs that didn't depend on the failing job.
> >>
> >> Problem is, this doesn't work well for e.g. CUDA compilation without
> >> -save-temps.  In this case, the device-side and host-side Assemble
> >> actions (which actually are responsible for preprocess, compile,
> >> backend, and assemble, since we're not saving temps) are necessarily
> >> distinct.  So our clever heuristic doesn't help us, and we repeat every
> >> error message once for host and once for each device arch.
> >>
> >> The main effect of this change, other than fixing CUDA, is that if you
> >> pass multiple cc files to one instance of clang and you get a compile
> >> error, we'll stop when the first cc1 job fails.
> >>
> >> Reviewers: echristo
> >>
> >> Subscribers: cfe-commits, jhen, echristo, tra, rafael
> >>
> >> Differential Revision: http://reviews.llvm.org/D17217
> >>
> >> Modified:
> >> cfe/trunk/lib/Driver/Compilation.cpp
> >> cfe/trunk/test/Driver/output-file-cleanup.c
> >>
> >> Modified: cfe/trunk/lib/Driver/Compilation.cpp
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Compilation.cpp?rev=261774&r1=261773&r2=261774&view=diff
> >>
> >>
> ==
> >> --- cfe/trunk/lib/Driver/Compilation.cpp (original)
> >> +++ cfe/trunk/lib/Driver/Compilation.cpp Wed Feb 24 15:49:28 2016
> >> @@ -163,39 +163,17 

Re: [PATCH] D17622: [PGO] clang cc1 option change to enable IR level instrumenation

2016-02-29 Thread Rong Xu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL262239: [PGO] clang cc1 option change to enable IR level 
instrumentation (authored by xur).

Changed prior to commit:
  http://reviews.llvm.org/D17622?vs=49243&id=49394#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17622

Files:
  cfe/trunk/include/clang/Driver/CC1Options.td
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/include/clang/Frontend/CodeGenOptions.h
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGen/pgo-instrumentation.c

Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def
@@ -104,7 +104,7 @@
 VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) is specified.
 
 /// \brief Choose profile instrumenation kind or no instrumentation.
-ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNoInstr)
+ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNone)
 CODEGENOPT(CoverageMapping , 1, 0) ///< Generate coverage mapping regions to
///< enable code coverage analysis.
 CODEGENOPT(DumpCoverageMapping , 1, 0) ///< Dump the generated coverage mapping
Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h
@@ -80,9 +80,10 @@
   };
 
   enum ProfileInstrKind {
-ProfileNoInstr,// No instrumentation.
-ProfileClangInstr  // Clang instrumentation to generate execution counts
+ProfileNone,   // Profile instrumentation is turned off.
+ProfileClangInstr, // Clang instrumentation to generate execution counts
// to use with PGO.
+ProfileIRInstr,// IR level PGO instrumentation in LLVM.
   };
 
   /// The code model to use (-mcmodel).
@@ -226,6 +227,11 @@
   bool hasProfileClangInstr() const {
 return getProfileInstr() == ProfileClangInstr;
   }
+
+  /// \brief Check if IR level profile instrumentation is on.
+  bool hasProfileIRInstr() const {
+return getProfileInstr() == ProfileIRInstr;
+  }
 };
 
 }  // end namespace clang
Index: cfe/trunk/include/clang/Driver/CC1Options.td
===
--- cfe/trunk/include/clang/Driver/CC1Options.td
+++ cfe/trunk/include/clang/Driver/CC1Options.td
@@ -274,8 +274,8 @@
 : Flag<["-"], "fsanitize-coverage-trace-pc">,
   HelpText<"Enable PC tracing in sanitizer coverage">;
 def fprofile_instrument_EQ : Joined<["-"], "fprofile-instrument=">,
-HelpText<"Enable PGO instrumentation. The accepted values is clang or "
- "none">;
+HelpText<"Enable PGO instrumentation. The accepted value is clang, llvm, "
+ "or none">;
 def fprofile_instrument_path_EQ : Joined<["-"], "fprofile-instrument-path=">,
 HelpText<"Generate instrumented code to collect execution counts into "
  " (overridden by LLVM_PROFILE_FILE env var)">;
Index: cfe/trunk/test/CodeGen/pgo-instrumentation.c
===
--- cfe/trunk/test/CodeGen/pgo-instrumentation.c
+++ cfe/trunk/test/CodeGen/pgo-instrumentation.c
@@ -0,0 +1,9 @@
+// Test if PGO instrumentation and use pass are invoked.
+//
+// Ensure Pass PGOInstrumentationGenPass is invoked.
+// RUN: %clang_cc1 -O2 -fprofile-instrument=llvm %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=CHECK-PGOGENPASS-INVOKED-INSTR-GEN
+// CHECK-PGOGENPASS-INVOKED-INSTR-GEN: PGOInstrumentationGenPass
+//
+// Ensure Pass PGOInstrumentationGenPass is not invoked.
+// RUN: %clang_cc1 -O2 -fprofile-instrument=clang %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=CHECK-PGOGENPASS-INVOKED-INSTR-GEN-CLANG
+// CHECK-PGOGENPASS-INVOKED-INSTR-GEN-CLANG-NOT: PGOInstrumentationGenPass
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -437,6 +437,12 @@
 Options.InstrProfileOutput = CodeGenOpts.InstrProfileOutput;
 MPM->add(createInstrProfilingPass(Options));
   }
+  if (CodeGenOpts.hasProfileIRInstr()) {
+if (!CodeGenOpts.InstrProfileOutput.empty())
+  PMBuilder.PGOInstrGen = CodeGenOpts.InstrProfileOutput;
+else
+  PMBuilder.PGOInstrGen = "default.profraw";
+  }
 
   if (!CodeGenOpts.SampleProfileFile.empty())
 MPM->add(createSampleProfileLoaderPass(CodeGenOpts.SampleProfileFile));
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvoca

r262239 - [PGO] clang cc1 option change to enable IR level instrumentation

2016-02-29 Thread Rong Xu via cfe-commits
Author: xur
Date: Mon Feb 29 12:54:59 2016
New Revision: 262239

URL: http://llvm.org/viewvc/llvm-project?rev=262239&view=rev
Log:
[PGO] clang cc1 option change to enable IR level instrumentation

This patch expands cc1 option -fprofile-instrument= with a new value: 
-fprofile-instrument=llvm
which enables IR level PGO instrumentation.

Reviewers: davidxl, silvas

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

Added:
cfe/trunk/test/CodeGen/pgo-instrumentation.c
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=262239&r1=262238&r2=262239&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Feb 29 12:54:59 2016
@@ -274,8 +274,8 @@ def fsanitize_coverage_trace_pc
 : Flag<["-"], "fsanitize-coverage-trace-pc">,
   HelpText<"Enable PC tracing in sanitizer coverage">;
 def fprofile_instrument_EQ : Joined<["-"], "fprofile-instrument=">,
-HelpText<"Enable PGO instrumentation. The accepted values is clang or "
- "none">;
+HelpText<"Enable PGO instrumentation. The accepted value is clang, llvm, "
+ "or none">;
 def fprofile_instrument_path_EQ : Joined<["-"], "fprofile-instrument-path=">,
 HelpText<"Generate instrumented code to collect execution counts into "
  " (overridden by LLVM_PROFILE_FILE env var)">;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=262239&r1=262238&r2=262239&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Mon Feb 29 12:54:59 2016
@@ -104,7 +104,7 @@ VALUE_CODEGENOPT(OptimizationLevel, 2, 0
 VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) is 
specified.
 
 /// \brief Choose profile instrumenation kind or no instrumentation.
-ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNoInstr)
+ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNone)
 CODEGENOPT(CoverageMapping , 1, 0) ///< Generate coverage mapping regions to
///< enable code coverage analysis.
 CODEGENOPT(DumpCoverageMapping , 1, 0) ///< Dump the generated coverage mapping

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.h?rev=262239&r1=262238&r2=262239&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h Mon Feb 29 12:54:59 2016
@@ -80,9 +80,10 @@ public:
   };
 
   enum ProfileInstrKind {
-ProfileNoInstr,// No instrumentation.
-ProfileClangInstr  // Clang instrumentation to generate execution counts
+ProfileNone,   // Profile instrumentation is turned off.
+ProfileClangInstr, // Clang instrumentation to generate execution counts
// to use with PGO.
+ProfileIRInstr,// IR level PGO instrumentation in LLVM.
   };
 
   /// The code model to use (-mcmodel).
@@ -226,6 +227,11 @@ public:
   bool hasProfileClangInstr() const {
 return getProfileInstr() == ProfileClangInstr;
   }
+
+  /// \brief Check if IR level profile instrumentation is on.
+  bool hasProfileIRInstr() const {
+return getProfileInstr() == ProfileIRInstr;
+  }
 };
 
 }  // end namespace clang

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=262239&r1=262238&r2=262239&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon Feb 29 12:54:59 2016
@@ -437,6 +437,12 @@ void EmitAssemblyHelper::CreatePasses(Fu
 Options.InstrProfileOutput = CodeGenOpts.InstrProfileOutput;
 MPM->add(createInstrProfilingPass(Options));
   }
+  if (CodeGenOpts.hasProfileIRInstr()) {
+if (!CodeGenOpts.InstrProfileOutput.empty())
+  PMBuilder.PGOInstrGen = CodeGenOpts.InstrProfileOutput;
+else
+  PMBuilder.PGOInstrGen = "default.profraw";
+  }
 
   if (!CodeGenOpts.SampleProfileFile.empty())
 MPM->add(createSampleProfileLoaderPass(CodeGenOpts.SampleProfileFile));

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc

RE: [PATCH] D17550: Adding doxygen comments to the LLVM intrinsics (part 6, popcntintrin.h)

2016-02-29 Thread Romanova, Katya via cfe-commits
Hi Dmitri,
Could you please let us know your opinion about C++ vs C-style doxygen 
comments. Read this thread for ‘pro’ and ‘con’ arguments about using C++ 
headers. Will LLVM online documentation look proper if we decide to use C-style 
headers? Which style do you personally prefer to see?

Note, that if there is any complaint in the future, it will take a couple of 
hours to write a python script to convert from C++ to C style doxygen comments.

Katya.

From: Eric Christopher [mailto:echri...@gmail.com]
Sent: Wednesday, February 24, 2016 6:40 PM
To: Romanova, Katya; reviews+d17550+public+bc8ce213fd9db...@reviews.llvm.org; 
Gao, Yunzhong; griboz...@gmail.com; craig.top...@gmail.com; Robinson, Paul
Cc: Bedwell, Greg; cfe-commits@lists.llvm.org
Subject: Re: [PATCH] D17550: Adding doxygen comments to the LLVM intrinsics 
(part 6, popcntintrin.h)

Those are all compelling reasons for me. Let's go with whatever you and Dmitri 
think would be best for now. :)

-eric

On Wed, Feb 24, 2016 at 12:41 PM Romanova, Katya 
mailto:katya_roman...@playstation.sony.com>>
 wrote:
Hello,

I don’t think it will too hard to convert C++ style doxygen comments into C 
style doxygen comments by writing a post-processing python script. However, at 
first we need to decide if we really want to do that. If so, we need to settle 
on the exact format. After that, I need to make sure that the comments in the 
new format will be rendered correctly in MS Tooltips, XCode, online 
documentation and PS4 internal documentation. This discussion + investigation 
might take a few days.

Before we start discussing the exact format, I want to make sure that we really 
want to change to C-style doxygen comments.
Here are my not-so-strong arguments against it:

-There currently are 257 occurrences C++ style comments in 14 other 
header files in /llvm/tools/clang/lib/Headers directory (I’m talking about the 
files that I didn’t touch). C++ style comments were there for AGES and nobody 
complained so far. If we decide to change C++ style doxygen comments -> 
C-style, we also need to change all regular C++ comments to C-style in these 
header files.

-c99 (and later) supports C++ style comments, while I c89 doesn’t. I’m 
not sure if we have users that still use c89 format and x86 intrinsic headers 
at the same time.

-C++ style doxygen comments are more pretty and readable compared to 
C-style comment (though it might be my subjective opinion).

Let me know what you think.

I will try to get Dmitri Gribenko’s opinion. He did a lot of work on doxygen in 
LLVM. I’m curious what he thinks about Javadoc style format.

Katya.


From: Eric Christopher [mailto:echri...@gmail.com]
Sent: Tuesday, February 23, 2016 10:51 PM
To: 
reviews+d17550+public+bc8ce213fd9db...@reviews.llvm.org;
 Romanova, Katya; Gao, Yunzhong; 
griboz...@gmail.com; 
craig.top...@gmail.com; Robinson, Paul
Cc: Bedwell, Greg; cfe-commits@lists.llvm.org
Subject: Re: [PATCH] D17550: Adding doxygen comments to the LLVM intrinsics 
(part 6, popcntintrin.h)


Yeah, we should be doing this. Nice catch Paul and Greg.

On Tue, Feb 23, 2016, 10:34 PM Greg Bedwell 
mailto:greg_bedw...@sn.scee.net>> wrote:
gbedwell added a subscriber: gbedwell.
gbedwell added a comment.

In http://reviews.llvm.org/D17550#360177, @probinson wrote:

> One question I have, which shouldn't block this (as we've done several like 
> this already):
>  Is is okay to be using C++ style comments in these headers?
>  (Is there a C-style comment that Doxygen recognizes?)


There are a few various formats that Doxygen supports.  Looking at headers from 
llvm-c the most common convention appears to be JavaDoc style, although there 
are a few examples of other supported styles floating around the codebase.  
E.g. from include/llvm-c/lto.h using JavaDoc style:

/**

- Diagnostic handler type.
- \p severity defines the severity.
- \p diag is the actual diagnostic.
- The diagnostic is not prefixed by any of severity keyword, e.g., 'error: '.
- \p ctxt is used to pass the context set with the diagnostic handler. *
- \since LTO_API_VERSION=7 */

-Greg


Repository:
  rL LLVM

http://reviews.llvm.org/D17550

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


Re: Embedded Bitcode in Object Files

2016-02-29 Thread Steven Wu via cfe-commits
Ping. I don't know who is the best review for the patches. Thanks for Rafael 
looking at the LLVM change. Richard, do you have any opinions on the clang 
changes?

Thanks

Steven

> On Feb 18, 2016, at 9:57 AM, Steven Wu  wrote:
> 
> Hi all
> 
> I put up some patches for embedding bitcode inside the object file 
> (-fembed-bitcode) option. As I described in the dev list before, the new 
> option can create normal object file with bitcode embedded in a special 
> section. You can easily recreate the same object file with the embedded 
> bitcode in it.
> 
> I split the patch into several parts:
> llvm patch:
> http://reviews.llvm.org/D17388: Introduce the section for embedding bitcode 
> in MachO file.
> 
> There are four clang patches:
> http://reviews.llvm.org/D17390: Implementing the clang driver for the new 
> option.
> http://reviews.llvm.org/D17392: Teach clang how to embed bitcode into the 
> object file.
> http://reviews.llvm.org/D17393: Slightly tweak the bitcode emitted in embed 
> bitcode stage 1.
> http://reviews.llvm.org/D17394: Reduce the amount of option gets embedded in 
> the bitcode by introducing a whitelist and a blacklist.
> 
> Let me know if anyone is interested in helping reviewing these changes.
> 
> Thanks
> 
> Steven
> 
> 
> 

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


[PATCH] D17727: Moved applyAllReplacementsAndFormat to clangFormat to avoid cyclic dependency.

2016-02-29 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added a reviewer: klimek.
ioeric added subscribers: klimek, cfe-commits.

Merge branch 'master' of http://llvm.org/git/clang
Moved applyAllReplacementsAndFormat to clangFormat to avoid cyclic dependency.

http://reviews.llvm.org/D17727

Files:
  include/clang/Format/Format.h
  include/clang/Tooling/Core/Replacement.h
  lib/Format/Format.cpp
  lib/Tooling/Core/Replacement.cpp
  unittests/Format/CMakeLists.txt
  unittests/Format/FormatTest.cpp
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -418,6 +418,25 @@
   EXPECT_FALSE(Range(0, 10).contains(Range(0, 11)));
 }
 
+TEST(Range, CalculateRangesOfReplacements) {
+  // Before: bbz
+  // After : bbzz
+  Replacements Replaces;
+  Replaces.insert(Replacement("foo", 0, 4, ""));
+  Replaces.insert(Replacement("foo", 10, 1, "zz"));
+  Replaces.insert(Replacement("foo", 11, 0, ""));
+
+  std::vector Ranges = calculateChangedRangesInFile(Replaces);
+
+  EXPECT_EQ(3ul, Ranges.size());
+  EXPECT_TRUE(Ranges[0].getOffset() == 0);
+  EXPECT_TRUE(Ranges[0].getLength() == 0);
+  EXPECT_TRUE(Ranges[1].getOffset() == 6);
+  EXPECT_TRUE(Ranges[1].getLength() == 6);
+  EXPECT_TRUE(Ranges[2].getOffset() == 12);
+  EXPECT_TRUE(Ranges[2].getLength() == 16);
+}
+
 TEST(DeduplicateTest, removesDuplicates) {
   std::vector Input;
   Input.push_back(Replacement("fileA", 50, 0, " foo "));
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -7,8 +7,12 @@
 //
 //===--===//
 
-#include "FormatTestUtils.h"
 #include "clang/Format/Format.h"
+
+#include "../Tooling/RewriterTestContext.h" // FIXME: is it okay to include it?
+#include "FormatTestUtils.h"
+
+#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "llvm/Support/Debug.h"
 #include "gtest/gtest.h"
 
@@ -11165,6 +11169,49 @@
   verifyFormat("include \"a.td\"\ninclude \"b.td\"", Style);
 }
 
+// This class is copied from ../Tooling/RefactoringTest.cpp
+// Although we are only use it in one test case, we need it for testing features
+// to be added in the future.
+class ReplacementTest : public ::testing::Test {
+protected:
+  tooling::Replacement createReplacement(SourceLocation Start, unsigned Length,
+ llvm::StringRef ReplacementText) {
+return tooling::Replacement(Context.Sources, Start, Length,
+ReplacementText);
+  }
+
+  RewriterTestContext Context;
+};
+
+TEST_F(ReplacementTest, FormatCodeAfterReplacements) {
+  // Column limit is 20.
+  std::string Code = "Type *a =\n"
+ "new Type();\n"
+ "g(i, 0, j,\n"
+ "  0, k, 0, mm);\n"
+ "int  bad = format   ;";
+  std::string Expected = "auto a = new Type();\n"
+ "g(i, nullptr,\n"
+ "  j, nullptr,\n"
+ "  k, nullptr,\n"
+ "  mm);\n"
+ "int  bad = format   ;";
+  FileID ID = Context.createInMemoryFile("format.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 1, 1), 6, "auto "));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 3, 10), 1, "nullptr"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 4, 3), 1, "nullptr"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 4, 13), 1, "nullptr"));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  Style.ColumnLimit = 20; // Set column limit to 20 to increase readibility.
+  EXPECT_EQ(Expected, applyAllReplacementsAndFormat(Code, Replaces, Style));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: unittests/Format/CMakeLists.txt
===
--- unittests/Format/CMakeLists.txt
+++ unittests/Format/CMakeLists.txt
@@ -13,5 +13,6 @@
 
 target_link_libraries(FormatTests
   clangFormat
+  clangFrontend
   clangToolingCore
   )
Index: lib/Tooling/Core/Replacement.cpp
===
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -11,14 +11,15 @@
 //
 //===--===//
 
+#include "clang/Tooling/Core/Replacement.h"
+
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticIDs.h"
 #include "clang/Basic/Diagnostic

Re: r261774 - Bail on compilation as soon as a job fails.

2016-02-29 Thread Justin Lebar via cfe-commits
> Can you expand on this? The idea is that those implicit deps are in addition 
> to regular dependencies, not a replacement.

Sure.

What I was trying to say is, suppose you have two CUDA device
compilations.  You want device compilation B to bail if device
compilation A fails.  So what are the implicit dependencies of B?

Well, B must implicitly depend on everything in A that may trigger a
failure.  Which is, I recall, four actions: preprocessor, compilation,
backend, and assemble.  It may in fact be one or two more because we
have these CUDADeviceActions that wrap other actions, and maybe we'd
have to depend on those too.

Or maybe the thing you're proposing is smart enough that we only need
to depend on the assemble action and it will infer the rest correctly.
Either way, I was just saying that if you add another action, C, it
now has to depend on everything from A and B, and so on.

> One problem I have with this change is that it breaks part of my patch ;-)

Now it's my turn to admit that I didn't quite follow the rest of this.  :)

> if you're in the office tomorrow, maybe we could discuss this for half an 
> hour or so in person?

Yes, absolutely, let's talk irl and figure this out.

On Mon, Feb 29, 2016 at 10:43 AM, Nico Weber  wrote:
> On Sun, Feb 28, 2016 at 3:40 PM, Justin Lebar  wrote:
>>
>> On Sun, Feb 28, 2016 at 1:46 PM, Nico Weber  wrote:
>> > Do you think something like the implicit inputs thing in
>> > http://reviews.llvm.org/D17695 could work for you as well, instead of
>> > this
>> > patch?
>>
>> Having read just the patch description, I think it would be workable,
>> although it might not be particularly clean.  I think you'd have to
>> make most (all?) of the intermediate actions associated with a
>> compilation be implicit inputs to all later actions in all other
>> compilations.  Otherwise things like saving vs. not saving temps would
>> give you different behavior.
>
>
> Can you expand on this? The idea is that those implicit deps are in addition
> to regular dependencies, not a replacement.
>
>>
>> It seems like kind of a fragile way to get this behavior.
>>
>> > Then we don't have to forever promise to compile all .cc input files
>> > serially.
>>
>> I've thought about this some, since we don't really want this even for
>> CUDA.  With CUDA, you commonly want to compile the device code for
>> different architectures, and it would be reasonable to do those
>> compilations in parallel.
>>
>> What I think may be a reasonable promise, at least for CUDA, is that
>> we will behave *as if* we're compiling in series.  Which just means
>> not interleaving diagnostics from different compilations, and not
>> showing diagnostics from other subcompilations after we hit an error.
>>
>> I think basically nobody wants randomly-interleaved diagnostics.
>> Whether or there's a good use-case where we continue after we hit an
>> error is a harder question, I'm not sure.  But in any case, stopping
>> after an error shouldn't mean we're forced to serialize, I think.
>
>
> One problem I have with this change is that it breaks part of my patch ;-)
> I'd like to run two commands, one to build a pch, and another to compile a
> source file using the just-built pch, and if the first fails I don't want to
> run the second: `make_pch && compile`. This part still works after your
> patch. But we also have a flag /fallback that says "if compilation falls,
> try again with this other compiler. Ideally I want `(make_pch && compile) ||
> fallback_compile`, but since it's a bit of a corner case and arguably good
> enough, my patch did `make_pch ; compile || fallback`. Your change makes it
> impossible to run commands after one another if one fails, so now this is
> `make_pch && (compile || fallback)`, i.e. if compilation of the pch fails
> the fallback compiler won't be invoked.
>
> I can try looking at maybe making FallbackCommand a FallbackAction instead
> or something. But since CUDA seems to not fit the internal model of the
> driver super well (lots of isCUDA() calls in many places), maybe it'd make
> sense to discuss what your requirements are and if it's possible to extend
> the Action / Job / Command abstractions in a way that support CUDA without
> as many special cases. I happen to be in Mountain View – if you're in the
> office tomorrow, maybe we could discuss this for half an hour or so in
> person?
>
>>
>>
>> -Justin
>>
>> > On Wed, Feb 24, 2016 at 4:49 PM, Justin Lebar via cfe-commits
>> >  wrote:
>> >>
>> >> Author: jlebar
>> >> Date: Wed Feb 24 15:49:28 2016
>> >> New Revision: 261774
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=261774&view=rev
>> >> Log:
>> >> Bail on compilation as soon as a job fails.
>> >>
>> >> Summary:
>> >> (Re-land of r260448, which was reverted in r260522 due to a test
>> >> failure
>> >> in Driver/output-file-cleanup.c that only showed up in fresh builds.)
>> >>
>> >> Previously we attempted to be smart; if one job failed, we'd run all
>> >> jobs that didn't de

Re: [PATCH] D17286: Make FreeBSD and NetBSD use CLANG_DEFAULT_CXX_STDLIB

2016-02-29 Thread Jonas Hahnfeld via cfe-commits
Hahnfeld added a comment.

In http://reviews.llvm.org/D17286#364353, @joerg wrote:

> I dislike the value `default`, since with `CLANG_DEFAULT_CXX_STDLIB` it is 
> not. Otherwise, it should be fine.


Hmm, had this feeling as well... What about `-stdlib=test` as I only plan to 
use this for the tests that require it?


http://reviews.llvm.org/D17286



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


Re: [PATCH] D17390: Introduce -fembed-bitcode driver option

2016-02-29 Thread Nico Weber via cfe-commits
thakis added a subscriber: thakis.
thakis added a comment.

I don't understand the changes to Driver.cpp lines 1760 and down. The rest 
looks good to me.



Comment at: lib/Driver/Driver.cpp:1761
@@ -1747,1 +1760,3 @@
+const ActionList *BackendInputs =
+  (EmbedBitcode ? Inputs : &(*Inputs)[0]->getInputs());
 // Compile job may be wrapped in CudaHostAction, extract it if

Why is this change needed? If its needed, is the preceding comment out of date 
now?


http://reviews.llvm.org/D17390



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


Re: [PATCH] D17286: Make FreeBSD and NetBSD use CLANG_DEFAULT_CXX_STDLIB

2016-02-29 Thread Joerg Sonnenberger via cfe-commits
joerg added a comment.

I was thinking about something like `-stdlib=platform` to reflect that it is 
the target choice.


http://reviews.llvm.org/D17286



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


Re: [PATCH] D17286: Make FreeBSD and NetBSD use CLANG_DEFAULT_CXX_STDLIB

2016-02-29 Thread Jonas Hahnfeld via cfe-commits
Hahnfeld added a comment.

In http://reviews.llvm.org/D17286#364544, @joerg wrote:

> I was thinking about something like `-stdlib=platform` to reflect that it is 
> the target choice.


Ah yes, that was the term I was missing, `architecture` wasn't actually correct


http://reviews.llvm.org/D17286



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


Re: r261774 - Bail on compilation as soon as a job fails.

2016-02-29 Thread David Blaikie via cfe-commits
On Mon, Feb 29, 2016 at 11:19 AM, Justin Lebar via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> > Can you expand on this? The idea is that those implicit deps are in
> addition to regular dependencies, not a replacement.
>
> Sure.
>
> What I was trying to say is, suppose you have two CUDA device
> compilations.  You want device compilation B to bail if device
> compilation A fails.  So what are the implicit dependencies of B?
>
> Well, B must implicitly depend on everything in A that may trigger a
> failure.  Which is, I recall, four actions: preprocessor, compilation,
> backend, and assemble.  It may in fact be one or two more because we
> have these CUDADeviceActions that wrap other actions, and maybe we'd
> have to depend on those too.
>

Yeah, that doesn't sound quite right - presumably our link action doesn't
depend on all those steps, just the last one. If any others fail, the rest
can't run (because they depend on them in turn) so the link won't run.

(but, yeah, I'm no Driver expert by any means..)


>
> Or maybe the thing you're proposing is smart enough that we only need
> to depend on the assemble action and it will infer the rest correctly.
> Either way, I was just saying that if you add another action, C, it
> now has to depend on everything from A and B, and so on.
>
> > One problem I have with this change is that it breaks part of my patch
> ;-)
>
> Now it's my turn to admit that I didn't quite follow the rest of this.  :)
>
> > if you're in the office tomorrow, maybe we could discuss this for half
> an hour or so in person?
>
> Yes, absolutely, let's talk irl and figure this out.
>
> On Mon, Feb 29, 2016 at 10:43 AM, Nico Weber  wrote:
> > On Sun, Feb 28, 2016 at 3:40 PM, Justin Lebar  wrote:
> >>
> >> On Sun, Feb 28, 2016 at 1:46 PM, Nico Weber 
> wrote:
> >> > Do you think something like the implicit inputs thing in
> >> > http://reviews.llvm.org/D17695 could work for you as well, instead of
> >> > this
> >> > patch?
> >>
> >> Having read just the patch description, I think it would be workable,
> >> although it might not be particularly clean.  I think you'd have to
> >> make most (all?) of the intermediate actions associated with a
> >> compilation be implicit inputs to all later actions in all other
> >> compilations.  Otherwise things like saving vs. not saving temps would
> >> give you different behavior.
> >
> >
> > Can you expand on this? The idea is that those implicit deps are in
> addition
> > to regular dependencies, not a replacement.
> >
> >>
> >> It seems like kind of a fragile way to get this behavior.
> >>
> >> > Then we don't have to forever promise to compile all .cc input files
> >> > serially.
> >>
> >> I've thought about this some, since we don't really want this even for
> >> CUDA.  With CUDA, you commonly want to compile the device code for
> >> different architectures, and it would be reasonable to do those
> >> compilations in parallel.
> >>
> >> What I think may be a reasonable promise, at least for CUDA, is that
> >> we will behave *as if* we're compiling in series.  Which just means
> >> not interleaving diagnostics from different compilations, and not
> >> showing diagnostics from other subcompilations after we hit an error.
> >>
> >> I think basically nobody wants randomly-interleaved diagnostics.
> >> Whether or there's a good use-case where we continue after we hit an
> >> error is a harder question, I'm not sure.  But in any case, stopping
> >> after an error shouldn't mean we're forced to serialize, I think.
> >
> >
> > One problem I have with this change is that it breaks part of my patch
> ;-)
> > I'd like to run two commands, one to build a pch, and another to compile
> a
> > source file using the just-built pch, and if the first fails I don't
> want to
> > run the second: `make_pch && compile`. This part still works after your
> > patch. But we also have a flag /fallback that says "if compilation falls,
> > try again with this other compiler. Ideally I want `(make_pch &&
> compile) ||
> > fallback_compile`, but since it's a bit of a corner case and arguably
> good
> > enough, my patch did `make_pch ; compile || fallback`. Your change makes
> it
> > impossible to run commands after one another if one fails, so now this is
> > `make_pch && (compile || fallback)`, i.e. if compilation of the pch fails
> > the fallback compiler won't be invoked.
> >
> > I can try looking at maybe making FallbackCommand a FallbackAction
> instead
> > or something. But since CUDA seems to not fit the internal model of the
> > driver super well (lots of isCUDA() calls in many places), maybe it'd
> make
> > sense to discuss what your requirements are and if it's possible to
> extend
> > the Action / Job / Command abstractions in a way that support CUDA
> without
> > as many special cases. I happen to be in Mountain View – if you're in the
> > office tomorrow, maybe we could discuss this for half an hour or so in
> > person?
> >
> >>
> >>
> >> -Justin
> >>
> >> > On Wed,

Re: [PATCH] D17695: clang-cl: Implement initial limited support for precompiled headers.

2016-02-29 Thread Hans Wennborg via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Very nice!

I only have some style nits, really. Look forward to using this :-)



Comment at: include/clang/Basic/DiagnosticDriverKinds.td:112
@@ +111,3 @@
+def warn_drv_yc_multiple_inputs_clang_cl : Warning<
+  "support for '/Yc' with more than one input source file not implemented yet, 
ignoring flag">,
+  InGroup;

nit: I think it's more common in Clang's warnings to say "ignored" than 
"ignoring", and "flag ignored" saves one character :-)

Also I would have gone for a semicolon instead of comma, but this is not 
important.

Maybe "input" is redundant in "more than one input source file"?




Comment at: include/clang/Driver/CLCompatOptions.td:258
@@ +257,3 @@
+def _SLASH_Yu : CLJoined<"Yu">;
+def _SLASH_Fp : CLJoined<"Fp">;
+

Can you add HelpText for these? I've tried to be good about documenting 
supported cl-mode flags.


Comment at: lib/Driver/Driver.cpp:1448
@@ +1447,3 @@
+  Arg *YuArg = Args.getLastArg(options::OPT__SLASH_Yu);
+  if (YcArg && YcArg->getValue()[0] == '\0') {
+Diag(clang::diag::warn_drv_ycyu_no_arg_clang_cl) << YcArg->getSpelling();

A bit surprised that getValue() doesn't return a StringRef. But given that it 
doesn't, I suppose this is the nicest way to write it.


Comment at: lib/Driver/Driver.cpp:1466
@@ +1465,3 @@
+StringRef Val = YcArg ? YcArg->getValue() : YuArg->getValue();
+bool Found = false;
+for (const Arg *Inc : Args.filtered(options::OPT_include)) {

FoundMatchingInclude?


Comment at: lib/Driver/Driver.cpp:2178
@@ -2085,3 +2177,3 @@
   NamedOutput = C.getArgs().MakeArgString(Output.c_str());
 } else
   NamedOutput = getDefaultImageName();

maybe add curlies around this else statement to make it a little easier to 
parse the else if that comes after?


Comment at: lib/Driver/Driver.cpp:2355
@@ +2354,3 @@
+
+// Add pch if needed: "If you do not specify an extension as part of the
+// path name, an extension of .pch is assumed. "

Maybe add .pch if needed?


Comment at: lib/Driver/Tools.cpp:395
@@ +394,3 @@
+for (const Arg *A : Args.filtered(options::OPT_clang_i_Group)) {
+  // Walk the whole i_Group and the skip non "-include" flags so that the
+  // index here matches the index in the next loop below.

"the skip" -> just "skip"?


Comment at: lib/Driver/Tools.cpp:431
@@ +430,3 @@
+  if (AI >= YcIndex)
+continue;
+} else {

I got confused here, because even if we don't "continue", we still won't hit 
the else if (A->getOption().matches(options::OPT_include)) branch below.

But that branch is just dealing with implicit includes, we will still do the 
"Not translated, render as usual." step.

Maybe add a comment to the "else if" branch below that that code is for non-CL 
style PCH includes?


http://reviews.llvm.org/D17695



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


Re: r261774 - Bail on compilation as soon as a job fails.

2016-02-29 Thread Justin Lebar via cfe-commits
I think the reason this becomes tricky is that you can reuse Action
nodes for multiple invocations of cc1 (or your favorite tool).  We do
this on macos with bindarch for universal binaries.

So you can't necessarily point to one CompilationAction node and say
"*that* failed with an error", with no ambiguity.

On Mon, Feb 29, 2016 at 12:50 PM, David Blaikie  wrote:
>
>
> On Mon, Feb 29, 2016 at 11:19 AM, Justin Lebar via cfe-commits
>  wrote:
>>
>> > Can you expand on this? The idea is that those implicit deps are in
>> > addition to regular dependencies, not a replacement.
>>
>> Sure.
>>
>> What I was trying to say is, suppose you have two CUDA device
>> compilations.  You want device compilation B to bail if device
>> compilation A fails.  So what are the implicit dependencies of B?
>>
>> Well, B must implicitly depend on everything in A that may trigger a
>> failure.  Which is, I recall, four actions: preprocessor, compilation,
>> backend, and assemble.  It may in fact be one or two more because we
>> have these CUDADeviceActions that wrap other actions, and maybe we'd
>> have to depend on those too.
>
>
> Yeah, that doesn't sound quite right - presumably our link action doesn't
> depend on all those steps, just the last one. If any others fail, the rest
> can't run (because they depend on them in turn) so the link won't run.
>
> (but, yeah, I'm no Driver expert by any means..)
>
>>
>>
>> Or maybe the thing you're proposing is smart enough that we only need
>> to depend on the assemble action and it will infer the rest correctly.
>> Either way, I was just saying that if you add another action, C, it
>> now has to depend on everything from A and B, and so on.
>>
>> > One problem I have with this change is that it breaks part of my patch
>> > ;-)
>>
>> Now it's my turn to admit that I didn't quite follow the rest of this.  :)
>>
>> > if you're in the office tomorrow, maybe we could discuss this for half
>> > an hour or so in person?
>>
>> Yes, absolutely, let's talk irl and figure this out.
>>
>> On Mon, Feb 29, 2016 at 10:43 AM, Nico Weber  wrote:
>> > On Sun, Feb 28, 2016 at 3:40 PM, Justin Lebar  wrote:
>> >>
>> >> On Sun, Feb 28, 2016 at 1:46 PM, Nico Weber 
>> >> wrote:
>> >> > Do you think something like the implicit inputs thing in
>> >> > http://reviews.llvm.org/D17695 could work for you as well, instead of
>> >> > this
>> >> > patch?
>> >>
>> >> Having read just the patch description, I think it would be workable,
>> >> although it might not be particularly clean.  I think you'd have to
>> >> make most (all?) of the intermediate actions associated with a
>> >> compilation be implicit inputs to all later actions in all other
>> >> compilations.  Otherwise things like saving vs. not saving temps would
>> >> give you different behavior.
>> >
>> >
>> > Can you expand on this? The idea is that those implicit deps are in
>> > addition
>> > to regular dependencies, not a replacement.
>> >
>> >>
>> >> It seems like kind of a fragile way to get this behavior.
>> >>
>> >> > Then we don't have to forever promise to compile all .cc input files
>> >> > serially.
>> >>
>> >> I've thought about this some, since we don't really want this even for
>> >> CUDA.  With CUDA, you commonly want to compile the device code for
>> >> different architectures, and it would be reasonable to do those
>> >> compilations in parallel.
>> >>
>> >> What I think may be a reasonable promise, at least for CUDA, is that
>> >> we will behave *as if* we're compiling in series.  Which just means
>> >> not interleaving diagnostics from different compilations, and not
>> >> showing diagnostics from other subcompilations after we hit an error.
>> >>
>> >> I think basically nobody wants randomly-interleaved diagnostics.
>> >> Whether or there's a good use-case where we continue after we hit an
>> >> error is a harder question, I'm not sure.  But in any case, stopping
>> >> after an error shouldn't mean we're forced to serialize, I think.
>> >
>> >
>> > One problem I have with this change is that it breaks part of my patch
>> > ;-)
>> > I'd like to run two commands, one to build a pch, and another to compile
>> > a
>> > source file using the just-built pch, and if the first fails I don't
>> > want to
>> > run the second: `make_pch && compile`. This part still works after your
>> > patch. But we also have a flag /fallback that says "if compilation
>> > falls,
>> > try again with this other compiler. Ideally I want `(make_pch &&
>> > compile) ||
>> > fallback_compile`, but since it's a bit of a corner case and arguably
>> > good
>> > enough, my patch did `make_pch ; compile || fallback`. Your change makes
>> > it
>> > impossible to run commands after one another if one fails, so now this
>> > is
>> > `make_pch && (compile || fallback)`, i.e. if compilation of the pch
>> > fails
>> > the fallback compiler won't be invoked.
>> >
>> > I can try looking at maybe making FallbackCommand a FallbackAction
>> > instead
>> > or something. But since CUDA s

[clang-tools-extra] r262257 - IdentifierNamingCheck.cpp: try to fix MSVC build

2016-02-29 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Feb 29 15:17:39 2016
New Revision: 262257

URL: http://llvm.org/viewvc/llvm-project?rev=262257&view=rev
Log:
IdentifierNamingCheck.cpp: try to fix MSVC build

It was failing to build with:

clang-tidy\readability\IdentifierNamingCheck.cpp(640):
error C2882: 'format' : illegal use of namespace identifier in expression

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

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp?rev=262257&r1=262256&r2=262257&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp 
Mon Feb 29 15:17:39 2016
@@ -634,10 +634,10 @@ void IdentifierNamingCheck::check(const
 std::string Fixup = fixupWithStyle(Name, Style);
 if (StringRef(Fixup).equals(Name)) {
   if (!IgnoreFailedSplit) {
-DEBUG(llvm::dbgs() << Decl->getLocStart().printToString(
-  *Result.SourceManager)
-   << format(": unable to split words for %s '%s'\n",
- KindName.c_str(), Name));
+DEBUG(llvm::dbgs()
+  << Decl->getLocStart().printToString(*Result.SourceManager)
+  << llvm::format(": unable to split words for %s '%s'\n",
+  KindName.c_str(), Name));
   }
 } else {
   NamingCheckFailure &Failure = NamingCheckFailures[Decl];


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


[PATCH] D17734: [libcxx] PR26777 Fix tests when built with CXX="ccache clang++"

2016-02-29 Thread don hinton via cfe-commits
hintonda created this revision.
hintonda added a reviewer: mclow.lists.
hintonda added a subscriber: cfe-commits.

If you use ccache to build libcxx by setting CXX="ccache
clang++", check-libcxx will fail since LIBCXX_COMPILER will be set to
"ccache".

We can't just include CMAKE_CXX_COMPILER_ARG1 because of a python
parsing issue, so the best we can do right now is to use
CMAKE_CXX_COMPILER_ARG1 if it exists, and CMAKE_CXX_COMPILER if it
doesn't.

http://reviews.llvm.org/D17734

Files:
  CMakeLists.txt

Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -219,7 +219,14 @@
 # Configure System
 
#===
 
-set(LIBCXX_COMPILER${CMAKE_CXX_COMPILER})
+# When ccache is used, the actual compiler will be in arg1.  Solves
+# a python parsing issue in CXXCompiler() where parameters with spaces are
+# treated as seperate parameters.
+if(CMAKE_CXX_COMPILER_ARG1)
+  string(STRIP ${CMAKE_CXX_COMPILER_ARG1} LIBCXX_COMPILER )
+else()
+  set(LIBCXX_COMPILER ${CMAKE_CXX_COMPILER})
+endif()
 set(LIBCXX_SOURCE_DIR  ${CMAKE_CURRENT_SOURCE_DIR})
 set(LIBCXX_BINARY_DIR  ${CMAKE_CURRENT_BINARY_DIR})
 set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -219,7 +219,14 @@
 # Configure System
 #===
 
-set(LIBCXX_COMPILER${CMAKE_CXX_COMPILER})
+# When ccache is used, the actual compiler will be in arg1.  Solves
+# a python parsing issue in CXXCompiler() where parameters with spaces are
+# treated as seperate parameters.
+if(CMAKE_CXX_COMPILER_ARG1)
+  string(STRIP ${CMAKE_CXX_COMPILER_ARG1} LIBCXX_COMPILER )
+else()
+  set(LIBCXX_COMPILER ${CMAKE_CXX_COMPILER})
+endif()
 set(LIBCXX_SOURCE_DIR  ${CMAKE_CURRENT_SOURCE_DIR})
 set(LIBCXX_BINARY_DIR  ${CMAKE_CURRENT_BINARY_DIR})
 set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262261 - [analyzer] Don't treat calls to system headers as escaping in CheckObjCDealloc.

2016-02-29 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Mon Feb 29 15:44:08 2016
New Revision: 262261

URL: http://llvm.org/viewvc/llvm-project?rev=262261&view=rev
Log:
[analyzer] Don't treat calls to system headers as escaping in CheckObjCDealloc.

This prevents false negatives when a -dealloc method, for example, removes 
itself as
as an observer with [[NSNotificationCenter defaultCenter] removeObserver:self]. 
It is
unlikely that passing 'self' to a system header method will release 'self''s 
instance
variables, so this is unlikely to produce false positives.

A challenge here is that while CheckObjCDealloc no longer treats these calls as
escaping, the rest of the analyzer still does. In particular, this means that 
loads
from the same instance variable before and after a call to a system header will
result in different symbols being loaded by the region store. To account for 
this,
the checker now treats different ivar symbols with the same instance and ivar 
decl as
the same for the purpose of release checking and more eagerly removes a release
requirement when an instance variable is assumed to be nil. This was not needed 
before
because when an ivar escaped its release requirement was always removed -- now 
the
requirement is not removed for calls to system headers.

Added:
cfe/trunk/test/Analysis/Inputs/system-header-simulator-for-objc-dealloc.h
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
cfe/trunk/test/Analysis/DeallocMissingRelease.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp?rev=262261&r1=262260&r2=262261&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp Mon Feb 29 
15:44:08 2016
@@ -93,6 +93,7 @@ class ObjCDeallocChecker
 : public Checker,
  check::PreObjCMessage, check::PostObjCMessage,
  check::BeginFunction, check::EndFunction,
+ eval::Assume,
  check::PointerEscape,
  check::PreStmt> {
 
@@ -111,6 +112,9 @@ public:
   void checkPreObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const;
   void checkPostObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const;
 
+  ProgramStateRef evalAssume(ProgramStateRef State, SVal Cond,
+ bool Assumption) const;
+
   ProgramStateRef checkPointerEscape(ProgramStateRef State,
  const InvalidatedSymbols &Escaped,
  const CallEvent *Call,
@@ -129,6 +133,7 @@ private:
   SymbolRef getValueReleasedByNillingOut(const ObjCMethodCall &M,
  CheckerContext &C) const;
 
+  const ObjCIvarRegion *getIvarRegionForIvarSymbol(SymbolRef IvarSym) const;
   SymbolRef getInstanceSymbolFromIvarSymbol(SymbolRef IvarSym) const;
 
   ReleaseRequirement
@@ -284,20 +289,31 @@ void ObjCDeallocChecker::checkBeginFunct
   }
 }
 
+/// Given a symbol for an ivar, return the ivar region it was loaded from.
+/// Returns nullptr if the instance symbol cannot be found.
+const ObjCIvarRegion *
+ObjCDeallocChecker::getIvarRegionForIvarSymbol(SymbolRef IvarSym) const {
+  const MemRegion *RegionLoadedFrom = nullptr;
+  if (auto *DerivedSym = dyn_cast(IvarSym))
+RegionLoadedFrom = DerivedSym->getRegion();
+  else if (auto *RegionSym = dyn_cast(IvarSym))
+RegionLoadedFrom = RegionSym->getRegion();
+  else
+return nullptr;
+
+  return dyn_cast(RegionLoadedFrom);
+}
+
 /// Given a symbol for an ivar, return a symbol for the instance containing
 /// the ivar. Returns nullptr if the instance symbol cannot be found.
 SymbolRef
 ObjCDeallocChecker::getInstanceSymbolFromIvarSymbol(SymbolRef IvarSym) const {
-  if (auto *SRV = dyn_cast(IvarSym)) {
-const TypedValueRegion *TVR = SRV->getRegion();
-const ObjCIvarRegion *IvarRegion = dyn_cast_or_null(TVR);
-if (!IvarRegion)
-  return nullptr;
 
-return IvarRegion->getSymbolicBase()->getSymbol();
-  }
+  const ObjCIvarRegion *IvarRegion = getIvarRegionForIvarSymbol(IvarSym);
+  if (!IvarRegion)
+return nullptr;
 
-  return nullptr;
+  return IvarRegion->getSymbolicBase()->getSymbol();
 }
 
 /// If we are in -dealloc or -dealloc is on the stack, handle the call if it is
@@ -362,11 +378,58 @@ void ObjCDeallocChecker::checkPreStmt(
   diagnoseMissingReleases(C);
 }
 
+/// When a symbol is assumed to be nil, remove it from the set of symbols
+/// require to be nil.
+ProgramStateRef ObjCDeallocChecker::evalAssume(ProgramStateRef State, SVal 
Cond,
+   bool Assumption) const {
+  if (State->get().isEmpty())
+return State;
+
+  auto *CondBSE = dyn_cast_or_null(Cond.getAsSymExpr());
+  if (!CondBSE)
+return State;
+
+  Bin

[PATCH] D17735: [libcxxabi] PR26778 Fix tests when CXX="ccache clang++"

2016-02-29 Thread don hinton via cfe-commits
hintonda created this revision.
hintonda added a reviewer: mclow.lists.
hintonda added a subscriber: cfe-commits.

If you use ccache to build libcxxabi by setting CXX="ccache
clang++", check-libcxxabi will fail since LIBCXXABI_COMPILER will be
set to "ccache".

We can't just include CMAKE_CXX_COMPILER_ARG1 because of a python
parsing issue, so the best we can do right now is to use
CMAKE_CXX_COMPILER_ARG1 if it exists, and CMAKE_CXX_COMPILER if it
doesn't.

http://reviews.llvm.org/D17735

Files:
  CMakeLists.txt

Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -177,7 +177,14 @@
 # Configure compiler.
 include(config-ix)
 
-set(LIBCXXABI_COMPILER${CMAKE_CXX_COMPILER})
+# When ccache is used, the actual compiler will be in arg1.  Solves
+# a python parsing issue in CXXCompiler() where parameters with spaces are
+# treated as seperate parameters.
+if(CMAKE_CXX_COMPILER_ARG1)
+  string(STRIP ${CMAKE_CXX_COMPILER_ARG1} LIBCXXABI_COMPILER )
+else()
+  set(LIBCXXABI_COMPILER ${CMAKE_CXX_COMPILER})
+endif()
 set(LIBCXXABI_SOURCE_DIR  ${CMAKE_CURRENT_SOURCE_DIR})
 set(LIBCXXABI_BINARY_DIR  ${CMAKE_CURRENT_BINARY_DIR})
 set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -177,7 +177,14 @@
 # Configure compiler.
 include(config-ix)
 
-set(LIBCXXABI_COMPILER${CMAKE_CXX_COMPILER})
+# When ccache is used, the actual compiler will be in arg1.  Solves
+# a python parsing issue in CXXCompiler() where parameters with spaces are
+# treated as seperate parameters.
+if(CMAKE_CXX_COMPILER_ARG1)
+  string(STRIP ${CMAKE_CXX_COMPILER_ARG1} LIBCXXABI_COMPILER )
+else()
+  set(LIBCXXABI_COMPILER ${CMAKE_CXX_COMPILER})
+endif()
 set(LIBCXXABI_SOURCE_DIR  ${CMAKE_CURRENT_SOURCE_DIR})
 set(LIBCXXABI_BINARY_DIR  ${CMAKE_CURRENT_BINARY_DIR})
 set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D17737: [PGO] change profile use cc1 option

2016-02-29 Thread Rong Xu via cfe-commits
xur created this revision.
xur added reviewers: davidxl, silvas, bogner.
xur added subscribers: davidxl, xur, cfe-commits.

This patch takes the suggestion by Sean Silva in 
https://reviews.llvm.org/D17622 to decouple cc1 option from driver level option.

-fprofile-instr-use={} is now a driver only option. The cc1 part is replaced by 
-fprofile-instrument-use={llvm,clang}.
It sets a CodeGenOpt `ProfileUse` which is either {None, Clang, LLVM}, a common 
enum for -fprofile-instrument={} (for the profile instrument).

The profile path cc1 option now becomes -fprofile-instrument-usepath={}.

http://reviews.llvm.org/D17737

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/Inputs/pgotestclang.profraw
  test/CodeGen/Inputs/pgotestir.profraw
  test/CodeGen/pgo-instrumentation.c
  test/Driver/clang_f_opts.c
  test/Profile/c-captured.c
  test/Profile/c-counter-overflows.c
  test/Profile/c-general.c
  test/Profile/c-outdated-data.c
  test/Profile/c-unprofiled-blocks.c
  test/Profile/c-unprofiled.c
  test/Profile/cxx-lambda.cpp
  test/Profile/cxx-rangefor.cpp
  test/Profile/cxx-templates.cpp
  test/Profile/objc-general.m
  test/Profile/profile-does-not-exist.c

Index: test/Profile/profile-does-not-exist.c
===
--- test/Profile/profile-does-not-exist.c
+++ test/Profile/profile-does-not-exist.c
@@ -1,4 +1,4 @@
-// RUN: not %clang_cc1 -emit-llvm %s -o - -fprofile-instr-use=%t.nonexistent.profdata 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -emit-llvm %s -o - -fprofile-instrument-usepath=%t.nonexistent.profdata -fprofile-instrument-use=clang 2>&1 | FileCheck %s
 
 // CHECK: error: Could not read profile {{.*}}.nonexistent.profdata:
 // CHECK-NOT: Assertion failed
Index: test/Profile/objc-general.m
===
--- test/Profile/objc-general.m
+++ test/Profile/objc-general.m
@@ -3,7 +3,7 @@
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name objc-general.m %s -o - -emit-llvm -fblocks -fprofile-instrument=clang | FileCheck -check-prefix=PGOGEN %s
 
 // RUN: llvm-profdata merge %S/Inputs/objc-general.proftext -o %t.profdata
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name objc-general.m %s -o - -emit-llvm -fblocks -fprofile-instr-use=%t.profdata | FileCheck -check-prefix=PGOUSE %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name objc-general.m %s -o - -emit-llvm -fblocks -fprofile-instrument-usepath=%t.profdata -fprofile-instrument-use=clang | FileCheck -check-prefix=PGOUSE %s
 
 #ifdef HAVE_FOUNDATION
 
Index: test/Profile/cxx-templates.cpp
===
--- test/Profile/cxx-templates.cpp
+++ test/Profile/cxx-templates.cpp
@@ -6,7 +6,7 @@
 // RUN: FileCheck --input-file=%tgen -check-prefix=T100GEN -check-prefix=ALL %s
 
 // RUN: llvm-profdata merge %S/Inputs/cxx-templates.proftext -o %t.profdata
-// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-templates.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-use=%t.profdata > %tuse
+// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-templates.cpp -std=c++11 -o - -emit-llvm -fprofile-instrument-usepath=%t.profdata -fprofile-instrument-use=clang > %tuse
 // RUN: FileCheck --input-file=%tuse -check-prefix=T0USE -check-prefix=ALL %s
 // RUN: FileCheck --input-file=%tuse -check-prefix=T100USE -check-prefix=ALL %s
 
Index: test/Profile/cxx-rangefor.cpp
===
--- test/Profile/cxx-rangefor.cpp
+++ test/Profile/cxx-rangefor.cpp
@@ -4,7 +4,7 @@
 // RUN: FileCheck --input-file=%tgen -check-prefix=CHECK -check-prefix=PGOGEN %s
 
 // RUN: llvm-profdata merge %S/Inputs/cxx-rangefor.proftext -o %t.profdata
-// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-rangefor.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-use=%t.profdata > %tuse
+// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-rangefor.cpp -std=c++11 -o - -emit-llvm -fprofile-instrument-usepath=%t.profdata -fprofile-instrument-use=clang > %tuse
 // RUN: FileCheck --input-file=%tuse -check-prefix=CHECK -check-prefix=PGOUSE %s
 
 // PGOGEN: @[[RFC:__profc__Z9range_forv]] = private global [5 x i64] zeroinitializer
Index: test/Profile/cxx-lambda.cpp
===
--- test/Profile/cxx-lambda.cpp
+++ test/Profile/cxx-lambda.cpp
@@ -5,7 +5,7 @@
 // RUN: FileCheck --input-file=%tgen -check-prefix=LMBGEN %s
 
 // RUN: llvm-profdata merge %S/Inputs/cxx-lambda.proftext -o %t.profdata
-// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-

[PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2016-02-29 Thread Weiming Zhao via cfe-commits
weimingz created this revision.
weimingz added a subscriber: cfe-commits.

__FILE__ will be expanded to the full path. In some embedded system scenarios, 
the final images is linked from many objs and the image size is a very 
important factor.
The full filenames can occupy a lot space in the string pool and most of the 
time,  knowing the base name is sufficient.
__FILE_BASENAME__ can be used in this scenario.

http://reviews.llvm.org/D17741

Files:
  include/clang/Lex/Preprocessor.h
  lib/Lex/PPMacroExpansion.cpp
  test/Lexer/file_basename.c

Index: test/Lexer/file_basename.c
===
--- /dev/null
+++ test/Lexer/file_basename.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -E %s | FileCheck %s
+
+const char *filename (const char *name) {
+  // CHECK:  static const char this_file_basename[] = "file_basename.c";
+  static const char this_file_basename[] = __FILE_BASENAME__;
+  // CHECK:  static const char this_file[] = "{{.*}}/Lexer/file_basename.c";
+  static const char this_file[] = __FILE__;
+  return this_file;
+}
Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -28,6 +28,7 @@
 #include "llvm/Config/llvm-config.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -292,6 +293,7 @@
 void Preprocessor::RegisterBuiltinMacros() {
   Ident__LINE__ = RegisterBuiltinMacro(*this, "__LINE__");
   Ident__FILE__ = RegisterBuiltinMacro(*this, "__FILE__");
+  Ident__FILE_BASENAME__ = RegisterBuiltinMacro(*this, "__FILE_BASENAME__");
   Ident__DATE__ = RegisterBuiltinMacro(*this, "__DATE__");
   Ident__TIME__ = RegisterBuiltinMacro(*this, "__TIME__");
   Ident__COUNTER__ = RegisterBuiltinMacro(*this, "__COUNTER__");
@@ -1509,7 +1511,8 @@
 // __LINE__ expands to a simple numeric value.
 OS << (PLoc.isValid()? PLoc.getLine() : 1);
 Tok.setKind(tok::numeric_constant);
-  } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__) {
+  } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__ ||
+ II == Ident__FILE_BASENAME__) {
 // C99 6.10.8: "__FILE__: The presumed name of the current source file (a
 // character string literal)". This can be affected by #line.
 PresumedLoc PLoc = SourceMgr.getPresumedLoc(Tok.getLocation());
@@ -1530,7 +1533,9 @@
 // Escape this filename.  Turn '\' -> '\\' '"' -> '\"'
 SmallString<128> FN;
 if (PLoc.isValid()) {
-  FN += PLoc.getFilename();
+  FN += II == Ident__FILE_BASENAME__
+  ? llvm::sys::path::filename(PLoc.getFilename())
+  : PLoc.getFilename();
   Lexer::Stringify(FN);
   OS << '"' << FN << '"';
 }
Index: include/clang/Lex/Preprocessor.h
===
--- include/clang/Lex/Preprocessor.h
+++ include/clang/Lex/Preprocessor.h
@@ -119,6 +119,7 @@
 
   /// Identifiers for builtin macros and other builtins.
   IdentifierInfo *Ident__LINE__, *Ident__FILE__;   // __LINE__, __FILE__
+  IdentifierInfo *Ident__FILE_BASENAME__;  //  __FILE_BASENAME__
   IdentifierInfo *Ident__DATE__, *Ident__TIME__;   // __DATE__, __TIME__
   IdentifierInfo *Ident__INCLUDE_LEVEL__;  // __INCLUDE_LEVEL__
   IdentifierInfo *Ident__BASE_FILE__;  // __BASE_FILE__


Index: test/Lexer/file_basename.c
===
--- /dev/null
+++ test/Lexer/file_basename.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -E %s | FileCheck %s
+
+const char *filename (const char *name) {
+  // CHECK:  static const char this_file_basename[] = "file_basename.c";
+  static const char this_file_basename[] = __FILE_BASENAME__;
+  // CHECK:  static const char this_file[] = "{{.*}}/Lexer/file_basename.c";
+  static const char this_file[] = __FILE__;
+  return this_file;
+}
Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -28,6 +28,7 @@
 #include "llvm/Config/llvm-config.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -292,6 +293,7 @@
 void Preprocessor::RegisterBuiltinMacros() {
   Ident__LINE__ = RegisterBuiltinMacro(*this, "__LINE__");
   Ident__FILE__ = RegisterBuiltinMacro(*this, "__FILE__");
+  Ident__FILE_BASENAME__ = RegisterBuiltinMacro(*this, "__FILE_BASENAME__");
   Ident__DATE__ = RegisterBuiltinMacro(*this, "__DATE__");
   Ident__TIME__ = RegisterBuiltinMacro(*this, "__TIME__");
   Ident__COUNTER__ = RegisterBuiltinMacro(*this, "__COUNTER__");
@@ -1509,7 +1511,8 @@
 // __LINE__ expands to a simple numeric value.
 OS << (PLoc.isValid()? PLoc.getLine() : 1);
 Tok.setKind(to

Re: r260760 - [libclang] Separate the underlying indexing functionality of libclang and introduce it into the clangIndex library.

2016-02-29 Thread Justin Lebar via cfe-commits
Hi, I think this broke clang/test/Index/index-many-call-ops.cpp.  I
get a segfault due to recursive stack overflow in release builds on my
linux x86-64 box when running that test -- it seems the purpose of
that test is to check that we *don't* segfault.

This has been broken for a while, and people don't seem to be
complaining -- I'm not sure if there's something specific about my
config or if I'm just the first person to bother bisecting this...
Maybe the test just needs to be pared down some?

Please advise.

Regards,
-Justin

On Sat, Feb 13, 2016 at 12:47 PM, Argyrios Kyrtzidis via cfe-commits
 wrote:
> I guess refreshing the build directory fixed the bots now.
> You may want to look into ccache as possibly the issue here.
>
>> On Feb 13, 2016, at 12:08 PM, Argyrios Kyrtzidis  wrote:
>>
>> clangIndex library is not part of that command so I don’t understand how my 
>> changes affect linking the clang binary, clangIndex is only used for 
>> libclang.
>>
>>> On Feb 13, 2016, at 11:55 AM, Argyrios Kyrtzidis  wrote:
>>>
>>> Sorry, I looked at it but it wasn’t clear to me what the problem is:
>>>
>>> FAILED: : 
>>> /home/linaro/buildbot/clang-cmake-armv7-a15/stage1/tools/clang/clang.order: 
>>> file not recognized: File truncated
>>>
>>> I thought it was some build SNAFU, do you have some hint on what I need to 
>>> do to fix this ?
>>>
 On Feb 13, 2016, at 7:48 AM, Renato Golin  wrote:

 On 12 February 2016 at 23:11, Argyrios Kyrtzidis via cfe-commits
  wrote:
> Author: akirtzidis
> Date: Fri Feb 12 17:10:59 2016
> New Revision: 260760
>
> URL: http://llvm.org/viewvc/llvm-project?rev=260760&view=rev
> Log:
> [libclang] Separate the underlying indexing functionality of libclang and 
> introduce it into the clangIndex library.
>
> It is a general goodness for libclang itself to mostly be a wrapper of 
> functionality provided by the libraries.

 Hi,

 This broke both ARM builds:

 http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/9853

 http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/9806

 And it's still broken. I'm going to refresh the build directory, but
 please keep an eye or revert if that doesn't work.

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


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-02-29 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Nit: Could you change the prefix from "win" to "win_"?


http://reviews.llvm.org/D17688



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


Re: [PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2016-02-29 Thread Ben Craig via cfe-commits
bcraig added a subscriber: bcraig.
bcraig added a comment.

Note: this doesn't count as an official "LGTM".

The code change seems fine to me.  I think this has been implemented in gcc as 
well, but I don't recall for certain.  If this has been implemented in gcc, 
then I would expect the semantics to be the same.  If it hasn't been 
implemented in gcc, then we might want to pick a different name for the macro 
(e.g. __CLANG_FILE_BASENAME__).


http://reviews.llvm.org/D17741



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


Re: r260760 - [libclang] Separate the underlying indexing functionality of libclang and introduce it into the clangIndex library.

2016-02-29 Thread Argyrios Kyrtzidis via cfe-commits
Is this still an issue after r260785 ?
Could you provide a stack trace ?

> On Feb 29, 2016, at 2:27 PM, Justin Lebar  wrote:
> 
> Hi, I think this broke clang/test/Index/index-many-call-ops.cpp.  I
> get a segfault due to recursive stack overflow in release builds on my
> linux x86-64 box when running that test -- it seems the purpose of
> that test is to check that we *don't* segfault.
> 
> This has been broken for a while, and people don't seem to be
> complaining -- I'm not sure if there's something specific about my
> config or if I'm just the first person to bother bisecting this...
> Maybe the test just needs to be pared down some?
> 
> Please advise.
> 
> Regards,
> -Justin
> 
> On Sat, Feb 13, 2016 at 12:47 PM, Argyrios Kyrtzidis via cfe-commits
>  wrote:
>> I guess refreshing the build directory fixed the bots now.
>> You may want to look into ccache as possibly the issue here.
>> 
>>> On Feb 13, 2016, at 12:08 PM, Argyrios Kyrtzidis  wrote:
>>> 
>>> clangIndex library is not part of that command so I don’t understand how my 
>>> changes affect linking the clang binary, clangIndex is only used for 
>>> libclang.
>>> 
 On Feb 13, 2016, at 11:55 AM, Argyrios Kyrtzidis  wrote:
 
 Sorry, I looked at it but it wasn’t clear to me what the problem is:
 
 FAILED: : 
 /home/linaro/buildbot/clang-cmake-armv7-a15/stage1/tools/clang/clang.order:
  file not recognized: File truncated
 
 I thought it was some build SNAFU, do you have some hint on what I need to 
 do to fix this ?
 
> On Feb 13, 2016, at 7:48 AM, Renato Golin  wrote:
> 
> On 12 February 2016 at 23:11, Argyrios Kyrtzidis via cfe-commits
>  wrote:
>> Author: akirtzidis
>> Date: Fri Feb 12 17:10:59 2016
>> New Revision: 260760
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=260760&view=rev
>> Log:
>> [libclang] Separate the underlying indexing functionality of libclang 
>> and introduce it into the clangIndex library.
>> 
>> It is a general goodness for libclang itself to mostly be a wrapper of 
>> functionality provided by the libraries.
> 
> Hi,
> 
> This broke both ARM builds:
> 
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/9853
> 
> http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/9806
> 
> And it's still broken. I'm going to refresh the build directory, but
> please keep an eye or revert if that doesn't work.
> 
> cheers,
> --renato
 
>>> 
>> 
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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


Re: [PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2016-02-29 Thread Nico Weber via cfe-commits
thakis added a subscriber: thakis.
thakis added a comment.

Instead of doing this, would it make sense to have a flag like -ffile-basename 
that changes what __FILE__ expands to?

I had wished I'd be able to have some control over __FILE__ (I'd like to say 
"make all __FILE__s relative to this given directory for my use case), and 
changing __FILE__ to something else in all the world's code isn't easy – so 
maybe having a flag that provides some control over __FILE__ instead of adding 
a separate macro would be a good idea.


http://reviews.llvm.org/D17741



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


Re: r260760 - [libclang] Separate the underlying indexing functionality of libclang and introduce it into the clangIndex library.

2016-02-29 Thread Justin Lebar via cfe-commits
> Is this still an issue after r260785 ?

I just sync'ed to r262268 and was able to reproduce the segfault.

> Could you provide a stack trace ?

$ gdb --args release/bin/c-index-test -index-file
/usr/local/google/home/jlebar/code/llvm/src/tools/clang/test/Index/index-many-call-ops.cpp
(gdb) run
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x72ca2700 (LWP 3936)]
0x74f264be in
clang::DeclarationName::print(llvm::raw_ostream&,
clang::PrintingPolicy const&) ()
   from 
/usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
(gdb) bt
#0  0x74f264be in
clang::DeclarationName::print(llvm::raw_ostream&,
clang::PrintingPolicy const&) ()
   from 
/usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
#1  0x74f26c9e in clang::operator<<(llvm::raw_ostream&,
clang::DeclarationName) ()
   from 
/usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
#2  0x74ebcb91 in
clang::cxindex::CXIndexDataConsumer::getEntityInfo(clang::NamedDecl
const*, clang::cxindex::EntityInfo&, clang::cxindex::ScratchAlloc&) ()
from 
/usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
#3  0x74ebc206 in
clang::cxindex::CXIndexDataConsumer::handleReference(clang::NamedDecl
const*, clang::SourceLocation, CXCursor, clang::NamedDecl const*,
clang::DeclContext const*, clang::Expr const*, CXIdxEntityRefKind) ()
   from 
/usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
#4  0x74ebbae2 in
clang::cxindex::CXIndexDataConsumer::handleDeclOccurence(clang::Decl
const*, unsigned int, llvm::ArrayRef,
clang::FileID, unsigned int,
clang::index::IndexDataConsumer::ASTNodeInfo) ()
   from 
/usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
#5  0x751a05c5 in
clang::index::IndexingContext::handleDeclOccurrence(clang::Decl
const*, clang::SourceLocation, bool, clang::Decl const*, unsigned int,
llvm::ArrayRef, clang::Expr const*,
clang::Decl const*, clang::DeclContext const*) ()
   from 
/usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
#6  0x751a092a in
clang::index::IndexingContext::handleReference(clang::NamedDecl
const*, clang::SourceLocation, clang::NamedDecl const*,
clang::DeclContext const*, unsigned int,
llvm::ArrayRef, clang::Expr const*,
clang::Decl const*) ()
   from 
/usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
#7  0x751a9256 in clang::RecursiveASTVisitor<(anonymous
namespace)::BodyIndexer>::dataTraverseNode(clang::Stmt*,
llvm::SmallVectorImpl,
llvm::PointerIntPairInfo > > >*) () from
/usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
#8  0x751a60dd in clang::RecursiveASTVisitor<(anonymous
namespace)::BodyIndexer>::TraverseStmt(clang::Stmt*,
llvm::SmallVectorImpl,
llvm::PointerIntPairInfo > > >*) () from
/usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
#9  0x751a880e in clang::RecursiveASTVisitor<(anonymous
namespace)::BodyIndexer>::dataTraverseNode(clang::Stmt*,
llvm::SmallVectorImpl,
llvm::PointerIntPairInfo > > >*) () from
/usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
#10 0x751a60dd in clang::RecursiveASTVisitor<(anonymous
namespace)::BodyIndexer>::TraverseStmt(clang::Stmt*,
llvm::SmallVectorImpl,
llvm::PointerIntPairInfo > > >*) () from
/usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
#11 0x751a880e in clang::RecursiveASTVisitor<(anonymous
namespace)::BodyIndexer>::dataTraverseNode(clang::Stmt*,
llvm::SmallVectorImpl,
llvm::PointerIntPairInfo > > >*) () from
/usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
#12 0x751a60dd in clang::RecursiveASTVisitor<(anonymous
namespace)::BodyIndexer>::TraverseStmt(clang::Stmt*,
llvm::SmallVectorImpl,
llvm::PointerIntPairInfo > > >*) () from
/usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
#13 0x751a880e in clang::RecursiveASTVisitor<(anonymous
namespace)::BodyIndexer>::dataTraverseNode(clang::Stmt*,
llvm::SmallVectorImpl,
llvm::PointerIntPairInfo > > >*) () from
/usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
#14 0x751a60dd in clang::RecursiveASTVisitor<(anonymous
namespace)::BodyIndexer>::TraverseStmt(clang::Stmt*,
llvm::SmallVectorImpl,
llvm::PointerIntPairInfo > > >*) () from
/usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
#15 0x751a880e in clang::RecursiveASTVisitor<(anonymous
namespace)::BodyIndexer>::dataTraverseNode(clang::Stmt*,
llvm::SmallVectorImpl,
llvm::PointerIntPairInfo > > >*) () from
/usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
#16 0x751a60dd in clang::Recursi

Re: [PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2016-02-29 Thread Joerg Sonnenberger via cfe-commits
joerg added a subscriber: joerg.
joerg added a comment.

I've added functionality like that to NetBSD's GCC 
 a long time ago. That 
functionality is useful for a variety of situations, cutting down file space or 
canonicalization are two uses.


http://reviews.llvm.org/D17741



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


Re: [PATCH] D17390: Introduce -fembed-bitcode driver option

2016-02-29 Thread Steven Wu via cfe-commits
steven_wu updated this revision to Diff 49431.
steven_wu added a comment.

Make selectToolForJob logic better and less disruptive for -fembed-bitcode.

When -fembed-bitcode is used, the same old logic is used to decide if
CompileJob and BackendJob can be combined with an extra requirement for
-fembed-bitcode. The old logic was there to work around the Fortran input
which invokes gcc to compile. -fembed-bitcode requires CompileJob and BackendJob
to be the same (and can emit IR) so it can be splited between these two stages.


http://reviews.llvm.org/D17390

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/Driver.h
  include/clang/Driver/Options.td
  include/clang/Driver/ToolChain.h
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  test/Driver/embed-bitcode.c

Index: test/Driver/embed-bitcode.c
===
--- /dev/null
+++ test/Driver/embed-bitcode.c
@@ -0,0 +1,38 @@
+// RUN: %clang -ccc-print-bindings -c %s -fembed-bitcode 2>&1 | FileCheck %s
+// CHECK: clang
+// CHECK: clang
+
+// RUN: %clang %s -fembed-bitcode 2>&1 -### | FileCheck %s -check-prefix=CHECK-CC
+// CHECK-CC: -cc1
+// CHECK-CC: -emit-llvm-bc
+// CHECK-CC: -cc1
+// CHECK-CC: -emit-obj
+// CHECK-CC: -fembed-bitcode
+// CHECK-CC: ld
+// CHECK-CC: -bitcode_bundle
+
+// RUN: %clang %s -save-temps -fembed-bitcode 2>&1 -### | FileCheck %s -check-prefix=CHECK-SAVE-TEMP
+// CHECK-SAVE-TEMP: -cc1
+// CHECK-SAVE-TEMP: -E
+// CHECK-SAVE-TEMP: -cc1
+// CHECK-SAVE-TEMP: -emit-llvm-bc
+// CHECK-SAVE-TEMP: -cc1
+// CHECK-SAVE-TEMP: -S
+// CHECK-SAVE-TEMP: -fembed-bitcode
+// CHECK-SAVE-TEMP: -cc1as
+// CHECK-SAVE-TEMP: ld
+// CHECK-SAVE-TEMP: -bitcode_bundle
+
+// RUN: %clang -c %s -flto -fembed-bitcode 2>&1 -### | FileCheck %s -check-prefix=CHECK-LTO
+// CHECK-LTO: -cc1
+// CHECK-LTO: -emit-llvm-bc
+// CHECK-LTO-NOT: warning: argument unused during compilation: '-fembed-bitcode'
+// CHECK-LTO-NOT: -cc1
+// CHECK-LTO-NOT: -fembed-bitcode
+
+// RUN: %clang -c %s -fembed-bitcode-marker 2>&1 -### | FileCheck %s -check-prefix=CHECK-MARKER
+// CHECK-MARKER: -cc1
+// CHECK-MARKER: -emit-obj
+// CHECK-MARKER: -fembed-bitcode-marker
+// CHECK-MARKER-NOT: -cc1
+
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3625,6 +3625,17 @@
 Args.AddLastArg(CmdArgs, options::OPT_fthinlto_index_EQ);
   }
 
+  // Embed-bitcode option.
+  if (C.getDriver().embedBitcodeEnabled() &&
+  (isa(JA) || isa(JA))) {
+// Add flags implied by -fembed-bitcode.
+CmdArgs.push_back("-fembed-bitcode");
+// Disable all llvm IR level optimizations.
+CmdArgs.push_back("-disable-llvm-optzns");
+  }
+  if (C.getDriver().embedBitcodeMarkerOnly())
+CmdArgs.push_back("-fembed-bitcode-marker");
+
   // We normally speed up the clang process a bit by skipping destructors at
   // exit, but when we're generating diagnostics we can rely on some of the
   // cleanup.
@@ -7262,6 +7273,15 @@
 else
   CmdArgs.push_back("-no_pie");
   }
+  // for embed-bitcode, use -bitcode_bundle in linker command
+  if (C.getDriver().embedBitcodeEnabled() ||
+  C.getDriver().embedBitcodeMarkerOnly()) {
+// Check if the toolchain supports bitcode build flow.
+if (MachOTC.SupportsEmbeddedBitcode())
+  CmdArgs.push_back("-bitcode_bundle");
+else
+  D.Diag(diag::err_drv_bitcode_unsupported_on_toolchain);
+  }
 
   Args.AddLastArg(CmdArgs, options::OPT_prebind);
   Args.AddLastArg(CmdArgs, options::OPT_noprebind);
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -542,6 +542,8 @@
 
   bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override;
 
+  bool SupportsEmbeddedBitcode() const override;
+
   SanitizerMask getSupportedSanitizers() const override;
 };
 
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1103,6 +1103,13 @@
   return !Triple.isWatchABI();
 }
 
+bool Darwin::SupportsEmbeddedBitcode() const {
+  assert(TargetInitialized && "Target not initialized!");
+  if (isTargetIPhoneOS() && isIPhoneOSVersionLT(6, 0))
+return false;
+  return true;
+}
+
 bool MachO::isPICDefault() const { return true; }
 
 bool MachO::isPIEDefault() const { return false; }
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -50,7 +50,7 @@
DiagnosticsEngine &Diags,
IntrusiveRefCntPtr VFS)
 : Opts(createDriverOptTable()), Diags(Diags), VFS(VFS), Mode(GCCMode),
-  SaveTemps(SaveTempsNone), LTOMode(LTOK_None),
+  SaveTemps(SaveTempsNone), BitcodeEmbed(EmbedNone), LTOMode(LTOK_None),

Re: [PATCH] D17737: [PGO] change profile use cc1 option

2016-02-29 Thread Sean Silva via cfe-commits
silvas added a comment.

Thanks, this is looking good. I have some naming suggestions and nits, but the 
overall content of the patch LGTM.



Comment at: include/clang/Driver/CC1Options.td:286
@@ +285,3 @@
+def fprofile_instrument_usepath_EQ :
+Joined<["-"], "fprofile-instrument-usepath=">,
+HelpText<"Specify the profile path in PGO use compilation">;

Small bikeshed: `usepath` reads weird to me. Can we make it `use-path`?


Comment at: include/clang/Frontend/CodeGenOptions.h:237
@@ +236,3 @@
+  /// \brief Check if Clang profile use is on.
+  bool hasProfileClangUse () const {
+return getProfileUse() == ProfileClangInstr;

No space before the parens. Here and elsewhere.


Comment at: lib/Frontend/CompilerInvocation.cpp:378
@@ -377,1 +377,3 @@
 
+enum PGOInstrumentor { ProfileUnknown, ProfileNone, ProfileClang, ProfileLLVM 
};
+static PGOInstrumentor getPGOInstrumentor(StringRef S) {

Can we reuse the enum used for CodeGenOpts? Please add a comment if not.


Comment at: lib/Frontend/CompilerInvocation.cpp:533
@@ +532,3 @@
+  Args.getLastArgValue(OPT_fprofile_instrument_path_EQ);
+  Opts.InstrProfileInput =
+  Args.getLastArgValue(OPT_fprofile_instrument_usepath_EQ);

Maybe consider renaming these variables in a separate patch. The current naming 
is pretty confusing since it makes it seems like InstrProfileOutput mirrors 
InstrProfileInput, but they are totally unrelated. Maybe 
`InstrProfileDefaultProfrawPath` and `InstrProfileUsePath`, respectively.

Maybe in this patch rename `InstrProfileInput` to `ProfileInstrumentUsePath` to 
match the option name?


http://reviews.llvm.org/D17737



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


r262272 - [analyzer] Teach CheckObjCDealloc about Block_release().

2016-02-29 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Mon Feb 29 17:57:10 2016
New Revision: 262272

URL: http://llvm.org/viewvc/llvm-project?rev=262272&view=rev
Log:
[analyzer] Teach CheckObjCDealloc about Block_release().

It now treats Block_release(b) as a release in addition to [b release].

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
cfe/trunk/test/Analysis/DeallocMissingRelease.m
cfe/trunk/test/Analysis/Inputs/system-header-simulator-for-objc-dealloc.h

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp?rev=262272&r1=262271&r2=262272&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp Mon Feb 29 
17:57:10 2016
@@ -92,12 +92,13 @@ namespace {
 class ObjCDeallocChecker
 : public Checker,
  check::PreObjCMessage, check::PostObjCMessage,
+ check::PreCall,
  check::BeginFunction, check::EndFunction,
  eval::Assume,
  check::PointerEscape,
  check::PreStmt> {
 
-  mutable IdentifierInfo *NSObjectII, *SenTestCaseII;
+  mutable IdentifierInfo *NSObjectII, *SenTestCaseII, *Block_releaseII;
   mutable Selector DeallocSel, ReleaseSel;
 
   std::unique_ptr MissingReleaseBugType;
@@ -110,6 +111,7 @@ public:
 BugReporter &BR) const;
   void checkBeginFunction(CheckerContext &Ctx) const;
   void checkPreObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const;
+  void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
   void checkPostObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const;
 
   ProgramStateRef evalAssume(ProgramStateRef State, SVal Cond,
@@ -152,6 +154,7 @@ private:
   const ObjCPropertyDecl *
   findShadowedPropertyDecl(const ObjCPropertyImplDecl *PropImpl) const;
 
+  void transitionToReleaseValue(CheckerContext &C, SymbolRef Value) const;
   ProgramStateRef removeValueRequiringRelease(ProgramStateRef State,
   SymbolRef InstanceSym,
   SymbolRef ValueSym) const;
@@ -341,19 +344,26 @@ void ObjCDeallocChecker::checkPreObjCMes
   if (!ReleasedValue)
 return;
 
-  SymbolRef InstanceSym = getInstanceSymbolFromIvarSymbol(ReleasedValue);
-  if (!InstanceSym)
+  transitionToReleaseValue(C, ReleasedValue);
+}
+
+/// If we are in -dealloc or -dealloc is on the stack, handle the call if it is
+/// call to Block_release().
+void ObjCDeallocChecker::checkPreCall(const CallEvent &Call,
+  CheckerContext &C) const {
+  const IdentifierInfo *II = Call.getCalleeIdentifier();
+  if (II != Block_releaseII)
 return;
-  ProgramStateRef InitialState = C.getState();
 
-  ProgramStateRef ReleasedState =
-  removeValueRequiringRelease(InitialState, InstanceSym, ReleasedValue);
+  if (Call.getNumArgs() != 1)
+return;
 
-  if (ReleasedState != InitialState) {
-C.addTransition(ReleasedState);
-  }
-}
+  SymbolRef ReleasedValue = Call.getArgSVal(0).getAsSymbol();
+  if (!ReleasedValue)
+return;
 
+  transitionToReleaseValue(C, ReleasedValue);
+}
 /// If the message was a call to '[super dealloc]', diagnose any missing
 /// releases.
 void ObjCDeallocChecker::checkPostObjCMessage(
@@ -684,6 +694,7 @@ void ObjCDeallocChecker::initIdentifierI
 
   NSObjectII = &Ctx.Idents.get("NSObject");
   SenTestCaseII = &Ctx.Idents.get("SenTestCase");
+  Block_releaseII = &Ctx.Idents.get("_Block_release");
 
   IdentifierInfo *DeallocII = &Ctx.Idents.get("dealloc");
   IdentifierInfo *ReleaseII = &Ctx.Idents.get("release");
@@ -739,6 +750,23 @@ const ObjCPropertyDecl *ObjCDeallocCheck
   return nullptr;
 }
 
+/// Add a transition noting the release of the given value.
+void ObjCDeallocChecker::transitionToReleaseValue(CheckerContext &C,
+  SymbolRef Value) const {
+  assert(Value);
+  SymbolRef InstanceSym = getInstanceSymbolFromIvarSymbol(Value);
+  if (!InstanceSym)
+return;
+  ProgramStateRef InitialState = C.getState();
+
+  ProgramStateRef ReleasedState =
+  removeValueRequiringRelease(InitialState, InstanceSym, Value);
+
+  if (ReleasedState != InitialState) {
+C.addTransition(ReleasedState);
+  }
+}
+
 /// Remove the Value requiring a release from the tracked set for
 /// Instance and return the resultant state.
 ProgramStateRef ObjCDeallocChecker::removeValueRequiringRelease(

Modified: cfe/trunk/test/Analysis/DeallocMissingRelease.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/DeallocMissingRelease.m?rev=262272&r1=262271&r2=262272&view=diff
==
--- cfe/trunk/test/Analysis/D

r262275 - Infrastructure improvements to Clang attribute TableGen.

2016-02-29 Thread John McCall via cfe-commits
Author: rjmccall
Date: Mon Feb 29 18:18:05 2016
New Revision: 262275

URL: http://llvm.org/viewvc/llvm-project?rev=262275&view=rev
Log:
Infrastructure improvements to Clang attribute TableGen.

This should make it easier to add new Attr subclasses.

Modified:
cfe/trunk/include/clang/AST/Attr.h
cfe/trunk/include/clang/Basic/AttrKinds.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/include/clang/AST/Attr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=262275&r1=262274&r2=262275&view=diff
==
--- cfe/trunk/include/clang/AST/Attr.h (original)
+++ cfe/trunk/include/clang/AST/Attr.h Mon Feb 29 18:18:05 2016
@@ -129,7 +129,8 @@ public:
 
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Attr *A) {
-return A->getKind() <= attr::LAST_INHERITABLE;
+return A->getKind() >= attr::FirstInheritableAttr &&
+   A->getKind() <= attr::LastInheritableAttr;
   }
 };
 
@@ -143,9 +144,8 @@ protected:
 public:
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Attr *A) {
-// Relies on relative order of enum emission with respect to MS inheritance
-// attrs.
-return A->getKind() <= attr::LAST_INHERITABLE_PARAM;
+return A->getKind() >= attr::FirstInheritableParamAttr &&
+   A->getKind() <= attr::LastInheritableParamAttr;
   }
 };
 

Modified: cfe/trunk/include/clang/Basic/AttrKinds.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrKinds.h?rev=262275&r1=262274&r2=262275&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrKinds.h (original)
+++ cfe/trunk/include/clang/Basic/AttrKinds.h Mon Feb 29 18:18:05 2016
@@ -22,10 +22,10 @@ namespace attr {
 // \brief A list of all the recognized kinds of attributes.
 enum Kind {
 #define ATTR(X) X,
-#define LAST_INHERITABLE_ATTR(X) X, LAST_INHERITABLE = X,
-#define LAST_INHERITABLE_PARAM_ATTR(X) X, LAST_INHERITABLE_PARAM = X,
+#define ATTR_RANGE(CLASS, FIRST_NAME, LAST_NAME) \
+  First##CLASS = FIRST_NAME,\
+  Last##CLASS = LAST_NAME,
 #include "clang/Basic/AttrList.inc"
-  NUM_ATTRS
 };
 
 } // end namespace attr

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=262275&r1=262274&r2=262275&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Mon Feb 29 18:18:05 2016
@@ -819,8 +819,6 @@ void ASTDumper::dumpAttr(const Attr *A)
   switch (A->getKind()) {
 #define ATTR(X) case attr::X: OS << #X; break;
 #include "clang/Basic/AttrList.inc"
-  default:
-llvm_unreachable("unexpected attribute kind");
   }
   OS << "Attr";
 }

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=262275&r1=262274&r2=262275&view=diff
==
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Mon Feb 29 18:18:05 2016
@@ -1718,8 +1718,6 @@ void EmitClangAttrImpl(RecordKeeper &Rec
   OS << "return cast<" << R.getName() << "Attr>(this)->" << Method
  << ";\n";
 }
-OS << "  case attr::NUM_ATTRS:\n";
-OS << "break;\n";
 OS << "  }\n";
 OS << "  llvm_unreachable(\"Unexpected attribute kind!\");\n";
 OS << "}\n\n";
@@ -1738,20 +1736,10 @@ void EmitClangAttrImpl(RecordKeeper &Rec
 
 } // end namespace clang
 
-static void EmitAttrList(raw_ostream &OS, StringRef Class,
+static void emitAttrList(raw_ostream &OS, StringRef Class,
  const std::vector &AttrList) {
-  auto i = AttrList.cbegin(), e = AttrList.cend();
-
-  if (i != e) {
-// Move the end iterator back to emit the last attribute.
-for(--e; i != e; ++i) {
-  if (!(*i)->getValueAsBit("ASTNode"))
-continue;
-  
-  OS << Class << "(" << (*i)->getName() << ")\n";
-}
-
-OS << "LAST_" << Class << "(" << (*i)->getName() << ")\n\n";
+  for (auto Cur : AttrList) {
+OS << Class << "(" << Cur->getName() << ")\n";
   }
 }
 
@@ -1764,71 +1752,216 @@ static bool AttrHasPragmaSpelling(const
  }) != Spellings.end();
 }
 
-namespace clang {
-// Emits the enumeration list for attributes.
-void EmitClangAttrList(RecordKeeper &Records, raw_ostream &OS) {
-  emitSourceFileHeader("List of all attributes that Clang recognizes", OS);
+namespace {
+  struct AttrClassDescriptor {
+const char * const MacroName;
+const char * const TableGenName;
+  };
+}
 
-  OS << "#ifndef LAST_ATTR\n";
-  OS << "#define LAST_ATTR(NAME) ATTR(NAME)\n";
-  OS << "#endif\n\n";
+static const

Re: [PATCH] D17390: Introduce -fembed-bitcode driver option

2016-02-29 Thread Nico Weber via cfe-commits
thakis accepted this revision.
thakis added a reviewer: thakis.
thakis added a comment.
This revision is now accepted and ready to land.

Thanks, that's much clearer :-)


http://reviews.llvm.org/D17390



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


r262277 - [analyzer] Update CheckObjCDealloc diagnostic for missing -dealloc.

2016-02-29 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Mon Feb 29 18:39:04 2016
New Revision: 262277

URL: http://llvm.org/viewvc/llvm-project?rev=262277&view=rev
Log:
[analyzer] Update CheckObjCDealloc diagnostic for missing -dealloc.

Update the diagnostic for classes missing -dealloc to mention an instance
variable that needs to be released.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
cfe/trunk/test/Analysis/MissingDealloc.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp?rev=262277&r1=262276&r2=262277&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp Mon Feb 29 
18:39:04 2016
@@ -190,23 +190,27 @@ void ObjCDeallocChecker::checkASTDecl(co
   initIdentifierInfoAndSelectors(Mgr.getASTContext());
 
   const ObjCInterfaceDecl *ID = D->getClassInterface();
+  // If the class is known to have a lifecycle with a separate teardown method
+  // then it may not require a -dealloc method.
+  if (classHasSeparateTeardown(ID))
+return;
 
   // Does the class contain any synthesized properties that are retainable?
   // If not, skip the check entirely.
-  bool containsRetainedSynthesizedProperty = false;
+  const ObjCPropertyImplDecl *PropImplRequiringRelease = nullptr;
+  bool HasOthers = false;
   for (const auto *I : D->property_impls()) {
 if (getDeallocReleaseRequirement(I) == ReleaseRequirement::MustRelease) {
-  containsRetainedSynthesizedProperty = true;
-  break;
+  if (!PropImplRequiringRelease)
+PropImplRequiringRelease = I;
+  else {
+HasOthers = true;
+break;
+  }
 }
   }
 
-  if (!containsRetainedSynthesizedProperty)
-return;
-
-  // If the class is known to have a lifecycle with a separate teardown method
-  // then it may not require a -dealloc method.
-  if (classHasSeparateTeardown(ID))
+  if (!PropImplRequiringRelease)
 return;
 
   const ObjCMethodDecl *MD = nullptr;
@@ -224,8 +228,12 @@ void ObjCDeallocChecker::checkASTDecl(co
 
 std::string Buf;
 llvm::raw_string_ostream OS(Buf);
-OS << "Objective-C class '" << *D << "' lacks a 'dealloc' instance method";
+OS << "'" << *D << "' lacks a 'dealloc' instance method but "
+   << "must release '" << *PropImplRequiringRelease->getPropertyIvarDecl()
+   << "'";
 
+if (HasOthers)
+  OS << " and others";
 PathDiagnosticLocation DLoc =
 PathDiagnosticLocation::createBegin(D, BR.getSourceManager());
 

Modified: cfe/trunk/test/Analysis/MissingDealloc.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/MissingDealloc.m?rev=262277&r1=262276&r2=262277&view=diff
==
--- cfe/trunk/test/Analysis/MissingDealloc.m (original)
+++ cfe/trunk/test/Analysis/MissingDealloc.m Mon Feb 29 18:39:04 2016
@@ -1,5 +1,12 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.osx.cocoa.Dealloc -fblocks 
%s 2>&1 | FileCheck -check-prefix=CHECK %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.osx.cocoa.Dealloc -fblocks 
-triple x86_64-apple-darwin10 -fobjc-arc %s 2>&1 | FileCheck 
-check-prefix=CHECK-ARC -allow-empty '--implicit-check-not=error:' 
'--implicit-check-not=warning:' %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.osx.cocoa.Dealloc -fblocks 
-verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.osx.cocoa.Dealloc -fblocks 
-verify -triple x86_64-apple-darwin10 -fobjc-arc %s
+
+#define NON_ARC !__has_feature(objc_arc)
+
+// No diagnostics expected under ARC.
+#if !NON_ARC
+  // expected-no-diagnostics
+#endif
 
 typedef signed char BOOL;
 @protocol NSObject
@@ -51,7 +58,9 @@ typedef struct objc_selector *SEL;
 @property (copy) NSObject *ivar;
 @end
 
-// CHECK: MissingDealloc.m:[[@LINE+1]]:1: warning: Objective-C class 
'MissingDeallocWithCopyProperty' lacks a 'dealloc' instance method
+#if NON_ARC
+// expected-warning@+2{{'MissingDeallocWithCopyProperty' lacks a 'dealloc' 
instance method but must release '_ivar'}}
+#endif
 @implementation MissingDeallocWithCopyProperty
 @end
 
@@ -59,17 +68,32 @@ typedef struct objc_selector *SEL;
 @property (retain) NSObject *ivar;
 @end
 
-// CHECK: MissingDealloc.m:[[@LINE+1]]:1: warning: Objective-C class 
'MissingDeallocWithRetainProperty' lacks a 'dealloc' instance method
+#if NON_ARC
+// expected-warning@+2{{'MissingDeallocWithRetainProperty' lacks a 'dealloc' 
instance method but must release '_ivar'}}
+#endif
 @implementation MissingDeallocWithRetainProperty
 @end
 
+@interface MissingDeallocWithMultipleProperties : NSObject
+@property (retain) NSObject *ivar1;
+@property (retain) NSObject *ivar2;
+@end
+
+#if NON_ARC
+// expected-warning@+2{{'MissingDeallocWithMultipleProperties' lacks a 
'dealloc' instance me

r262278 - Generalize the consumed-parameter array on FunctionProtoType

2016-02-29 Thread John McCall via cfe-commits
Author: rjmccall
Date: Mon Feb 29 18:49:02 2016
New Revision: 262278

URL: http://llvm.org/viewvc/llvm-project?rev=262278&view=rev
Log:
Generalize the consumed-parameter array on FunctionProtoType
to allow arbitrary data to be associated with a parameter.

Also, fix a bug where we apparently haven't been serializing
this information for the last N years.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=262278&r1=262277&r2=262278&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Feb 29 18:49:02 2016
@@ -2260,7 +2260,7 @@ public:
   
   QualType mergeObjCGCQualifiers(QualType, QualType);
 
-  bool FunctionTypesMatchOnNSConsumedAttrs(
+  bool doFunctionTypesMatchOnExtParameterInfos(
  const FunctionProtoType *FromFunctionType,
  const FunctionProtoType *ToFunctionType);
 

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=262278&r1=262277&r2=262278&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Mon Feb 29 18:49:02 2016
@@ -3040,6 +3040,44 @@ public:
 /// type.
 class FunctionProtoType : public FunctionType, public llvm::FoldingSetNode {
 public:
+  class ExtParameterInfo {
+enum {
+  IsConsumed  = 0x01,
+};
+unsigned char Data;
+  public:
+ExtParameterInfo() : Data(0) {}
+
+/// Is this parameter considered "consumed" by Objective-C ARC?
+/// Consumed parameters must have retainable object type.
+bool isConsumed() const {
+  return (Data & IsConsumed);
+}
+ExtParameterInfo withIsConsumed(bool consumed) const {
+  ExtParameterInfo copy = *this;
+  if (consumed) {
+copy.Data |= IsConsumed;
+  } else {
+copy.Data &= ~IsConsumed;
+  }
+  return copy;
+}
+
+unsigned char getOpaqueValue() const { return Data; }
+static ExtParameterInfo getFromOpaqueValue(unsigned char data) {
+  ExtParameterInfo result;
+  result.Data = data;
+  return result;
+}
+
+friend bool operator==(ExtParameterInfo lhs, ExtParameterInfo rhs) {
+  return lhs.Data == rhs.Data;
+}
+friend bool operator!=(ExtParameterInfo lhs, ExtParameterInfo rhs) {
+  return lhs.Data != rhs.Data;
+}
+  };
+
   struct ExceptionSpecInfo {
 ExceptionSpecInfo()
 : Type(EST_None), NoexceptExpr(nullptr),
@@ -3067,11 +3105,11 @@ public:
   struct ExtProtoInfo {
 ExtProtoInfo()
 : Variadic(false), HasTrailingReturn(false), TypeQuals(0),
-  RefQualifier(RQ_None), ConsumedParameters(nullptr) {}
+  RefQualifier(RQ_None), ExtParameterInfos(nullptr) {}
 
 ExtProtoInfo(CallingConv CC)
 : ExtInfo(CC), Variadic(false), HasTrailingReturn(false), TypeQuals(0),
-  RefQualifier(RQ_None), ConsumedParameters(nullptr) {}
+  RefQualifier(RQ_None), ExtParameterInfos(nullptr) {}
 
 ExtProtoInfo withExceptionSpec(const ExceptionSpecInfo &O) {
   ExtProtoInfo Result(*this);
@@ -3085,7 +3123,7 @@ public:
 unsigned char TypeQuals;
 RefQualifierKind RefQualifier;
 ExceptionSpecInfo ExceptionSpec;
-const bool *ConsumedParameters;
+const ExtParameterInfo *ExtParameterInfos;
   };
 
 private:
@@ -3112,8 +3150,8 @@ private:
   /// The type of exception specification this function has.
   unsigned ExceptionSpecType : 4;
 
-  /// Whether this function has any consumed parameters.
-  unsigned HasAnyConsumedParams : 1;
+  /// Whether this function has extended parameter information.
+  unsigned HasExtParameterInfos : 1;
 
   /// Whether the function is variadic.
   unsigned Variadic : 1;
@@ -3135,25 +3173,36 @@ private:
   // instantiate this function type's exception specification, and the function
   // from which it should be instantiated.
 
-  // ConsumedParameters - A variable size array, following Exceptions
-  // and of length NumParams, holding flags indicating which parameters
-  // are consumed.  This only appears if HasAnyConsumedParams is true.
+  // ExtParameterInfos - A variable size array, following the exception
+  // specification and of length NumParams, holding an ExtParameterInfo
+  // for each of the parameters.  This only appears if HasExtParameterInfos
+  // is true.
 
   friend class ASTContext;  // ASTContext creates these.
 
-  const bool *getConsumedParamsBuffer() cons

Re: r262278 - Generalize the consumed-parameter array on FunctionProtoType

2016-02-29 Thread Pariborz Jahanian via cfe-commits

> On Feb 29, 2016, at 4:49 PM, John McCall via cfe-commits 
>  wrote:
> 
> Author: rjmccall
> Date: Mon Feb 29 18:49:02 2016
> New Revision: 262278
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=262278&view=rev
> Log:
> Generalize the consumed-parameter array on FunctionProtoType
> to allow arbitrary data to be associated with a parameter.
> 

Hi John,
Would you mind providing a test for this scenario?
- Fariborz

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


r262282 - Introduce -fembed-bitcode driver option

2016-02-29 Thread Steven Wu via cfe-commits
Author: steven_wu
Date: Mon Feb 29 19:07:58 2016
New Revision: 262282

URL: http://llvm.org/viewvc/llvm-project?rev=262282&view=rev
Log:
Introduce -fembed-bitcode driver option

Summary:
This is the clang driver part of the change to embedded bitcode. This
includes:
1. -fembed-bitcode option which breaks down the compilation into two
stages. The first stage emits optimized bitcode and the second stage
compiles bitcode into object file.
2. -fembed-bitcode-marker option which doesn't really break down to
two stages to speedup the compilation flow.
3. pass the correct linker flag to darwin linker if tool chains supports
embedded bitcode.

Reviewers: rsmith, thakis

Subscribers: thakis, cfe-commits

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

Added:
cfe/trunk/test/Driver/embed-bitcode.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=262282&r1=262281&r2=262282&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon Feb 29 19:07:58 
2016
@@ -134,7 +134,9 @@ def err_drv_omp_host_ir_file_not_found :
   "The provided host compiler IR file '%0' is required to generate code for 
OpenMP target regions but cannot be found.">;
 def err_drv_omp_host_target_not_supported : Error<
   "The target '%0' is not a supported OpenMP host target.">;
-  
+def err_drv_bitcode_unsupported_on_toolchain : Error<
+  "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
+
 def warn_O4_is_O3 : Warning<"-O4 is equivalent to -O3">, InGroup;
 def warn_drv_lto_libpath : Warning<"libLTO.dylib relative to clang installed 
dir not found; using 'ld' default search path instead">,
   InGroup;

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=262282&r1=262281&r2=262282&view=diff
==
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Mon Feb 29 19:07:58 2016
@@ -83,6 +83,12 @@ class Driver {
 SaveTempsObj
   } SaveTemps;
 
+  enum BitcodeEmbedMode {
+EmbedNone,
+EmbedMarker,
+EmbedBitcode
+  } BitcodeEmbed;
+
   /// LTO mode selected via -f(no-)?lto(=.*)? options.
   LTOKind LTOMode;
 
@@ -262,6 +268,9 @@ public:
   bool isSaveTempsEnabled() const { return SaveTemps != SaveTempsNone; }
   bool isSaveTempsObj() const { return SaveTemps == SaveTempsObj; }
 
+  bool embedBitcodeEnabled() const { return BitcodeEmbed == EmbedBitcode; }
+  bool embedBitcodeMarkerOnly() const { return BitcodeEmbed == EmbedMarker; }
+
   /// @}
   /// @name Primary Functionality
   /// @{

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=262282&r1=262281&r2=262282&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Feb 29 19:07:58 2016
@@ -437,6 +437,12 @@ def fno_autolink : Flag <["-"], "fno-aut
   Flags<[DriverOption, CC1Option]>,
   HelpText<"Disable generation of linker directives for automatic library 
linking">;
 
+def fembed_bitcode : Flag<["-"], "fembed-bitcode">, Group,
+  Flags<[CC1Option, CC1AsOption]>,
+  HelpText<"Embed LLVM IR bitcode as data">;
+def fembed_bitcode_marker : Flag<["-"], "fembed-bitcode-marker">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Embed placeholder LLVM IR data as a marker">;
 def fgnu_inline_asm : Flag<["-"], "fgnu-inline-asm">, Group, 
Flags<[DriverOption]>;
 def fno_gnu_inline_asm : Flag<["-"], "fno-gnu-inline-asm">, Group,
   Flags<[DriverOption, CC1Option]>,

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=262282&r1=262281&r2=262282&view=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Mon Feb 29 19:07:58 2016
@@ -319,6 +319,11 @@ public:
 return false;
   }
 
+  /// SupportsEmbeddedBitcode - Does this tool chain support embedded bitcode.
+  virtual bool SupportsEmbeddedBitcode() const {
+return false;
+  }
+
   /// getThreadModel() - Which thread model does this target use?
   virtual

RE: r250293 - Bring back r250262: PS4 toolchain

2016-02-29 Thread Robinson, Paul via cfe-commits
Nico asks:

+def warn_drv_ps4_force_pic : Warning<
+  "option '%0' was ignored by the PS4 toolchain, using '-fPIC'">,
+  InGroup;

Should this use the existing UnusedCommandLineArgument instead of introducing a 
new group?

Depends on what kinds of distinctions you want to make, when it comes to 
how-to-turn-off-warnings.  OptionIgnored, IgnoredOptimizationArgument, 
InvalidCommandLineArgument, and UnusedCommandLineArgument all seem to be 
somewhat related; each of the first three has only one warning in the group, 
maybe they could all be folded into the last one.
Looks like there are other similar warnings that currently have no group but 
probably could be folded into the group, e.g. warn_c_kext.

Is there guidance/documentation about how groups ought to be used and when it's 
appropriate to define a new one?  Or is it more like "check around for an 
existing group that seems to fit"?
Thanks,
--paulr

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


Re: [PATCH] D17390: Introduce -fembed-bitcode driver option

2016-02-29 Thread Steven Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL262282: Introduce -fembed-bitcode driver option (authored by 
steven_wu).

Changed prior to commit:
  http://reviews.llvm.org/D17390?vs=49431&id=49437#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17390

Files:
  cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
  cfe/trunk/include/clang/Driver/Driver.h
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/Driver/ToolChain.h
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/lib/Driver/ToolChains.h
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/embed-bitcode.c

Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
@@ -134,7 +134,9 @@
   "The provided host compiler IR file '%0' is required to generate code for OpenMP target regions but cannot be found.">;
 def err_drv_omp_host_target_not_supported : Error<
   "The target '%0' is not a supported OpenMP host target.">;
-  
+def err_drv_bitcode_unsupported_on_toolchain : Error<
+  "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
+
 def warn_O4_is_O3 : Warning<"-O4 is equivalent to -O3">, InGroup;
 def warn_drv_lto_libpath : Warning<"libLTO.dylib relative to clang installed dir not found; using 'ld' default search path instead">,
   InGroup;
Index: cfe/trunk/include/clang/Driver/ToolChain.h
===
--- cfe/trunk/include/clang/Driver/ToolChain.h
+++ cfe/trunk/include/clang/Driver/ToolChain.h
@@ -319,6 +319,11 @@
 return false;
   }
 
+  /// SupportsEmbeddedBitcode - Does this tool chain support embedded bitcode.
+  virtual bool SupportsEmbeddedBitcode() const {
+return false;
+  }
+
   /// getThreadModel() - Which thread model does this target use?
   virtual std::string getThreadModel() const { return "posix"; }
 
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -437,6 +437,12 @@
   Flags<[DriverOption, CC1Option]>,
   HelpText<"Disable generation of linker directives for automatic library linking">;
 
+def fembed_bitcode : Flag<["-"], "fembed-bitcode">, Group,
+  Flags<[CC1Option, CC1AsOption]>,
+  HelpText<"Embed LLVM IR bitcode as data">;
+def fembed_bitcode_marker : Flag<["-"], "fembed-bitcode-marker">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Embed placeholder LLVM IR data as a marker">;
 def fgnu_inline_asm : Flag<["-"], "fgnu-inline-asm">, Group, Flags<[DriverOption]>;
 def fno_gnu_inline_asm : Flag<["-"], "fno-gnu-inline-asm">, Group,
   Flags<[DriverOption, CC1Option]>,
Index: cfe/trunk/include/clang/Driver/Driver.h
===
--- cfe/trunk/include/clang/Driver/Driver.h
+++ cfe/trunk/include/clang/Driver/Driver.h
@@ -83,6 +83,12 @@
 SaveTempsObj
   } SaveTemps;
 
+  enum BitcodeEmbedMode {
+EmbedNone,
+EmbedMarker,
+EmbedBitcode
+  } BitcodeEmbed;
+
   /// LTO mode selected via -f(no-)?lto(=.*)? options.
   LTOKind LTOMode;
 
@@ -262,6 +268,9 @@
   bool isSaveTempsEnabled() const { return SaveTemps != SaveTempsNone; }
   bool isSaveTempsObj() const { return SaveTemps == SaveTempsObj; }
 
+  bool embedBitcodeEnabled() const { return BitcodeEmbed == EmbedBitcode; }
+  bool embedBitcodeMarkerOnly() const { return BitcodeEmbed == EmbedMarker; }
+
   /// @}
   /// @name Primary Functionality
   /// @{
Index: cfe/trunk/test/Driver/embed-bitcode.c
===
--- cfe/trunk/test/Driver/embed-bitcode.c
+++ cfe/trunk/test/Driver/embed-bitcode.c
@@ -0,0 +1,38 @@
+// RUN: %clang -ccc-print-bindings -c %s -fembed-bitcode 2>&1 | FileCheck %s
+// CHECK: clang
+// CHECK: clang
+
+// RUN: %clang %s -fembed-bitcode 2>&1 -### | FileCheck %s -check-prefix=CHECK-CC
+// CHECK-CC: -cc1
+// CHECK-CC: -emit-llvm-bc
+// CHECK-CC: -cc1
+// CHECK-CC: -emit-obj
+// CHECK-CC: -fembed-bitcode
+// CHECK-CC: ld
+// CHECK-CC: -bitcode_bundle
+
+// RUN: %clang %s -save-temps -fembed-bitcode 2>&1 -### | FileCheck %s -check-prefix=CHECK-SAVE-TEMP
+// CHECK-SAVE-TEMP: -cc1
+// CHECK-SAVE-TEMP: -E
+// CHECK-SAVE-TEMP: -cc1
+// CHECK-SAVE-TEMP: -emit-llvm-bc
+// CHECK-SAVE-TEMP: -cc1
+// CHECK-SAVE-TEMP: -S
+// CHECK-SAVE-TEMP: -fembed-bitcode
+// CHECK-SAVE-TEMP: -cc1as
+// CHECK-SAVE-TEMP: ld
+// CHECK-SAVE-TEMP: -bitcode_bundle
+
+// RUN: %clang -c %s -flto -fembed-bitcode 2>&1 -### | FileCheck %s -check-prefix=CHECK-LTO
+// CHECK-LTO: -cc1
+// CHECK-LTO: -emit-llvm-bc
+// CHECK-LTO-NOT: warning: argument unused during compilation: '-fembed-bitcode'
+// CHECK-LTO-NOT: -cc1
+// CHECK-LTO-NOT: -fembed-bitcode
+
+//

Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct

2016-02-29 Thread Jason Merrill via cfe-commits

On 02/29/2016 10:13 AM, Michael Matz via cfe-commits wrote:

Also this insistence that all of "trivially copyable" is
already quite nicely specified in the C++ ABI is still not really relevant
because C++ _is not the only language out there_.  I'm not sure how often
I have to repeat this until people get it.


Other language ABIs can handle language specific calling conventions as 
appropriate for them.  The psABI can only talk about things that are in 
its domain.


Jason


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


Re: r262278 - Generalize the consumed-parameter array on FunctionProtoType

2016-02-29 Thread John McCall via cfe-commits
> On Feb 29, 2016, at 5:06 PM, Pariborz Jahanian  wrote:
>> On Feb 29, 2016, at 4:49 PM, John McCall via cfe-commits 
>>  wrote:
>> 
>> Author: rjmccall
>> Date: Mon Feb 29 18:49:02 2016
>> New Revision: 262278
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=262278&view=rev
>> Log:
>> Generalize the consumed-parameter array on FunctionProtoType
>> to allow arbitrary data to be associated with a parameter.
>> 
> 
> Hi John,
> Would you mind providing a test for this scenario?

Hi, Fariborz!  The generalization itself isn’t really testable; it’s NFC.

John.

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


r262285 - Make test more robust.

2016-02-29 Thread Sean Silva via cfe-commits
Author: silvas
Date: Mon Feb 29 19:20:15 2016
New Revision: 262285

URL: http://llvm.org/viewvc/llvm-project?rev=262285&view=rev
Log:
Make test more robust.

Really all these tests are checking is that we find a file path. The
behavior when we don't find one will have `"ps4-ld"` in it. We just need
a path separator to know that a path has been found.

The root cause of the flakiness of these tests is the same on Windows
and non-Windows: setting the PATH environment variable is not sufficient
to guarantee that a particular path is looked up first.
Driver::GetProgramPath checks some paths before deferring to PATH
(in particular, the directory containing the clang binary itself).

I initally ran into this on Windows when putting a PS4 linker in
build-dir/bin/ps4-ld for testing.
After digging for a while thinking that it was some windows path search
oddity (the Windows SearchPathW documentation indicates that its
behavior varies depending on a registry setting...).
I eventually tried reproducing the issue on Mac and to my surprise found
the same issue.
Ultimately I traced it down to the extra lookups in
Driver::GetProgramPath.

Modified:
cfe/trunk/test/Driver/ps4-linker-non-win.c
cfe/trunk/test/Driver/ps4-linker-win.c

Modified: cfe/trunk/test/Driver/ps4-linker-non-win.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ps4-linker-non-win.c?rev=262285&r1=262284&r2=262285&view=diff
==
--- cfe/trunk/test/Driver/ps4-linker-non-win.c (original)
+++ cfe/trunk/test/Driver/ps4-linker-non-win.c Mon Feb 29 19:20:15 2016
@@ -18,4 +18,4 @@
 // RUN: env "PATH=%T/Output:%PATH%" %clang -### -target x86_64-scei-ps4  %s 
-shared \
 // RUN: -fuse-ld=ps4 2>&1 | FileCheck --check-prefix=CHECK-PS4-LINKER %s
 
-// CHECK-PS4-LINKER: Output/ps4-ld
+// CHECK-PS4-LINKER: /ps4-ld

Modified: cfe/trunk/test/Driver/ps4-linker-win.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ps4-linker-win.c?rev=262285&r1=262284&r2=262285&view=diff
==
--- cfe/trunk/test/Driver/ps4-linker-win.c (original)
+++ cfe/trunk/test/Driver/ps4-linker-win.c Mon Feb 29 19:20:15 2016
@@ -22,6 +22,5 @@
 // RUN: env "PATH=%T;%PATH%;" %clang -target x86_64-scei-ps4  %s -shared \
 // RUN: -fuse-ld=ps4 -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-LINKER 
%s
 
-// FIXME: "Output\\" is hardcoded part of %T.
-// CHECK-PS4-GOLD: Output\\ps4-ld.gold.exe"
-// CHECK-PS4-LINKER: Output\\ps4-ld.exe"
+// CHECK-PS4-GOLD: \\ps4-ld.gold
+// CHECK-PS4-LINKER: \\ps4-ld


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


r262286 - Fix the testcase in r262282

2016-02-29 Thread Steven Wu via cfe-commits
Author: steven_wu
Date: Mon Feb 29 19:24:54 2016
New Revision: 262286

URL: http://llvm.org/viewvc/llvm-project?rev=262286&view=rev
Log:
Fix the testcase in r262282

-bitcode_bundle is only passed to the darwin ld64 linker and it is only
implemented there. Remove the check on the linker flag.

Modified:
cfe/trunk/test/Driver/embed-bitcode.c

Modified: cfe/trunk/test/Driver/embed-bitcode.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/embed-bitcode.c?rev=262286&r1=262285&r2=262286&view=diff
==
--- cfe/trunk/test/Driver/embed-bitcode.c (original)
+++ cfe/trunk/test/Driver/embed-bitcode.c Mon Feb 29 19:24:54 2016
@@ -2,16 +2,14 @@
 // CHECK: clang
 // CHECK: clang
 
-// RUN: %clang %s -fembed-bitcode 2>&1 -### | FileCheck %s 
-check-prefix=CHECK-CC
+// RUN: %clang %s -c -fembed-bitcode 2>&1 -### | FileCheck %s 
-check-prefix=CHECK-CC
 // CHECK-CC: -cc1
 // CHECK-CC: -emit-llvm-bc
 // CHECK-CC: -cc1
 // CHECK-CC: -emit-obj
 // CHECK-CC: -fembed-bitcode
-// CHECK-CC: ld
-// CHECK-CC: -bitcode_bundle
 
-// RUN: %clang %s -save-temps -fembed-bitcode 2>&1 -### | FileCheck %s 
-check-prefix=CHECK-SAVE-TEMP
+// RUN: %clang %s -c -save-temps -fembed-bitcode 2>&1 -### | FileCheck %s 
-check-prefix=CHECK-SAVE-TEMP
 // CHECK-SAVE-TEMP: -cc1
 // CHECK-SAVE-TEMP: -E
 // CHECK-SAVE-TEMP: -cc1
@@ -20,8 +18,6 @@
 // CHECK-SAVE-TEMP: -S
 // CHECK-SAVE-TEMP: -fembed-bitcode
 // CHECK-SAVE-TEMP: -cc1as
-// CHECK-SAVE-TEMP: ld
-// CHECK-SAVE-TEMP: -bitcode_bundle
 
 // RUN: %clang -c %s -flto -fembed-bitcode 2>&1 -### | FileCheck %s 
-check-prefix=CHECK-LTO
 // CHECK-LTO: -cc1


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


Re: [PATCH] D17390: Introduce -fembed-bitcode driver option

2016-02-29 Thread Steven Wu via cfe-commits
steven_wu added a comment.

Thanks for reviewing the patch. There is a problem in the test case (it only 
works on darwin). It is fixed in r262286.



Comment at: lib/Driver/Driver.cpp:1761
@@ -1747,1 +1760,3 @@
+const ActionList *BackendInputs =
+  (EmbedBitcode ? Inputs : &(*Inputs)[0]->getInputs());
 // Compile job may be wrapped in CudaHostAction, extract it if

thakis wrote:
> Why is this change needed? If its needed, is the preceding comment out of 
> date now?
The preceding comment is still true but this condition makes 
BackendInputs->begin() not always CompileJobAction. I have a cleaner way to 
handle this. I am rebasing and updating the patch.


Repository:
  rL LLVM

http://reviews.llvm.org/D17390



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


Re: r260760 - [libclang] Separate the underlying indexing functionality of libclang and introduce it into the clangIndex library.

2016-02-29 Thread Argyrios Kyrtzidis via cfe-commits
I don’t quite understand how it gets that stack trace, dataTraverseNode() was 
introduced to avoid exactly this.
How are you configuring and what compiler and version are you using ?

> On Feb 29, 2016, at 3:14 PM, Justin Lebar  wrote:
> 
>> Is this still an issue after r260785 ?
> 
> I just sync'ed to r262268 and was able to reproduce the segfault.
> 
>> Could you provide a stack trace ?
> 
> $ gdb --args release/bin/c-index-test -index-file
> /usr/local/google/home/jlebar/code/llvm/src/tools/clang/test/Index/index-many-call-ops.cpp
> (gdb) run
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 0x72ca2700 (LWP 3936)]
> 0x74f264be in
> clang::DeclarationName::print(llvm::raw_ostream&,
> clang::PrintingPolicy const&) ()
>   from 
> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
> (gdb) bt
> #0  0x74f264be in
> clang::DeclarationName::print(llvm::raw_ostream&,
> clang::PrintingPolicy const&) ()
>   from 
> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
> #1  0x74f26c9e in clang::operator<<(llvm::raw_ostream&,
> clang::DeclarationName) ()
>   from 
> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
> #2  0x74ebcb91 in
> clang::cxindex::CXIndexDataConsumer::getEntityInfo(clang::NamedDecl
> const*, clang::cxindex::EntityInfo&, clang::cxindex::ScratchAlloc&) ()
> from 
> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
> #3  0x74ebc206 in
> clang::cxindex::CXIndexDataConsumer::handleReference(clang::NamedDecl
> const*, clang::SourceLocation, CXCursor, clang::NamedDecl const*,
> clang::DeclContext const*, clang::Expr const*, CXIdxEntityRefKind) ()
>   from 
> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
> #4  0x74ebbae2 in
> clang::cxindex::CXIndexDataConsumer::handleDeclOccurence(clang::Decl
> const*, unsigned int, llvm::ArrayRef,
> clang::FileID, unsigned int,
> clang::index::IndexDataConsumer::ASTNodeInfo) ()
>   from 
> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
> #5  0x751a05c5 in
> clang::index::IndexingContext::handleDeclOccurrence(clang::Decl
> const*, clang::SourceLocation, bool, clang::Decl const*, unsigned int,
> llvm::ArrayRef, clang::Expr const*,
> clang::Decl const*, clang::DeclContext const*) ()
>   from 
> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
> #6  0x751a092a in
> clang::index::IndexingContext::handleReference(clang::NamedDecl
> const*, clang::SourceLocation, clang::NamedDecl const*,
> clang::DeclContext const*, unsigned int,
> llvm::ArrayRef, clang::Expr const*,
> clang::Decl const*) ()
>   from 
> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
> #7  0x751a9256 in clang::RecursiveASTVisitor<(anonymous
> namespace)::BodyIndexer>::dataTraverseNode(clang::Stmt*,
> llvm::SmallVectorImpl llvm::PointerLikeTypeTraits,
> llvm::PointerIntPairInfo llvm::PointerLikeTypeTraits > > >*) () from
> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
> #8  0x751a60dd in clang::RecursiveASTVisitor<(anonymous
> namespace)::BodyIndexer>::TraverseStmt(clang::Stmt*,
> llvm::SmallVectorImpl llvm::PointerLikeTypeTraits,
> llvm::PointerIntPairInfo llvm::PointerLikeTypeTraits > > >*) () from
> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
> #9  0x751a880e in clang::RecursiveASTVisitor<(anonymous
> namespace)::BodyIndexer>::dataTraverseNode(clang::Stmt*,
> llvm::SmallVectorImpl llvm::PointerLikeTypeTraits,
> llvm::PointerIntPairInfo llvm::PointerLikeTypeTraits > > >*) () from
> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
> #10 0x751a60dd in clang::RecursiveASTVisitor<(anonymous
> namespace)::BodyIndexer>::TraverseStmt(clang::Stmt*,
> llvm::SmallVectorImpl llvm::PointerLikeTypeTraits,
> llvm::PointerIntPairInfo llvm::PointerLikeTypeTraits > > >*) () from
> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
> #11 0x751a880e in clang::RecursiveASTVisitor<(anonymous
> namespace)::BodyIndexer>::dataTraverseNode(clang::Stmt*,
> llvm::SmallVectorImpl llvm::PointerLikeTypeTraits,
> llvm::PointerIntPairInfo llvm::PointerLikeTypeTraits > > >*) () from
> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
> #12 0x751a60dd in clang::RecursiveASTVisitor<(anonymous
> namespace)::BodyIndexer>::TraverseStmt(clang::Stmt*,
> llvm::SmallVectorImpl llvm::PointerLikeTypeTraits,
> llvm::PointerIntPairInfo llvm::PointerLikeTypeTraits > > >*) () from
> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
> #13 0x751a880e in clang::RecursiveASTVisitor<(anonymous
> namespace)::BodyIndexer>::dataT

[PATCH] D17746: Fix PR26741 -- __builtin_object_size is not consistently conservative with C++ inheritance

2016-02-29 Thread George Burgess IV via cfe-commits
george.burgess.iv created this revision.
george.burgess.iv added a reviewer: rsmith.
george.burgess.iv added a subscriber: cfe-commits.

This patch fixes PR26741, and makes us handle inheritance more sanely.

Broken code:

```
struct Foo { char a[1]; };
struct Bar : Foo {};

int break() {
  Bar *b;
  int size = __builtin_object_size(b->a, 1);
  assert(size == -1); // Fires; size is 1.
}
```

Because we're now handling inheritance, this patch has a few fun things in it 
(see: the new loop at ExprConstant.cpp:6489) so that we aren't overly 
conservative when inheritance is involved. I'm not entirely thrilled with how 
we determine if a base class is considered to be at the end of a derived class; 
better approaches are appreciated.

http://reviews.llvm.org/D17746

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

Index: test/CodeGen/object-size.cpp
===
--- test/CodeGen/object-size.cpp
+++ test/CodeGen/object-size.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | FileCheck %s
 
 // C++-specific tests for __builtin_object_size
 
@@ -62,3 +62,110 @@
   // CHECK: store i32 16
   gi = __builtin_object_size(&c->bs[0].buf[0], 3);
 }
+
+// CHECK-LABEL: define void @_Z5test3v()
+void test3() {
+  struct A { int i; char buf[1]; };
+  struct B : A {};
+  struct C : B {};
+  struct D { int i; B bs[1]; } *d;
+
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(&d->bs[0].buf[0], 0);
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(&d->bs[0].buf[0], 1);
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 true)
+  gi = __builtin_object_size(&d->bs[0].buf[0], 2);
+  // CHECK: store i32 1
+  gi = __builtin_object_size(&d->bs[0].buf[0], 3);
+}
+
+// CHECK-LABEL: define void @_Z5test4v()
+void test4() {
+  struct A { int i; char buf[1]; };
+  struct B : A { char c; };
+  struct C { int i; B bs[1]; } *c;
+
+  // CHECK: store i32 1
+  gi = __builtin_object_size(&c->bs[0].buf[0], 1);
+  // CHECK: store i32 1
+  gi = __builtin_object_size(&c->bs[0].buf[0], 3);
+}
+
+// CHECK-LABEL: define void @_Z5test5v()
+void test5() {
+  struct A { int i; char buf[1]; };
+  struct B : A { char c; };
+  struct C : B {};
+  struct D { int i; B bs[1]; } *d;
+
+  // CHECK: store i32 1
+  gi = __builtin_object_size(&d->bs[0].buf[0], 1);
+  // CHECK: store i32 1
+  gi = __builtin_object_size(&d->bs[0].buf[0], 3);
+}
+
+// CHECK-LABEL: define void @_Z5test6v()
+void test6() {
+  // A   A
+  // |   |
+  // B   C
+  //  \ /
+  //   D
+  struct A { int i; char buf[1]; };
+  struct B : A {};
+  struct C : A {};
+  struct D : B, C {} *d;
+
+  // CHECK: store i32 1
+  gi = __builtin_object_size(&d->B::buf[0], 1);
+  // CHECK: store i32 1
+  gi = __builtin_object_size(&d->B::buf[0], 3);
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(&d->C::buf[0], 1);
+  // CHECK: store i32 1
+  gi = __builtin_object_size(&d->C::buf[0], 3);
+
+  D &dr = *d;
+  // CHECK: store i32 1
+  gi = __builtin_object_size(&dr.B::buf[0], 1);
+  // CHECK: store i32 1
+  gi = __builtin_object_size(&dr.B::buf[0], 3);
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(&dr.C::buf[0], 1);
+  // CHECK: store i32 1
+  gi = __builtin_object_size(&dr.C::buf[0], 3);
+
+  D &&drval = static_cast(*d);
+  // CHECK: store i32 1
+  gi = __builtin_object_size(&drval.B::buf[0], 1);
+  // CHECK: store i32 1
+  gi = __builtin_object_size(&drval.B::buf[0], 3);
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(&drval.C::buf[0], 1);
+  // CHECK: store i32 1
+  gi = __builtin_object_size(&drval.C::buf[0], 3);
+
+  // CHECK: store i32 1
+  gi = __builtin_object_size(&static_cast(drval).B::buf[0], 1);
+  // CHECK: store i32 1
+  gi = __builtin_object_size(&static_cast(drval).B::buf[0], 3);
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(&static_cast(drval).C::buf[0], 1);
+  // CHECK: store i32 1
+  gi = __builtin_object_size(&static_cast(drval).C::buf[0], 3);
+}
+
+// CHECK-LABEL: define void @_Z5test7v()
+void test7() {
+  // Always give up when virtual inheritance is involved.
+  struct A { int i; char buf[1]; };
+  struct B : virtual A {};
+  struct C : virtual A {};
+  struct D : B, C {} *d;
+
+  // CHECK: store i32 1
+  gi = __builtin_object_size(&d->buf[0], 1);
+  // CHECK: store i32 1
+  gi = __builtin_object_size(&d->buf[0], 3);
+}
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -6447,6 +6447,27 @@
 static bool isDesignatorAtObjectEnd(const ASTContext &Ctx, const LValue

Re: r260760 - [libclang] Separate the underlying indexing functionality of libclang and introduce it into the clangIndex library.

2016-02-29 Thread Justin Lebar via cfe-commits
> How are you configuring

cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++ -DLLVM_ENABLE_ASSERTIONS=On
-DLLVM_ENABLE_SPHINX=true -DSPHINX_OUTPUT_MAN=true ../llvm

>  and what compiler and version are you using ?

$ clang --version
Ubuntu clang version 3.5.0-4ubuntu2~trusty2 (tags/RELEASE_350/final)
(based on LLVM 3.5.0)
Target: x86_64-pc-linux-gnu
Thread model: posix

I do not see the stack overflow or segfault in debug builds.  I do see
it regardless of whether or not I enable assertions.  I also do not
see the stack overflow in a release build if I reduce the amount of
nesting in the test to about 2/3 of its present value.

On Mon, Feb 29, 2016 at 5:38 PM, Argyrios Kyrtzidis  wrote:
> I don’t quite understand how it gets that stack trace, dataTraverseNode() was 
> introduced to avoid exactly this.
> How are you configuring and what compiler and version are you using ?
>
>> On Feb 29, 2016, at 3:14 PM, Justin Lebar  wrote:
>>
>>> Is this still an issue after r260785 ?
>>
>> I just sync'ed to r262268 and was able to reproduce the segfault.
>>
>>> Could you provide a stack trace ?
>>
>> $ gdb --args release/bin/c-index-test -index-file
>> /usr/local/google/home/jlebar/code/llvm/src/tools/clang/test/Index/index-many-call-ops.cpp
>> (gdb) run
>> Program received signal SIGSEGV, Segmentation fault.
>> [Switching to Thread 0x72ca2700 (LWP 3936)]
>> 0x74f264be in
>> clang::DeclarationName::print(llvm::raw_ostream&,
>> clang::PrintingPolicy const&) ()
>>   from 
>> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
>> (gdb) bt
>> #0  0x74f264be in
>> clang::DeclarationName::print(llvm::raw_ostream&,
>> clang::PrintingPolicy const&) ()
>>   from 
>> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
>> #1  0x74f26c9e in clang::operator<<(llvm::raw_ostream&,
>> clang::DeclarationName) ()
>>   from 
>> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
>> #2  0x74ebcb91 in
>> clang::cxindex::CXIndexDataConsumer::getEntityInfo(clang::NamedDecl
>> const*, clang::cxindex::EntityInfo&, clang::cxindex::ScratchAlloc&) ()
>> from 
>> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
>> #3  0x74ebc206 in
>> clang::cxindex::CXIndexDataConsumer::handleReference(clang::NamedDecl
>> const*, clang::SourceLocation, CXCursor, clang::NamedDecl const*,
>> clang::DeclContext const*, clang::Expr const*, CXIdxEntityRefKind) ()
>>   from 
>> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
>> #4  0x74ebbae2 in
>> clang::cxindex::CXIndexDataConsumer::handleDeclOccurence(clang::Decl
>> const*, unsigned int, llvm::ArrayRef,
>> clang::FileID, unsigned int,
>> clang::index::IndexDataConsumer::ASTNodeInfo) ()
>>   from 
>> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
>> #5  0x751a05c5 in
>> clang::index::IndexingContext::handleDeclOccurrence(clang::Decl
>> const*, clang::SourceLocation, bool, clang::Decl const*, unsigned int,
>> llvm::ArrayRef, clang::Expr const*,
>> clang::Decl const*, clang::DeclContext const*) ()
>>   from 
>> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
>> #6  0x751a092a in
>> clang::index::IndexingContext::handleReference(clang::NamedDecl
>> const*, clang::SourceLocation, clang::NamedDecl const*,
>> clang::DeclContext const*, unsigned int,
>> llvm::ArrayRef, clang::Expr const*,
>> clang::Decl const*) ()
>>   from 
>> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
>> #7  0x751a9256 in clang::RecursiveASTVisitor<(anonymous
>> namespace)::BodyIndexer>::dataTraverseNode(clang::Stmt*,
>> llvm::SmallVectorImpl> llvm::PointerLikeTypeTraits,
>> llvm::PointerIntPairInfo> llvm::PointerLikeTypeTraits > > >*) () from
>> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
>> #8  0x751a60dd in clang::RecursiveASTVisitor<(anonymous
>> namespace)::BodyIndexer>::TraverseStmt(clang::Stmt*,
>> llvm::SmallVectorImpl> llvm::PointerLikeTypeTraits,
>> llvm::PointerIntPairInfo> llvm::PointerLikeTypeTraits > > >*) () from
>> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
>> #9  0x751a880e in clang::RecursiveASTVisitor<(anonymous
>> namespace)::BodyIndexer>::dataTraverseNode(clang::Stmt*,
>> llvm::SmallVectorImpl> llvm::PointerLikeTypeTraits,
>> llvm::PointerIntPairInfo> llvm::PointerLikeTypeTraits > > >*) () from
>> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
>> #10 0x751a60dd in clang::RecursiveASTVisitor<(anonymous
>> namespace)::BodyIndexer>::TraverseStmt(clang::Stmt*,
>> llvm::SmallVectorImpl> llvm::PointerLikeTypeTraits,
>> llvm::PointerIntPairInfo> llvm::PointerLikeTypeTraits > > >*) () from
>> /usr/local/go

Re: r262275 - Infrastructure improvements to Clang attribute TableGen.

2016-02-29 Thread Sean Silva via cfe-commits
This seems to be causing a substantial amount of warning spew from MSVC:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/955

I think our recommended "portable" method of using llvm_unreachable is
outside the switch, instead of in the default case:
http://llvm.org/docs/CodingStandards.html#don-t-use-default-labels-in-fully-covered-switches-over-enumerations

-- Sean Silva

On Mon, Feb 29, 2016 at 4:18 PM, John McCall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rjmccall
> Date: Mon Feb 29 18:18:05 2016
> New Revision: 262275
>
> URL: http://llvm.org/viewvc/llvm-project?rev=262275&view=rev
> Log:
> Infrastructure improvements to Clang attribute TableGen.
>
> This should make it easier to add new Attr subclasses.
>
> Modified:
> cfe/trunk/include/clang/AST/Attr.h
> cfe/trunk/include/clang/Basic/AttrKinds.h
> cfe/trunk/lib/AST/ASTDumper.cpp
> cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
>
> Modified: cfe/trunk/include/clang/AST/Attr.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=262275&r1=262274&r2=262275&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/Attr.h (original)
> +++ cfe/trunk/include/clang/AST/Attr.h Mon Feb 29 18:18:05 2016
> @@ -129,7 +129,8 @@ public:
>
>// Implement isa/cast/dyncast/etc.
>static bool classof(const Attr *A) {
> -return A->getKind() <= attr::LAST_INHERITABLE;
> +return A->getKind() >= attr::FirstInheritableAttr &&
> +   A->getKind() <= attr::LastInheritableAttr;
>}
>  };
>
> @@ -143,9 +144,8 @@ protected:
>  public:
>// Implement isa/cast/dyncast/etc.
>static bool classof(const Attr *A) {
> -// Relies on relative order of enum emission with respect to MS
> inheritance
> -// attrs.
> -return A->getKind() <= attr::LAST_INHERITABLE_PARAM;
> +return A->getKind() >= attr::FirstInheritableParamAttr &&
> +   A->getKind() <= attr::LastInheritableParamAttr;
>}
>  };
>
>
> Modified: cfe/trunk/include/clang/Basic/AttrKinds.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrKinds.h?rev=262275&r1=262274&r2=262275&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/AttrKinds.h (original)
> +++ cfe/trunk/include/clang/Basic/AttrKinds.h Mon Feb 29 18:18:05 2016
> @@ -22,10 +22,10 @@ namespace attr {
>  // \brief A list of all the recognized kinds of attributes.
>  enum Kind {
>  #define ATTR(X) X,
> -#define LAST_INHERITABLE_ATTR(X) X, LAST_INHERITABLE = X,
> -#define LAST_INHERITABLE_PARAM_ATTR(X) X, LAST_INHERITABLE_PARAM = X,
> +#define ATTR_RANGE(CLASS, FIRST_NAME, LAST_NAME) \
> +  First##CLASS = FIRST_NAME,\
> +  Last##CLASS = LAST_NAME,
>  #include "clang/Basic/AttrList.inc"
> -  NUM_ATTRS
>  };
>
>  } // end namespace attr
>
> Modified: cfe/trunk/lib/AST/ASTDumper.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=262275&r1=262274&r2=262275&view=diff
>
> ==
> --- cfe/trunk/lib/AST/ASTDumper.cpp (original)
> +++ cfe/trunk/lib/AST/ASTDumper.cpp Mon Feb 29 18:18:05 2016
> @@ -819,8 +819,6 @@ void ASTDumper::dumpAttr(const Attr *A)
>switch (A->getKind()) {
>  #define ATTR(X) case attr::X: OS << #X; break;
>  #include "clang/Basic/AttrList.inc"
> -  default:
> -llvm_unreachable("unexpected attribute kind");
>}
>OS << "Attr";
>  }
>
> Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=262275&r1=262274&r2=262275&view=diff
>
> ==
> --- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
> +++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Mon Feb 29 18:18:05 2016
> @@ -1718,8 +1718,6 @@ void EmitClangAttrImpl(RecordKeeper &Rec
>OS << "return cast<" << R.getName() << "Attr>(this)->" << Method
>   << ";\n";
>  }
> -OS << "  case attr::NUM_ATTRS:\n";
> -OS << "break;\n";
>  OS << "  }\n";
>  OS << "  llvm_unreachable(\"Unexpected attribute kind!\");\n";
>  OS << "}\n\n";
> @@ -1738,20 +1736,10 @@ void EmitClangAttrImpl(RecordKeeper &Rec
>
>  } // end namespace clang
>
> -static void EmitAttrList(raw_ostream &OS, StringRef Class,
> +static void emitAttrList(raw_ostream &OS, StringRef Class,
>   const std::vector &AttrList) {
> -  auto i = AttrList.cbegin(), e = AttrList.cend();
> -
> -  if (i != e) {
> -// Move the end iterator back to emit the last attribute.
> -for(--e; i != e; ++i) {
> -  if (!(*i)->getValueAsBit("ASTNode"))
> -continue;
> -
> -  OS << Class << "(" << (*i)->getName() << ")\n";
> -   

Re: [PATCH] D17581: [CUDA] disable attribute-based overloading for __global__ functions.

2016-02-29 Thread Justin Lebar via cfe-commits
jlebar closed this revision.
jlebar added a comment.

Landed in http://reviews.llvm.org/rL261778.


http://reviews.llvm.org/D17581



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


Re: [PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2016-02-29 Thread Weiming Zhao via cfe-commits
weimingz added a comment.

In http://reviews.llvm.org/D17741#364742, @bcraig wrote:

> Note: this doesn't count as an official "LGTM".
>
> The code change seems fine to me.  I think this has been implemented in gcc 
> as well, but I don't recall for certain.  If this has been implemented in 
> gcc, then I would expect the semantics to be the same.  If it hasn't been 
> implemented in gcc, then we might want to pick a different name for the macro 
> (e.g. __CLANG_FILE_BASENAME__).


GCC has a macro "__BASE_FILE__", which I initially thought was for this 
purpose, but it's not.
__BASE_FILE__

  This macro expands to the name of the main input file, in the form of a C 
string constant. This is the source file that was specified on the command line 
of the preprocessor or C compiler. 

I will rename the macro to CLANG_FILE_BASENAME


http://reviews.llvm.org/D17741



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


Re: [PATCH] D17737: [PGO] change profile use cc1 option

2016-02-29 Thread Rong Xu via cfe-commits
xur marked 4 inline comments as done.


Comment at: lib/Frontend/CompilerInvocation.cpp:378
@@ -377,1 +377,3 @@
 
+enum PGOInstrumentor { ProfileUnknown, ProfileNone, ProfileClang, ProfileLLVM 
};
+static PGOInstrumentor getPGOInstrumentor(StringRef S) {

silvas wrote:
> Can we reuse the enum used for CodeGenOpts? Please add a comment if not.
this is a very good suggestion. I'll change the code as you suggested.


Comment at: lib/Frontend/CompilerInvocation.cpp:533
@@ +532,3 @@
+  Args.getLastArgValue(OPT_fprofile_instrument_path_EQ);
+  Opts.InstrProfileInput =
+  Args.getLastArgValue(OPT_fprofile_instrument_usepath_EQ);

silvas wrote:
> Maybe consider renaming these variables in a separate patch. The current 
> naming is pretty confusing since it makes it seems like InstrProfileOutput 
> mirrors InstrProfileInput, but they are totally unrelated. Maybe 
> `InstrProfileDefaultProfrawPath` and `InstrProfileUsePath`, respectively.
> 
> Maybe in this patch rename `InstrProfileInput` to `ProfileInstrumentUsePath` 
> to match the option name?
Will change the name InstrProfileInput to ProfileInstrumentUsePath in this path.

I will change Opts.InstrProfileOutput to InstrProfileDefaultProfrawPath in a 
separated patch.


http://reviews.llvm.org/D17737



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


Re: [PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2016-02-29 Thread Weiming Zhao via cfe-commits
weimingz added a comment.

In http://reviews.llvm.org/D17741#364756, @thakis wrote:

> Instead of doing this, would it make sense to have a flag like 
> -ffile-basename that changes what __FILE__ expands to?
>
> I had wished I'd be able to have some control over __FILE__ (I'd like to say 
> "make all __FILE__s relative to this given directory for my use case), and 
> changing __FILE__ to something else in all the world's code isn't easy – so 
> maybe having a flag that provides some control over __FILE__ instead of 
> adding a separate macro would be a good idea.


do you mean this?
if source file is /a/b/c/d/foo.c and if  -ffile-name-stem-remove=/a/b/c, then 
_FILE_ will be expanded to "d/foo.c" ?


http://reviews.llvm.org/D17741



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


Re: [PATCH] D17737: [PGO] change profile use cc1 option

2016-02-29 Thread Sean Silva via cfe-commits
silvas accepted this revision.
silvas added a comment.
This revision is now accepted and ready to land.

Thanks!


http://reviews.llvm.org/D17737



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


r262288 - Add an llvm_unreachable back to the autogeneration of this covered switch.

2016-02-29 Thread John McCall via cfe-commits
Author: rjmccall
Date: Mon Feb 29 20:09:20 2016
New Revision: 262288

URL: http://llvm.org/viewvc/llvm-project?rev=262288&view=rev
Log:
Add an llvm_unreachable back to the autogeneration of this covered switch.

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

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=262288&r1=262287&r2=262288&view=diff
==
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Mon Feb 29 20:09:20 2016
@@ -2294,7 +2294,8 @@ void EmitClangAttrASTVisitor(RecordKeepe
<< "  return getDerived().Traverse" << R.getName() << "Attr("
<< "cast<" << R.getName() << "Attr>(A));\n";
   }
-  OS << "  }\n";  // end case
+  OS << "  }\n";  // end switch
+  OS << "  llvm_unreachable(\"bad attribute kind\");\n";
   OS << "}\n";  // end function
   OS << "#endif  // ATTR_VISITOR_DECLS_ONLY\n";
 }


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


r262289 - Fix the template instantiation of ExtParameterInfos; tests to follow.

2016-02-29 Thread John McCall via cfe-commits
Author: rjmccall
Date: Mon Feb 29 20:09:25 2016
New Revision: 262289

URL: http://llvm.org/viewvc/llvm-project?rev=262289&view=rev
Log:
Fix the template instantiation of ExtParameterInfos; tests to follow.

Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/TreeTransform.h

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=262289&r1=262288&r2=262289&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Mon Feb 29 20:09:25 2016
@@ -3355,6 +3355,11 @@ public:
 return ArrayRef(getExtParameterInfosBuffer(),
   getNumParams());
   }
+  const ExtParameterInfo *getExtParameterInfosOrNull() const {
+if (!hasExtParameterInfos())
+  return nullptr;
+return getExtParameterInfosBuffer();
+  }
 
   ExtParameterInfo getExtParameterInfo(unsigned I) const {
 assert(I < getNumParams() && "parameter index out of range");

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=262289&r1=262288&r2=262289&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Feb 29 20:09:25 2016
@@ -6982,6 +6982,26 @@ public:
 SavedPendingLocalImplicitInstantiations;
   };
 
+  class ExtParameterInfoBuilder {
+SmallVector Infos;
+bool HasInteresting = false;
+
+  public:
+void set(unsigned index, FunctionProtoType::ExtParameterInfo info) {
+  assert(Infos.size() <= index);
+  Infos.resize(index);
+  Infos.push_back(info);
+
+  if (!HasInteresting)
+HasInteresting = (info != FunctionProtoType::ExtParameterInfo());
+}
+
+const FunctionProtoType::ExtParameterInfo *
+getPointerOrNull(unsigned numParams) {
+  return (HasInteresting ? Infos.data() : nullptr);
+}
+  };
+
   void PerformPendingInstantiations(bool LocalOnly = false);
 
   TypeSourceInfo *SubstType(TypeSourceInfo *T,
@@ -7011,9 +7031,11 @@ public:
 bool ExpectParameterPack);
   bool SubstParmTypes(SourceLocation Loc,
   ParmVarDecl **Params, unsigned NumParams,
+  const FunctionProtoType::ExtParameterInfo *ExtParamInfos,
   const MultiLevelTemplateArgumentList &TemplateArgs,
   SmallVectorImpl &ParamTypes,
-  SmallVectorImpl *OutParams = nullptr);
+  SmallVectorImpl *OutParams,
+  ExtParameterInfoBuilder &ParamInfos);
   ExprResult SubstExpr(Expr *E,
const MultiLevelTemplateArgumentList &TemplateArgs);
 

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=262289&r1=262288&r2=262289&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Mon Feb 29 20:09:25 2016
@@ -2552,6 +2552,8 @@ Sema::SubstituteExplicitTemplateArgument
   // Isolate our substituted parameters from our caller.
   LocalInstantiationScope InstScope(*this, /*MergeWithOuterScope*/true);
 
+  ExtParameterInfoBuilder ExtParamInfos;
+
   // Instantiate the types of each of the function parameters given the
   // explicitly-specified template arguments. If the function has a trailing
   // return type, substitute it after the arguments to ensure we substitute
@@ -2559,8 +2561,9 @@ Sema::SubstituteExplicitTemplateArgument
   if (Proto->hasTrailingReturn()) {
 if (SubstParmTypes(Function->getLocation(),
Function->param_begin(), Function->getNumParams(),
+   Proto->getExtParameterInfosOrNull(),
MultiLevelTemplateArgumentList(*ExplicitArgumentList),
-   ParamTypes))
+   ParamTypes, /*params*/ nullptr, ExtParamInfos))
   return TDK_SubstitutionFailure;
   }
   
@@ -2590,21 +2593,24 @@ Sema::SubstituteExplicitTemplateArgument
 if (ResultType.isNull() || Trap.hasErrorOccurred())
   return TDK_SubstitutionFailure;
   }
-  
+
   // Instantiate the types of each of the function parameters given the
   // explicitly-specified template arguments if we didn't do so earlier.
   if (!Proto->hasTrailingReturn() &&
   SubstParmTypes(Function->getLocation(),
  Function->param_begin(), Function->getNumParams(),
+ Proto->getExtParamet

Re: r262275 - Infrastructure improvements to Clang attribute TableGen.

2016-02-29 Thread John McCall via cfe-commits
> On Feb 29, 2016, at 5:44 PM, Sean Silva  wrote:
> This seems to be causing a substantial amount of warning spew from MSVC:
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/955
>  
> 
> 
> I think our recommended "portable" method of using llvm_unreachable is 
> outside the switch, instead of in the default case: 
> http://llvm.org/docs/CodingStandards.html#don-t-use-default-labels-in-fully-covered-switches-over-enumerations
>  
> 
Sorry, should be fixed in r262288.  I’ll be back in a few hours, feel free to 
revert if it doesn’t clear up.

John.

> 
> -- Sean Silva
> 
> On Mon, Feb 29, 2016 at 4:18 PM, John McCall via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: rjmccall
> Date: Mon Feb 29 18:18:05 2016
> New Revision: 262275
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=262275&view=rev 
> 
> Log:
> Infrastructure improvements to Clang attribute TableGen.
> 
> This should make it easier to add new Attr subclasses.
> 
> Modified:
> cfe/trunk/include/clang/AST/Attr.h
> cfe/trunk/include/clang/Basic/AttrKinds.h
> cfe/trunk/lib/AST/ASTDumper.cpp
> cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
> 
> Modified: cfe/trunk/include/clang/AST/Attr.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=262275&r1=262274&r2=262275&view=diff
>  
> 
> ==
> --- cfe/trunk/include/clang/AST/Attr.h (original)
> +++ cfe/trunk/include/clang/AST/Attr.h Mon Feb 29 18:18:05 2016
> @@ -129,7 +129,8 @@ public:
> 
>// Implement isa/cast/dyncast/etc.
>static bool classof(const Attr *A) {
> -return A->getKind() <= attr::LAST_INHERITABLE;
> +return A->getKind() >= attr::FirstInheritableAttr &&
> +   A->getKind() <= attr::LastInheritableAttr;
>}
>  };
> 
> @@ -143,9 +144,8 @@ protected:
>  public:
>// Implement isa/cast/dyncast/etc.
>static bool classof(const Attr *A) {
> -// Relies on relative order of enum emission with respect to MS 
> inheritance
> -// attrs.
> -return A->getKind() <= attr::LAST_INHERITABLE_PARAM;
> +return A->getKind() >= attr::FirstInheritableParamAttr &&
> +   A->getKind() <= attr::LastInheritableParamAttr;
>}
>  };
> 
> 
> Modified: cfe/trunk/include/clang/Basic/AttrKinds.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrKinds.h?rev=262275&r1=262274&r2=262275&view=diff
>  
> 
> ==
> --- cfe/trunk/include/clang/Basic/AttrKinds.h (original)
> +++ cfe/trunk/include/clang/Basic/AttrKinds.h Mon Feb 29 18:18:05 2016
> @@ -22,10 +22,10 @@ namespace attr {
>  // \brief A list of all the recognized kinds of attributes.
>  enum Kind {
>  #define ATTR(X) X,
> -#define LAST_INHERITABLE_ATTR(X) X, LAST_INHERITABLE = X,
> -#define LAST_INHERITABLE_PARAM_ATTR(X) X, LAST_INHERITABLE_PARAM = X,
> +#define ATTR_RANGE(CLASS, FIRST_NAME, LAST_NAME) \
> +  First##CLASS = FIRST_NAME,\
> +  Last##CLASS = LAST_NAME,
>  #include "clang/Basic/AttrList.inc"
> -  NUM_ATTRS
>  };
> 
>  } // end namespace attr
> 
> Modified: cfe/trunk/lib/AST/ASTDumper.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=262275&r1=262274&r2=262275&view=diff
>  
> 
> ==
> --- cfe/trunk/lib/AST/ASTDumper.cpp (original)
> +++ cfe/trunk/lib/AST/ASTDumper.cpp Mon Feb 29 18:18:05 2016
> @@ -819,8 +819,6 @@ void ASTDumper::dumpAttr(const Attr *A)
>switch (A->getKind()) {
>  #define ATTR(X) case attr::X: OS << #X; break;
>  #include "clang/Basic/AttrList.inc"
> -  default:
> -llvm_unreachable("unexpected attribute kind");
>}
>OS << "Attr";
>  }
> 
> Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=262275&r1=262274&r2=262275&view=diff
>  
> 
> ==
> --- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
> +++ cfe/trunk/utils/TableGen/ClangAttrEm

Re: [PATCH] D17737: [PGO] change profile use cc1 option

2016-02-29 Thread Rong Xu via cfe-commits
xur updated this revision to Diff 49444.
xur marked 2 inline comments as done.
xur added a comment.

Integrated Sean's review suggestions.

-Rong


http://reviews.llvm.org/D17737

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/Inputs/pgotestclang.profraw
  test/CodeGen/Inputs/pgotestir.profraw
  test/CodeGen/pgo-instrumentation.c
  test/Driver/clang_f_opts.c
  test/Profile/c-captured.c
  test/Profile/c-counter-overflows.c
  test/Profile/c-general.c
  test/Profile/c-outdated-data.c
  test/Profile/c-unprofiled-blocks.c
  test/Profile/c-unprofiled.c
  test/Profile/cxx-lambda.cpp
  test/Profile/cxx-rangefor.cpp
  test/Profile/cxx-templates.cpp
  test/Profile/objc-general.m
  test/Profile/profile-does-not-exist.c

Index: test/Profile/profile-does-not-exist.c
===
--- test/Profile/profile-does-not-exist.c
+++ test/Profile/profile-does-not-exist.c
@@ -1,4 +1,4 @@
-// RUN: not %clang_cc1 -emit-llvm %s -o - -fprofile-instr-use=%t.nonexistent.profdata 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -emit-llvm %s -o - -fprofile-instrument-use-path=%t.nonexistent.profdata -fprofile-instrument-use=clang 2>&1 | FileCheck %s
 
 // CHECK: error: Could not read profile {{.*}}.nonexistent.profdata:
 // CHECK-NOT: Assertion failed
Index: test/Profile/objc-general.m
===
--- test/Profile/objc-general.m
+++ test/Profile/objc-general.m
@@ -3,7 +3,7 @@
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name objc-general.m %s -o - -emit-llvm -fblocks -fprofile-instrument=clang | FileCheck -check-prefix=PGOGEN %s
 
 // RUN: llvm-profdata merge %S/Inputs/objc-general.proftext -o %t.profdata
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name objc-general.m %s -o - -emit-llvm -fblocks -fprofile-instr-use=%t.profdata | FileCheck -check-prefix=PGOUSE %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name objc-general.m %s -o - -emit-llvm -fblocks -fprofile-instrument-use-path=%t.profdata -fprofile-instrument-use=clang | FileCheck -check-prefix=PGOUSE %s
 
 #ifdef HAVE_FOUNDATION
 
Index: test/Profile/cxx-templates.cpp
===
--- test/Profile/cxx-templates.cpp
+++ test/Profile/cxx-templates.cpp
@@ -6,7 +6,7 @@
 // RUN: FileCheck --input-file=%tgen -check-prefix=T100GEN -check-prefix=ALL %s
 
 // RUN: llvm-profdata merge %S/Inputs/cxx-templates.proftext -o %t.profdata
-// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-templates.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-use=%t.profdata > %tuse
+// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-templates.cpp -std=c++11 -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata -fprofile-instrument-use=clang > %tuse
 // RUN: FileCheck --input-file=%tuse -check-prefix=T0USE -check-prefix=ALL %s
 // RUN: FileCheck --input-file=%tuse -check-prefix=T100USE -check-prefix=ALL %s
 
Index: test/Profile/cxx-rangefor.cpp
===
--- test/Profile/cxx-rangefor.cpp
+++ test/Profile/cxx-rangefor.cpp
@@ -4,7 +4,7 @@
 // RUN: FileCheck --input-file=%tgen -check-prefix=CHECK -check-prefix=PGOGEN %s
 
 // RUN: llvm-profdata merge %S/Inputs/cxx-rangefor.proftext -o %t.profdata
-// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-rangefor.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-use=%t.profdata > %tuse
+// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-rangefor.cpp -std=c++11 -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata -fprofile-instrument-use=clang > %tuse
 // RUN: FileCheck --input-file=%tuse -check-prefix=CHECK -check-prefix=PGOUSE %s
 
 // PGOGEN: @[[RFC:__profc__Z9range_forv]] = private global [5 x i64] zeroinitializer
Index: test/Profile/cxx-lambda.cpp
===
--- test/Profile/cxx-lambda.cpp
+++ test/Profile/cxx-lambda.cpp
@@ -5,7 +5,7 @@
 // RUN: FileCheck --input-file=%tgen -check-prefix=LMBGEN %s
 
 // RUN: llvm-profdata merge %S/Inputs/cxx-lambda.proftext -o %t.profdata
-// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-lambda.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-use=%t.profdata > %tuse
+// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-lambda.cpp -std=c++11 -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata -fprofile-instrument-use=clang > %tuse
 // RUN: FileCheck --input-file=%tuse -check-prefix=PGOUSE %s
 // RUN: FileCheck --input-file=%tuse -check-prefix=LMBUSE %s
 
Index: test/Profile/c-unprofiled.c
===

Re: [PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2016-02-29 Thread Weiming Zhao via cfe-commits
weimingz updated this revision to Diff 49445.
weimingz added a comment.

rename the macro to CLANG_FILE_BASENAME per Ben's comments.


http://reviews.llvm.org/D17741

Files:
  include/clang/Lex/Preprocessor.h
  lib/Lex/PPMacroExpansion.cpp
  test/Lexer/file_basename.c

Index: test/Lexer/file_basename.c
===
--- /dev/null
+++ test/Lexer/file_basename.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -E %s | FileCheck %s
+
+const char *filename (const char *name) {
+  // CHECK:  static const char this_file_basename[] = "file_basename.c";
+  static const char this_file_basename[] = __CLANG_FILE_BASENAME__;
+  // CHECK:  static const char this_file[] = "{{.*}}/Lexer/file_basename.c";
+  static const char this_file[] = __FILE__;
+  return this_file;
+}
Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -28,6 +28,7 @@
 #include "llvm/Config/llvm-config.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -292,6 +293,8 @@
 void Preprocessor::RegisterBuiltinMacros() {
   Ident__LINE__ = RegisterBuiltinMacro(*this, "__LINE__");
   Ident__FILE__ = RegisterBuiltinMacro(*this, "__FILE__");
+  Ident__CLANG_FILE_BASENAME__ =
+  RegisterBuiltinMacro(*this, "__CLANG_FILE_BASENAME__");
   Ident__DATE__ = RegisterBuiltinMacro(*this, "__DATE__");
   Ident__TIME__ = RegisterBuiltinMacro(*this, "__TIME__");
   Ident__COUNTER__ = RegisterBuiltinMacro(*this, "__COUNTER__");
@@ -1509,7 +1512,8 @@
 // __LINE__ expands to a simple numeric value.
 OS << (PLoc.isValid()? PLoc.getLine() : 1);
 Tok.setKind(tok::numeric_constant);
-  } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__) {
+  } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__ ||
+ II == Ident__CLANG_FILE_BASENAME__) {
 // C99 6.10.8: "__FILE__: The presumed name of the current source file (a
 // character string literal)". This can be affected by #line.
 PresumedLoc PLoc = SourceMgr.getPresumedLoc(Tok.getLocation());
@@ -1530,7 +1534,9 @@
 // Escape this filename.  Turn '\' -> '\\' '"' -> '\"'
 SmallString<128> FN;
 if (PLoc.isValid()) {
-  FN += PLoc.getFilename();
+  FN += II == Ident__CLANG_FILE_BASENAME__
+? llvm::sys::path::filename(PLoc.getFilename())
+: PLoc.getFilename();
   Lexer::Stringify(FN);
   OS << '"' << FN << '"';
 }
Index: include/clang/Lex/Preprocessor.h
===
--- include/clang/Lex/Preprocessor.h
+++ include/clang/Lex/Preprocessor.h
@@ -119,6 +119,7 @@
 
   /// Identifiers for builtin macros and other builtins.
   IdentifierInfo *Ident__LINE__, *Ident__FILE__;   // __LINE__, __FILE__
+  IdentifierInfo *Ident__CLANG_FILE_BASENAME__;//  __FILE_BASENAME__
   IdentifierInfo *Ident__DATE__, *Ident__TIME__;   // __DATE__, __TIME__
   IdentifierInfo *Ident__INCLUDE_LEVEL__;  // __INCLUDE_LEVEL__
   IdentifierInfo *Ident__BASE_FILE__;  // __BASE_FILE__


Index: test/Lexer/file_basename.c
===
--- /dev/null
+++ test/Lexer/file_basename.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -E %s | FileCheck %s
+
+const char *filename (const char *name) {
+  // CHECK:  static const char this_file_basename[] = "file_basename.c";
+  static const char this_file_basename[] = __CLANG_FILE_BASENAME__;
+  // CHECK:  static const char this_file[] = "{{.*}}/Lexer/file_basename.c";
+  static const char this_file[] = __FILE__;
+  return this_file;
+}
Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -28,6 +28,7 @@
 #include "llvm/Config/llvm-config.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -292,6 +293,8 @@
 void Preprocessor::RegisterBuiltinMacros() {
   Ident__LINE__ = RegisterBuiltinMacro(*this, "__LINE__");
   Ident__FILE__ = RegisterBuiltinMacro(*this, "__FILE__");
+  Ident__CLANG_FILE_BASENAME__ =
+  RegisterBuiltinMacro(*this, "__CLANG_FILE_BASENAME__");
   Ident__DATE__ = RegisterBuiltinMacro(*this, "__DATE__");
   Ident__TIME__ = RegisterBuiltinMacro(*this, "__TIME__");
   Ident__COUNTER__ = RegisterBuiltinMacro(*this, "__COUNTER__");
@@ -1509,7 +1512,8 @@
 // __LINE__ expands to a simple numeric value.
 OS << (PLoc.isValid()? PLoc.getLine() : 1);
 Tok.setKind(tok::numeric_constant);
-  } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__) {
+  } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__ ||
+ II == Ident__CLANG_FILE_BASENAME__) {
   

Re: r260760 - [libclang] Separate the underlying indexing functionality of libclang and introduce it into the clangIndex library.

2016-02-29 Thread Argyrios Kyrtzidis via cfe-commits
Ah, I see the problem in the code, will fix shortly.

> On Feb 29, 2016, at 5:43 PM, Justin Lebar  wrote:
> 
>> How are you configuring
> 
> cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang
> -DCMAKE_CXX_COMPILER=clang++ -DLLVM_ENABLE_ASSERTIONS=On
> -DLLVM_ENABLE_SPHINX=true -DSPHINX_OUTPUT_MAN=true ../llvm
> 
>> and what compiler and version are you using ?
> 
> $ clang --version
> Ubuntu clang version 3.5.0-4ubuntu2~trusty2 (tags/RELEASE_350/final)
> (based on LLVM 3.5.0)
> Target: x86_64-pc-linux-gnu
> Thread model: posix
> 
> I do not see the stack overflow or segfault in debug builds.  I do see
> it regardless of whether or not I enable assertions.  I also do not
> see the stack overflow in a release build if I reduce the amount of
> nesting in the test to about 2/3 of its present value.
> 
> On Mon, Feb 29, 2016 at 5:38 PM, Argyrios Kyrtzidis  wrote:
>> I don’t quite understand how it gets that stack trace, dataTraverseNode() 
>> was introduced to avoid exactly this.
>> How are you configuring and what compiler and version are you using ?
>> 
>>> On Feb 29, 2016, at 3:14 PM, Justin Lebar  wrote:
>>> 
 Is this still an issue after r260785 ?
>>> 
>>> I just sync'ed to r262268 and was able to reproduce the segfault.
>>> 
 Could you provide a stack trace ?
>>> 
>>> $ gdb --args release/bin/c-index-test -index-file
>>> /usr/local/google/home/jlebar/code/llvm/src/tools/clang/test/Index/index-many-call-ops.cpp
>>> (gdb) run
>>> Program received signal SIGSEGV, Segmentation fault.
>>> [Switching to Thread 0x72ca2700 (LWP 3936)]
>>> 0x74f264be in
>>> clang::DeclarationName::print(llvm::raw_ostream&,
>>> clang::PrintingPolicy const&) ()
>>>  from 
>>> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
>>> (gdb) bt
>>> #0  0x74f264be in
>>> clang::DeclarationName::print(llvm::raw_ostream&,
>>> clang::PrintingPolicy const&) ()
>>>  from 
>>> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
>>> #1  0x74f26c9e in clang::operator<<(llvm::raw_ostream&,
>>> clang::DeclarationName) ()
>>>  from 
>>> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
>>> #2  0x74ebcb91 in
>>> clang::cxindex::CXIndexDataConsumer::getEntityInfo(clang::NamedDecl
>>> const*, clang::cxindex::EntityInfo&, clang::cxindex::ScratchAlloc&) ()
>>> from 
>>> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
>>> #3  0x74ebc206 in
>>> clang::cxindex::CXIndexDataConsumer::handleReference(clang::NamedDecl
>>> const*, clang::SourceLocation, CXCursor, clang::NamedDecl const*,
>>> clang::DeclContext const*, clang::Expr const*, CXIdxEntityRefKind) ()
>>>  from 
>>> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
>>> #4  0x74ebbae2 in
>>> clang::cxindex::CXIndexDataConsumer::handleDeclOccurence(clang::Decl
>>> const*, unsigned int, llvm::ArrayRef,
>>> clang::FileID, unsigned int,
>>> clang::index::IndexDataConsumer::ASTNodeInfo) ()
>>>  from 
>>> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
>>> #5  0x751a05c5 in
>>> clang::index::IndexingContext::handleDeclOccurrence(clang::Decl
>>> const*, clang::SourceLocation, bool, clang::Decl const*, unsigned int,
>>> llvm::ArrayRef, clang::Expr const*,
>>> clang::Decl const*, clang::DeclContext const*) ()
>>>  from 
>>> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
>>> #6  0x751a092a in
>>> clang::index::IndexingContext::handleReference(clang::NamedDecl
>>> const*, clang::SourceLocation, clang::NamedDecl const*,
>>> clang::DeclContext const*, unsigned int,
>>> llvm::ArrayRef, clang::Expr const*,
>>> clang::Decl const*) ()
>>>  from 
>>> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
>>> #7  0x751a9256 in clang::RecursiveASTVisitor<(anonymous
>>> namespace)::BodyIndexer>::dataTraverseNode(clang::Stmt*,
>>> llvm::SmallVectorImpl>> llvm::PointerLikeTypeTraits,
>>> llvm::PointerIntPairInfo>> llvm::PointerLikeTypeTraits > > >*) () from
>>> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
>>> #8  0x751a60dd in clang::RecursiveASTVisitor<(anonymous
>>> namespace)::BodyIndexer>::TraverseStmt(clang::Stmt*,
>>> llvm::SmallVectorImpl>> llvm::PointerLikeTypeTraits,
>>> llvm::PointerIntPairInfo>> llvm::PointerLikeTypeTraits > > >*) () from
>>> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
>>> #9  0x751a880e in clang::RecursiveASTVisitor<(anonymous
>>> namespace)::BodyIndexer>::dataTraverseNode(clang::Stmt*,
>>> llvm::SmallVectorImpl>> llvm::PointerLikeTypeTraits,
>>> llvm::PointerIntPairInfo>> llvm::PointerLikeTypeTraits > > >*) () from
>>> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
>>> #10 0x751a60dd in clang::

Re: [PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2016-02-29 Thread Nico Weber via cfe-commits
thakis added a comment.

In http://reviews.llvm.org/D17741#364931, @weimingz wrote:

> In http://reviews.llvm.org/D17741#364756, @thakis wrote:
>
> > Instead of doing this, would it make sense to have a flag like 
> > -ffile-basename that changes what __FILE__ expands to?
> >
> > I had wished I'd be able to have some control over __FILE__ (I'd like to 
> > say "make all __FILE__s relative to this given directory for my use case), 
> > and changing __FILE__ to something else in all the world's code isn't easy 
> > – so maybe having a flag that provides some control over __FILE__ instead 
> > of adding a separate macro would be a good idea.
>
>
> do you mean this?
>  if source file is /a/b/c/d/foo.c and if  -ffile-name-stem-remove=/a/b/c, 
> then _FILE_ will be expanded to "d/foo.c" ?


Yes, something like that. Maybe it could look like 
`-f__file__-expansion=basename` (to make __FILE__ expand to just the basename, 
what you want), `-f__file__-expansion=relative-to:/a/b/c` to make it relative 
to a given path.


http://reviews.llvm.org/D17741



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


Re: r262275 - Infrastructure improvements to Clang attribute TableGen.

2016-02-29 Thread Sean Silva via cfe-commits
All green on the two latest commits. Thanks!
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/961

-- Sean Silva

On Mon, Feb 29, 2016 at 6:14 PM, John McCall  wrote:

> On Feb 29, 2016, at 5:44 PM, Sean Silva  wrote:
> This seems to be causing a substantial amount of warning spew from MSVC:
>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/955
>
> I think our recommended "portable" method of using llvm_unreachable is
> outside the switch, instead of in the default case:
> http://llvm.org/docs/CodingStandards.html#don-t-use-default-labels-in-fully-covered-switches-over-enumerations
>
>
> Sorry, should be fixed in r262288.  I’ll be back in a few hours, feel free
> to revert if it doesn’t clear up.
>
> John.
>
>
> -- Sean Silva
>
> On Mon, Feb 29, 2016 at 4:18 PM, John McCall via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rjmccall
>> Date: Mon Feb 29 18:18:05 2016
>> New Revision: 262275
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=262275&view=rev
>> Log:
>> Infrastructure improvements to Clang attribute TableGen.
>>
>> This should make it easier to add new Attr subclasses.
>>
>> Modified:
>> cfe/trunk/include/clang/AST/Attr.h
>> cfe/trunk/include/clang/Basic/AttrKinds.h
>> cfe/trunk/lib/AST/ASTDumper.cpp
>> cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/Attr.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=262275&r1=262274&r2=262275&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/Attr.h (original)
>> +++ cfe/trunk/include/clang/AST/Attr.h Mon Feb 29 18:18:05 2016
>> @@ -129,7 +129,8 @@ public:
>>
>>// Implement isa/cast/dyncast/etc.
>>static bool classof(const Attr *A) {
>> -return A->getKind() <= attr::LAST_INHERITABLE;
>> +return A->getKind() >= attr::FirstInheritableAttr &&
>> +   A->getKind() <= attr::LastInheritableAttr;
>>}
>>  };
>>
>> @@ -143,9 +144,8 @@ protected:
>>  public:
>>// Implement isa/cast/dyncast/etc.
>>static bool classof(const Attr *A) {
>> -// Relies on relative order of enum emission with respect to MS
>> inheritance
>> -// attrs.
>> -return A->getKind() <= attr::LAST_INHERITABLE_PARAM;
>> +return A->getKind() >= attr::FirstInheritableParamAttr &&
>> +   A->getKind() <= attr::LastInheritableParamAttr;
>>}
>>  };
>>
>>
>> Modified: cfe/trunk/include/clang/Basic/AttrKinds.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrKinds.h?rev=262275&r1=262274&r2=262275&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/AttrKinds.h (original)
>> +++ cfe/trunk/include/clang/Basic/AttrKinds.h Mon Feb 29 18:18:05 2016
>> @@ -22,10 +22,10 @@ namespace attr {
>>  // \brief A list of all the recognized kinds of attributes.
>>  enum Kind {
>>  #define ATTR(X) X,
>> -#define LAST_INHERITABLE_ATTR(X) X, LAST_INHERITABLE = X,
>> -#define LAST_INHERITABLE_PARAM_ATTR(X) X, LAST_INHERITABLE_PARAM = X,
>> +#define ATTR_RANGE(CLASS, FIRST_NAME, LAST_NAME) \
>> +  First##CLASS = FIRST_NAME,\
>> +  Last##CLASS = LAST_NAME,
>>  #include "clang/Basic/AttrList.inc"
>> -  NUM_ATTRS
>>  };
>>
>>  } // end namespace attr
>>
>> Modified: cfe/trunk/lib/AST/ASTDumper.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=262275&r1=262274&r2=262275&view=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/ASTDumper.cpp (original)
>> +++ cfe/trunk/lib/AST/ASTDumper.cpp Mon Feb 29 18:18:05 2016
>> @@ -819,8 +819,6 @@ void ASTDumper::dumpAttr(const Attr *A)
>>switch (A->getKind()) {
>>  #define ATTR(X) case attr::X: OS << #X; break;
>>  #include "clang/Basic/AttrList.inc"
>> -  default:
>> -llvm_unreachable("unexpected attribute kind");
>>}
>>OS << "Attr";
>>  }
>>
>> Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=262275&r1=262274&r2=262275&view=diff
>>
>> ==
>> --- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
>> +++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Mon Feb 29 18:18:05 2016
>> @@ -1718,8 +1718,6 @@ void EmitClangAttrImpl(RecordKeeper &Rec
>>OS << "return cast<" << R.getName() << "Attr>(this)->" <<
>> Method
>>   << ";\n";
>>  }
>> -OS << "  case attr::NUM_ATTRS:\n";
>> -OS << "break;\n";
>>  OS << "  }\n";
>>  OS << "  llvm_unreachable(\"Unexpected attribute kind!\");\n";
>>  OS << "}\n\n";
>> @@ -1738,20 +1736,10 @@ void EmitClangAttrImpl(RecordKeeper &Rec
>>
>> 

Re: [PATCH] D17737: [PGO] change profile use cc1 option

2016-02-29 Thread Sean Silva via cfe-commits
silvas added a comment.

Some comments but otherwise feel free to commit.



Comment at: lib/CodeGen/CodeGenModule.cpp:154
@@ +153,3 @@
+assert(!CodeGenOpts.ProfileInstrumentUsePath.empty() &&
+   "Need to explicitly specify the profile name.");
+auto ReaderOrErr = llvm::IndexedInstrProfReader::create(

Are we ensuring consistency in the driver? If not, we definitely want to do 
that.


Comment at: lib/Frontend/CompilerInvocation.cpp:381
@@ +380,3 @@
+   OptSpecifier Id, DiagnosticsEngine &Diags) {
+  if (Id != OPT_fprofile_instrument_EQ && Id != OPT_fprofile_instrument_use_EQ)
+return;

I think it would be better to assert that it is one of the two options rather 
than silently doing nothing.


http://reviews.llvm.org/D17737



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


r262290 - [index] Fix issue where data visitation was disabled with C++ operator call expressions, during indexing.

2016-02-29 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Mon Feb 29 20:46:32 2016
New Revision: 262290

URL: http://llvm.org/viewvc/llvm-project?rev=262290&view=rev
Log:
[index] Fix issue where data visitation was disabled with C++ operator call 
expressions, during indexing.

Modified:
cfe/trunk/lib/Index/IndexBody.cpp

Modified: cfe/trunk/lib/Index/IndexBody.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexBody.cpp?rev=262290&r1=262289&r2=262290&view=diff
==
--- cfe/trunk/lib/Index/IndexBody.cpp (original)
+++ cfe/trunk/lib/Index/IndexBody.cpp Mon Feb 29 20:46:32 2016
@@ -258,7 +258,7 @@ public:
DataRecursionQueue *Q = nullptr) {
 if (E->getOperatorLoc().isInvalid())
   return true; // implicit.
-return base::TraverseCXXOperatorCallExpr(E);
+return base::TraverseCXXOperatorCallExpr(E, Q);
   }
 
   bool VisitDeclStmt(DeclStmt *S) {
@@ -325,7 +325,7 @@ public:
 
 auto visitForm = [&](InitListExpr *Form) {
   for (Stmt *SubStmt : Form->children()) {
-if (!TraverseStmt(SubStmt))
+if (!TraverseStmt(SubStmt, Q))
   return false;
   }
   return true;


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


Re: r260760 - [libclang] Separate the underlying indexing functionality of libclang and introduce it into the clangIndex library.

2016-02-29 Thread Argyrios Kyrtzidis via cfe-commits
Try with r262290.

> On Feb 29, 2016, at 6:23 PM, Argyrios Kyrtzidis  wrote:
> 
> Ah, I see the problem in the code, will fix shortly.
> 
>> On Feb 29, 2016, at 5:43 PM, Justin Lebar  wrote:
>> 
>>> How are you configuring
>> 
>> cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang
>> -DCMAKE_CXX_COMPILER=clang++ -DLLVM_ENABLE_ASSERTIONS=On
>> -DLLVM_ENABLE_SPHINX=true -DSPHINX_OUTPUT_MAN=true ../llvm
>> 
>>> and what compiler and version are you using ?
>> 
>> $ clang --version
>> Ubuntu clang version 3.5.0-4ubuntu2~trusty2 (tags/RELEASE_350/final)
>> (based on LLVM 3.5.0)
>> Target: x86_64-pc-linux-gnu
>> Thread model: posix
>> 
>> I do not see the stack overflow or segfault in debug builds.  I do see
>> it regardless of whether or not I enable assertions.  I also do not
>> see the stack overflow in a release build if I reduce the amount of
>> nesting in the test to about 2/3 of its present value.
>> 
>> On Mon, Feb 29, 2016 at 5:38 PM, Argyrios Kyrtzidis  
>> wrote:
>>> I don’t quite understand how it gets that stack trace, dataTraverseNode() 
>>> was introduced to avoid exactly this.
>>> How are you configuring and what compiler and version are you using ?
>>> 
 On Feb 29, 2016, at 3:14 PM, Justin Lebar  wrote:
 
> Is this still an issue after r260785 ?
 
 I just sync'ed to r262268 and was able to reproduce the segfault.
 
> Could you provide a stack trace ?
 
 $ gdb --args release/bin/c-index-test -index-file
 /usr/local/google/home/jlebar/code/llvm/src/tools/clang/test/Index/index-many-call-ops.cpp
 (gdb) run
 Program received signal SIGSEGV, Segmentation fault.
 [Switching to Thread 0x72ca2700 (LWP 3936)]
 0x74f264be in
 clang::DeclarationName::print(llvm::raw_ostream&,
 clang::PrintingPolicy const&) ()
 from 
 /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
 (gdb) bt
 #0  0x74f264be in
 clang::DeclarationName::print(llvm::raw_ostream&,
 clang::PrintingPolicy const&) ()
 from 
 /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
 #1  0x74f26c9e in clang::operator<<(llvm::raw_ostream&,
 clang::DeclarationName) ()
 from 
 /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
 #2  0x74ebcb91 in
 clang::cxindex::CXIndexDataConsumer::getEntityInfo(clang::NamedDecl
 const*, clang::cxindex::EntityInfo&, clang::cxindex::ScratchAlloc&) ()
 from 
 /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
 #3  0x74ebc206 in
 clang::cxindex::CXIndexDataConsumer::handleReference(clang::NamedDecl
 const*, clang::SourceLocation, CXCursor, clang::NamedDecl const*,
 clang::DeclContext const*, clang::Expr const*, CXIdxEntityRefKind) ()
 from 
 /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
 #4  0x74ebbae2 in
 clang::cxindex::CXIndexDataConsumer::handleDeclOccurence(clang::Decl
 const*, unsigned int, llvm::ArrayRef,
 clang::FileID, unsigned int,
 clang::index::IndexDataConsumer::ASTNodeInfo) ()
 from 
 /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
 #5  0x751a05c5 in
 clang::index::IndexingContext::handleDeclOccurrence(clang::Decl
 const*, clang::SourceLocation, bool, clang::Decl const*, unsigned int,
 llvm::ArrayRef, clang::Expr const*,
 clang::Decl const*, clang::DeclContext const*) ()
 from 
 /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
 #6  0x751a092a in
 clang::index::IndexingContext::handleReference(clang::NamedDecl
 const*, clang::SourceLocation, clang::NamedDecl const*,
 clang::DeclContext const*, unsigned int,
 llvm::ArrayRef, clang::Expr const*,
 clang::Decl const*) ()
 from 
 /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
 #7  0x751a9256 in clang::RecursiveASTVisitor<(anonymous
 namespace)::BodyIndexer>::dataTraverseNode(clang::Stmt*,
 llvm::SmallVectorImpl>>> llvm::PointerLikeTypeTraits,
 llvm::PointerIntPairInfo>>> llvm::PointerLikeTypeTraits > > >*) () from
 /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
 #8  0x751a60dd in clang::RecursiveASTVisitor<(anonymous
 namespace)::BodyIndexer>::TraverseStmt(clang::Stmt*,
 llvm::SmallVectorImpl>>> llvm::PointerLikeTypeTraits,
 llvm::PointerIntPairInfo>>> llvm::PointerLikeTypeTraits > > >*) () from
 /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
 #9  0x751a880e in clang::RecursiveASTVisitor<(anonymous
 namespace)::BodyIndexer>::dataTraverseNode(clang::Stmt*,
 llvm::SmallVectorImpl>>> llvm::PointerLikeTypeTraits,
 llvm::Poi

Re: r262290 - [index] Fix issue where data visitation was disabled with C++ operator call expressions, during indexing.

2016-02-29 Thread David Blaikie via cfe-commits
Does this change any behavior? (missing test case?)

On Mon, Feb 29, 2016 at 6:46 PM, Argyrios Kyrtzidis via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: akirtzidis
> Date: Mon Feb 29 20:46:32 2016
> New Revision: 262290
>
> URL: http://llvm.org/viewvc/llvm-project?rev=262290&view=rev
> Log:
> [index] Fix issue where data visitation was disabled with C++ operator
> call expressions, during indexing.
>
> Modified:
> cfe/trunk/lib/Index/IndexBody.cpp
>
> Modified: cfe/trunk/lib/Index/IndexBody.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexBody.cpp?rev=262290&r1=262289&r2=262290&view=diff
>
> ==
> --- cfe/trunk/lib/Index/IndexBody.cpp (original)
> +++ cfe/trunk/lib/Index/IndexBody.cpp Mon Feb 29 20:46:32 2016
> @@ -258,7 +258,7 @@ public:
> DataRecursionQueue *Q = nullptr) {
>  if (E->getOperatorLoc().isInvalid())
>return true; // implicit.
> -return base::TraverseCXXOperatorCallExpr(E);
> +return base::TraverseCXXOperatorCallExpr(E, Q);
>}
>
>bool VisitDeclStmt(DeclStmt *S) {
> @@ -325,7 +325,7 @@ public:
>
>  auto visitForm = [&](InitListExpr *Form) {
>for (Stmt *SubStmt : Form->children()) {
> -if (!TraverseStmt(SubStmt))
> +if (!TraverseStmt(SubStmt, Q))
>return false;
>}
>return true;
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262291 - clang-format: [JS] Support quoted object literal keys.

2016-02-29 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Feb 29 22:19:47 2016
New Revision: 262291

URL: http://llvm.org/viewvc/llvm-project?rev=262291&view=rev
Log:
clang-format: [JS] Support quoted object literal keys.

Before:
  var x = {
a: a,
b: b, 'c': c,
  };

After:
  var x = {
a: a,
b: b,
'c': c,
  };

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=262291&r1=262290&r2=262291&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Feb 29 22:19:47 2016
@@ -409,7 +409,8 @@ private:
 (!Contexts.back().ColonIsDictLiteral ||
  Style.Language != FormatStyle::LK_Cpp)) ||
Style.Language == FormatStyle::LK_Proto) &&
-  Previous->Tok.getIdentifierInfo())
+  (Previous->Tok.getIdentifierInfo() ||
+   Previous->is(tok::char_constant)))
 Previous->Type = TT_SelectorName;
   if (CurrentToken->is(tok::colon) ||
   Style.Language == FormatStyle::LK_JavaScript)

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=262291&r1=262290&r2=262291&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Feb 29 22:19:47 2016
@@ -205,6 +205,13 @@ TEST_F(FormatTestJS, ContainerLiterals)
   verifyFormat("f({a}, () => {\n"
"  g();  //\n"
"});");
+
+  // Keys can be quoted.
+  verifyFormat("var x = {\n"
+   "  a: a,\n"
+   "  b: b,\n"
+   "  'c': c,\n"
+   "};");
 }
 
 TEST_F(FormatTestJS, MethodsInObjectLiterals) {


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


r262292 - clang-format: Increase the penalty for breaking between array subscripts.

2016-02-29 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Feb 29 22:19:55 2016
New Revision: 262292

URL: http://llvm.org/viewvc/llvm-project?rev=262292&view=rev
Log:
clang-format: Increase the penalty for breaking between array subscripts.

Before:
  aa[aaa]
[a].aa();

After:
  aa[aaa][a]
  .aa();

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=262292&r1=262291&r2=262292&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Feb 29 22:19:55 2016
@@ -1753,7 +1753,7 @@ unsigned TokenAnnotator::splitPenalty(co
 if (Style.Language == FormatStyle::LK_Proto)
   return 1;
 if (Left.is(tok::r_square))
-  return 25;
+  return 200;
 // Slightly prefer formatting local lambda definitions like functions.
 if (Right.is(TT_LambdaLSquare) && Left.is(tok::equal))
   return 35;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=262292&r1=262291&r2=262292&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Feb 29 22:19:55 2016
@@ -6160,6 +6160,8 @@ TEST_F(FormatTest, FormatsArrays) {
   "llvm::outs() << \": \"\n"
   " << (*aaaiaaa)[a]\n"
   "  [aa];");
+  verifyFormat("aa[a][a]\n"
+   ".aa();");
 
   verifyGoogleFormat("a\n"
  "aa[];");


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


r262293 - clang-format: Correctly apply wrap before multi-line RHS rule to

2016-02-29 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Feb 29 22:19:59 2016
New Revision: 262293

URL: http://llvm.org/viewvc/llvm-project?rev=262293&view=rev
Log:
clang-format: Correctly apply wrap before multi-line RHS rule to
ternary expressions.

Before:
  return a ? a : bbb +
 ;

After:
  return a ?
 a :
 bbb + ;

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

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=262293&r1=262292&r2=262293&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Mon Feb 29 22:19:59 2016
@@ -847,7 +847,7 @@ void ContinuationIndenter::moveStatePast
 // there is a line-break right after the operator.
 // Exclude relational operators, as there, it is always more desirable to
 // have the LHS 'left' of the RHS.
-if (Previous && Previous->getPrecedence() > prec::Assignment &&
+if (Previous && Previous->getPrecedence() != prec::Assignment &&
 Previous->isOneOf(TT_BinaryOperator, TT_ConditionalExpr) &&
 Previous->getPrecedence() != prec::Relational) {
   bool BreakBeforeOperator =

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=262293&r1=262292&r2=262293&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Feb 29 22:19:59 2016
@@ -4708,6 +4708,10 @@ TEST_F(FormatTest, BreaksConditionalExpr
"/*bbb=*/b :\n"
"ccc;",
Style);
+  verifyFormat("return aaa ?\n"
+   "   a :\n"
+   "   bbb + ;",
+   Style);
 }
 
 TEST_F(FormatTest, DeclarationsOfMultipleVariables) {


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


Re: r262290 - [index] Fix issue where data visitation was disabled with C++ operator call expressions, during indexing.

2016-02-29 Thread Argyrios Kyrtzidis via cfe-commits
This is to reduce stack usage, whether it hits stack overflow or not is highly 
dependent on configuration.
I've tried forcing smaller stack on the specific test 
(test/Index/index-many-call-ops.cpp) but then it can hit stack overflow in 
sema; I don’t have a good way to test this.
I believe asan was also hitting stack overflow and I’m going to try re-enabling 
for that test.

> On Feb 29, 2016, at 8:10 PM, David Blaikie  wrote:
> 
> Does this change any behavior? (missing test case?)
> 
> On Mon, Feb 29, 2016 at 6:46 PM, Argyrios Kyrtzidis via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: akirtzidis
> Date: Mon Feb 29 20:46:32 2016
> New Revision: 262290
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=262290&view=rev 
> 
> Log:
> [index] Fix issue where data visitation was disabled with C++ operator call 
> expressions, during indexing.
> 
> Modified:
> cfe/trunk/lib/Index/IndexBody.cpp
> 
> Modified: cfe/trunk/lib/Index/IndexBody.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexBody.cpp?rev=262290&r1=262289&r2=262290&view=diff
>  
> 
> ==
> --- cfe/trunk/lib/Index/IndexBody.cpp (original)
> +++ cfe/trunk/lib/Index/IndexBody.cpp Mon Feb 29 20:46:32 2016
> @@ -258,7 +258,7 @@ public:
> DataRecursionQueue *Q = nullptr) {
>  if (E->getOperatorLoc().isInvalid())
>return true; // implicit.
> -return base::TraverseCXXOperatorCallExpr(E);
> +return base::TraverseCXXOperatorCallExpr(E, Q);
>}
> 
>bool VisitDeclStmt(DeclStmt *S) {
> @@ -325,7 +325,7 @@ public:
> 
>  auto visitForm = [&](InitListExpr *Form) {
>for (Stmt *SubStmt : Form->children()) {
> -if (!TraverseStmt(SubStmt))
> +if (!TraverseStmt(SubStmt, Q))
>return false;
>}
>return true;
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org 
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits 
> 
> 

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


Re: r262290 - [index] Fix issue where data visitation was disabled with C++ operator call expressions, during indexing.

2016-02-29 Thread David Blaikie via cfe-commits
On Mon, Feb 29, 2016 at 8:34 PM, Argyrios Kyrtzidis 
wrote:

> This is to reduce stack usage, whether it hits stack overflow or not is
> highly dependent on configuration.
> I've tried forcing smaller stack on the specific test
> (test/Index/index-many-call-ops.cpp) but then it can hit stack overflow in
> sema; I don’t have a good way to test this.
> I believe asan was also hitting stack overflow and I’m going to try
> re-enabling for that test.
>

ah, no worries - yeah, I wouldn't bother with a test for stack size
reduction either


>
> On Feb 29, 2016, at 8:10 PM, David Blaikie  wrote:
>
> Does this change any behavior? (missing test case?)
>
> On Mon, Feb 29, 2016 at 6:46 PM, Argyrios Kyrtzidis via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: akirtzidis
>> Date: Mon Feb 29 20:46:32 2016
>> New Revision: 262290
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=262290&view=rev
>> Log:
>> [index] Fix issue where data visitation was disabled with C++ operator
>> call expressions, during indexing.
>>
>> Modified:
>> cfe/trunk/lib/Index/IndexBody.cpp
>>
>> Modified: cfe/trunk/lib/Index/IndexBody.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexBody.cpp?rev=262290&r1=262289&r2=262290&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Index/IndexBody.cpp (original)
>> +++ cfe/trunk/lib/Index/IndexBody.cpp Mon Feb 29 20:46:32 2016
>> @@ -258,7 +258,7 @@ public:
>> DataRecursionQueue *Q = nullptr) {
>>  if (E->getOperatorLoc().isInvalid())
>>return true; // implicit.
>> -return base::TraverseCXXOperatorCallExpr(E);
>> +return base::TraverseCXXOperatorCallExpr(E, Q);
>>}
>>
>>bool VisitDeclStmt(DeclStmt *S) {
>> @@ -325,7 +325,7 @@ public:
>>
>>  auto visitForm = [&](InitListExpr *Form) {
>>for (Stmt *SubStmt : Form->children()) {
>> -if (!TraverseStmt(SubStmt))
>> +if (!TraverseStmt(SubStmt, Q))
>>return false;
>>}
>>return true;
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262295 - [test] After r262290 reducing stack usage, try re-enabling asan on the related test.

2016-02-29 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Mon Feb 29 22:40:20 2016
New Revision: 262295

URL: http://llvm.org/viewvc/llvm-project?rev=262295&view=rev
Log:
[test] After r262290 reducing stack usage, try re-enabling asan on the related 
test.

Modified:
cfe/trunk/test/Index/index-many-call-ops.cpp

Modified: cfe/trunk/test/Index/index-many-call-ops.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-many-call-ops.cpp?rev=262295&r1=262294&r2=262295&view=diff
==
--- cfe/trunk/test/Index/index-many-call-ops.cpp (original)
+++ cfe/trunk/test/Index/index-many-call-ops.cpp Mon Feb 29 22:40:20 2016
@@ -4,8 +4,8 @@
 // Check that we don't get stack overflow trying to index a huge number of
 // call operators.
 
-// ASan and UBSan increase stack usage.
-// REQUIRES: not_asan, not_ubsan
+// UBSan increses stack usage.
+// REQUIRES: not_ubsan
 
 struct S {
   S &operator()();


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


[PATCH] [libclang/python] Add bindings for children of diagnostics

2016-02-29 Thread Hanson via cfe-commits
This exposes the Clang API bindings `clang_getChildDiagnostics` (which
returns a `CXDiagnosticSet`) and `clang_getNumDiagnosticsInSet` /
`clang_getDiagnosticInSet` (to traverse the `CXDiagnosticSet`), and adds a
helper `children` property in the Python `Diagnostic` wrapper.

Also, this adds the missing `OVERLOAD_CANDIDATE` (700) cursor type.


child_diagnostics.patch
Description: Binary data
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r260760 - [libclang] Separate the underlying indexing functionality of libclang and introduce it into the clangIndex library.

2016-02-29 Thread Justin Lebar via cfe-commits
Works!  Thank you for fixing this, and so quickly.

On Mon, Feb 29, 2016 at 6:51 PM, Argyrios Kyrtzidis  wrote:
> Try with r262290.
>
>> On Feb 29, 2016, at 6:23 PM, Argyrios Kyrtzidis  wrote:
>>
>> Ah, I see the problem in the code, will fix shortly.
>>
>>> On Feb 29, 2016, at 5:43 PM, Justin Lebar  wrote:
>>>
 How are you configuring
>>>
>>> cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang
>>> -DCMAKE_CXX_COMPILER=clang++ -DLLVM_ENABLE_ASSERTIONS=On
>>> -DLLVM_ENABLE_SPHINX=true -DSPHINX_OUTPUT_MAN=true ../llvm
>>>
 and what compiler and version are you using ?
>>>
>>> $ clang --version
>>> Ubuntu clang version 3.5.0-4ubuntu2~trusty2 (tags/RELEASE_350/final)
>>> (based on LLVM 3.5.0)
>>> Target: x86_64-pc-linux-gnu
>>> Thread model: posix
>>>
>>> I do not see the stack overflow or segfault in debug builds.  I do see
>>> it regardless of whether or not I enable assertions.  I also do not
>>> see the stack overflow in a release build if I reduce the amount of
>>> nesting in the test to about 2/3 of its present value.
>>>
>>> On Mon, Feb 29, 2016 at 5:38 PM, Argyrios Kyrtzidis  
>>> wrote:
 I don’t quite understand how it gets that stack trace, dataTraverseNode() 
 was introduced to avoid exactly this.
 How are you configuring and what compiler and version are you using ?

> On Feb 29, 2016, at 3:14 PM, Justin Lebar  wrote:
>
>> Is this still an issue after r260785 ?
>
> I just sync'ed to r262268 and was able to reproduce the segfault.
>
>> Could you provide a stack trace ?
>
> $ gdb --args release/bin/c-index-test -index-file
> /usr/local/google/home/jlebar/code/llvm/src/tools/clang/test/Index/index-many-call-ops.cpp
> (gdb) run
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 0x72ca2700 (LWP 3936)]
> 0x74f264be in
> clang::DeclarationName::print(llvm::raw_ostream&,
> clang::PrintingPolicy const&) ()
> from 
> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
> (gdb) bt
> #0  0x74f264be in
> clang::DeclarationName::print(llvm::raw_ostream&,
> clang::PrintingPolicy const&) ()
> from 
> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
> #1  0x74f26c9e in clang::operator<<(llvm::raw_ostream&,
> clang::DeclarationName) ()
> from 
> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
> #2  0x74ebcb91 in
> clang::cxindex::CXIndexDataConsumer::getEntityInfo(clang::NamedDecl
> const*, clang::cxindex::EntityInfo&, clang::cxindex::ScratchAlloc&) ()
> from 
> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
> #3  0x74ebc206 in
> clang::cxindex::CXIndexDataConsumer::handleReference(clang::NamedDecl
> const*, clang::SourceLocation, CXCursor, clang::NamedDecl const*,
> clang::DeclContext const*, clang::Expr const*, CXIdxEntityRefKind) ()
> from 
> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
> #4  0x74ebbae2 in
> clang::cxindex::CXIndexDataConsumer::handleDeclOccurence(clang::Decl
> const*, unsigned int, llvm::ArrayRef,
> clang::FileID, unsigned int,
> clang::index::IndexDataConsumer::ASTNodeInfo) ()
> from 
> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
> #5  0x751a05c5 in
> clang::index::IndexingContext::handleDeclOccurrence(clang::Decl
> const*, clang::SourceLocation, bool, clang::Decl const*, unsigned int,
> llvm::ArrayRef, clang::Expr const*,
> clang::Decl const*, clang::DeclContext const*) ()
> from 
> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
> #6  0x751a092a in
> clang::index::IndexingContext::handleReference(clang::NamedDecl
> const*, clang::SourceLocation, clang::NamedDecl const*,
> clang::DeclContext const*, unsigned int,
> llvm::ArrayRef, clang::Expr const*,
> clang::Decl const*) ()
> from 
> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
> #7  0x751a9256 in clang::RecursiveASTVisitor<(anonymous
> namespace)::BodyIndexer>::dataTraverseNode(clang::Stmt*,
> llvm::SmallVectorImpl llvm::PointerLikeTypeTraits,
> llvm::PointerIntPairInfo llvm::PointerLikeTypeTraits > > >*) () from
> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.3.9
> #8  0x751a60dd in clang::RecursiveASTVisitor<(anonymous
> namespace)::BodyIndexer>::TraverseStmt(clang::Stmt*,
> llvm::SmallVectorImpl llvm::PointerLikeTypeTraits,
> llvm::PointerIntPairInfo llvm::PointerLikeTypeTraits > > >*) () from
> /usr/local/google/home/jlebar/code/llvm-complete/release/bin/../lib/libclang.so.

  1   2   >