r314494 - [X86][MS-InlineAsm] Extended support for variables / identifiers on memory / immediate expressions

2017-09-29 Thread Coby Tayree via cfe-commits
Author: coby
Date: Fri Sep 29 00:02:49 2017
New Revision: 314494

URL: http://llvm.org/viewvc/llvm-project?rev=314494&view=rev
Log:
[X86][MS-InlineAsm] Extended support for variables / identifiers on memory / 
immediate expressions

Allow the proper recognition of Enum values and global variables inside ms 
inline-asm memory / immediate expressions, as they require some additional 
overhead and treated incorrect if doesn't early recognized.
supersedes D33278, D35774

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

Added:
cfe/trunk/test/CodeGen/ms-inline-asm-enums.cpp   (with props)
cfe/trunk/test/CodeGen/ms-inline-asm-variables.c   (with props)
Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseStmtAsm.cpp
cfe/trunk/lib/Sema/SemaStmtAsm.cpp

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=314494&r1=314493&r2=314494&view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Fri Sep 29 00:02:49 2017
@@ -1474,7 +1474,6 @@ public:
 
   ExprResult ParseMSAsmIdentifier(llvm::SmallVectorImpl &LineToks,
   unsigned &NumLineToksConsumed,
-  void *Info,
   bool IsUnevaluated);
 
 private:

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=314494&r1=314493&r2=314494&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Sep 29 00:02:49 2017
@@ -3788,15 +3788,15 @@ public:
  Expr *AsmString, MultiExprArg Clobbers,
  SourceLocation RParenLoc);
 
+  void FillInlineAsmIdentifierInfo(Expr *Res,
+   llvm::InlineAsmIdentifierInfo &Info);
   ExprResult LookupInlineAsmIdentifier(CXXScopeSpec &SS,
SourceLocation TemplateKWLoc,
UnqualifiedId &Id,
-   llvm::InlineAsmIdentifierInfo &Info,
bool IsUnevaluatedContext);
   bool LookupInlineAsmField(StringRef Base, StringRef Member,
 unsigned &Offset, SourceLocation AsmLoc);
   ExprResult LookupInlineAsmVarDeclField(Expr *RefExpr, StringRef Member,
- llvm::InlineAsmIdentifierInfo &Info,
  SourceLocation AsmLoc);
   StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc,
 ArrayRef AsmToks,

Modified: cfe/trunk/lib/Parse/ParseStmtAsm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmtAsm.cpp?rev=314494&r1=314493&r2=314494&view=diff
==
--- cfe/trunk/lib/Parse/ParseStmtAsm.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmtAsm.cpp Fri Sep 29 00:02:49 2017
@@ -54,9 +54,9 @@ public:
 assert(AsmToks.size() == AsmTokOffsets.size());
   }
 
-  void *LookupInlineAsmIdentifier(StringRef &LineBuf,
-  llvm::InlineAsmIdentifierInfo &Info,
-  bool IsUnevaluatedContext) override {
+  void LookupInlineAsmIdentifier(StringRef &LineBuf,
+ llvm::InlineAsmIdentifierInfo &Info,
+ bool IsUnevaluatedContext) override {
 // Collect the desired tokens.
 SmallVector LineToks;
 const Token *FirstOrigToken = nullptr;
@@ -64,7 +64,7 @@ public:
 
 unsigned NumConsumedToks;
 ExprResult Result = TheParser.ParseMSAsmIdentifier(
-LineToks, NumConsumedToks, &Info, IsUnevaluatedContext);
+LineToks, NumConsumedToks, IsUnevaluatedContext);
 
 // If we consumed the entire line, tell MC that.
 // Also do this if we consumed nothing as a way of reporting failure.
@@ -89,9 +89,10 @@ public:
   LineBuf = LineBuf.substr(0, TotalOffset);
 }
 
-// Initialize the "decl" with the lookup result.
-Info.OpDecl = static_cast(Result.get());
-return Info.OpDecl;
+// Initialize Info with the lookup result.
+if (!Result.isUsable())
+  return;
+TheParser.getActions().FillInlineAsmIdentifierInfo(Result.get(), Info);
   }
 
   StringRef LookupInlineAsmLabel(StringRef Identifier, llvm::SourceMgr &LSM,
@@ -178,16 +179,9 @@ private:
 }
 
 /// Parse an identifier in an MS-style inline assembly block.
-///
-/// \param CastInfo - a void* so that we don't have to teach Parser.h
-///   about the actual type.
 ExprResult Parser::ParseMSAsmIdentifier(llvm::SmallVe

[PATCH] D37413: [X86][MS-InlineAsm] Extended support for variables / identifiers on memory / immediate expressions

2017-09-29 Thread coby via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314494: [X86][MS-InlineAsm] Extended support for variables / 
identifiers on memory /… (authored by coby).

Changed prior to commit:
  https://reviews.llvm.org/D37413?vs=115564&id=117095#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37413

Files:
  cfe/trunk/include/clang/Parse/Parser.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Parse/ParseStmtAsm.cpp
  cfe/trunk/lib/Sema/SemaStmtAsm.cpp
  cfe/trunk/test/CodeGen/ms-inline-asm-enums.cpp
  cfe/trunk/test/CodeGen/ms-inline-asm-variables.c

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -3788,15 +3788,15 @@
  Expr *AsmString, MultiExprArg Clobbers,
  SourceLocation RParenLoc);
 
+  void FillInlineAsmIdentifierInfo(Expr *Res,
+   llvm::InlineAsmIdentifierInfo &Info);
   ExprResult LookupInlineAsmIdentifier(CXXScopeSpec &SS,
SourceLocation TemplateKWLoc,
UnqualifiedId &Id,
-   llvm::InlineAsmIdentifierInfo &Info,
bool IsUnevaluatedContext);
   bool LookupInlineAsmField(StringRef Base, StringRef Member,
 unsigned &Offset, SourceLocation AsmLoc);
   ExprResult LookupInlineAsmVarDeclField(Expr *RefExpr, StringRef Member,
- llvm::InlineAsmIdentifierInfo &Info,
  SourceLocation AsmLoc);
   StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc,
 ArrayRef AsmToks,
Index: cfe/trunk/include/clang/Parse/Parser.h
===
--- cfe/trunk/include/clang/Parse/Parser.h
+++ cfe/trunk/include/clang/Parse/Parser.h
@@ -1474,7 +1474,6 @@
 
   ExprResult ParseMSAsmIdentifier(llvm::SmallVectorImpl &LineToks,
   unsigned &NumLineToksConsumed,
-  void *Info,
   bool IsUnevaluated);
 
 private:
Index: cfe/trunk/test/CodeGen/ms-inline-asm-variables.c
===
--- cfe/trunk/test/CodeGen/ms-inline-asm-variables.c
+++ cfe/trunk/test/CodeGen/ms-inline-asm-variables.c
@@ -0,0 +1,35 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -fasm-blocks -triple i386-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+int gVar;
+void t1() {
+  // CHECK: add eax, dword ptr gVar[eax]
+  __asm add eax, dword ptr gVar[eax]
+  // CHECK: add dword ptr gVar[eax], eax
+  __asm add dword ptr [eax+gVar], eax
+  // CHECK: add ebx, dword ptr gVar[ebx + $$270]
+  __asm add ebx, dword ptr gVar[271 - 82 + 81 + ebx]
+  // CHECK: add dword ptr gVar[ebx + $$828], ebx
+  __asm add dword ptr [ebx + gVar + 828], ebx
+  // CHECK: add ecx, dword ptr gVar[ecx + ecx * $$4 + $$4590]
+  __asm add ecx, dword ptr gVar[4590 + ecx + ecx*4]
+  // CHECK: add dword ptr gVar[ecx + ecx * $$8 + $$73], ecx
+  __asm add dword ptr [gVar + ecx + 45 + 23 - 53 + 60 - 2 + ecx*8], ecx
+  // CHECK: add gVar[ecx + ebx + $$7], eax
+  __asm add 1 + 1 + 2 + 3[gVar + ecx + ebx], eax
+}
+
+void t2() {
+  int lVar;
+  // CHECK: mov eax, dword ptr ${{[0-9]}}[eax]
+  __asm mov eax, dword ptr lVar[eax]
+  // CHECK: mov dword ptr ${{[0-9]}}[eax], eax
+  __asm mov dword ptr [eax+lVar], eax
+  // CHECK: mov ebx, dword ptr ${{[0-9]}}[ebx + $$270]
+  __asm mov ebx, dword ptr lVar[271 - 82 + 81 + ebx]
+  // CHECK: mov dword ptr ${{[0-9]}}[ebx + $$828], ebx
+  __asm mov dword ptr [ebx + lVar + 828], ebx
+  // CHECK: mov ${{[0-9]}}[ebx + $$47], eax
+  __asm mov 5 + 8 + 13 + 21[lVar + ebx], eax
+}
+
Index: cfe/trunk/test/CodeGen/ms-inline-asm-enums.cpp
===
--- cfe/trunk/test/CodeGen/ms-inline-asm-enums.cpp
+++ cfe/trunk/test/CodeGen/ms-inline-asm-enums.cpp
@@ -0,0 +1,55 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -fasm-blocks -triple i386-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+namespace x {
+  enum { A = 12 };
+  struct y_t {
+enum { A = 17 };
+int r;
+  } y;
+}
+
+// CHECK-LABEL: t1
+void t1() {
+  enum { A = 1 };
+  // CHECK: call void asm
+  // CHECK-SAME: mov eax, $$12
+  __asm mov eax, x::A
+  // CHECK-SAME: mov eax, $$17
+  __asm mov eax, x::y_t::A
+  // CHECK-NEXT: call void asm
+  // CHECK-SAME: mov eax, $$1
+  __asm {mov eax, A}
+}
+
+// CHECK-LABEL: t2
+void t2() {
+  enum { A = 1, B };
+  // CHECK: call void asm
+  // CHECK-SAME: mov eax, $$21
+  __asm mov eax, (A + 9) * 2 + A
+  // CHECK-SAME: mov eax, $$4
+  __asm mov eax, A << 2
+  // CHECK-SAME: mov eax, $$2
+  __asm mov eax, B & 3
+  // CH

r314499 - [Sema] Suppress warnings for C's zero initializer

2017-09-29 Thread Daniel Marjamaki via cfe-commits
Author: danielmarjamaki
Date: Fri Sep 29 02:44:41 2017
New Revision: 314499

URL: http://llvm.org/viewvc/llvm-project?rev=314499&view=rev
Log:
[Sema] Suppress warnings for C's zero initializer

Patch by S. Gilles!

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

Added:
cfe/trunk/test/Sema/zero-initializer.c
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=314499&r1=314498&r2=314499&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Fri Sep 29 02:44:41 2017
@@ -4011,6 +4011,10 @@ public:
   /// initializer)?
   bool isTransparent() const;
 
+  /// Is this the zero initializer {0} in a language which considers it
+  /// idiomatic?
+  bool isIdiomaticZeroInitializer(const LangOptions &LangOpts) const;
+
   SourceLocation getLBraceLoc() const { return LBraceLoc; }
   void setLBraceLoc(SourceLocation Loc) { LBraceLoc = Loc; }
   SourceLocation getRBraceLoc() const { return RBraceLoc; }
@@ -4020,6 +4024,9 @@ public:
   InitListExpr *getSemanticForm() const {
 return isSemanticForm() ? nullptr : AltForm.getPointer();
   }
+  bool isSyntacticForm() const {
+return !AltForm.getInt() || !AltForm.getPointer();
+  }
   InitListExpr *getSyntacticForm() const {
 return isSemanticForm() ? AltForm.getPointer() : nullptr;
   }

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=314499&r1=314498&r2=314499&view=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Fri Sep 29 02:44:41 2017
@@ -1951,6 +1951,17 @@ bool InitListExpr::isTransparent() const
  getInit(0)->getType().getCanonicalType();
 }
 
+bool InitListExpr::isIdiomaticZeroInitializer(const LangOptions &LangOpts) 
const {
+  assert(isSyntacticForm() && "only test syntactic form as zero initializer");
+
+  if (LangOpts.CPlusPlus || getNumInits() != 1) {
+return false;
+  }
+
+  const IntegerLiteral *Lit = dyn_cast(getInit(0));
+  return Lit && Lit->getValue() == 0;
+}
+
 SourceLocation InitListExpr::getLocStart() const {
   if (InitListExpr *SyntacticForm = getSyntacticForm())
 return SyntacticForm->getLocStart();

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=314499&r1=314498&r2=314499&view=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Fri Sep 29 02:44:41 2017
@@ -886,7 +886,8 @@ void InitListChecker::CheckImplicitInitL
 }
 
 // Complain about missing braces.
-if (T->isArrayType() || T->isRecordType()) {
+if ((T->isArrayType() || T->isRecordType()) &&
+!ParentIList->isIdiomaticZeroInitializer(SemaRef.getLangOpts())) {
   SemaRef.Diag(StructuredSubobjectInitList->getLocStart(),
diag::warn_missing_braces)
   << StructuredSubobjectInitList->getSourceRange()
@@ -1833,7 +1834,9 @@ void InitListChecker::CheckStructUnionTy
   // worthwhile to skip over the rest of the initializer, though.
   RecordDecl *RD = DeclType->getAs()->getDecl();
   RecordDecl::field_iterator FieldEnd = RD->field_end();
-  bool CheckForMissingFields = true;
+  bool CheckForMissingFields =
+!IList->isIdiomaticZeroInitializer(SemaRef.getLangOpts());
+
   while (Index < IList->getNumInits()) {
 Expr *Init = IList->getInit(Index);
 

Added: cfe/trunk/test/Sema/zero-initializer.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/zero-initializer.c?rev=314499&view=auto
==
--- cfe/trunk/test/Sema/zero-initializer.c (added)
+++ cfe/trunk/test/Sema/zero-initializer.c Fri Sep 29 02:44:41 2017
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -std=c99 -Wmissing-field-initializers -Wmissing-braces 
-verify %s
+
+// Tests that using {0} in struct initialization or assignment is supported
+struct foo { int x; int y; };
+struct bar { struct foo a; struct foo b; };
+struct A { int a; };
+struct B { struct A a; };
+struct C { struct B b; };
+
+int main(void)
+{
+  struct foo f = { 0 }; // no-warning
+  struct foo g = { 9 }; // expected-warning {{missing field 'y' initializer}}
+  struct foo h = { 9, 9 }; // no-warning
+  struct bar i = { 0 }; // no-warning
+  struct bar j = { 0, 0 }; // expected-warning {{suggest braces around 
initialization of subobject}} expected-warning {{missing field 'b' initializer}}
+  struct bar k = { { 9, 9 }, { 9, 9 } }; // no-warning
+  struct bar l = { { 9, 9 }, { 0 } }; // no-warning
+  struct bar m = { { 0 }, { 0 } }; // no-warning
+  struct

[PATCH] D28148: [Sema] Suppress warnings for C's zero initializer

2017-09-29 Thread Daniel Marjamäki via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314499: [Sema] Suppress warnings for C's zero initializer 
(authored by danielmarjamaki).

Changed prior to commit:
  https://reviews.llvm.org/D28148?vs=82849&id=117107#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28148

Files:
  cfe/trunk/include/clang/AST/Expr.h
  cfe/trunk/lib/AST/Expr.cpp
  cfe/trunk/lib/Sema/SemaInit.cpp
  cfe/trunk/test/Sema/zero-initializer.c

Index: cfe/trunk/lib/AST/Expr.cpp
===
--- cfe/trunk/lib/AST/Expr.cpp
+++ cfe/trunk/lib/AST/Expr.cpp
@@ -1951,6 +1951,17 @@
  getInit(0)->getType().getCanonicalType();
 }
 
+bool InitListExpr::isIdiomaticZeroInitializer(const LangOptions &LangOpts) const {
+  assert(isSyntacticForm() && "only test syntactic form as zero initializer");
+
+  if (LangOpts.CPlusPlus || getNumInits() != 1) {
+return false;
+  }
+
+  const IntegerLiteral *Lit = dyn_cast(getInit(0));
+  return Lit && Lit->getValue() == 0;
+}
+
 SourceLocation InitListExpr::getLocStart() const {
   if (InitListExpr *SyntacticForm = getSyntacticForm())
 return SyntacticForm->getLocStart();
Index: cfe/trunk/lib/Sema/SemaInit.cpp
===
--- cfe/trunk/lib/Sema/SemaInit.cpp
+++ cfe/trunk/lib/Sema/SemaInit.cpp
@@ -886,7 +886,8 @@
 }
 
 // Complain about missing braces.
-if (T->isArrayType() || T->isRecordType()) {
+if ((T->isArrayType() || T->isRecordType()) &&
+!ParentIList->isIdiomaticZeroInitializer(SemaRef.getLangOpts())) {
   SemaRef.Diag(StructuredSubobjectInitList->getLocStart(),
diag::warn_missing_braces)
   << StructuredSubobjectInitList->getSourceRange()
@@ -1833,7 +1834,9 @@
   // worthwhile to skip over the rest of the initializer, though.
   RecordDecl *RD = DeclType->getAs()->getDecl();
   RecordDecl::field_iterator FieldEnd = RD->field_end();
-  bool CheckForMissingFields = true;
+  bool CheckForMissingFields =
+!IList->isIdiomaticZeroInitializer(SemaRef.getLangOpts());
+
   while (Index < IList->getNumInits()) {
 Expr *Init = IList->getInit(Index);
 
Index: cfe/trunk/include/clang/AST/Expr.h
===
--- cfe/trunk/include/clang/AST/Expr.h
+++ cfe/trunk/include/clang/AST/Expr.h
@@ -4011,6 +4011,10 @@
   /// initializer)?
   bool isTransparent() const;
 
+  /// Is this the zero initializer {0} in a language which considers it
+  /// idiomatic?
+  bool isIdiomaticZeroInitializer(const LangOptions &LangOpts) const;
+
   SourceLocation getLBraceLoc() const { return LBraceLoc; }
   void setLBraceLoc(SourceLocation Loc) { LBraceLoc = Loc; }
   SourceLocation getRBraceLoc() const { return RBraceLoc; }
@@ -4020,6 +4024,9 @@
   InitListExpr *getSemanticForm() const {
 return isSemanticForm() ? nullptr : AltForm.getPointer();
   }
+  bool isSyntacticForm() const {
+return !AltForm.getInt() || !AltForm.getPointer();
+  }
   InitListExpr *getSyntacticForm() const {
 return isSemanticForm() ? AltForm.getPointer() : nullptr;
   }
Index: cfe/trunk/test/Sema/zero-initializer.c
===
--- cfe/trunk/test/Sema/zero-initializer.c
+++ cfe/trunk/test/Sema/zero-initializer.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -std=c99 -Wmissing-field-initializers -Wmissing-braces -verify %s
+
+// Tests that using {0} in struct initialization or assignment is supported
+struct foo { int x; int y; };
+struct bar { struct foo a; struct foo b; };
+struct A { int a; };
+struct B { struct A a; };
+struct C { struct B b; };
+
+int main(void)
+{
+  struct foo f = { 0 }; // no-warning
+  struct foo g = { 9 }; // expected-warning {{missing field 'y' initializer}}
+  struct foo h = { 9, 9 }; // no-warning
+  struct bar i = { 0 }; // no-warning
+  struct bar j = { 0, 0 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{missing field 'b' initializer}}
+  struct bar k = { { 9, 9 }, { 9, 9 } }; // no-warning
+  struct bar l = { { 9, 9 }, { 0 } }; // no-warning
+  struct bar m = { { 0 }, { 0 } }; // no-warning
+  struct bar n = { { 0 }, { 9, 9 } }; // no-warning
+  struct bar o = { { 9 }, { 9, 9 } }; // expected-warning {{missing field 'y' initializer}}
+  struct C p = { 0 }; // no-warning
+  struct C q = { 9 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{suggest braces around initialization of subobject}}
+  f = (struct foo ) { 0 }; // no-warning
+  g = (struct foo ) { 9 }; // expected-warning {{missing field 'y' initializer}}
+  h = (struct foo ) { 9, 9 }; // no-warning
+  i = (struct bar) { 0 }; // no-warning
+  j = (struct bar) { 0, 0 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{missing field 'b' initializer}}
+  k = (struct bar) { { 9, 9 }, { 9, 9 } };

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

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

Address review comments


Repository:
  rL LLVM

https://reviews.llvm.org/D37856

Files:
  include/clang/Tooling/Refactoring/RefactoringActionRule.h
  include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h
  include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h
  include/clang/Tooling/Refactoring/RefactoringOption.h
  include/clang/Tooling/Refactoring/RefactoringOptionVisitor.h
  include/clang/Tooling/Refactoring/RefactoringOptions.h
  include/clang/Tooling/Refactoring/Rename/RenamingAction.h
  lib/Tooling/Refactoring/Rename/RenamingAction.cpp
  test/Refactor/LocalRename/Field.cpp
  test/Refactor/tool-test-support.c
  tools/clang-refactor/ClangRefactor.cpp

Index: tools/clang-refactor/ClangRefactor.cpp
===
--- tools/clang-refactor/ClangRefactor.cpp
+++ tools/clang-refactor/ClangRefactor.cpp
@@ -18,6 +18,7 @@
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Refactoring.h"
 #include "clang/Tooling/Refactoring/RefactoringAction.h"
+#include "clang/Tooling/Refactoring/RefactoringOptions.h"
 #include "clang/Tooling/Refactoring/Rename/RenamingAction.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
@@ -32,10 +33,10 @@
 
 namespace opts {
 
-static cl::OptionCategory CommonRefactorOptions("Common refactoring options");
+static cl::OptionCategory CommonRefactorOptions("Refactoring options");
 
 static cl::opt Verbose("v", cl::desc("Use verbose output"),
- cl::cat(CommonRefactorOptions),
+ cl::cat(cl::GeneralCategory),
  cl::sub(*cl::AllSubCommands));
 } // end namespace opts
 
@@ -116,6 +117,98 @@
   return nullptr;
 }
 
+/// A container that stores the command-line options used by a single
+/// refactoring option.
+class RefactoringActionCommandLineOptions {
+public:
+  template 
+  void addOption(const RefactoringOption &Option,
+ std::unique_ptr> CLOption);
+
+  const cl::opt &
+  getStringOption(const RefactoringOption &Opt) const {
+auto It = StringOptions.find(&Opt);
+return *It->second;
+  }
+
+private:
+  llvm::DenseMap>>
+  StringOptions;
+};
+
+template <>
+void RefactoringActionCommandLineOptions::addOption(
+const RefactoringOption &Option,
+std::unique_ptr> CLOption) {
+  StringOptions[&Option] = std::move(CLOption);
+}
+
+/// Passes the command-line option values to the options used by a single
+/// refactoring action rule.
+class CommandLineRefactoringOptionConsumer final
+: public RefactoringOptionVisitor {
+public:
+  CommandLineRefactoringOptionConsumer(
+  const RefactoringActionCommandLineOptions &Options)
+  : Options(Options) {}
+
+  void visit(const RefactoringOption &Opt,
+ Optional &Value) override {
+const cl::opt &CLOpt = Options.getStringOption(Opt);
+if (!CLOpt.getValue().empty()) {
+  Value = CLOpt.getValue();
+  return;
+}
+Value = None;
+if (Opt.isRequired())
+  MissingRequiredOptions.push_back(&Opt);
+  }
+
+  ArrayRef getMissingRequiredOptions() const {
+return MissingRequiredOptions;
+  }
+
+private:
+  llvm::SmallVector MissingRequiredOptions;
+  const RefactoringActionCommandLineOptions &Options;
+};
+
+/// Creates the refactoring options used by all the rules in a single
+/// refactoring action.
+class CommandLineRefactoringOptionCreator final
+: public RefactoringOptionVisitor {
+public:
+  CommandLineRefactoringOptionCreator(
+  cl::OptionCategory &Category, cl::SubCommand &Subcommand,
+  RefactoringActionCommandLineOptions &Options)
+  : Category(Category), Subcommand(Subcommand), Options(Options) {}
+
+  void visit(const RefactoringOption &Opt, Optional &) override {
+if (Visited.insert(&Opt).second)
+  Options.addOption(Opt, create(Opt));
+  }
+
+private:
+  template 
+  std::unique_ptr> create(const RefactoringOption &Opt) {
+if (!OptionNames.insert(Opt.getName()).second)
+  llvm::report_fatal_error("Multiple identical refactoring options "
+   "specified for one refactoring action");
+// FIXME: cl::Required can be specified when this option is present
+// in all rules in an action.
+return llvm::make_unique>(
+Opt.getName(), cl::desc(Opt.getDescription()), cl::Optional,
+cl::cat(Category), cl::sub(Subcommand));
+  }
+
+  llvm::SmallPtrSet Visited;
+  llvm::StringSet<> OptionNames;
+  cl::OptionCategory &Category;
+  cl::SubCommand &Subcommand;
+  RefactoringActionCommandLineOptions &Options;
+};
+
 /// A subcommand that corresponds to individual refactoring action.
 class RefactoringActionSubcommand : public cl::SubCommand {
 public:
@@ -138,6 +231,12 @@
"::)"),
   cl::cat(Category), cl::sub(*this));
 }
+// Create 

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

2017-09-29 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: 
include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h:78
+  std::vector>
+  getRefactoringOptions() const final override {
+return {Opt};

ioeric wrote:
> Why return a vector instead of a single value if there is only one element?
To support more complex requirements that need multiple options.



Comment at: 
include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h:83
+  Expected().getValue())>
+  evaluate(RefactoringRuleContext &) const {
+return Opt->getValue();

ioeric wrote:
> This could use some comment, e.g. what is `getValue` expected to do?
I've simplified this by using a typealias in the option itself.



Comment at: 
include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h:88
+private:
+  std::shared_ptr Opt;
+};

ioeric wrote:
> Please explain why `shared_ptr` is needed here.
The same option can be used by multiple rules, hence options can be owned by 
multiple requirements in  different rules at once. I documented this.



Comment at: 
include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h:68
+/// Scans the tuple and returns a valid \c Error if any of the values are
+/// invalid.
+template 

ioeric wrote:
> Please elaborate on what's valid or invalid.
Oops, copy-pasted comment. I fixed it up.



Comment at: 
include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h:74
+  struct OptionGatherer {
+std::vector> &Options;
+

ioeric wrote:
> Why `shared_ptr`? Would `unique_ptr` work?
I refactored this to change the redundant ownership here.



Comment at: tools/clang-refactor/ClangRefactor.cpp:372
   if (Rule->hasSelectionRequirement()) {
 HasSelection = true;
+if (!Subcommand.getSelection()) {

ioeric wrote:
> Wondering if it is sensible to make `selection` also a general option so that 
> we don't need to special-case selections.
I think right now it's tricky because of the testing support. However, I think 
that it would be better to use a similar mechanism for selection option as 
well. I'll think about how we can reconcile the two approaches and will 
hopefully come up with a patch for it.


Repository:
  rL LLVM

https://reviews.llvm.org/D37856



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


r314509 - [docs][refactor] Add refactoring engine design documentation

2017-09-29 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Sep 29 05:21:38 2017
New Revision: 314509

URL: http://llvm.org/viewvc/llvm-project?rev=314509&view=rev
Log:
[docs][refactor] Add refactoring engine design documentation

This commit adds a refactoring engine design document that talks about the
design and provides several example of how the engine can be used.

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

Added:
cfe/trunk/docs/RefactoringEngine.rst
Modified:
cfe/trunk/docs/index.rst

Added: cfe/trunk/docs/RefactoringEngine.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/RefactoringEngine.rst?rev=314509&view=auto
==
--- cfe/trunk/docs/RefactoringEngine.rst (added)
+++ cfe/trunk/docs/RefactoringEngine.rst Fri Sep 29 05:21:38 2017
@@ -0,0 +1,253 @@
+==
+Clang's refactoring engine
+==
+
+This document describes the design of Clang's refactoring engine and provides
+a couple of examples that show how various primitives in the refactoring API
+can be used to implement different refactoring actions. The :doc:`LibTooling`
+library provides several other APIs that are used when developing a
+refactoring action.
+
+Refactoring engine can be used to implement local refactorings that are
+initiated using a selection in an editor or an IDE. You can combine
+:doc:`AST matchers` and the refactoring engine to implement
+refactorings that don't lend themselves well to source selection and/or have to
+query ASTs for some particular nodes.
+
+We assume basic knowledge about the Clang AST. See the :doc:`Introduction
+to the Clang AST ` if you want to learn more
+about how the AST is structured.
+
+..  FIXME: create new refactoring action tutorial and link to the tutorial
+
+Introduction
+
+
+Clang's refactoring engine defines a set refactoring actions that implement
+a number of different source transformations. The ``clang-refactor``
+command-line tool can be used to perform these refactorings. Certain
+refactorings are also available in other clients like text editors and IDEs.
+
+A refactoring action is a class that defines a list of related refactoring
+operations (rules). These rules are grouped under a common umbrella - a single
+``clang-refactor`` command. In addition to rules, the refactoring action
+provides the action's command name and description to ``clang-refactor``.
+Each action must implement the ``RefactoringAction`` interface. Here's an
+outline of a ``local-rename`` action:
+
+.. code-block:: c++
+
+  class LocalRename final : public RefactoringAction {
+  public:
+StringRef getCommand() const override { return "local-rename"; }
+
+   StringRef getDescription() const override {
+  return "Finds and renames symbols in code with no indexer support";
+}
+
+RefactoringActionRules createActionRules() const override {
+  ...
+}
+  };
+
+Refactoring Action Rules
+
+
+An individual refactoring action is responsible for creating the set of
+grouped refactoring action rules that represent one refactoring operation.
+Although the rules in one action may have a number of different 
implementations,
+they should strive to produce a similar result. It should be easy for users to
+identify which refactoring action produced the result regardless of which
+refactoring action rule was used.
+
+The distinction between actions and rules enables the creation of actions
+that define a set of different rules that produce similar results. For example,
+the "add missing switch cases" refactoring operation typically adds missing
+cases to one switch at a time. However, it could be useful to have a
+refactoring that works on all switches that operate on a particular enum, as
+one could then automatically update all of them after adding a new enum
+constant. To achieve that, we can create two different rules that will use one
+``clang-refactor`` subcommand. The first rule will describe a local operation
+that's initiated when the user selects a single switch. The second rule will
+describe a global operation that works across translation units and is 
initiated
+when the user provides the name of the enum to clang-refactor (or the user 
could
+select the enum declaration instead). The clang-refactor tool will then analyze
+the selection and other options passed to the refactoring action, and will pick
+the most appropriate rule for the given selection and other options.
+
+Rule Types
+^^
+
+Clang's refactoring engine supports several different refactoring rules:
+
+- ``SourceChangeRefactoringRule`` produces source replacements that are applied
+  to the source files. Subclasses that choose to implement this rule have to
+  implement the ``createSourceReplacements`` member function. This type of
+  rule is typically used to implement local refactorings that transform the
+  source in one translation unit only.
+
+- ``FindSymbolOccurrences

[PATCH] D37976: [docs][refactor] add refactoring engine design documentation

2017-09-29 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
arphaman marked 2 inline comments as done.
Closed by commit rL314509: [docs][refactor] Add refactoring engine design 
documentation (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D37976?vs=115638&id=117127#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37976

Files:
  cfe/trunk/docs/RefactoringEngine.rst
  cfe/trunk/docs/index.rst

Index: cfe/trunk/docs/RefactoringEngine.rst
===
--- cfe/trunk/docs/RefactoringEngine.rst
+++ cfe/trunk/docs/RefactoringEngine.rst
@@ -0,0 +1,253 @@
+==
+Clang's refactoring engine
+==
+
+This document describes the design of Clang's refactoring engine and provides
+a couple of examples that show how various primitives in the refactoring API
+can be used to implement different refactoring actions. The :doc:`LibTooling`
+library provides several other APIs that are used when developing a
+refactoring action.
+
+Refactoring engine can be used to implement local refactorings that are
+initiated using a selection in an editor or an IDE. You can combine
+:doc:`AST matchers` and the refactoring engine to implement
+refactorings that don't lend themselves well to source selection and/or have to
+query ASTs for some particular nodes.
+
+We assume basic knowledge about the Clang AST. See the :doc:`Introduction
+to the Clang AST ` if you want to learn more
+about how the AST is structured.
+
+..  FIXME: create new refactoring action tutorial and link to the tutorial
+
+Introduction
+
+
+Clang's refactoring engine defines a set refactoring actions that implement
+a number of different source transformations. The ``clang-refactor``
+command-line tool can be used to perform these refactorings. Certain
+refactorings are also available in other clients like text editors and IDEs.
+
+A refactoring action is a class that defines a list of related refactoring
+operations (rules). These rules are grouped under a common umbrella - a single
+``clang-refactor`` command. In addition to rules, the refactoring action
+provides the action's command name and description to ``clang-refactor``.
+Each action must implement the ``RefactoringAction`` interface. Here's an
+outline of a ``local-rename`` action:
+
+.. code-block:: c++
+
+  class LocalRename final : public RefactoringAction {
+  public:
+StringRef getCommand() const override { return "local-rename"; }
+
+   StringRef getDescription() const override {
+  return "Finds and renames symbols in code with no indexer support";
+}
+
+RefactoringActionRules createActionRules() const override {
+  ...
+}
+  };
+
+Refactoring Action Rules
+
+
+An individual refactoring action is responsible for creating the set of
+grouped refactoring action rules that represent one refactoring operation.
+Although the rules in one action may have a number of different implementations,
+they should strive to produce a similar result. It should be easy for users to
+identify which refactoring action produced the result regardless of which
+refactoring action rule was used.
+
+The distinction between actions and rules enables the creation of actions
+that define a set of different rules that produce similar results. For example,
+the "add missing switch cases" refactoring operation typically adds missing
+cases to one switch at a time. However, it could be useful to have a
+refactoring that works on all switches that operate on a particular enum, as
+one could then automatically update all of them after adding a new enum
+constant. To achieve that, we can create two different rules that will use one
+``clang-refactor`` subcommand. The first rule will describe a local operation
+that's initiated when the user selects a single switch. The second rule will
+describe a global operation that works across translation units and is initiated
+when the user provides the name of the enum to clang-refactor (or the user could
+select the enum declaration instead). The clang-refactor tool will then analyze
+the selection and other options passed to the refactoring action, and will pick
+the most appropriate rule for the given selection and other options.
+
+Rule Types
+^^
+
+Clang's refactoring engine supports several different refactoring rules:
+
+- ``SourceChangeRefactoringRule`` produces source replacements that are applied
+  to the source files. Subclasses that choose to implement this rule have to
+  implement the ``createSourceReplacements`` member function. This type of
+  rule is typically used to implement local refactorings that transform the
+  source in one translation unit only.
+
+- ``FindSymbolOccurrencesRefactoringRule`` produces a "partial" refactoring
+  result: a set of occurrences that refer to a particular symbol. This type
+  of rule is typically used to implement an interactive re

[PATCH] D38277: [compiler-rt][CMake] Fix configuration on PowerPC with sanitizers

2017-09-29 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314512: [CMake] Fix configuration on PowerPC with sanitizers 
(authored by Hahnfeld).

Changed prior to commit:
  https://reviews.llvm.org/D38277?vs=116977&id=117132#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38277

Files:
  compiler-rt/trunk/cmake/base-config-ix.cmake


Index: compiler-rt/trunk/cmake/base-config-ix.cmake
===
--- compiler-rt/trunk/cmake/base-config-ix.cmake
+++ compiler-rt/trunk/cmake/base-config-ix.cmake
@@ -148,7 +148,13 @@
 endif()
   endif()
 elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "powerpc")
+  # Strip out -nodefaultlibs when calling TEST_BIG_ENDIAN. Configuration
+  # will fail with this option when building with a sanitizer.
+  cmake_push_check_state()
+  string(REPLACE "-nodefaultlibs" "" CMAKE_REQUIRED_FLAGS 
${OLD_CMAKE_REQUIRED_FLAGS})
   TEST_BIG_ENDIAN(HOST_IS_BIG_ENDIAN)
+  cmake_pop_check_state()
+
   if(HOST_IS_BIG_ENDIAN)
 test_target_arch(powerpc64 "" "-m64")
   else()


Index: compiler-rt/trunk/cmake/base-config-ix.cmake
===
--- compiler-rt/trunk/cmake/base-config-ix.cmake
+++ compiler-rt/trunk/cmake/base-config-ix.cmake
@@ -148,7 +148,13 @@
 endif()
   endif()
 elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "powerpc")
+  # Strip out -nodefaultlibs when calling TEST_BIG_ENDIAN. Configuration
+  # will fail with this option when building with a sanitizer.
+  cmake_push_check_state()
+  string(REPLACE "-nodefaultlibs" "" CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
   TEST_BIG_ENDIAN(HOST_IS_BIG_ENDIAN)
+  cmake_pop_check_state()
+
   if(HOST_IS_BIG_ENDIAN)
 test_target_arch(powerpc64 "" "-m64")
   else()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2017-09-29 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

This patch actually brings clang-refactor to a usable state as it can now apply 
the refactoring changes to the source files.
The `-selection` option is now also fully supported.


Repository:
  rL LLVM

https://reviews.llvm.org/D38402

Files:
  include/clang/Frontend/CommandLineSourceLoc.h
  test/Refactor/tool-apply-replacements.cpp
  test/Refactor/tool-selection-option.c
  tools/clang-refactor/ClangRefactor.cpp

Index: tools/clang-refactor/ClangRefactor.cpp
===
--- tools/clang-refactor/ClangRefactor.cpp
+++ tools/clang-refactor/ClangRefactor.cpp
@@ -14,6 +14,7 @@
 //===--===//
 
 #include "TestSupport.h"
+#include "clang/Frontend/CommandLineSourceLoc.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Refactoring.h"
@@ -54,7 +55,7 @@
 
   /// Prints any additional state associated with the selection argument to
   /// the given output stream.
-  virtual void print(raw_ostream &OS) = 0;
+  virtual void print(raw_ostream &OS) {}
 
   /// Returns a replacement refactoring result consumer (if any) that should
   /// consume the results of a refactoring operation.
@@ -99,6 +100,41 @@
   TestSelectionRangesInFile TestSelections;
 };
 
+/// Stores the parsed -selection=filename:line:column[-line:column] option.
+class SourceRangeSelectionArgument final : public SourceSelectionArgument {
+public:
+  SourceRangeSelectionArgument(ParsedSourceRange Range)
+  : Range(std::move(Range)) {}
+
+  bool forAllRanges(const SourceManager &SM,
+llvm::function_ref Callback) override {
+const FileEntry *FE = SM.getFileManager().getFile(Range.FileName);
+FileID FID = FE ? SM.translateFile(FE) : FileID();
+if (!FE || FID.isInvalid()) {
+  llvm::errs() << "error: -selection=" << Range.FileName
+   << ":... : given file is not in the target TU\n";
+  return true;
+}
+
+SourceLocation Start = SM.getMacroArgExpandedLocation(
+SM.translateLineCol(FID, Range.Begin.first, Range.Begin.second));
+SourceLocation End = SM.getMacroArgExpandedLocation(
+SM.translateLineCol(FID, Range.End.first, Range.End.second));
+if (Start.isInvalid() || End.isInvalid()) {
+  llvm::errs() << "error: -selection=" << Range.FileName << ':'
+   << Range.Begin.first << ':' << Range.Begin.second << '-'
+   << Range.End.first << ':' << Range.End.second
+   << " : invalid source location\n";
+  return true;
+}
+Callback(SourceRange(Start, End));
+return false;
+  }
+
+private:
+  ParsedSourceRange Range;
+};
+
 std::unique_ptr
 SourceSelectionArgument::fromString(StringRef Value) {
   if (Value.startswith("test:")) {
@@ -110,10 +146,12 @@
 return llvm::make_unique(
 std::move(*ParsedTestSelection));
   }
-  // FIXME: Support true selection ranges.
+  Optional Range = ParsedSourceRange::fromString(Value);
+  if (Range)
+return llvm::make_unique(std::move(*Range));
   llvm::errs() << "error: '-selection' option must be specified using "
   ":: or "
-  "::-: format";
+  "::-: format\n";
   return nullptr;
 }
 
@@ -278,7 +316,18 @@
 llvm::errs() << llvm::toString(std::move(Err)) << "\n";
   }
 
-  // FIXME: Consume atomic changes and apply them to files.
+  void handle(AtomicChanges SourceReplacements) {
+AllSourceReplacements.insert(AllSourceReplacements.begin(),
+ SourceReplacements.begin(),
+ SourceReplacements.end());
+  }
+
+  const AtomicChanges &getAllSourceReplacements() const {
+return AllSourceReplacements;
+  }
+
+private:
+  AtomicChanges AllSourceReplacements;
 };
 
 class ClangRefactorTool {
@@ -358,6 +407,38 @@
 }
   }
 
+  bool applySourceReplacements(const AtomicChanges &Replacements) {
+std::set Files;
+for (const auto &Change : Replacements)
+  Files.insert(Change.getFilePath());
+// FIXME: Add automatic formatting support as well.
+tooling::ApplyChangesSpec Spec;
+Spec.Cleanup = false;
+for (const auto &File : Files) {
+  llvm::ErrorOr> BufferErr =
+  llvm::MemoryBuffer::getFile(File);
+  if (!BufferErr) {
+llvm::errs() << "error: failed to open" << File << " for rewriting\n";
+return true;
+  }
+  auto Result = tooling::applyAtomicChanges(File, (*BufferErr)->getBuffer(),
+Replacements, Spec);
+  if (!Result) {
+llvm::errs() << toString(Result.takeError());
+return true;
+  }
+
+  std::error_code EC;
+  llvm::raw_fd_ostream OS(File, EC, llvm::sys::fs::F_Text);
+  if (EC) {
+llvm::errs() << EC.message() << "\n";
+return true;
+  }
+  OS << *Result;
+  

[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI

2017-09-29 Thread Christian Bruel via Phabricator via cfe-commits
chrib updated this revision to Diff 117139.
chrib added a comment.

Hello,

I realized that testing CCCisCXX for IsUnwindTablesDefault was not really good 
and useless here, because we cannot treat C as C++ mode. In fact only the file 
type matters, as seen in the tests.

So I'd like to amend my previous proposal to

- Add the InputType parameter to IsUnwindTablesDefault and use in the new 
function ARMNeedUnwindTable
- Fix tests thinko (wrong triplet)
- Rebase

sorry for the respin, thanks !


https://reviews.llvm.org/D31140

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Arch/ARM.cpp
  lib/Driver/ToolChains/Arch/ARM.h
  lib/Driver/ToolChains/BareMetal.cpp
  lib/Driver/ToolChains/BareMetal.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/CrossWindows.cpp
  lib/Driver/ToolChains/CrossWindows.h
  lib/Driver/ToolChains/Darwin.cpp
  lib/Driver/ToolChains/Darwin.h
  lib/Driver/ToolChains/Fuchsia.h
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Gnu.h
  lib/Driver/ToolChains/Linux.cpp
  lib/Driver/ToolChains/Linux.h
  lib/Driver/ToolChains/MSVC.cpp
  lib/Driver/ToolChains/MSVC.h
  lib/Driver/ToolChains/MinGW.cpp
  lib/Driver/ToolChains/MinGW.h
  lib/Driver/ToolChains/NetBSD.h
  test/Driver/arm-unwind.c
  test/Driver/arm-unwind.cpp

Index: test/Driver/arm-unwind.cpp
===
--- /dev/null
+++ test/Driver/arm-unwind.cpp
@@ -0,0 +1,9 @@
+// Add function attribute "uwtable" for arm ehabi targets in C++.
+
+// RUN: %clang -target arm-none-eabi  -### -S %s -o %t.s 2>&1 \
+// RUN:| FileCheck --check-prefix=CHECK-EABI %s
+// CHECK-EABI: -munwind-tables
+
+// RUN: %clang -target arm-linux-gnueabihf  -### -S %s -o %t.s 2>&1 \
+// RUN:| FileCheck --check-prefix=CHECK-GNU %s
+// CHECK-GNU: -munwind-tables
Index: test/Driver/arm-unwind.c
===
--- /dev/null
+++ test/Driver/arm-unwind.c
@@ -0,0 +1,9 @@
+// Do not add function attribute "uwtable" for arm ehabi targets for C mode.
+
+// RUN: %clang -target arm-none-eabi  -### -S %s -o %t.s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-EABI %s
+// CHECK-EABI-NOT: -munwind-tables
+
+// RUN: %clang -target arm-linux-gnueabihf -### -S %s -o %t.s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-GNU %s
+// CHECK-GNU-NOT: -munwind-tables
Index: lib/Driver/ToolChains/NetBSD.h
===
--- lib/Driver/ToolChains/NetBSD.h
+++ lib/Driver/ToolChains/NetBSD.h
@@ -65,7 +65,7 @@
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
 
-  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override {
+  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args, types::ID InputType) const override {
 return true;
   }
 
Index: lib/Driver/ToolChains/MinGW.h
===
--- lib/Driver/ToolChains/MinGW.h
+++ lib/Driver/ToolChains/MinGW.h
@@ -60,7 +60,7 @@
 const llvm::opt::ArgList &Args);
 
   bool IsIntegratedAssemblerDefault() const override;
-  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
+  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args, types::ID InputType) const override;
   bool isPICDefault() const override;
   bool isPIEDefault() const override;
   bool isPICDefaultForced() const override;
Index: lib/Driver/ToolChains/MinGW.cpp
===
--- lib/Driver/ToolChains/MinGW.cpp
+++ lib/Driver/ToolChains/MinGW.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 #include "MinGW.h"
+#include "Arch/ARM.h"
 #include "InputInfo.h"
 #include "CommonArgs.h"
 #include "clang/Driver/Compilation.h"
@@ -361,8 +362,18 @@
   return new tools::MinGW::Linker(*this);
 }
 
-bool toolchains::MinGW::IsUnwindTablesDefault(const ArgList &Args) const {
-  return getArch() == llvm::Triple::x86_64;
+bool toolchains::MinGW::IsUnwindTablesDefault(const ArgList &Args, types::ID InputType) const {
+  switch (getArch()) {
+  case llvm::Triple::arm:
+  case llvm::Triple::armeb:
+  case llvm::Triple::thumb:
+  case llvm::Triple::thumbeb:
+return tools::arm::ARMNeedUnwindTable(Args, types::isCXX(InputType));
+  case llvm::Triple::x86_64:
+return true;
+  default:
+return false;
+  }
 }
 
 bool toolchains::MinGW::isPICDefault() const {
Index: lib/Driver/ToolChains/MSVC.h
===
--- lib/Driver/ToolChains/MSVC.h
+++ lib/Driver/ToolChains/MSVC.h
@@ -73,7 +73,8 @@
 Action::OffloadKind DeviceOffloadKind) const override;
 
   bool IsIntegratedAssemblerDefault() const override;
-  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
+  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args,
+			

[PATCH] D38404: [CodeGen] Do not refer to complete TBAA info where we actually deal with just TBAA access types

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

This patch fixes misleading names of entities related to getting, setting and 
generation of TBAA access type descriptors.

This is effectively an attempt to provide a review for 
https://reviews.llvm.org/D37826 by breaking it into smaller pieces.


Repository:
  rL LLVM

https://reviews.llvm.org/D38404

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

Index: CodeGen/CodeGenTBAA.h
===
--- CodeGen/CodeGenTBAA.h
+++ CodeGen/CodeGenTBAA.h
@@ -95,9 +95,9 @@
   MangleContext &MContext);
   ~CodeGenTBAA();
 
-  /// getTBAAInfo - Get the TBAA MDNode to be used for a dereference
-  /// of the given type.
-  llvm::MDNode *getTBAAInfo(QualType QTy);
+  /// getTypeInfo - Get metadata used to describe accesses to objects of the
+  /// given type.
+  llvm::MDNode *getTypeInfo(QualType QTy);
 
   /// getTBAAInfoForVTablePtr - Get the TBAA MDNode to be used for a
   /// dereference of a vtable pointer.
Index: CodeGen/CodeGenTBAA.cpp
===
--- CodeGen/CodeGenTBAA.cpp
+++ CodeGen/CodeGenTBAA.cpp
@@ -88,8 +88,7 @@
   return false;
 }
 
-llvm::MDNode *
-CodeGenTBAA::getTBAAInfo(QualType QTy) {
+llvm::MDNode *CodeGenTBAA::getTypeInfo(QualType QTy) {
   // At -O0 or relaxed aliasing, TBAA is not emitted for regular types.
   if (CodeGenOpts.OptimizationLevel == 0 || CodeGenOpts.RelaxedAliasing)
 return nullptr;
@@ -120,15 +119,15 @@
 
 // Unsigned types can alias their corresponding signed types.
 case BuiltinType::UShort:
-  return getTBAAInfo(Context.ShortTy);
+  return getTypeInfo(Context.ShortTy);
 case BuiltinType::UInt:
-  return getTBAAInfo(Context.IntTy);
+  return getTypeInfo(Context.IntTy);
 case BuiltinType::ULong:
-  return getTBAAInfo(Context.LongTy);
+  return getTypeInfo(Context.LongTy);
 case BuiltinType::ULongLong:
-  return getTBAAInfo(Context.LongLongTy);
+  return getTypeInfo(Context.LongLongTy);
 case BuiltinType::UInt128:
-  return getTBAAInfo(Context.Int128Ty);
+  return getTypeInfo(Context.Int128Ty);
 
 // Treat all other builtin types as distinct types. This includes
 // treating wchar_t, char16_t, and char32_t as distinct from their
@@ -212,7 +211,7 @@
   /* Otherwise, treat whatever it is as a field. */
   uint64_t Offset = BaseOffset;
   uint64_t Size = Context.getTypeSizeInChars(QTy).getQuantity();
-  llvm::MDNode *TBAAInfo = MayAlias ? getChar() : getTBAAInfo(QTy);
+  llvm::MDNode *TBAAInfo = MayAlias ? getChar() : getTypeInfo(QTy);
   llvm::MDNode *TBAATag = getTBAAScalarTagInfo(TBAAInfo);
   Fields.push_back(llvm::MDBuilder::TBAAStructField(Offset, Size, TBAATag));
   return true;
@@ -268,7 +267,7 @@
   if (isTBAAPathStruct(FieldQTy))
 FieldNode = getTBAAStructTypeInfo(FieldQTy);
   else
-FieldNode = getTBAAInfo(FieldQTy);
+FieldNode = getTypeInfo(FieldQTy);
   if (!FieldNode)
 return StructTypeMetadataCache[Ty] = nullptr;
   Fields.push_back(std::make_pair(
Index: CodeGen/CodeGenModule.h
===
--- CodeGen/CodeGenModule.h
+++ CodeGen/CodeGenModule.h
@@ -652,7 +652,10 @@
   CtorList &getGlobalCtors() { return GlobalCtors; }
   CtorList &getGlobalDtors() { return GlobalDtors; }
 
-  llvm::MDNode *getTBAAInfo(QualType QTy);
+  /// getTBAATypeInfo - Get metadata used to describe accesses to objects of
+  /// the given type.
+  llvm::MDNode *getTBAATypeInfo(QualType QTy);
+
   llvm::MDNode *getTBAAInfoForVTablePtr();
   llvm::MDNode *getTBAAStructInfo(QualType QTy);
   /// Return the path-aware tag for given base type, access node and offset.
Index: CodeGen/CodeGenModule.cpp
===
--- CodeGen/CodeGenModule.cpp
+++ CodeGen/CodeGenModule.cpp
@@ -573,10 +573,10 @@
   Types.RefreshTypeCacheForClass(RD);
 }
 
-llvm::MDNode *CodeGenModule::getTBAAInfo(QualType QTy) {
+llvm::MDNode *CodeGenModule::getTBAATypeInfo(QualType QTy) {
   if (!TBAA)
 return nullptr;
-  return TBAA->getTBAAInfo(QTy);
+  return TBAA->getTypeInfo(QTy);
 }
 
 llvm::MDNode *CodeGenModule::getTBAAInfoForVTablePtr() {
Index: CodeGen/CodeGenFunction.h
===
--- CodeGen/CodeGenFunction.h
+++ CodeGen/CodeGenFunction.h
@@ -1910,14 +1910,14 @@
 LValueBaseInfo BaseInfo =
 LValueBaseInfo(AlignmentSource::Type)) {
 return LValue::MakeAddr(Addr, T, getContext(), BaseInfo,
-CGM.getTBAAInfo(T));
+CGM.getTBAATypeInfo(T));
   }
 
   LValue MakeAddrLValu

[PATCH] D38364: Fix Modules/builtin-import.mm to be able to handle non-Darwin targets

2017-09-29 Thread Filipe Cabecinhas via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314524: Fix 
Modules/{builtin-import.mm,umbrella-header-include-builtin.mm} to be able… 
(authored by filcab).

Repository:
  rL LLVM

https://reviews.llvm.org/D38364

Files:
  cfe/trunk/test/Modules/builtin-import.mm
  cfe/trunk/test/Modules/umbrella-header-include-builtin.mm


Index: cfe/trunk/test/Modules/builtin-import.mm
===
--- cfe/trunk/test/Modules/builtin-import.mm
+++ cfe/trunk/test/Modules/builtin-import.mm
@@ -1,7 +1,5 @@
-// REQUIRES: system-darwin
-
 // RUN: rm -rf %t
-// RUN: %clang -cc1 -fsyntax-only -nostdinc++ -isysroot 
%S/Inputs/libc-libcxx/sysroot -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -std=c++11 -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ 
-fmodules-local-submodule-visibility %s
+// RUN: %clang -cc1 -fsyntax-only -nobuiltininc -nostdinc++ -isysroot 
%S/Inputs/libc-libcxx/sysroot -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include -std=c++11 -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ 
-fmodules-local-submodule-visibility %s
 
 #include 
 #include 
Index: cfe/trunk/test/Modules/umbrella-header-include-builtin.mm
===
--- cfe/trunk/test/Modules/umbrella-header-include-builtin.mm
+++ cfe/trunk/test/Modules/umbrella-header-include-builtin.mm
@@ -1,7 +1,5 @@
-// REQUIRES: system-darwin
-
 // RUN: rm -rf %t
-// RUN: %clang -cc1 -fsyntax-only -nostdinc++ -isysroot 
%S/Inputs/libc-libcxx/sysroot -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 
-F%S/Inputs/libc-libcxx/sysroot/Frameworks -std=c++11 -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ %s
+// RUN: %clang -cc1 -fsyntax-only -nobuiltininc -nostdinc++ -isysroot 
%S/Inputs/libc-libcxx/sysroot -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include 
-F%S/Inputs/libc-libcxx/sysroot/Frameworks -std=c++11 -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ %s
 
 #include 
 


Index: cfe/trunk/test/Modules/builtin-import.mm
===
--- cfe/trunk/test/Modules/builtin-import.mm
+++ cfe/trunk/test/Modules/builtin-import.mm
@@ -1,7 +1,5 @@
-// REQUIRES: system-darwin
-
 // RUN: rm -rf %t
-// RUN: %clang -cc1 -fsyntax-only -nostdinc++ -isysroot %S/Inputs/libc-libcxx/sysroot -isystem %S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ -fmodules-local-submodule-visibility %s
+// RUN: %clang -cc1 -fsyntax-only -nobuiltininc -nostdinc++ -isysroot %S/Inputs/libc-libcxx/sysroot -isystem %S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -isystem %S/Inputs/libc-libcxx/sysroot/usr/include -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ -fmodules-local-submodule-visibility %s
 
 #include 
 #include 
Index: cfe/trunk/test/Modules/umbrella-header-include-builtin.mm
===
--- cfe/trunk/test/Modules/umbrella-header-include-builtin.mm
+++ cfe/trunk/test/Modules/umbrella-header-include-builtin.mm
@@ -1,7 +1,5 @@
-// REQUIRES: system-darwin
-
 // RUN: rm -rf %t
-// RUN: %clang -cc1 -fsyntax-only -nostdinc++ -isysroot %S/Inputs/libc-libcxx/sysroot -isystem %S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -F%S/Inputs/libc-libcxx/sysroot/Frameworks -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ %s
+// RUN: %clang -cc1 -fsyntax-only -nobuiltininc -nostdinc++ -isysroot %S/Inputs/libc-libcxx/sysroot -isystem %S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -isystem %S/Inputs/libc-libcxx/sysroot/usr/include -F%S/Inputs/libc-libcxx/sysroot/Frameworks -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ %s
 
 #include 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r314524 - Fix Modules/{builtin-import.mm, umbrella-header-include-builtin.mm} to be able to handle non-Darwin targets

2017-09-29 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Fri Sep 29 08:45:34 2017
New Revision: 314524

URL: http://llvm.org/viewvc/llvm-project?rev=314524&view=rev
Log:
Fix Modules/{builtin-import.mm,umbrella-header-include-builtin.mm} to be able 
to handle non-Darwin targets

Summary: Also makes them pass on Darwin, if the default target triple is a 
Linux triple.

Reviewers: bruno, rsmith

Subscribers: cfe-commits

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

Modified:
cfe/trunk/test/Modules/builtin-import.mm
cfe/trunk/test/Modules/umbrella-header-include-builtin.mm

Modified: cfe/trunk/test/Modules/builtin-import.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/builtin-import.mm?rev=314524&r1=314523&r2=314524&view=diff
==
--- cfe/trunk/test/Modules/builtin-import.mm (original)
+++ cfe/trunk/test/Modules/builtin-import.mm Fri Sep 29 08:45:34 2017
@@ -1,7 +1,5 @@
-// REQUIRES: system-darwin
-
 // RUN: rm -rf %t
-// RUN: %clang -cc1 -fsyntax-only -nostdinc++ -isysroot 
%S/Inputs/libc-libcxx/sysroot -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -std=c++11 -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ 
-fmodules-local-submodule-visibility %s
+// RUN: %clang -cc1 -fsyntax-only -nobuiltininc -nostdinc++ -isysroot 
%S/Inputs/libc-libcxx/sysroot -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include -std=c++11 -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ 
-fmodules-local-submodule-visibility %s
 
 #include 
 #include 

Modified: cfe/trunk/test/Modules/umbrella-header-include-builtin.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/umbrella-header-include-builtin.mm?rev=314524&r1=314523&r2=314524&view=diff
==
--- cfe/trunk/test/Modules/umbrella-header-include-builtin.mm (original)
+++ cfe/trunk/test/Modules/umbrella-header-include-builtin.mm Fri Sep 29 
08:45:34 2017
@@ -1,7 +1,5 @@
-// REQUIRES: system-darwin
-
 // RUN: rm -rf %t
-// RUN: %clang -cc1 -fsyntax-only -nostdinc++ -isysroot 
%S/Inputs/libc-libcxx/sysroot -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 
-F%S/Inputs/libc-libcxx/sysroot/Frameworks -std=c++11 -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ %s
+// RUN: %clang -cc1 -fsyntax-only -nobuiltininc -nostdinc++ -isysroot 
%S/Inputs/libc-libcxx/sysroot -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include 
-F%S/Inputs/libc-libcxx/sysroot/Frameworks -std=c++11 -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ %s
 
 #include 
 


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


r314526 - [test] Disable leak checking on a clang crash test on Darwin

2017-09-29 Thread Francis Ricci via cfe-commits
Author: fjricci
Date: Fri Sep 29 08:46:27 2017
New Revision: 314526

URL: http://llvm.org/viewvc/llvm-project?rev=314526&view=rev
Log:
[test] Disable leak checking on a clang crash test on Darwin

Suspected failure due to LSan's atexit and exit interception behavior.

Reviewers: kcc, kubamracek, bogner, hfinkel, alekseyshl, Hahnfeld, gtbercea

Subscribers: llvm-commits

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

Modified:
cfe/trunk/test/Modules/crash-vfs-ivfsoverlay.m

Modified: cfe/trunk/test/Modules/crash-vfs-ivfsoverlay.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-ivfsoverlay.m?rev=314526&r1=314525&r2=314526&view=diff
==
--- cfe/trunk/test/Modules/crash-vfs-ivfsoverlay.m (original)
+++ cfe/trunk/test/Modules/crash-vfs-ivfsoverlay.m Fri Sep 29 08:46:27 2017
@@ -7,6 +7,7 @@
 // RUN:   %S/../VFS/Inputs/vfsoverlay2.yaml > %t/srcvfs.yaml
 
 // RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
+// RUN: ASAN_OPTIONS=detect_leaks=0 \
 // RUN: %clang -fsyntax-only -nostdinc %s \
 // RUN: -I %S/Inputs/crash-recovery/usr/include \
 // RUN: -ivfsoverlay %t/srcvfs.yaml \


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


[PATCH] D38277: [compiler-rt][CMake] Fix configuration on PowerPC with sanitizers

2017-09-29 Thread Aleksey Shlyapnikov via Phabricator via cfe-commits
alekseyshl added a comment.

http://lab.llvm.org:8011/builders/sanitizer-ppc64be-linux/builds/4004 is broken 
by this change


Repository:
  rL LLVM

https://reviews.llvm.org/D38277



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


[PATCH] D38277: [compiler-rt][CMake] Fix configuration on PowerPC with sanitizers

2017-09-29 Thread Aleksey Shlyapnikov via Phabricator via cfe-commits
alekseyshl added inline comments.



Comment at: compiler-rt/trunk/cmake/base-config-ix.cmake:154
+  cmake_push_check_state()
+  string(REPLACE "-nodefaultlibs" "" CMAKE_REQUIRED_FLAGS 
${OLD_CMAKE_REQUIRED_FLAGS})
   TEST_BIG_ENDIAN(HOST_IS_BIG_ENDIAN)

Oh, right, it should be:

string(REPLACE "-nodefaultlibs" "" CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})


Repository:
  rL LLVM

https://reviews.llvm.org/D38277



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


r314529 - fixup, post rL314493

2017-09-29 Thread Coby Tayree via cfe-commits
Author: coby
Date: Fri Sep 29 09:04:16 2017
New Revision: 314529

URL: http://llvm.org/viewvc/llvm-project?rev=314529&view=rev
Log:
fixup, post rL314493
'InlineAsmIdentifierInfo' is now a struct - notify Sema.h it isn't a class 
anymore

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

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=314529&r1=314528&r2=314529&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Sep 29 09:04:16 2017
@@ -64,7 +64,7 @@ namespace llvm {
   template  struct DenseMapInfo;
   template  class DenseSet;
   class SmallBitVector;
-  class InlineAsmIdentifierInfo;
+  struct InlineAsmIdentifierInfo;
 }
 
 namespace clang {


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


[PATCH] D38277: [compiler-rt][CMake] Fix configuration on PowerPC with sanitizers

2017-09-29 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: compiler-rt/trunk/cmake/base-config-ix.cmake:154
+  cmake_push_check_state()
+  string(REPLACE "-nodefaultlibs" "" CMAKE_REQUIRED_FLAGS 
${OLD_CMAKE_REQUIRED_FLAGS})
   TEST_BIG_ENDIAN(HOST_IS_BIG_ENDIAN)

alekseyshl wrote:
> Oh, right, it should be:
> 
> string(REPLACE "-nodefaultlibs" "" CMAKE_REQUIRED_FLAGS 
> ${CMAKE_REQUIRED_FLAGS})
Sorry! Thanks for fixing it so fast, my `git-svn` just told me that I'm out of 
sync!


Repository:
  rL LLVM

https://reviews.llvm.org/D38277



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


[PATCH] D38408: [CodeGen] Have a special function to get TBAA info for may-alias accesses

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

This is part of https://reviews.llvm.org/D37826 reworked to be a separate patch 
to simplify review.


Repository:
  rL LLVM

https://reviews.llvm.org/D38408

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

Index: lib/CodeGen/CodeGenTBAA.h
===
--- lib/CodeGen/CodeGenTBAA.h
+++ lib/CodeGen/CodeGenTBAA.h
@@ -116,6 +116,10 @@
 
   /// Get the scalar tag MDNode for a given scalar type.
   llvm::MDNode *getTBAAScalarTagInfo(llvm::MDNode *AccessNode);
+
+  /// getMayAliasAccessInfo - Get TBAA information that represents may-alias
+  /// accesses.
+  llvm::MDNode *getMayAliasTypeInfo();
 };
 
 }  // end namespace CodeGen
Index: lib/CodeGen/CodeGenTBAA.cpp
===
--- lib/CodeGen/CodeGenTBAA.cpp
+++ lib/CodeGen/CodeGenTBAA.cpp
@@ -327,3 +327,7 @@
   return ScalarTagMetadataCache[AccessNode] =
 MDHelper.createTBAAStructTagNode(AccessNode, AccessNode, 0);
 }
+
+llvm::MDNode *CodeGenTBAA::getMayAliasTypeInfo() {
+  return getChar();
+}
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -659,6 +659,10 @@
   llvm::MDNode *getTBAAStructTagInfo(QualType BaseTy, llvm::MDNode *AccessN,
  uint64_t O);
 
+  /// getTBAAMayAliasTypeInfo - Get TBAA information that represents
+  /// may-alias accesses.
+  llvm::MDNode *getTBAAMayAliasTypeInfo();
+
   bool isTypeConstant(QualType QTy, bool ExcludeCtorDtor);
 
   bool isPaddedAtomicType(QualType type);
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -599,6 +599,12 @@
   return TBAA->getTBAAStructTagInfo(BaseTy, AccessN, O);
 }
 
+llvm::MDNode *CodeGenModule::getTBAAMayAliasTypeInfo() {
+  if (!TBAA)
+return nullptr;
+  return TBAA->getMayAliasTypeInfo();
+}
+
 /// Decorate the instruction with a TBAA tag. For both scalar TBAA
 /// and struct-path aware TBAA, the tag has the same format:
 /// base type, access type and offset.
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -1519,7 +1519,7 @@
   if (TBAAInfo) {
 bool MayAlias = BaseInfo.getMayAlias();
 llvm::MDNode *TBAA = MayAlias
-? CGM.getTBAAInfo(getContext().CharTy)
+? CGM.getTBAAMayAliasTypeInfo()
 : CGM.getTBAAStructTagInfo(TBAABaseType, TBAAInfo, TBAAOffset);
 if (TBAA)
   CGM.DecorateInstructionWithTBAA(Load, TBAA, MayAlias);
@@ -1610,7 +1610,7 @@
   if (TBAAInfo) {
 bool MayAlias = BaseInfo.getMayAlias();
 llvm::MDNode *TBAA = MayAlias
-? CGM.getTBAAInfo(getContext().CharTy)
+? CGM.getTBAAMayAliasTypeInfo()
 : CGM.getTBAAStructTagInfo(TBAABaseType, TBAAInfo, TBAAOffset);
 if (TBAA)
   CGM.DecorateInstructionWithTBAA(Store, TBAA, MayAlias);
@@ -3720,11 +3720,8 @@
   // Loading the reference will disable path-aware TBAA.
   TBAAPath = false;
   if (CGM.shouldUseTBAA()) {
-llvm::MDNode *tbaa;
-if (mayAlias)
-  tbaa = CGM.getTBAAInfo(getContext().CharTy);
-else
-  tbaa = CGM.getTBAAInfo(type);
+llvm::MDNode *tbaa = mayAlias ? CGM.getTBAAMayAliasTypeInfo() :
+CGM.getTBAAInfo(type);
 if (tbaa)
   CGM.DecorateInstructionWithTBAA(load, tbaa);
   }
@@ -3776,7 +3773,7 @@
   // FIXME: this should get propagated down through anonymous structs
   // and unions.
   if (mayAlias && LV.getTBAAInfo())
-LV.setTBAAInfo(CGM.getTBAAInfo(getContext().CharTy));
+LV.setTBAAInfo(CGM.getTBAAMayAliasTypeInfo());
 
   return LV;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r314532 - Small clangd cleanups, NFC

2017-09-29 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Fri Sep 29 09:41:23 2017
New Revision: 314532

URL: http://llvm.org/viewvc/llvm-project?rev=314532&view=rev
Log:
Small clangd cleanups, NFC

 - remove old ASTUnit includes
 - fix typo (regiterCallbackHandlers)

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/ClangdUnit.h
clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
clang-tools-extra/trunk/clangd/ProtocolHandlers.h

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=314532&r1=314531&r2=314532&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Fri Sep 29 09:41:23 2017
@@ -256,7 +256,7 @@ void ClangdLSPServer::run(std::istream &
   // Set up JSONRPCDispatcher.
   LSPProtocolCallbacks Callbacks(*this);
   JSONRPCDispatcher Dispatcher(llvm::make_unique(Out));
-  regiterCallbackHandlers(Dispatcher, Out, Callbacks);
+  registerCallbackHandlers(Dispatcher, Out, Callbacks);
 
   // Run the Language Server loop.
   runLanguageServerLoop(In, Out, Dispatcher, IsDone);

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=314532&r1=314531&r2=314532&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Fri Sep 29 09:41:23 2017
@@ -9,7 +9,6 @@
 
 #include "ClangdServer.h"
 #include "clang/Format/Format.h"
-#include "clang/Frontend/ASTUnit.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Tooling/CompilationDatabase.h"

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=314532&r1=314531&r2=314532&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Fri Sep 29 09:41:23 2017
@@ -13,7 +13,6 @@
 #include "ClangdUnitStore.h"
 #include "DraftStore.h"
 #include "GlobalCompilationDatabase.h"
-#include "clang/Frontend/ASTUnit.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.h?rev=314532&r1=314531&r2=314532&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.h Fri Sep 29 09:41:23 2017
@@ -12,7 +12,7 @@
 
 #include "Path.h"
 #include "Protocol.h"
-#include "clang/Frontend/ASTUnit.h"
+#include "clang/Frontend/FrontendAction.h"
 #include "clang/Frontend/PrecompiledPreamble.h"
 #include "clang/Serialization/ASTBitCodes.h"
 #include "clang/Tooling/CompilationDatabase.h"
@@ -27,7 +27,6 @@ class raw_ostream;
 }
 
 namespace clang {
-class ASTUnit;
 class PCHContainerOperations;
 
 namespace vfs {

Modified: clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp?rev=314532&r1=314531&r2=314532&view=diff
==
--- clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp (original)
+++ clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp Fri Sep 29 09:41:23 2017
@@ -228,7 +228,7 @@ private:
 
 } // namespace
 
-void clangd::regiterCallbackHandlers(JSONRPCDispatcher &Dispatcher,
+void clangd::registerCallbackHandlers(JSONRPCDispatcher &Dispatcher,
  JSONOutput &Out,
  ProtocolCallbacks &Callbacks) {
   Dispatcher.registerHandler(

Modified: clang-tools-extra/trunk/clangd/ProtocolHandlers.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ProtocolHandlers.h?rev=314532&r1=314531&r2=314532&view=diff
==
--- clang-tools-extra/trunk/clangd/ProtocolHandlers.h (original)
+++ clang-tools-extra/trunk/clangd/ProtocolHandlers.h Fri Sep 29 09:41:23 2017
@@ -53,7 +53,7 @@ public:
 JSONOutput &Out) = 0;  

 };
 
-void regiterCallbackHandlers(JSONRPCDispatcher &Dispatcher, JSONOutput &Out,
+void registerCallbackHandlers(JSONRPCDispatcher &Dispatcher, JSONOutput &O

[PATCH] D38414: [clangd] simplify ClangdLSPServer by private-inheriting callback interfaces. NFC

2017-09-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.

There doesn't seem to be any real separation between the current three objects.
Feel free to reject this if you find the current style valuable, though.

(Mostly I'm just looking around for cleanups to help me understand the code).


https://reviews.llvm.org/D38414

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h

Index: clangd/ClangdLSPServer.h
===
--- clangd/ClangdLSPServer.h
+++ clangd/ClangdLSPServer.h
@@ -14,6 +14,7 @@
 #include "GlobalCompilationDatabase.h"
 #include "Path.h"
 #include "Protocol.h"
+#include "ProtocolHandlers.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/Optional.h"
 
@@ -24,7 +25,7 @@
 
 /// This class provides implementation of an LSP server, glueing the JSON
 /// dispatch and ClangdServer together.
-class ClangdLSPServer {
+class ClangdLSPServer : private DiagnosticsConsumer, private ProtocolCallbacks {
 public:
   ClangdLSPServer(JSONOutput &Out, unsigned AsyncThreadsCount,
   bool SnippetCompletions,
@@ -37,18 +38,35 @@
   void run(std::istream &In);
 
 private:
-  class LSPProtocolCallbacks;
-  class LSPDiagnosticsConsumer : public DiagnosticsConsumer {
-  public:
-LSPDiagnosticsConsumer(ClangdLSPServer &Server);
-
-virtual void
-onDiagnosticsReady(PathRef File,
-   Tagged> Diagnostics);
-
-  private:
-ClangdLSPServer &Server;
-  };
+  // DiagnosticsConsumer
+  virtual void
+  onDiagnosticsReady(PathRef File,
+ Tagged> Diagnostics) override;
+
+  // ProtocolCallbacks
+  void onInitialize(StringRef ID, InitializeParams IP,
+JSONOutput &Out) override;
+  void onShutdown(JSONOutput &Out) override;
+  void onDocumentDidOpen(DidOpenTextDocumentParams Params,
+ JSONOutput &Out) override;
+  void onDocumentDidChange(DidChangeTextDocumentParams Params,
+   JSONOutput &Out) override;
+  void onDocumentDidClose(DidCloseTextDocumentParams Params,
+  JSONOutput &Out) override;
+  void onDocumentOnTypeFormatting(DocumentOnTypeFormattingParams Params,
+  StringRef ID, JSONOutput &Out) override;
+  void onDocumentRangeFormatting(DocumentRangeFormattingParams Params,
+ StringRef ID, JSONOutput &Out) override;
+  void onDocumentFormatting(DocumentFormattingParams Params, StringRef ID,
+JSONOutput &Out) override;
+  void onCodeAction(CodeActionParams Params, StringRef ID,
+JSONOutput &Out) override;
+  void onCompletion(TextDocumentPositionParams Params, StringRef ID,
+JSONOutput &Out) override;
+  void onGoToDefinition(TextDocumentPositionParams Params, StringRef ID,
+JSONOutput &Out) override;
+  void onSwitchSourceHeader(TextDocumentIdentifier Params, StringRef ID,
+JSONOutput &Out) override;
 
   std::vector
   getFixIts(StringRef File, const clangd::Diagnostic &D);
@@ -74,7 +92,6 @@
   // Various ClangdServer parameters go here. It's important they're created
   // before ClangdServer.
   DirectoryBasedGlobalCompilationDatabase CDB;
-  LSPDiagnosticsConsumer DiagConsumer;
   RealFileSystemProvider FSProvider;
 
   // Server must be the last member of the class to allow its destructor to exit
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -9,7 +9,6 @@
 
 #include "ClangdLSPServer.h"
 #include "JSONRPCDispatcher.h"
-#include "ProtocolHandlers.h"
 
 using namespace clang::clangd;
 using namespace clang;
@@ -38,50 +37,8 @@
 
 } // namespace
 
-ClangdLSPServer::LSPDiagnosticsConsumer::LSPDiagnosticsConsumer(
-ClangdLSPServer &Server)
-: Server(Server) {}
-
-void ClangdLSPServer::LSPDiagnosticsConsumer::onDiagnosticsReady(
-PathRef File, Tagged> Diagnostics) {
-  Server.consumeDiagnostics(File, Diagnostics.Value);
-}
-
-class ClangdLSPServer::LSPProtocolCallbacks : public ProtocolCallbacks {
-public:
-  LSPProtocolCallbacks(ClangdLSPServer &LangServer) : LangServer(LangServer) {}
-
-  void onInitialize(StringRef ID, InitializeParams IP,
-JSONOutput &Out) override;
-  void onShutdown(JSONOutput &Out) override;
-  void onDocumentDidOpen(DidOpenTextDocumentParams Params,
- JSONOutput &Out) override;
-  void onDocumentDidChange(DidChangeTextDocumentParams Params,
-   JSONOutput &Out) override;
-  void onDocumentDidClose(DidCloseTextDocumentParams Params,
-  JSONOutput &Out) override;
-  void onDocumentOnTypeFormatting(DocumentOnTypeFormattingParams Params,
-  StringRef ID, JSONOutput &Out) override;
-  void onDocumentRangeFormatting(DocumentRangeFormattingParams Params,
-

[PATCH] D38303: [Sema] Correct IUnknown to support Unknwnbase.h Header.

2017-09-29 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm




Comment at: lib/AST/DeclCXX.cpp:1473
 
+static bool IsDeclContextInNamespace(const DeclContext *DC) {
+  while (!DC->isTranslationUnit()) {

Lower case `isDeclContext...` is more inline with our style


https://reviews.llvm.org/D38303



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


[PATCH] D37903: Fix assume-filename handling in clang-format.el

2017-09-29 Thread Philipp via Phabricator via cfe-commits
phst added inline comments.



Comment at: tools/clang-format/clang-format.el:122
 ;;;###autoload
-(defun clang-format-region (start end &optional style assume-file-name)
-  "Use clang-format to format the code between START and END according to STYLE
-using ASSUME-FILE-NAME to locate a style config file. If called interactively
-uses the region or the current statement if there is no active region. If no
-style is given uses `clang-format-style'. If no assume-file-name is given uses
-`buffer-file-name'."
+(defun clang-format-region (start end &optional style)
+  "Use clang-format to format the code between START and END according to 
STYLE.

Hmm, somehow your patch got reverted?


https://reviews.llvm.org/D37903



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


[PATCH] D37299: [Modules] Add ability to specify module name to module file mapping in a file

2017-09-29 Thread Boris Kolpackov via Phabricator via cfe-commits
boris added a comment.

Ping.


https://reviews.llvm.org/D37299



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


[PATCH] D38284: [clang-tidy] Fix google-readability-namespace-comments handling of C++17 nested namespaces

2017-09-29 Thread Alexandru Octavian Buțiu via Phabricator via cfe-commits
predator5047 updated this revision to Diff 117193.
predator5047 marked 12 inline comments as done.
predator5047 added a comment.

Address review comments:

- Don't use auto if the type is not spelled out in initialization.
- Better names for variables.
- Elide braces.
- Format changes.




https://reviews.llvm.org/D38284

Files:
  clang-tidy/readability/NamespaceCommentCheck.cpp
  clang-tidy/readability/NamespaceCommentCheck.h
  test/clang-tidy/google-readability-nested-namespace-comments.cpp

Index: test/clang-tidy/google-readability-nested-namespace-comments.cpp
===
--- /dev/null
+++ test/clang-tidy/google-readability-nested-namespace-comments.cpp
@@ -0,0 +1,17 @@
+// RUN: %check_clang_tidy %s google-readability-namespace-comments %t -- -std=c++17
+
+namespace n1::n2 {
+namespace n3 {
+	
+	//So that namespace is not empty.
+	void f();
+	
+	
+// CHECK-MESSAGES: :[[@LINE+4]]:2: warning: namespace 'n3' not terminated with
+// CHECK-MESSAGES: :[[@LINE-7]]:11: note: namespace 'n3' starts here
+// CHECK-MESSAGES: :[[@LINE+2]]:3: warning: namespace 'n1::n2' not terminated with a closing comment [google-readability-namespace-comments]
+// CHECK-MESSAGES: :[[@LINE-10]]:11: note: namespace 'n1::n2' starts here
+}}
+// CHECK-FIXES: }  // namespace n3
+// CHECK-FIXES: }  // namespace n1::n2
+
Index: clang-tidy/readability/NamespaceCommentCheck.h
===
--- clang-tidy/readability/NamespaceCommentCheck.h
+++ clang-tidy/readability/NamespaceCommentCheck.h
@@ -34,6 +34,7 @@
   llvm::Regex NamespaceCommentPattern;
   const unsigned ShortNamespaceLines;
   const unsigned SpacesBeforeComments;
+  std::vector Ends;
 };
 
 } // namespace readability
Index: clang-tidy/readability/NamespaceCommentCheck.cpp
===
--- clang-tidy/readability/NamespaceCommentCheck.cpp
+++ clang-tidy/readability/NamespaceCommentCheck.cpp
@@ -23,7 +23,7 @@
  ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   NamespaceCommentPattern("^/[/*] *(end (of )?)? *(anonymous|unnamed)? *"
-  "namespace( +([a-zA-Z0-9_]+))?\\.? *(\\*/)?$",
+  "namespace( +([a-zA-Z0-9_:]+))?\\.? *(\\*/)?$",
   llvm::Regex::IgnoreCase),
   ShortNamespaceLines(Options.get("ShortNamespaceLines", 1u)),
   SpacesBeforeComments(Options.get("SpacesBeforeComments", 1u)) {}
@@ -56,6 +56,15 @@
   return Fix;
 }
 
+static std::string getNamespaceComment(const std::string &s,
+   bool InsertLineBreak) {
+  std::string Fix = "// namespace ";
+  Fix.append(s);
+  if (InsertLineBreak)
+Fix.append("\n");
+  return Fix;
+}
+
 void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *ND = Result.Nodes.getNodeAs("namespace");
   const SourceManager &Sources = *Result.SourceManager;
@@ -74,11 +83,37 @@
   SourceLocation AfterRBrace = ND->getRBraceLoc().getLocWithOffset(1);
   SourceLocation Loc = AfterRBrace;
   Token Tok;
+  SourceLocation LBracketLocation = ND->getLocation();
+  SourceLocation NestedNamespaceBegin = LBracketLocation;
+
+  // Currently for nested namepsace (n1::n2::...) the AST matcher will match foo
+  // then bar instead of a single match. So if we got a nested namespace we have
+  // to skip the next ones.
+  for (const auto &EndOfNameLocation : Ends)
+if (Sources.isBeforeInTranslationUnit(NestedNamespaceBegin,
+  EndOfNameLocation))
+  return;
+
+  while (Lexer::getRawToken(LBracketLocation, Tok, Sources, getLangOpts()) ||
+ !Tok.is(tok::l_brace)) {
+LBracketLocation = LBracketLocation.getLocWithOffset(1);
+  }
+
+  auto TextRange =
+  Lexer::getAsCharRange(SourceRange(NestedNamespaceBegin, LBracketLocation),
+Sources, getLangOpts());
+  auto NestedNamespaceName =
+  Lexer::getSourceText(TextRange, Sources, getLangOpts()).rtrim();
+  bool IsNested = NestedNamespaceName.contains(':');
+
+  if (IsNested)
+Ends.push_back(LBracketLocation);
+
   // Skip whitespace until we find the next token.
   while (Lexer::getRawToken(Loc, Tok, Sources, getLangOpts()) ||
- Tok.is(tok::semi)) {
+ Tok.is(tok::semi))
 Loc = Loc.getLocWithOffset(1);
-  }
+
   if (!locationsInSameFile(Sources, ND->getRBraceLoc(), Loc))
 return;
 
@@ -98,10 +133,14 @@
   StringRef NamespaceNameInComment = Groups.size() > 5 ? Groups[5] : "";
   StringRef Anonymous = Groups.size() > 3 ? Groups[3] : "";
 
-  // Check if the namespace in the comment is the same.
-  if ((ND->isAnonymousNamespace() && NamespaceNameInComment.empty()) ||
-  (ND->getNameAsString() == NamespaceNameInComment &&
-   Anonymous.empty())) {
+  if (IsNested && NestedNamespaceName ==

[libclc] r314547 - travis: Check built libraries on llvm-3.9

2017-09-29 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Fri Sep 29 12:06:50 2017
New Revision: 314547

URL: http://llvm.org/viewvc/llvm-project?rev=314547&view=rev
Log:
travis: Check built libraries on llvm-3.9

Signed-off-by: Jan Vesely 
Acked-by: Aaron Watry 

Modified:
libclc/trunk/.travis.yml

Modified: libclc/trunk/.travis.yml
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/.travis.yml?rev=314547&r1=314546&r2=314547&view=diff
==
--- libclc/trunk/.travis.yml (original)
+++ libclc/trunk/.travis.yml Fri Sep 29 12:06:50 2017
@@ -13,6 +13,7 @@ matrix:
 - LABEL="make gcc LLVM-3.9"
 - LLVM_VERSION=3.9
 - LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
+- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc"
   addons:
 apt:
   sources:
@@ -54,3 +55,6 @@ matrix:
 
 script:
   - $PYTHON ./configure.py --with-llvm-config=$LLVM_CONFIG 
--with-cxx-compiler=$CXX && make -j4
+  - for f in $CHECK_FILES; do
+./check_external_calls.sh built_libs/$f;
+done


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


[libclc] r314544 - travis: add build using llvm-3.9

2017-09-29 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Fri Sep 29 12:06:45 2017
New Revision: 314544

URL: http://llvm.org/viewvc/llvm-project?rev=314544&view=rev
Log:
travis: add build using llvm-3.9

Signed-off-by: Jan Vesely 
Acked-by: Aaron Watry 

Modified:
libclc/trunk/.travis.yml

Modified: libclc/trunk/.travis.yml
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/.travis.yml?rev=314544&r1=314543&r2=314544&view=diff
==
--- libclc/trunk/.travis.yml (original)
+++ libclc/trunk/.travis.yml Fri Sep 29 12:06:45 2017
@@ -10,6 +10,20 @@ cache:
 matrix:
   include:
 - env:
+- LABEL="make gcc LLVM-3.9"
+- LLVM_VERSION=3.9
+- LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
+  addons:
+apt:
+  sources:
+- llvm-toolchain-trusty-3.9
+  packages:
+- libedit-dev
+- g++-4.8
+# From sources above
+- llvm-3.9-dev
+- clang-3.9
+- env:
 - LABEL="make gcc LLVM-4.0"
 - LLVM_VERSION=4.0
 - LLVM_CONFIG="llvm-config-${LLVM_VERSION}"


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


[libclc] r314545 - geometric: geometric functions are only supported for vector lengths <=4

2017-09-29 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Fri Sep 29 12:06:47 2017
New Revision: 314545

URL: http://llvm.org/viewvc/llvm-project?rev=314545&view=rev
Log:
geometric: geometric functions are only supported for vector lengths <=4

Signed-off-by: Jan Vesely 
Reviewed-by: Aaron Watry 

Modified:
libclc/trunk/generic/include/clc/geometric/floatn.inc

Modified: libclc/trunk/generic/include/clc/geometric/floatn.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/geometric/floatn.inc?rev=314545&r1=314544&r2=314545&view=diff
==
--- libclc/trunk/generic/include/clc/geometric/floatn.inc (original)
+++ libclc/trunk/generic/include/clc/geometric/floatn.inc Fri Sep 29 12:06:47 
2017
@@ -19,14 +19,6 @@
 #include __CLC_BODY
 #undef __CLC_FLOATN
 
-#define __CLC_FLOATN float8
-#include __CLC_BODY
-#undef __CLC_FLOATN
-
-#define __CLC_FLOATN float16
-#include __CLC_BODY
-#undef __CLC_FLOATN
-
 #undef __CLC_FLOAT
 #undef __CLC_FPSIZE
 
@@ -54,14 +46,6 @@
 #include __CLC_BODY
 #undef __CLC_FLOATN
 
-#define __CLC_FLOATN double8
-#include __CLC_BODY
-#undef __CLC_FLOATN
-
-#define __CLC_FLOATN double16
-#include __CLC_BODY
-#undef __CLC_FLOATN
-
 #undef __CLC_FLOAT
 #undef __CLC_FPSIZE
 


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


[libclc] r314548 - Fix amdgcn-amdhsa on llvm-3.9

2017-09-29 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Fri Sep 29 12:06:52 2017
New Revision: 314548

URL: http://llvm.org/viewvc/llvm-project?rev=314548&view=rev
Log:
Fix amdgcn-amdhsa on llvm-3.9

Signed-off-by: Jan Vesely 
Acked-by: Aaron Watry 

Added:
libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES_3.9
libclc/trunk/amdgcn-amdhsa/lib/SOURCES_3.9
  - copied, changed from r314547, libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES
libclc/trunk/amdgcn-amdhsa/lib/workitem/get_global_size.39.ll
libclc/trunk/amdgcn-amdhsa/lib/workitem/get_local_size.39.ll
Modified:
libclc/trunk/.travis.yml
libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES

Modified: libclc/trunk/.travis.yml
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/.travis.yml?rev=314548&r1=314547&r2=314548&view=diff
==
--- libclc/trunk/.travis.yml (original)
+++ libclc/trunk/.travis.yml Fri Sep 29 12:06:52 2017
@@ -13,7 +13,7 @@ matrix:
 - LABEL="make gcc LLVM-3.9"
 - LLVM_VERSION=3.9
 - LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
-- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc"
+- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc"
   addons:
 apt:
   sources:

Modified: libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES?rev=314548&r1=314547&r2=314548&view=diff
==
--- libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES (original)
+++ libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES Fri Sep 29 12:06:52 2017
@@ -1,4 +1 @@
 workitem/get_num_groups.ll
-workitem/get_global_size.39.ll
-workitem/get_local_size.39.ll
-workitem/get_num_groups.39.ll

Added: libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES_3.9
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES_3.9?rev=314548&view=auto
==
--- libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES_3.9 (added)
+++ libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES_3.9 Fri Sep 29 12:06:52 2017
@@ -0,0 +1,3 @@
+workitem/get_global_size.ll
+workitem/get_local_size.ll
+workitem/get_num_groups.39.ll

Copied: libclc/trunk/amdgcn-amdhsa/lib/SOURCES_3.9 (from r314547, 
libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES)
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn-amdhsa/lib/SOURCES_3.9?p2=libclc/trunk/amdgcn-amdhsa/lib/SOURCES_3.9&p1=libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES&r1=314547&r2=314548&rev=314548&view=diff
==
--- libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES (original)
+++ libclc/trunk/amdgcn-amdhsa/lib/SOURCES_3.9 Fri Sep 29 12:06:52 2017
@@ -1,4 +1,2 @@
-workitem/get_num_groups.ll
 workitem/get_global_size.39.ll
 workitem/get_local_size.39.ll
-workitem/get_num_groups.39.ll

Added: libclc/trunk/amdgcn-amdhsa/lib/workitem/get_global_size.39.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn-amdhsa/lib/workitem/get_global_size.39.ll?rev=314548&view=auto
==
--- libclc/trunk/amdgcn-amdhsa/lib/workitem/get_global_size.39.ll (added)
+++ libclc/trunk/amdgcn-amdhsa/lib/workitem/get_global_size.39.ll Fri Sep 29 
12:06:52 2017
@@ -0,0 +1,36 @@
+declare i8 addrspace(2)* @llvm.amdgcn.dispatch.ptr() #0
+
+define i32 @get_global_size(i32 %dim) #1 {
+  %dispatch_ptr = call noalias nonnull dereferenceable(64) i8 addrspace(2)* 
@llvm.amdgcn.dispatch.ptr()
+  switch i32 %dim, label %default [
+i32 0, label %x
+i32 1, label %y
+i32 2, label %z
+  ]
+
+x:
+  %ptr_x = getelementptr inbounds i8, i8 addrspace(2)* %dispatch_ptr, i32 12
+  %ptr_x32 = bitcast i8 addrspace(2)* %ptr_x to i32 addrspace(2)*
+  %x32 = load i32, i32 addrspace(2)* %ptr_x32, align 4, !invariant.load !0
+  ret i32 %x32
+
+y:
+  %ptr_y = getelementptr inbounds i8, i8 addrspace(2)* %dispatch_ptr, i32 16
+  %ptr_y32 = bitcast i8 addrspace(2)* %ptr_y to i32 addrspace(2)*
+  %y32 = load i32, i32 addrspace(2)* %ptr_y32, align 4, !invariant.load !0
+  ret i32 %y32
+
+z:
+  %ptr_z = getelementptr inbounds i8, i8 addrspace(2)* %dispatch_ptr, i32 20
+  %ptr_z32 = bitcast i8 addrspace(2)* %ptr_z to i32 addrspace(2)*
+  %z32 = load i32, i32 addrspace(2)* %ptr_z32, align 4, !invariant.load !0
+  ret i32 %z32
+
+default:
+  ret i32 1
+}
+
+attributes #0 = { nounwind readnone }
+attributes #1 = { alwaysinline norecurse nounwind readonly }
+
+!0 = !{}

Added: libclc/trunk/amdgcn-amdhsa/lib/workitem/get_local_size.39.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn-amdhsa/lib/workitem/get_local_size.39.ll?rev=314548&view=auto
==
--- libclc/trunk/amdgcn-amdhsa/lib/workitem/get_local_s

[libclc] r314546 - Add script to check for unresolved function calls

2017-09-29 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Fri Sep 29 12:06:48 2017
New Revision: 314546

URL: http://llvm.org/viewvc/llvm-project?rev=314546&view=rev
Log:
Add script to check for unresolved function calls

v2: add shell shebang
improve error checks and reporting
v3: fix typo

Signed-off-by: Jan Vesely 
Reviewed-by: Aaron Watry 

Added:
libclc/trunk/check_external_calls.sh   (with props)

Added: libclc/trunk/check_external_calls.sh
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/check_external_calls.sh?rev=314546&view=auto
==
--- libclc/trunk/check_external_calls.sh (added)
+++ libclc/trunk/check_external_calls.sh Fri Sep 29 12:06:48 2017
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+FILE=$1
+if [ ! -f $FILE ]; then
+   echo "ERROR: Not a file: $FILE"
+   exit 3
+fi
+ret=0
+if [ "x$LLVM_CONFIG" = "x" ]; then
+   LLVM_CONFIG=llvm-config
+   echo 'WARNING: $LLVM_CONFIG not set, falling back to $PATH llvm-config'
+   ret=2
+fi
+
+
+BIN_DIR=$($LLVM_CONFIG --bindir)
+DIS="$BIN_DIR/llvm-dis"
+if [ ! -x $DIS ]; then
+   echo "ERROR: Disassembler '$DIS' is not executable"
+   exit 3
+fi
+
+TMP_FILE=$(mktemp)
+
+# Check for calls. Calls to llvm intrinsics are OK
+$DIS < $FILE | grep ' call ' | grep -v '@llvm' > "$TMP_FILE"
+
+if [ $(wc -l < "$TMP_FILE") -ne "0" ]; then
+   echo "ERROR: unresolved calls detected"
+   cat $TMP_FILE
+   ret=1
+else
+   echo "File $FILE is OK"
+fi
+exit $ret

Propchange: libclc/trunk/check_external_calls.sh
--
svn:executable = *


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


[libclc] r314543 - Restore support for llvm-3.9

2017-09-29 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Fri Sep 29 12:06:41 2017
New Revision: 314543

URL: http://llvm.org/viewvc/llvm-project?rev=314543&view=rev
Log:
Restore support for llvm-3.9

Signed-off-by: Jan Vesely 
Acked-by: Aaron Watry 

Added:
libclc/trunk/amdgcn/lib/OVERRIDES_3.9
libclc/trunk/amdgcn/lib/SOURCES_3.9
libclc/trunk/amdgcn/lib/workitem/get_global_size.39.ll
libclc/trunk/amdgcn/lib/workitem/get_local_size.39.ll
libclc/trunk/amdgcn/lib/workitem/get_num_groups.39.ll
libclc/trunk/amdgpu/lib/SOURCES_3.9
Modified:
libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES
libclc/trunk/configure.py
libclc/trunk/utils/prepare-builtins.cpp

Modified: libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES?rev=314543&r1=314542&r2=314543&view=diff
==
--- libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES (original)
+++ libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES Fri Sep 29 12:06:41 2017
@@ -1 +1,4 @@
 workitem/get_num_groups.ll
+workitem/get_global_size.39.ll
+workitem/get_local_size.39.ll
+workitem/get_num_groups.39.ll

Added: libclc/trunk/amdgcn/lib/OVERRIDES_3.9
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/OVERRIDES_3.9?rev=314543&view=auto
==
--- libclc/trunk/amdgcn/lib/OVERRIDES_3.9 (added)
+++ libclc/trunk/amdgcn/lib/OVERRIDES_3.9 Fri Sep 29 12:06:41 2017
@@ -0,0 +1,3 @@
+workitem/get_global_size.ll
+workitem/get_local_size.ll
+workitem/get_num_groups.ll

Added: libclc/trunk/amdgcn/lib/SOURCES_3.9
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/SOURCES_3.9?rev=314543&view=auto
==
--- libclc/trunk/amdgcn/lib/SOURCES_3.9 (added)
+++ libclc/trunk/amdgcn/lib/SOURCES_3.9 Fri Sep 29 12:06:41 2017
@@ -0,0 +1,3 @@
+workitem/get_global_size.39.ll
+workitem/get_local_size.39.ll
+workitem/get_num_groups.39.ll

Added: libclc/trunk/amdgcn/lib/workitem/get_global_size.39.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/workitem/get_global_size.39.ll?rev=314543&view=auto
==
--- libclc/trunk/amdgcn/lib/workitem/get_global_size.39.ll (added)
+++ libclc/trunk/amdgcn/lib/workitem/get_global_size.39.ll Fri Sep 29 12:06:41 
2017
@@ -0,0 +1,18 @@
+declare i32 @llvm.r600.read.global.size.x() nounwind readnone
+declare i32 @llvm.r600.read.global.size.y() nounwind readnone
+declare i32 @llvm.r600.read.global.size.z() nounwind readnone
+
+define i32 @get_global_size(i32 %dim) nounwind readnone alwaysinline {
+  switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 
2, label %z_dim]
+x_dim:
+  %x = call i32 @llvm.r600.read.global.size.x()
+  ret i32 %x
+y_dim:
+  %y = call i32 @llvm.r600.read.global.size.y()
+  ret i32 %y
+z_dim:
+  %z = call i32 @llvm.r600.read.global.size.z()
+  ret i32 %z
+default:
+  ret i32 1
+}

Added: libclc/trunk/amdgcn/lib/workitem/get_local_size.39.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/workitem/get_local_size.39.ll?rev=314543&view=auto
==
--- libclc/trunk/amdgcn/lib/workitem/get_local_size.39.ll (added)
+++ libclc/trunk/amdgcn/lib/workitem/get_local_size.39.ll Fri Sep 29 12:06:41 
2017
@@ -0,0 +1,18 @@
+declare i32 @llvm.r600.read.local.size.x() nounwind readnone
+declare i32 @llvm.r600.read.local.size.y() nounwind readnone
+declare i32 @llvm.r600.read.local.size.z() nounwind readnone
+
+define i32 @get_local_size(i32 %dim) nounwind readnone alwaysinline {
+  switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 
2, label %z_dim]
+x_dim:
+  %x = call i32 @llvm.r600.read.local.size.x()
+  ret i32 %x
+y_dim:
+  %y = call i32 @llvm.r600.read.local.size.y()
+  ret i32 %y
+z_dim:
+  %z = call i32 @llvm.r600.read.local.size.z()
+  ret i32 %z
+default:
+  ret i32 1
+}

Added: libclc/trunk/amdgcn/lib/workitem/get_num_groups.39.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/workitem/get_num_groups.39.ll?rev=314543&view=auto
==
--- libclc/trunk/amdgcn/lib/workitem/get_num_groups.39.ll (added)
+++ libclc/trunk/amdgcn/lib/workitem/get_num_groups.39.ll Fri Sep 29 12:06:41 
2017
@@ -0,0 +1,18 @@
+declare i32 @llvm.r600.read.ngroups.x() nounwind readnone
+declare i32 @llvm.r600.read.ngroups.y() nounwind readnone
+declare i32 @llvm.r600.read.ngroups.z() nounwind readnone
+
+define i32 @get_num_groups(i32 %dim) nounwind readnone alwaysinline {
+  switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 
2, label %z_dim]
+x_dim:
+  %x = call i32 @llvm.r600.read.ngroups.x()
+  ret i32 %x
+y_dim:
+  %y = call i32 @llvm.r600.read.ngroups.y()
+  r

Re: Fix for the issue 12176

2017-09-29 Thread Oscar Forner Martinez via cfe-commits



On 28/09/17 21:28, Jonathan Roelofs wrote:

+silvas


On 9/28/17 2:19 PM, Oscar Forner Martinez via cfe-commits wrote:

Hi,

Please find attached a diff to fix the issue 12176.


Link for the lazy: llvm.org/PR12176

Thanks ;)



Let me know if there is anything any improvements you can think of.

Best regards,

Oscar


Extract-getDepthAndIndex-issue-12176.patch


Index: lib/Sema/DepthAndIndex.h
===
--- lib/Sema/DepthAndIndex.h    (nonexistent)
+++ lib/Sema/DepthAndIndex.h    (working copy)
@@ -0,0 +1,32 @@
+//===- DepthAndIndex.h - Static declaration of the getDepthAndIndex 
function -*- C++ -*-===//

+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open 
Source

+// License. See LICENSE.TXT for details.
+//===--===// 


+//
+//  This file defines getDepthAndIndex function.
+//
+//===--===// 


+
+#ifndef LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
+#define LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
+
+#include "clang/AST/DeclTemplate.h"
+#include "clang/Sema/DeclSpec.h"
+
+/// \brief Retrieve the depth and index of a template parameter.
+static std::pair


This should be just a declaration and a doxygen comment for it. Drop 
the 'static'. You can also drop the "\brief" since autobrief is turned 
on.

Done


Then the body should go in a *.cpp somewhere in lib/Sema.
I haven't put the body in a *.cpp file because the other internal 
headers I've seen in lib/Sema have everything in the header file.



+getDepthAndIndex(NamedDecl *ND) {
+  if (TemplateTypeParmDecl *TTP = dyn_cast(ND))
+    return std::make_pair(TTP->getDepth(), TTP->getIndex());
+
+  if (NonTypeTemplateParmDecl *NTTP = 
dyn_cast(ND))

+    return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
+
+  TemplateTemplateParmDecl *TTP = cast(ND);
+  return std::make_pair(TTP->getDepth(), TTP->getIndex());
+}
+
+#endif // LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
\ No newline at end of file
Index: lib/Sema/SemaTemplateDeduction.cpp
===
--- lib/Sema/SemaTemplateDeduction.cpp    (revision 314321)
+++ lib/Sema/SemaTemplateDeduction.cpp    (working copy)
@@ -11,6 +11,7 @@
//===--===/
    #include "clang/Sema/TemplateDeduction.h"
+#include "DepthAndIndex.h"
  #include "TreeTransform.h"
  #include "clang/AST/ASTContext.h"
  #include "clang/AST/ASTLambda.h"
@@ -579,19 +580,6 @@
    }
  }
  -/// \brief Retrieve the depth and index of a template parameter.
-static std::pair
-getDepthAndIndex(NamedDecl *ND) {
-  if (TemplateTypeParmDecl *TTP = dyn_cast(ND))
-    return std::make_pair(TTP->getDepth(), TTP->getIndex());
-
-  if (NonTypeTemplateParmDecl *NTTP = 
dyn_cast(ND))

-    return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
-
-  TemplateTemplateParmDecl *TTP = cast(ND);
-  return std::make_pair(TTP->getDepth(), TTP->getIndex());
-}
-
  /// \brief Retrieve the depth and index of an unexpanded parameter 
pack.

  static std::pair
  getDepthAndIndex(UnexpandedParameterPack UPP) {


Maybe this ^ one should go too?

I added this method to the header.



Index: lib/Sema/SemaTemplateInstantiate.cpp


snip


Jon




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





Index: lib/Sema/DepthAndIndex.h
===
--- lib/Sema/DepthAndIndex.h	(nonexistent)
+++ lib/Sema/DepthAndIndex.h	(working copy)
@@ -0,0 +1,44 @@
+//===- DepthAndIndex.h - Static declaration of the getDepthAndIndex function -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//===--===//
+//
+//  This file defines getDepthAndIndex function.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
+#define LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
+
+#include "clang/AST/DeclTemplate.h"
+#include "clang/Sema/DeclSpec.h"
+#include "clang/Sema/Template.h"
+
+/// Retrieve the depth and index of a template parameter.
+std::pair
+getDepthAndIndex(NamedDecl *ND) {
+  if (TemplateTypeParmDecl *TTP = dyn_cast(ND))
+return std::make_pair(TTP->getDepth(), TTP->getIndex());
+
+  if (NonTypeTemplateParmDecl *NTTP = dyn_cast(ND))
+return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
+
+  TemplateTemplateParmDecl *TTP = cast(ND);
+  return std::make_pair(TTP->getDepth(), TTP->getIndex());
+}
+
+
+/// Retrieve the depth and index of an unexpanded parameter pack.

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

2017-09-29 Thread William Enright via Phabricator via cfe-commits
Nebiroth created this revision.

Implementation of Document Highlights Request as described in LSP.


https://reviews.llvm.org/D38425

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  test/clangd/documenthighlight.test

Index: test/clangd/documenthighlight.test
===
--- /dev/null
+++ test/clangd/documenthighlight.test
@@ -0,0 +1,29 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 455
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"#define MACRO 1\nnamespace ns1 {\nstruct MyClass {\nint xasd;\nvoid anotherOperation() {\n}\nstatic int foo(MyClass*) {\nreturn 0;\n}\n\n};\nstruct Foo {\nint xasd;\n};\n}\nint main() {\nint bonjour;\nbonjour = 2;\nns1::Foo bar = { xasd : 1};\nbar.xasd = 3;\nns1::MyClass* Params;\nParams->anotherOperation();}\n"}}}
+
+Content-Length: 156
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":17,"character":2}}}
+# Go to local variable
+# CHECK: {"jsonrpc":"2.0","id":1,"result":[{"range": {"start": {"line": 16, "character": 4}, "end": {"line": 16, "character": 12}}, "number": 1},{"range": {"start": {"line": 17, "character": 0}, "end": {"line": 17, "character": 7}}, "number": 1}]}
+
+Content-Length: 157
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":18,"character":17}}}
+# Go to local variable
+# CHECK: {"jsonrpc":"2.0","id":1,"result":[{"range": {"start": {"line": 12, "character": 4}, "end": {"line": 12, "character": 9}}, "number": 1},{"range": {"start": {"line": 18, "character": 17}, "end": {"line": 18, "character": 21}}, "number": 1},{"range": {"start": {"line": 19, "character": 4}, "end": {"line": 19, "character": 8}}, "number": 1}]}
+
+Content-Length: 157
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":21,"character":10}}}
+# Go to local variable
+# CHECK: {"jsonrpc":"2.0","id":1,"result":[{"range": {"start": {"line": 4, "character": 5}, "end": {"line": 4, "character": 22}}, "number": 1},{"range": {"start": {"line": 21, "character": 8}, "end": {"line": 21, "character": 25}}, "number": 1}]}
+
Index: clangd/ProtocolHandlers.h
===
--- clangd/ProtocolHandlers.h
+++ clangd/ProtocolHandlers.h
@@ -47,7 +47,9 @@
   virtual void onCompletion(TextDocumentPositionParams Params, StringRef ID,
 JSONOutput &Out) = 0;
   virtual void onGoToDefinition(TextDocumentPositionParams Params, StringRef ID,
-JSONOutput &Out) = 0;
+JSONOutput &Out) = 0;
+  virtual void onDocumentHighlight(TextDocumentPositionParams Params, StringRef ID,
+JSONOutput &Out) = 0;  
 };
 
 void regiterCallbackHandlers(JSONRPCDispatcher &Dispatcher, JSONOutput &Out,
Index: clangd/ProtocolHandlers.cpp
===
--- clangd/ProtocolHandlers.cpp
+++ clangd/ProtocolHandlers.cpp
@@ -204,6 +204,24 @@
   ProtocolCallbacks &Callbacks;
 };
 
+struct DocumentHighlightHandler : Handler {
+  DocumentHighlightHandler(JSONOutput &Output, ProtocolCallbacks &Callbacks)
+  : Handler(Output), Callbacks(Callbacks) {}
+
+  void handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) override {
+auto TDPP = TextDocumentPositionParams::parse(Params, Output);
+if (!TDPP) {
+  Output.log("Failed to decode TextDocumentPositionParams!\n");
+  return;
+}
+
+Callbacks.onDocumentHighlight(*TDPP, ID, Output);
+  }
+
+private:
+  ProtocolCallbacks &Callbacks;
+};
+
 } // namespace
 
 void clangd::regiterCallbackHandlers(JSONRPCDispatcher &Dispatcher,
@@ -240,4 +258,7 @@
   Dispatcher.registerHandler(
   "textDocument/definition",
   llvm::make_unique(Out, Callbacks));
+  Dispatcher.registerHandler(
+  "textDocument/documentHighlight",
+  llvm::make_unique(Out, Callbacks));
 }
Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -416,6 +416,41 @@
   static std::string unparse(const CompletionItem &P);
 };
 
+enum class DocumentHighlightKind {
+  Text = 1,
+  Read = 2,
+  Write = 3
+};
+
+/**
+ * A document highlight is 

[PATCH] D37150: [clangd] Command line arg to specify compile_commands.json path

2017-09-29 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 117217.
Nebiroth added a comment.

Fixed missed comments and suggstions.


https://reviews.llvm.org/D37150

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/tool/ClangdMain.cpp

Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -11,16 +11,22 @@
 #include "JSONRPCDispatcher.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
-
 #include 
 #include 
 #include 
 #include 
 
 using namespace clang;
 using namespace clang::clangd;
 
+static llvm::cl::opt CompileCommandsDir(
+"compile-commands-dir",
+llvm::cl::desc("Specify a path to look for compile_commands.json. If path "
+   "is invalid, clangd will look in the current directory and "
+   "parent paths of each source file."));
+
 static llvm::cl::opt
 WorkerThreadsCount("j",
llvm::cl::desc("Number of async workers used by clangd"),
@@ -56,18 +62,37 @@
   if (RunSynchronously)
 WorkerThreadsCount = 0;
 
+  /// Validate command line arguments.
   llvm::raw_ostream &Outs = llvm::outs();
   llvm::raw_ostream &Logs = llvm::errs();
   JSONOutput Out(Outs, Logs);
 
-  // Change stdin to binary to not lose \r\n on windows.
-  llvm::sys::ChangeStdinToBinary();
+  // If --compile-commands-dir arg was invoked, check value and override default
+  // path.
+  namespace path = llvm::sys::path;
+  llvm::Optional CompileCommandsDirPath;
+
+  if (CompileCommandsDir.empty()) {
+CompileCommandsDirPath = llvm::None;
+  } else if (!llvm::sys::path::is_absolute(CompileCommandsDir) ||
+ !llvm::sys::fs::exists(CompileCommandsDir)) {
+llvm::errs() << "Path specified by --compile-commands-dir either does not "
+"exist or is not an absolute "
+"path. The argument will be ignored.\n";
+CompileCommandsDirPath = llvm::None;
+  } else {
+CompileCommandsDirPath = CompileCommandsDir;
+  }
 
   llvm::Optional ResourceDirRef = None;
   if (!ResourceDir.empty())
 ResourceDirRef = ResourceDir;
 
+  /// Change stdin to binary to not lose \r\n on windows.
+  llvm::sys::ChangeStdinToBinary();
+
+  /// Initialize and run ClangdLSPServer.
   ClangdLSPServer LSPServer(Out, WorkerThreadsCount, EnableSnippets,
-ResourceDirRef);
+ResourceDirRef, CompileCommandsDirPath);
   LSPServer.run(std::cin);
 }
Index: clangd/GlobalCompilationDatabase.h
===
--- clangd/GlobalCompilationDatabase.h
+++ clangd/GlobalCompilationDatabase.h
@@ -47,15 +47,17 @@
 class DirectoryBasedGlobalCompilationDatabase
 : public GlobalCompilationDatabase {
 public:
-  DirectoryBasedGlobalCompilationDatabase(clangd::Logger &Logger);
+  DirectoryBasedGlobalCompilationDatabase(
+  clangd::Logger &Logger, llvm::Optional NewCompileCommandsDir);
 
   std::vector
   getCompileCommands(PathRef File) override;
 
   void setExtraFlagsForFile(PathRef File, std::vector ExtraFlags);
 
 private:
   tooling::CompilationDatabase *getCompilationDatabase(PathRef File);
+  tooling::CompilationDatabase *tryLoadDatabaseFromPath(PathRef File);
 
   std::mutex Mutex;
   /// Caches compilation databases loaded from directories(keys are
@@ -67,6 +69,9 @@
   llvm::StringMap> ExtraFlagsForFile;
   /// Used for logging.
   clangd::Logger &Logger;
+  /// Used for command argument pointing to folder where compile_commands.json
+  /// is located.
+  llvm::Optional CompileCommandsDir;
 };
 } // namespace clangd
 } // namespace clang
Index: clangd/GlobalCompilationDatabase.cpp
===
--- clangd/GlobalCompilationDatabase.cpp
+++ clangd/GlobalCompilationDatabase.cpp
@@ -8,10 +8,10 @@
 //===-===//
 
 #include "GlobalCompilationDatabase.h"
+#include "Logger.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
-#include "Logger.h"
 
 namespace clang {
 namespace clangd {
@@ -38,8 +38,9 @@
 }
 
 DirectoryBasedGlobalCompilationDatabase::
-DirectoryBasedGlobalCompilationDatabase(clangd::Logger &Logger)
-: Logger(Logger) {}
+DirectoryBasedGlobalCompilationDatabase(
+clangd::Logger &Logger, llvm::Optional NewCompileCommandsDir)
+: Logger(Logger), CompileCommandsDir(NewCompileCommandsDir) {}
 
 std::vector
 DirectoryBasedGlobalCompilationDatabase::getCompileCommands(PathRef File) {
@@ -67,34 +68,48 @@
 }
 
 tooling::CompilationDatabase *
-DirectoryBasedGlobalCompilationDatabase::getCompilationDatabase(PathRef File) {
-  std::lock_guard Lock(Mutex);
+D

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

2017-09-29 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

Just a few quick comments.




Comment at: clangd/ClangdServer.cpp:295
+  assert(FileContents.Draft &&
+ "findDefinitions is called for non-added document");
+

findDocumentHighlights?



Comment at: clangd/ClangdServer.cpp:300
+  std::shared_ptr Resources = Units.getFile(File);
+  assert(Resources && "Calling findDefinitions on non-added file");
+

findDocumentHighlights?



Comment at: clangd/Protocol.cpp:782
+llvm::raw_string_ostream(Result) << llvm::format(
+R"({"range": %s, "number": %d})", Range::unparse(DH.range).c_str(), 
DH.kind);
+return Result;

number -> kind


https://reviews.llvm.org/D38425



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


[PATCH] D38303: [Sema] Correct IUnknown to support Unknwnbase.h Header.

2017-09-29 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314557: [Sema] Correct IUnknown to support Unknwnbase.h 
Header. (authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D38303?vs=116876&id=117218#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38303

Files:
  cfe/trunk/lib/AST/DeclCXX.cpp
  cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp
  cfe/trunk/test/SemaCXX/ms-iunknown.cpp

Index: cfe/trunk/lib/AST/DeclCXX.cpp
===
--- cfe/trunk/lib/AST/DeclCXX.cpp
+++ cfe/trunk/lib/AST/DeclCXX.cpp
@@ -1470,6 +1470,15 @@
   return false;
 }
 
+static bool isDeclContextInNamespace(const DeclContext *DC) {
+  while (!DC->isTranslationUnit()) {
+if (DC->isNamespace())
+  return true;
+DC = DC->getParent();
+  }
+  return false;
+}
+
 bool CXXRecordDecl::isInterfaceLike() const {
   assert(hasDefinition() && "checking for interface-like without a definition");
   // All __interfaces are inheritently interface-like.
@@ -1486,13 +1495,16 @@
 
   // No interface-like type can have a method with a definition.
   for (const auto *const Method : methods())
-if (Method->isDefined())
+if (Method->isDefined() && !Method->isImplicit())
   return false;
 
   // Check "Special" types.
   const auto *Uuid = getAttr();
-  if (Uuid && isStruct() && (getDeclContext()->isTranslationUnit() ||
- getDeclContext()->isExternCXXContext()) &&
+  // MS SDK declares IUnknown/IDispatch both in the root of a TU, or in an
+  // extern C++ block directly in the TU.  These are only valid if in one
+  // of these two situations.
+  if (Uuid && isStruct() && !getDeclContext()->isExternCContext() &&
+  !isDeclContextInNamespace(getDeclContext()) &&
   ((getName() == "IUnknown" &&
 Uuid->getGuid() == "---C000-0046") ||
(getName() == "IDispatch" &&
Index: cfe/trunk/test/SemaCXX/ms-iunknown.cpp
===
--- cfe/trunk/test/SemaCXX/ms-iunknown.cpp
+++ cfe/trunk/test/SemaCXX/ms-iunknown.cpp
@@ -2,19 +2,30 @@
 
 extern "C++" struct __declspec(uuid("---C000-0046")) IUnknown {
   void foo();
+  // Definitions aren't allowed, unless they are a template.
+  template
+  void bar(T t){}
 };
+
 struct IPropertyPageBase : public IUnknown {};
 struct IPropertyPage : public IPropertyPageBase {};
 __interface ISfFileIOPropertyPage : public IPropertyPage {};
 
 
 namespace NS {
   struct __declspec(uuid("---C000-0046")) IUnknown {};
   // expected-error@+1 {{interface type cannot inherit from}}
-  __interface IPropertyPageBase : public IUnknown {}; 
+  __interface IPropertyPageBase : public IUnknown {};
 }
+
+namespace NS2 {
+extern "C++" struct __declspec(uuid("---C000-0046")) IUnknown {};
+// expected-error@+1 {{interface type cannot inherit from}}
+__interface IPropertyPageBase : public IUnknown{};
+}
+
 // expected-error@+1 {{interface type cannot inherit from}}
-__interface IPropertyPageBase2 : public NS::IUnknown {}; 
+__interface IPropertyPageBase2 : public NS::IUnknown {};
 
 __interface temp_iface {};
 struct bad_base : temp_iface {};
@@ -32,8 +43,8 @@
 
 struct Page5 : public Page3, Page4{};
 // expected-error@+1 {{interface type cannot inherit from}}
-__interface PropertyPage2 : public Page5 {}; 
+__interface PropertyPage2 : public Page5 {};
 
 __interface IF1 {};
-__interface PP : IUnknown, IF1{}; 
+__interface PP : IUnknown, IF1{};
 __interface PP2 : PP, Page3, Page4{};
Index: cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp
===
--- cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp
+++ cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s 
+typedef long HRESULT;
+typedef unsigned long ULONG;
+typedef struct _GUID {
+  unsigned long Data1;
+  unsigned short Data2;
+  unsigned short Data3;
+  unsigned char Data4[8];
+} GUID;
+typedef GUID IID;
+
+// remove stdcall, since the warnings have nothing to do with
+// what is being tested.
+#define __stdcall
+
+extern "C" {
+extern "C++" {
+// expected-warning@+1 {{__declspec attribute 'novtable'}}
+struct __declspec(uuid("---C000-0046")) __declspec(novtable)
+IUnknown {
+public:
+  virtual HRESULT __stdcall QueryInterface(
+  const IID &riid,
+  void **ppvObject) = 0;
+
+  virtual ULONG __stdcall AddRef(void) = 0;
+
+  virtual ULONG __stdcall Release(void) = 0;
+
+  template 
+  HRESULT __stdcall QueryInterface(Q **pp) {
+return QueryInterface(__uuidof(Q), (void **)pp);
+  }
+};
+}
+}
+
+__interface ISfFileIOPropertyPage : public IUnknown{};
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://list

r314557 - [Sema] Correct IUnknown to support Unknwnbase.h Header.

2017-09-29 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Sep 29 14:06:00 2017
New Revision: 314557

URL: http://llvm.org/viewvc/llvm-project?rev=314557&view=rev
Log:
[Sema] Correct IUnknown to support Unknwnbase.h Header.

Apparently, the MSVC SDK has a strange implementation that
causes a number of implicit functions as well as a template member
function of the IUnknown type. This patch allows these as InterfaceLike
types as well.

Additionally, it corrects the behavior where extern-C++ wrapped around an
Interface-Like type would permit an interface-like type to exist in a namespace.

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

Added:
cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp   (with props)
Modified:
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/test/SemaCXX/ms-iunknown.cpp

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=314557&r1=314556&r2=314557&view=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Fri Sep 29 14:06:00 2017
@@ -1470,6 +1470,15 @@ bool CXXRecordDecl::isAnyDestructorNoRet
   return false;
 }
 
+static bool isDeclContextInNamespace(const DeclContext *DC) {
+  while (!DC->isTranslationUnit()) {
+if (DC->isNamespace())
+  return true;
+DC = DC->getParent();
+  }
+  return false;
+}
+
 bool CXXRecordDecl::isInterfaceLike() const {
   assert(hasDefinition() && "checking for interface-like without a 
definition");
   // All __interfaces are inheritently interface-like.
@@ -1486,13 +1495,16 @@ bool CXXRecordDecl::isInterfaceLike() co
 
   // No interface-like type can have a method with a definition.
   for (const auto *const Method : methods())
-if (Method->isDefined())
+if (Method->isDefined() && !Method->isImplicit())
   return false;
 
   // Check "Special" types.
   const auto *Uuid = getAttr();
-  if (Uuid && isStruct() && (getDeclContext()->isTranslationUnit() ||
- getDeclContext()->isExternCXXContext()) &&
+  // MS SDK declares IUnknown/IDispatch both in the root of a TU, or in an
+  // extern C++ block directly in the TU.  These are only valid if in one
+  // of these two situations.
+  if (Uuid && isStruct() && !getDeclContext()->isExternCContext() &&
+  !isDeclContextInNamespace(getDeclContext()) &&
   ((getName() == "IUnknown" &&
 Uuid->getGuid() == "---C000-0046") ||
(getName() == "IDispatch" &&

Added: cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp?rev=314557&view=auto
==
--- cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp (added)
+++ cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp Fri Sep 29 
14:06:00 2017
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s 
+typedef long HRESULT;
+typedef unsigned long ULONG;
+typedef struct _GUID {
+  unsigned long Data1;
+  unsigned short Data2;
+  unsigned short Data3;
+  unsigned char Data4[8];
+} GUID;
+typedef GUID IID;
+
+// remove stdcall, since the warnings have nothing to do with
+// what is being tested.
+#define __stdcall
+
+extern "C" {
+extern "C++" {
+// expected-warning@+1 {{__declspec attribute 'novtable'}}
+struct __declspec(uuid("---C000-0046")) 
__declspec(novtable)
+IUnknown {
+public:
+  virtual HRESULT __stdcall QueryInterface(
+  const IID &riid,
+  void **ppvObject) = 0;
+
+  virtual ULONG __stdcall AddRef(void) = 0;
+
+  virtual ULONG __stdcall Release(void) = 0;
+
+  template 
+  HRESULT __stdcall QueryInterface(Q **pp) {
+return QueryInterface(__uuidof(Q), (void **)pp);
+  }
+};
+}
+}
+
+__interface ISfFileIOPropertyPage : public IUnknown{};
+

Propchange: cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp
--
svn:eol-style = native

Propchange: cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp
--
svn:keywords = Author Date Id Rev URL

Propchange: cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp
--
svn:mime-type = text/plain

Modified: cfe/trunk/test/SemaCXX/ms-iunknown.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ms-iunknown.cpp?rev=314557&r1=314556&r2=314557&view=diff
==
--- cfe/trunk/test/SemaCXX/ms-iunknown.cpp (original)
+++ cfe/trunk/test/SemaCXX/ms-iunknown.cpp Fri Sep 29 14:06:00 2017
@@ -2,7 +2,11 @@
 
 extern "C++" struct __declspec(uuid("---C000-0046")) 
IUnknown {
   void foo();
+  // 

r314558 - [PS4] Tidy up some debug-tuning v. triple decision-making.

2017-09-29 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Fri Sep 29 14:25:07 2017
New Revision: 314558

URL: http://llvm.org/viewvc/llvm-project?rev=314558&view=rev
Log:
[PS4] Tidy up some debug-tuning v. triple decision-making.

Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGenCXX/debug-info-anon-namespace.cpp
cfe/trunk/test/Driver/debug-options.c

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=314558&r1=314557&r2=314558&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Fri Sep 29 14:25:07 2017
@@ -200,6 +200,9 @@ def arange_sections : Flag<["-"], "arang
 def dwarf_ext_refs : Flag<["-"], "dwarf-ext-refs">,
   HelpText<"Generate debug info with external references to clang modules"
" or precompiled headers">;
+def dwarf_explicit_import : Flag<["-"], "dwarf-explicit-import">,
+  HelpText<"Generate explicit import from anonymous namespace to containing"
+   " scope">;
 def debug_forward_template_params : Flag<["-"], 
"debug-forward-template-params">,
   HelpText<"Emit complete descriptions of template parameters in forward"
" declarations">;

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=314558&r1=314557&r2=314558&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Sep 29 14:25:07 2017
@@ -2816,8 +2816,6 @@ static void RenderDebugOptions(const Too
ArgStringList &CmdArgs,
codegenoptions::DebugInfoKind &DebugInfoKind,
const Arg *&SplitDWARFArg) {
-  bool IsPS4CPU = T.isPS4CPU();
-
   if (Args.hasFlag(options::OPT_fdebug_info_for_profiling,
options::OPT_fno_debug_info_for_profiling, false))
 CmdArgs.push_back("-fdebug-info-for-profiling");
@@ -2900,13 +2898,14 @@ static void RenderDebugOptions(const Too
   // And we handle flag -grecord-gcc-switches later with DWARFDebugFlags.
   Args.ClaimAllArgs(options::OPT_g_flags_Group);
 
-  // Column info is included by default for everything except PS4 and CodeView.
+  // Column info is included by default for everything except SCE and CodeView.
   // Clang doesn't track end columns, just starting columns, which, in theory,
   // is fine for CodeView (and PDB).  In practice, however, the Microsoft
   // debuggers don't handle missing end columns well, so it's better not to
   // include any column info.
   if (Args.hasFlag(options::OPT_gcolumn_info, options::OPT_gno_column_info,
-   /*Default=*/ !IsPS4CPU && !(IsWindowsMSVC && EmitCodeView)))
+   /*Default=*/!(IsWindowsMSVC && EmitCodeView) &&
+   DebuggerTuning != llvm::DebuggerKind::SCE))
 CmdArgs.push_back("-dwarf-column-info");
 
   // FIXME: Move backend command line options to the module.
@@ -2957,8 +2956,9 @@ static void RenderDebugOptions(const Too
 
   // -gdwarf-aranges turns on the emission of the aranges section in the
   // backend.
-  // Always enabled on the PS4.
-  if (Args.hasArg(options::OPT_gdwarf_aranges) || IsPS4CPU) {
+  // Always enabled for SCE tuning.
+  if (Args.hasArg(options::OPT_gdwarf_aranges) ||
+  DebuggerTuning == llvm::DebuggerKind::SCE) {
 CmdArgs.push_back("-backend-option");
 CmdArgs.push_back("-generate-arange-section");
   }
@@ -2974,6 +2974,10 @@ static void RenderDebugOptions(const Too
   if (DebuggerTuning == llvm::DebuggerKind::SCE)
 CmdArgs.push_back("-debug-forward-template-params");
 
+  // Do we need to explicitly import anonymous namespaces into the parent 
scope?
+  if (DebuggerTuning == llvm::DebuggerKind::SCE)
+CmdArgs.push_back("-dwarf-explicit-import");
+
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D);
 }
 

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=314558&r1=314557&r2=314558&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Sep 29 14:25:07 2017
@@ -527,7 +527,7 @@ static bool ParseCodeGenArgs(CodeGenOpti
   Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file);
   Opts.SplitDwarfInlining = !Args.hasArg(OPT_fno_split_dwarf_inlining);
   Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs);
-  Opts.DebugExplicitImport = Triple.isPS4CPU();
+  Opts.DebugExplicitImport = Args.hasArg(OPT_dwarf_expli

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

2017-09-29 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis created this revision.

Also enable -no-pie on Gnu toolchain (previously available on Darwin only).

Non-PIE executables won't even start on recent Android, and DT_RPATH is ignored 
by the loader.


https://reviews.llvm.org/D38430

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/android-pie.c
  clang/test/Driver/fsanitize.c
  clang/test/Driver/linux-ld.c
  clang/test/Driver/pic.c
  clang/test/Driver/sanitizer-ld.c

Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -127,7 +127,7 @@
 //
 // CHECK-ASAN-ANDROID: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-ASAN-ANDROID-NOT: "-lc"
-// CHECK-ASAN-ANDROID: "-pie"
+// CHECK-ASAN-ANDROID-NOT: "-pie"
 // CHECK-ASAN-ANDROID-NOT: "-lpthread"
 // CHECK-ASAN-ANDROID: libclang_rt.asan-arm-android.so"
 // CHECK-ASAN-ANDROID-NOT: "-lpthread"
@@ -139,7 +139,7 @@
 //
 // CHECK-ASAN-ANDROID-X86: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-ASAN-ANDROID-X86-NOT: "-lc"
-// CHECK-ASAN-ANDROID-X86: "-pie"
+// CHECK-ASAN-ANDROID-X86-NOT: "-pie"
 // CHECK-ASAN-ANDROID-X86-NOT: "-lpthread"
 // CHECK-ASAN-ANDROID-X86: libclang_rt.asan-i686-android.so"
 // CHECK-ASAN-ANDROID-X86-NOT: "-lpthread"
Index: clang/test/Driver/pic.c
===
--- clang/test/Driver/pic.c
+++ clang/test/Driver/pic.c
@@ -251,17 +251,54 @@
 // RUN: %clang %s -target i386-pc-openbsd -no-pie -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-NOPIE-LD
 //
-// On Android PIC is enabled by default
+// On Android PIC is enabled by default, and PIE is enabled by default starting
+// with API16.
 // RUN: %clang -c %s -target i686-linux-android -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s -target i686-linux-android14 -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s -target i686-linux-android16 -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target i686-linux-android24 -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+//
 // RUN: %clang -c %s -target arm-linux-androideabi -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC1
+// RUN: %clang -c %s -target arm-linux-androideabi14 -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC1
+// RUN: %clang -c %s -target arm-linux-androideabi16 -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target arm-linux-androideabi24 -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+//
 // RUN: %clang -c %s -target mipsel-linux-android -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC1
-// RUN: %clang -c %s -target aarch64-linux-android -### 2>&1 \
+// RUN: %clang -c %s -target mipsel-linux-android14 -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC1
+// RUN: %clang -c %s -target mipsel-linux-android16 -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target mipsel-linux-android24 -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+//
+// 64-bit Android targets are always PIE.
+// RUN: %clang -c %s -target aarch64-linux-android -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target aarch64-linux-android24 -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
 // RUN: %clang -c %s -target arm64-linux-android -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIC1
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+//
+// Default value of PIE can be overwritten, even on 64-bit targets.
+// RUN: %clang -c %s -target arm-linux-androideabi -fPIE -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target i686-linux-android14 -fPIE -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target i686-linux-android16 -fno-PIE -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target aarch64-linux-android -fno-PIE -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target aarch64-linux-android24 -fno-PIE -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIC
 //
 // On Windows-X64 PIC is enabled by default
 // RUN: %clang -c %s -target x86_64-pc-windows-msvc18.0.0 -### 2>&1 \
Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1133,6 +1133,7 @@
 // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
 // RUN:   | FileCheck --check-prefix=CHECK-ANDROID %s
 // CHECK-ANDROID: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-ANDROID: "--enable-new-dtags"
 // CHECK-ANDROID: "{{.*}}{{/|

[PATCH] D38414: [clangd] simplify ClangdLSPServer by private-inheriting callback interfaces. NFC

2017-09-29 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM.

PS I actually remember arguing to keep those classes separate in the original 
review :-)


https://reviews.llvm.org/D38414



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


[PATCH] D38414: [clangd] simplify ClangdLSPServer by private-inheriting callback interfaces. NFC

2017-09-29 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdLSPServer.h:41
 private:
-  class LSPProtocolCallbacks;
-  class LSPDiagnosticsConsumer : public DiagnosticsConsumer {
-  public:
-LSPDiagnosticsConsumer(ClangdLSPServer &Server);
-
-virtual void
-onDiagnosticsReady(PathRef File,
-   Tagged> Diagnostics);
-
-  private:
-ClangdLSPServer &Server;
-  };
+  // DiagnosticsConsumer
+  virtual void

NIT: Missing full stop at the end of the comment.



Comment at: clangd/ClangdLSPServer.h:46
+
+  // ProtocolCallbacks
+  void onInitialize(StringRef ID, InitializeParams IP,

NIT: Missing full stop at the end of the comment.


https://reviews.llvm.org/D38414



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


[PATCH] D37970: [clangd] Added a command-line arg to mirror clangd input into a file.

2017-09-29 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Friendly ping.


https://reviews.llvm.org/D37970



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


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

2017-09-29 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Thanks for the patch, I'll take a closer look a bit later.
But just wanted to post one very important comment right away.




Comment at: clangd/ClangdUnit.h:268
+std::vector findDocumentHighlights(ParsedAST &AST, Position 
Pos,
+  clangd::Logger &Logger);
+  

Please `clang-format` the code on every submission!


https://reviews.llvm.org/D38425



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


[PATCH] D36915: [Sema] Diagnose local variables and parameters captured by lambda and block expressions in a default argument

2017-09-29 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

ping.

Any comments on this patch or alternate approaches?


https://reviews.llvm.org/D36915



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


[PATCH] D36918: [Sema] Take into account the current context when checking the accessibility of a member function pointer

2017-09-29 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

ping


https://reviews.llvm.org/D36918



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


[PATCH] D35715: Preserve typedef names in debug info for template type parameters

2017-09-29 Thread Paul Robinson via Phabricator via cfe-commits
probinson abandoned this revision.
probinson added a comment.

Abandoning.  This change is irrelevant to the SCE debugger, and while I believe 
it could be made more complete and better reflect the original source (which is 
what the DWARF spec says names should be), I do not have time to pursue it.

If somebody else feels moved to take it up, go ahead.


https://reviews.llvm.org/D35715



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


r314570 - Add a "vexing parse" warning for ambiguity between a variable declaration and a

2017-09-29 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Sep 29 16:57:25 2017
New Revision: 314570

URL: http://llvm.org/viewvc/llvm-project?rev=314570&view=rev
Log:
Add a "vexing parse" warning for ambiguity between a variable declaration and a
function-style cast.

This fires for cases such as

  T(x);

... where 'x' was previously declared and T is a type. This construct declares
a variable named 'x' rather than the (probably expected) interpretation of a
function-style cast of 'x' to T.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp
cfe/trunk/test/FixIt/fixit-vexing-parse.cpp
cfe/trunk/test/Parser/cxx0x-condition.cpp
cfe/trunk/test/Parser/cxx1z-class-template-argument-deduction.cpp
cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=314570&r1=314569&r2=314570&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Sep 29 16:57:25 
2017
@@ -295,8 +295,20 @@ def warn_empty_parens_are_function_decl
 def warn_parens_disambiguated_as_function_declaration : Warning<
   "parentheses were disambiguated as a function declaration">,
   InGroup;
+def warn_parens_disambiguated_as_variable_declaration : Warning<
+  "parentheses were disambiguated as redundant parentheses around declaration "
+  "of variable named %0">, InGroup;
+def warn_redundant_parens_around_declarator : Warning<
+  "redundant parentheses surrounding declarator">,
+  InGroup>, DefaultIgnore;
 def note_additional_parens_for_variable_declaration : Note<
   "add a pair of parentheses to declare a variable">;
+def note_raii_guard_add_name : Note<
+  "add a variable name to declare a %0 initialized with %1">;
+def note_function_style_cast_add_parentheses : Note<
+  "add enclosing parentheses to perform a function-style cast">;
+def note_remove_parens_for_variable_declaration : Note<
+  "remove parentheses to silence this warning">;
 def note_empty_parens_function_call : Note<
   "change this ',' to a ';' to call %0">;
 def note_empty_parens_default_ctor : Note<

Modified: cfe/trunk/include/clang/Sema/DeclSpec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=314570&r1=314569&r2=314570&view=diff
==
--- cfe/trunk/include/clang/Sema/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Sema/DeclSpec.h Fri Sep 29 16:57:25 2017
@@ -2301,6 +2301,42 @@ public:
 }
 llvm_unreachable("unknown context kind!");
   }
+
+  /// Determine whether this declaration appears in a context where an
+  /// expression could appear.
+  bool isExpressionContext() const {
+switch (Context) {
+case FileContext:
+case KNRTypeListContext:
+case MemberContext:
+case TypeNameContext: // FIXME: sizeof(...) permits an expression.
+case FunctionalCastContext:
+case AliasDeclContext:
+case AliasTemplateContext:
+case PrototypeContext:
+case LambdaExprParameterContext:
+case ObjCParameterContext:
+case ObjCResultContext:
+case TemplateParamContext:
+case CXXNewContext:
+case CXXCatchContext:
+case ObjCCatchContext:
+case BlockLiteralContext:
+case LambdaExprContext:
+case ConversionIdContext:
+case TrailingReturnContext:
+  return false;
+
+case BlockContext:
+case ForContext:
+case InitStmtContext:
+case ConditionContext:
+case TemplateTypeArgContext:
+  return true;
+}
+
+llvm_unreachable("unknown context kind!");
+  }
   
   /// \brief Return true if a function declarator at this position would be a
   /// function declaration.

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=314570&r1=314569&r2=314570&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Fri Sep 29 16:57:25 2017
@@ -3065,6 +3065,7 @@ static void warnAboutAmbiguousFunction(S
 S.Diag(D.getCommaLoc(), diag::note_empty_parens_function_call)
   << FixItHint::CreateReplacement(D.getCommaLoc(), ";")
   << D.getIdentifier();
+  Result.suppressDiagnostics();
 }
   }
 
@@ -3106,6 +3107,99 @@ static void warnAboutAmbiguousFunction(S
   }
 }
 
+/// Produce an appropriate diagnostic for a declarator with top-level
+/// parentheses.
+static void warnAboutRedundantParens(Sema &S, Declarator &D, QualType T) {
+  DeclaratorChunk &Paren = D.getTypeObject(D.getNumTypeObjects() - 1);
+  assert(Paren.Kind == Declara

r314571 - [Analyzer] Synthesize function body for std::call_once

2017-09-29 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Fri Sep 29 17:03:22 2017
New Revision: 314571

URL: http://llvm.org/viewvc/llvm-project?rev=314571&view=rev
Log:
[Analyzer] Synthesize function body for std::call_once

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

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

Modified: cfe/trunk/lib/Analysis/BodyFarm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BodyFarm.cpp?rev=314571&r1=314570&r2=314571&view=diff
==
--- cfe/trunk/lib/Analysis/BodyFarm.cpp (original)
+++ cfe/trunk/lib/Analysis/BodyFarm.cpp Fri Sep 29 17:03:22 2017
@@ -14,11 +14,18 @@
 
 #include "BodyFarm.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/CXXInheritance.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprObjC.h"
+#include "clang/AST/NestedNameSpecifier.h"
 #include "clang/Analysis/CodeInjector.h"
+#include "clang/Basic/OperatorKinds.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/Debug.h"
+
+#define DEBUG_TYPE "body-farm"
 
 using namespace clang;
 
@@ -55,7 +62,9 @@ public:
   CompoundStmt *makeCompound(ArrayRef);
   
   /// Create a new DeclRefExpr for the referenced variable.
-  DeclRefExpr *makeDeclRefExpr(const VarDecl *D);
+  DeclRefExpr *makeDeclRefExpr(const VarDecl *D,
+   bool RefersToEnclosingVariableOrCapture = false,
+   bool GetNonReferenceType = false);
   
   /// Create a new UnaryOperator representing a dereference.
   UnaryOperator *makeDereference(const Expr *Arg, QualType Ty);
@@ -66,9 +75,24 @@ public:
   /// Create an implicit cast to a builtin boolean type.
   ImplicitCastExpr *makeIntegralCastToBoolean(const Expr *Arg);
   
-  // Create an implicit cast for lvalue-to-rvaluate conversions.
+  /// Create an implicit cast for lvalue-to-rvaluate conversions.
   ImplicitCastExpr *makeLvalueToRvalue(const Expr *Arg, QualType Ty);
   
+  /// Create an implicit cast for lvalue-to-rvaluate conversions.
+  ImplicitCastExpr *makeLvalueToRvalue(const Expr *Arg,
+   bool GetNonReferenceType = false);
+
+  /// Make RValue out of variable declaration, creating a temporary
+  /// DeclRefExpr in the process.
+  ImplicitCastExpr *
+  makeLvalueToRvalue(const VarDecl *Decl,
+ bool RefersToEnclosingVariableOrCapture = false,
+ bool GetNonReferenceType = false);
+
+  /// Create an implicit cast of the given type.
+  ImplicitCastExpr *makeImplicitCast(const Expr *Arg, QualType Ty,
+ CastKind CK = CK_LValueToRValue);
+
   /// Create an Objective-C bool literal.
   ObjCBoolLiteralExpr *makeObjCBool(bool Val);
 
@@ -78,6 +102,18 @@ public:
   /// Create a Return statement.
   ReturnStmt *makeReturn(const Expr *RetVal);
   
+  /// Create an integer literal.
+  IntegerLiteral *makeIntegerLiteral(uint64_t value);
+
+  /// Create a member expression.
+  MemberExpr *makeMemberExpression(Expr *base, ValueDecl *MemberDecl,
+   bool IsArrow = false,
+   ExprValueKind ValueKind = VK_LValue);
+
+  /// Returns a *first* member field of a record declaration with a given name.
+  /// \return an nullptr if no member with such a name exists.
+  NamedDecl *findMemberField(const CXXRecordDecl *RD, StringRef Name);
+
 private:
   ASTContext &C;
 };
@@ -106,16 +142,16 @@ CompoundStmt *ASTMaker::makeCompound(Arr
   return new (C) CompoundStmt(C, Stmts, SourceLocation(), SourceLocation());
 }
 
-DeclRefExpr *ASTMaker::makeDeclRefExpr(const VarDecl *D) {
-  DeclRefExpr *DR =
-DeclRefExpr::Create(/* Ctx = */ C,
-/* QualifierLoc = */ NestedNameSpecifierLoc(),
-/* TemplateKWLoc = */ SourceLocation(),
-/* D = */ const_cast(D),
-/* RefersToEnclosingVariableOrCapture = */ false,
-/* NameLoc = */ SourceLocation(),
-/* T = */ D->getType(),
-/* VK = */ VK_LValue);
+DeclRefExpr *ASTMaker::makeDeclRefExpr(const VarDecl *D,
+   bool RefersToEnclosingVariableOrCapture,
+   bool GetNonReferenceType) {
+  auto Type = D->getType();
+  if (GetNonReferenceType)
+Type = Type.getNonReferenceType();
+
+  DeclRefExpr *DR = DeclRefExpr::Create(
+  C, NestedNameSpecifierLoc(), SourceLocation(), const_cast(D),
+  RefersToEnclosingVariableOrCapture, SourceLocation(), Type, VK_LValue);
   return DR;
 }
 
@@ -125,8 +161,38 @@ UnaryOperator *ASTMaker::makeDereference
 }
 
 ImplicitCastExpr *ASTMaker::makeLvalueToRvalue(const Expr *Arg, QualType Ty) {
-  return ImplicitCastExpr::Create(C, Ty, CK_LValueToRValue,
- 

r314572 - [Analyzer] Add nullability to the list of tested checkers in SATestBuild

2017-09-29 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Fri Sep 29 17:05:24 2017
New Revision: 314572

URL: http://llvm.org/viewvc/llvm-project?rev=314572&view=rev
Log:
[Analyzer] Add nullability to the list of tested checkers in SATestBuild

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

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

Modified: cfe/trunk/utils/analyzer/SATestBuild.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/SATestBuild.py?rev=314572&r1=314571&r2=314572&view=diff
==
--- cfe/trunk/utils/analyzer/SATestBuild.py (original)
+++ cfe/trunk/utils/analyzer/SATestBuild.py Fri Sep 29 17:05:24 2017
@@ -178,7 +178,18 @@ PatchfileName = "changes_for_analyzer.pa
 # The list of checkers used during analyzes.
 # Currently, consists of all the non-experimental checkers, plus a few alpha
 # checkers we don't want to regress on.
-Checkers="alpha.unix.SimpleStream,alpha.security.taint,cplusplus.NewDeleteLeaks,core,cplusplus,deadcode,security,unix,osx"
+Checkers=",".join([
+"alpha.unix.SimpleStream",
+"alpha.security.taint",
+"cplusplus.NewDeleteLeaks",
+"core",
+"cplusplus",
+"deadcode",
+"security",
+"unix",
+"osx",
+"nullability"
+])
 
 Verbose = 1
 


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


r314573 - [Analyzer] Document a gotcha: for C++ -analyze-function requires parameters in function name

2017-09-29 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Fri Sep 29 17:07:22 2017
New Revision: 314573

URL: http://llvm.org/viewvc/llvm-project?rev=314573&view=rev
Log:
[Analyzer] Document a gotcha: for C++ -analyze-function requires parameters in 
function name

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

Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/www/analyzer/checker_dev_manual.html

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=314573&r1=314572&r2=314573&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Fri Sep 29 17:07:22 2017
@@ -70,7 +70,7 @@ def analyzer_opt_analyze_nested_blocks :
 def analyzer_display_progress : Flag<["-"], "analyzer-display-progress">,
   HelpText<"Emit verbose output about the analyzer's progress">;
 def analyze_function : Separate<["-"], "analyze-function">,
-  HelpText<"Run analysis on specific function">;
+  HelpText<"Run analysis on specific function (for C++ include parameters in 
name)">;
 def analyze_function_EQ : Joined<["-"], "analyze-function=">, 
Alias;
 def analyzer_eagerly_assume : Flag<["-"], "analyzer-eagerly-assume">,
   HelpText<"Eagerly assume the truth/falseness of some symbolic constraints">;

Modified: cfe/trunk/www/analyzer/checker_dev_manual.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/analyzer/checker_dev_manual.html?rev=314573&r1=314572&r2=314573&view=diff
==
--- cfe/trunk/www/analyzer/checker_dev_manual.html (original)
+++ cfe/trunk/www/analyzer/checker_dev_manual.html Fri Sep 29 17:07:22 2017
@@ -575,8 +575,8 @@ execute a single checker:
 processing a large file use the  -analyzer-display-progress
 option.
 
-You can analyze a particular function within the file, which is often useful
-because the problem is always in a certain function:
+To selectively analyze only the given function, use the
+-analyze-function option:
 
 $ clang -cc1 -analyze -analyzer-checker=core test.c 
-analyzer-display-progress
 ANALYZE (Syntax): test.c foo
@@ -588,6 +588,16 @@ because the problem is always in a certa
 ANALYZE (Path,  Inline_Regular): test.c foo
 
 
+Note:  a fully qualified function name has to be used when selecting
+C++ functions and methods, Objective-C methods and blocks, e.g.:
+
+
+$ clang -cc1 -analyze -analyzer-checker=core test.cc 
-analyze-function=foo(int)
+
+
+The fully qualified name can be found from the
+-analyzer-display-progress output.
+
 The bug reporter mechanism removes path diagnostics inside intermediate
 function calls that have returned by the time the bug was found and contain
 no interesting pieces. Usually it is up to the checkers to produce more


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


[PATCH] D37478: [analyzer] Implement pointer arithmetic on constants

2017-09-29 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin requested changes to this revision.
dcoughlin added a subscriber: zaks.anna.
dcoughlin added a comment.
This revision now requires changes to proceed.

Rafael: Thanks for the patch! @NoQ, @zaks.anna, and I spoke about this off-line 
yesterday.

While this patch improves the modeling of pointer arithmetic, we're worried 
about losing valuable alarms that rely on the existing behavior.

Here is a case where the analyzer would warn before your patch but doesn't with 
it:

  void foo() {
int *p = 0;
int q = *(p + 5); // expected-warning {{Dereference of null pointer}}
  }

The existing diagnostic machinery relies on the fact that the analyzer treats 
`p + 5` as 0 to report the bad dereference. This comes up more often than you 
might think because the analyzer is sometimes quite aggressive about promoting 
a symbol constrained to 0 to be a concrete value of 0. For example:

  void bar(int *p) {
if (p)
  return;
  
int q = *(p + 5); // expected-warning {{Dereference of null pointer}}
  }

It would be good to add test cases for these diagnostics!

I think you can preserve the existing (although missing from the test suite) 
good diagnostics and still improve the modeling by skipping the 
addition/subtraction if the LHS is a concrete int with value 0. Doing so would 
be a very minor change to this patch.

Modeling the pointer arithmetic when the LHS is 0 while still keeping the 
diagnostics will likely be a more involved effort, with ramifications in 
multiple parts of the analyzer. We could discuss that, if you'd like to tackle 
it! But it would probably be good for you to get a couple more patches under 
your belt before taking that on.




Comment at: test/Analysis/inlining/inline-defensive-checks.c:144
+
+// Intuitively the following tests should all warn about a null dereference,
+// since the object pointer the operations are based on can be null.

The analyzer doesn't warn on these on purpose.

Throughout the analyzer, we have a broad heuristic that says: "if the 
programmer compares a pointer to NULL, then the analyzer should explicitly 
consider the case that the pointer is NULL". It will perform a case split in 
the symbolic execution: one case for when the value is definitely NULL and one 
case for one it is definitely not NULL. As a heuristic this works reasonably 
well: if the programmer bothered to add a check for NULL then they likely 
though the value could be NULL.

However, when context-sensitive analysis via inlining was added, this heuristic 
broke down for functions that called other functions with what we call "inlined 
defensive checks" or null.

Here is an example:

```
void hasInlinedDefensiveCheck(int *p) {
  if (!p)
return;

  // Do something useful
}

void foo(int *param) {
  hasInlinedDefensiveCheck(param);
  
  *param = 7;
}
```

In this case the warning about `*param = 7` is a false positive from foo's 
point of view because foo may have a strong invariant that param is not null; 
it doesn't care that hasInlinedDefensiveCheck() may have other callers that 
might call it with null. For this reason, we suppress reports about null 
pointer dereferences when we can detect an inlined defense check.



https://reviews.llvm.org/D37478



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


[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas

2017-09-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

A couple of remaining pieces that I think are missing:

- Tests for instantiation of templates containing one of these lambdas. I would 
expect you'll find you need to change Sema/TreeTransform.h to make that work.
- Updates to Itanium mangling (AST/ItaniumMangle.cpp) for the mangling changes 
described in https://github.com/itanium-cxx-abi/cxx-abi/issues/31




Comment at: lib/Parse/ParseExprCXX.cpp:1117
+/*EnteredScope=*/HasExplicitTemplateParams);
+  if (HasExplicitTemplateParams) {
+SmallVector TemplateParams;

Please add a pre-C++2a-compat warning along this code path, and permit this in 
pre-C++2a modes with an extension warning. (You can look at other C++2a 
features for examples of how to do this.)



Comment at: lib/Parse/ParseExprCXX.cpp:1151-1165
+  // Record the template parameter depth for auto parameters.
+  // Subtract 1 from the current depth if we've parsed an explicit template
+  // parameter list, because that will have increased the depth.
+  Actions.RecordParsingTemplateParameterDepth(HasExplicitTemplateParams
+? TemplateParameterDepth - 
1
+: TemplateParameterDepth);
+

This handling of the template depth is more subtle / error-prone than I'd like. 
Maybe you could add a `TemplateParameterDepthRAII::setAddedDepth(1)` to replace 
the conditional increment, and a 
`TemplateParameterDepthRAII::getOriginalDepth()` to replace the conditional 
subtraction of 1?



Comment at: lib/Sema/SemaLambda.cpp:484-490
+  assert(LSI->NumExplicitTemplateParams == 0
+ && "Already acted on explicit template parameters");
+  assert(LSI->TemplateParams.size() == 0
+ && "Explicit template parameters should come "
+"before invented (auto) ones");
+  assert(TParams.size() > 0
+ && "No template parameters to act on");

Please put the `&&` on the previous line.


https://reviews.llvm.org/D36527



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


r314580 - [Analyzer] Add dummy implementation to call_once to avoid linkage warnings in tests.

2017-09-29 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Fri Sep 29 18:15:35 2017
New Revision: 314580

URL: http://llvm.org/viewvc/llvm-project?rev=314580&view=rev
Log:
[Analyzer] Add dummy implementation to call_once to avoid linkage warnings in 
tests.

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

Modified: cfe/trunk/test/Analysis/call_once.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/call_once.cpp?rev=314580&r1=314579&r2=314580&view=diff
==
--- cfe/trunk/test/Analysis/call_once.cpp (original)
+++ cfe/trunk/test/Analysis/call_once.cpp Fri Sep 29 18:15:35 2017
@@ -9,7 +9,7 @@ typedef struct once_flag_s {
 } once_flag;
 
 template 
-void call_once(once_flag &o, Callable func, Args... args);
+void call_once(once_flag &o, Callable func, Args... args) {};
 } // namespace std
 
 // Check with Lambdas.
@@ -115,9 +115,9 @@ template 
 class function; // undefined
 template 
 struct function<_Rp(_ArgTypes...)> {
-  _Rp operator()(_ArgTypes...) const;
+  _Rp operator()(_ArgTypes...) const {};
   template 
-  function(_Fp);
+  function(_Fp) {};
 };
 
 // Note: currently we do not support calls to std::function,


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


[PATCH] D37624: add support for -fno-instrument-functions and -finstrument-functions-exclude-{file, function}-list= to match gcc options.

2017-09-29 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

Please also add a C++ test to check the mangling-related features.




Comment at: lib/CodeGen/CodeGenFunction.cpp:419
+// Assume that __cxa_demangle is provided by libcxxabi (except for Windows).
+extern "C" char *__cxa_demangle(const char *mangled_name, char *output_buffer,
+size_t *length, int *status);

Using the system demangler here seems like the wrong solution. You have the 
current function declaration, `CurFuncDecl`, and from it you should be able to 
extract the full name.

I think that this will do it:

  std::string FullFuncName = PredefinedExpr::ComputeName(
  PredefinedExpr::PrettyFunctionNoVirtual, CurFuncDecl);




Comment at: lib/CodeGen/CodeGenModule.cpp:4601
+CodeGenModule::GetSourceLocToFileNameMap() {
+  return SourceLocToFileNameMap;
+}

Make this function inline in the class definition.


https://reviews.llvm.org/D37624



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


r314581 - [ODRHash] Add base classes to hashing CXXRecordDecl.

2017-09-29 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Sep 29 19:19:17 2017
New Revision: 314581

URL: http://llvm.org/viewvc/llvm-project?rev=314581&view=rev
Log:
[ODRHash] Add base classes to hashing CXXRecordDecl.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=314581&r1=314580&r2=314581&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Fri Sep 29 
19:19:17 2017
@@ -122,6 +122,27 @@ def note_second_module_difference : Note
 def err_module_odr_violation_different_instantiations : Error<
   "instantiation of %q0 is different in different modules">;
 
+def err_module_odr_violation_definition_data : Error <
+  "%q0 has different definitions in different modules; first difference is "
+  "%select{definition in module '%2'|defined here}1 found "
+  "%select{"
+  "%4 base %plural{1:class|:classes}4|"
+  "%4 virtual base %plural{1:class|:classes}4|"
+  "%ordinal4 base class with type %5|"
+  "%ordinal4 %select{non-virtual|virtual}5 base class %6|"
+  "%ordinal4 base class %5 with "
+  "%select{public|protected|private|no}6 access specifier}3">;
+
+def note_module_odr_violation_definition_data : Note <
+  "but in '%0' found "
+  "%select{"
+  "%2 base %plural{1:class|:classes}2|"
+  "%2 virtual base %plural{1:class|:classes}2|"
+  "%ordinal2 base class with different type %3|"
+  "%ordinal2 %select{non-virtual|virtual}3 base class %4|"
+  "%ordinal2 base class %3 with "
+  "%select{public|protected|private|no}4 access specifier}1">;
+
 def err_module_odr_violation_template_parameter : Error <
   "%q0 has different definitions in different modules; first difference is "
   "%select{definition in module '%2'|defined here}1 found "

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=314581&r1=314580&r2=314581&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Fri Sep 29 19:19:17 2017
@@ -1043,8 +1043,11 @@ private:
   /// once recursing loading has been completed.
   llvm::SmallVector PendingOdrMergeChecks;
 
+  using DataPointers =
+  std::pair;
+
   /// \brief Record definitions in which we found an ODR violation.
-  llvm::SmallDenseMap, 2>
+  llvm::SmallDenseMap, 2>
   PendingOdrMergeFailures;
 
   /// \brief DeclContexts in which we have diagnosed an ODR violation.

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=314581&r1=314580&r2=314581&view=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Sep 29 19:19:17 2017
@@ -456,6 +456,14 @@ void ODRHash::AddCXXRecordDecl(const CXX
   if (TD) {
 AddTemplateParameterList(TD->getTemplateParameters());
   }
+
+  ID.AddInteger(Record->getNumBases());
+  auto Bases = Record->bases();
+  for (auto Base : Bases) {
+AddQualType(Base.getType());
+ID.AddInteger(Base.isVirtual());
+ID.AddInteger(Base.getAccessSpecifierAsWritten());
+  }
 }
 
 void ODRHash::AddDecl(const Decl *D) {

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=314581&r1=314580&r2=314581&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Sep 29 19:19:17 2017
@@ -9190,7 +9190,8 @@ void ASTReader::diagnoseOdrViolations()
 Merge.first->decls_begin();
 Merge.first->bases_begin();
 Merge.first->vbases_begin();
-for (auto *RD : Merge.second) {
+for (auto &RecordPair : Merge.second) {
+  auto *RD = RecordPair.first;
   RD->decls_begin();
   RD->bases_begin();
   RD->vbases_begin();
@@ -9296,13 +9297,132 @@ void ASTReader::diagnoseOdrViolations()
 bool Diagnosed = false;
 CXXRecordDecl *FirstRecord = Merge.first;
 std::string FirstModule = getOwningModuleNameForDiagnostic(FirstRecord);
-for (CXXRecordDecl *SecondRecord : Merge.second) {
+for (auto &RecordPair : Merge.second) {
+  CXXRecordDecl *SecondRecord = RecordPair.first;
   // Multiple different declarations got merged together; te

[PATCH] D38404: [CodeGen] Do not refer to complete TBAA info where we actually deal with just TBAA access types

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

LGTM.


Repository:
  rL LLVM

https://reviews.llvm.org/D38404



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


[PATCH] D38408: [CodeGen] Have a special function to get TBAA info for may-alias accesses

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

LGTM.


Repository:
  rL LLVM

https://reviews.llvm.org/D38408



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


Buildbot numbers for the week of 09/03/2017 - 09/09/2017

2017-09-29 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 09/03/2017 - 09/09/2017.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:

 buildername | was_red
-+-
 clang-s390x-linux-lnt   | 96:22:57
 llvm-mips-linux | 87:07:26
 clang-ppc64be-linux-multistage  | 86:13:04
 clang-ppc64be-linux-lnt | 85:19:29
 clang-ppc64be-linux | 85:17:30
 clang-s390x-linux   | 85:09:14
 reverse-iteration   | 72:01:21
 perf-x86_64-penryn-O3-polly-fast| 59:07:55
 perf-x86_64-penryn-O3-polly | 58:04:43
 sanitizer-x86_64-linux-fast | 40:08:18
 sanitizer-x86_64-linux-bootstrap| 39:36:59
 ubuntu-gcc7.1-werror| 26:34:15
 libcxx-libcxxabi-singlethreaded-x86_64-linux-debian | 24:51:06
 libcxx-libcxxabi-x86_64-linux-debian-noexceptions   | 24:32:30
 libcxx-libcxxabi-libunwind-x86_64-linux-debian  | 24:14:11
 libcxx-libcxxabi-x86_64-linux-debian| 23:58:11
 llvm-clang-x86_64-expensive-checks-win  | 17:18:19
 clang-x86-windows-msvc2015  | 16:40:52
 clang-x64-ninja-win7| 16:37:36
 clang-with-thin-lto-windows | 16:24:57
 clang-cmake-aarch64-full| 12:37:44
 clang-cmake-aarch64-quick   | 08:38:36
 clang-lld-x86_64-2stage | 06:01:58
 polly-amd64-linux   | 05:29:44
 clang-cmake-armv7-a15-selfhost  | 05:00:13
 clang-x86_64-debian-fast| 04:19:21
 clang-ppc64le-linux-multistage  | 03:37:01
 clang-cmake-aarch64-global-isel | 03:33:00
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast| 03:10:27
 clang-cmake-aarch64-lld | 03:07:39
 sanitizer-x86_64-linux-autoconf | 03:01:08
 libcxx-libcxxabi-libunwind-arm-linux| 02:59:25
 sanitizer-ppc64le-linux | 02:45:58
 clang-ppc64le-linux-lnt | 02:44:36
 clang-x86_64-linux-abi-test | 02:39:32
 lldb-x86_64-darwin-13.4 | 02:13:20
 sanitizer-ppc64be-linux | 02:12:57
 clang-with-lto-ubuntu   | 02:06:39
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03  | 01:56:50
 clang-with-thin-lto-ubuntu  | 01:51:03
 clang-cmake-x86_64-avx2-linux   | 01:49:23
 clang-x86_64-linux-selfhost-modules | 01:46:33
 clang-x86_64-linux-selfhost-modules-2   | 01:43:53
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx1z-32bit| 01:39:55
 clang-cuda-build| 01:37:11
 clang-ppc64le-linux | 01:35:39
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast  | 01:35:21
 clang-atom-d525-fedora-rel  | 01:35:12
 sanitizer-x86_64-linux  | 01:33:19
 clang-native-arm-lnt| 01:33:01
 clang-cmake-x86_64-sde-avx512-linux | 01:31:53
 clang-cmake-thumbv7-a15 | 01:20:51
 sanitizer-x86_64-linux-android  | 01:16:15
 lldb-amd64-ninja-netbsd8| 01:13:56
 clang-cmake-x86_64-avx2-linux-perf  | 01:11:23
 clang-hexagon-elf   | 01:11:23
 clang-cmake-armv7-a15-full  | 01:09:21
 lldb-x86_64-ubuntu-14.04-buildserver| 01:08:55
 lld-x86_64-darwin13 | 01:07:27
 lldb-x86_64-ubuntu-14.04-cmake  | 01:05:45
 sanitizer-x86_64-linux-fuzzer   | 00:55:59
 lldb-x86_64-ubuntu-14.04-android| 00:54:55
 clang-cmake-armv7-a15   | 00:32:13
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan   | 00:31:16
 lldb-amd64-ninja-freebsd11  | 00:23:03
 lld-x86_64-freebsd  | 00:13:46
 sanitizer-windows 

Buildbot numbers for the week of 09/10/2017 - 09/16/2017

2017-09-29 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 09/10/2017 - 09/16/2017.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:

buildername| was_red
---+-
 lld-x86_64-freebsd| 77:38:11
 clang-cuda-build  | 72:56:52
 lldb-windows7-android | 66:57:22
 clang-with-lto-ubuntu | 65:59:18
 clang-ppc64le-linux-lnt   | 64:29:58
 llvm-clang-lld-x86_64-debian-fast | 63:49:23
 clang-x64-ninja-win7  | 52:11:20
 clang-ppc64be-linux-lnt   | 49:14:32
 llvm-mips-linux   | 48:10:18
 clang-ppc64be-linux   | 47:06:24
 clang-ppc64be-linux-multistage| 45:46:21
 clang-with-thin-lto-ubuntu| 42:11:36
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast| 31:35:29
 sanitizer-x86_64-linux-fast   | 25:01:14
 reverse-iteration | 24:10:32
 lldb-amd64-ninja-netbsd8  | 22:55:55
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast  | 21:46:04
 libcxx-libcxxabi-x86_64-linux-debian  | 20:27:42
 libcxx-libcxxabi-libunwind-x86_64-linux-debian| 20:18:42
 sanitizer-x86_64-linux-bootstrap  | 16:25:47
 perf-x86_64-penryn-O3-polly-detect-only   | 14:34:58
 perf-x86_64-penryn-O3 | 14:14:57
 clang-x86_64-linux-selfhost-modules-2 | 13:36:45
 perf-x86_64-penryn-O3-polly   | 13:19:43
 clang-cmake-x86_64-sde-avx512-linux   | 13:17:40
 clang-x86-windows-msvc2015| 13:13:48
 llvm-clang-x86_64-expensive-checks-win| 13:04:58
 clang-cmake-x86_64-avx2-linux | 12:58:45
 clang-cmake-x86_64-avx2-linux-perf| 12:57:46
 clang-cmake-armv7-a15-selfhost-neon   | 11:51:13
 libcxx-libcxxabi-x86_64-linux-debian-noexceptions | 11:26:49
 sanitizer-ppc64be-linux   | 11:10:28
 sanitizer-x86_64-linux| 10:15:05
 sanitizer-x86_64-linux-android| 09:44:37
 clang-cmake-armv7-a15-selfhost| 09:31:35
 clang-lld-x86_64-2stage   | 08:20:55
 perf-x86_64-penryn-O3-polly-fast  | 07:39:33
 sanitizer-x86_64-linux-autoconf   | 06:32:19
 libcxx-libcxxabi-libunwind-arm-linux-noexceptions | 05:55:01
 clang-x86_64-linux-selfhost-modules   | 05:20:30
 ubuntu-gcc7.1-werror  | 05:17:58
 libcxx-libcxxabi-libunwind-aarch64-linux  | 05:09:02
 clang-x86_64-linux-abi-test   | 05:04:51
 clang-cmake-aarch64-lld   | 04:59:45
 clang-cmake-aarch64-global-isel   | 04:41:28
 clang-with-thin-lto-windows   | 04:41:03
 clang-cmake-aarch64-full  | 04:00:30
 clang-x86_64-debian-fast  | 03:59:45
 sanitizer-windows | 03:40:31
 clang-ppc64le-linux-multistage| 03:25:12
 lldb-x86_64-ubuntu-14.04-cmake| 03:18:36
 lldb-x86_64-darwin-13.4   | 03:13:30
 clang-cmake-aarch64-quick | 03:03:39
 clang-native-arm-lnt  | 02:52:10
 lldb-x86_64-ubuntu-14.04-android  | 02:18:02
 clang-ppc64le-linux   | 02:06:17
 polly-amd64-linux | 02:00:44
 clang-s390x-linux | 01:54:43
 clang-atom-d525-fedora-rel| 01:52:21
 clang-s390x-linux-lnt | 01:47:11
 clang-cmake-armv7-a15 | 01:36:24
 clang-cmake-thumbv7-a15   | 01:36:19
 lldb-x86-windows-msvc2015 | 01:31:21
 clang-hexagon-elf | 01:09:53
 lldb-x86_64-ubuntu-14.04-buildserver  | 01:08:20
 sanitizer-x86_64-linux-fuzzer | 01:06:33
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03| 01:01:59
 llvm-hexagon-elf  | 01:00:17
 lld-x86_64-darwin13   

Buildbot numbers for the week of 09/17/2017 - 09/23/2017

2017-09-29 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 09/17/2017 -
09/23/2017.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:

  buildername  | was_red
---+-
 clang-s390x-linux-multistage  | 65:09:50
 clang-cmake-aarch64-global-isel   | 43:46:11
 clang-x86-windows-msvc2015| 42:27:37
 clang-cmake-armv7-a15-selfhost| 41:20:55
 clang-cuda-build  | 40:55:08
 clang-cmake-armv7-a15-selfhost-neon   | 37:36:22
 clang-ppc64le-linux-multistage| 37:19:48
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast| 36:01:53
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast  | 35:56:46
 clang-ppc64le-linux-lnt   | 35:31:01
 clang-atom-d525-fedora-rel| 34:51:34
 clang-cmake-x86_64-sde-avx512-linux   | 34:41:42
 sanitizer-windows | 34:39:52
 clang-x86_64-linux-selfhost-modules-2 | 34:39:01
 clang-ppc64le-linux   | 33:28:48
 clang-ppc64be-linux   | 32:04:32
 clang-s390x-linux | 27:40:10
 lldb-x86_64-darwin-13.4   | 27:33:10
 lldb-windows7-android | 27:15:05
 clang-ppc64be-linux-lnt   | 27:02:19
 lldb-x86_64-ubuntu-14.04-android  | 26:37:13
 llvm-mips-linux   | 26:34:19
 clang-s390x-linux-lnt | 26:23:34
 clang-with-lto-ubuntu | 25:31:49
 clang-ppc64be-linux-multistage| 25:17:55
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan | 25:03:31
 libcxx-libcxxabi-libunwind-aarch64-linux  | 18:19:23
 ubuntu-gcc7.1-werror  | 17:42:44
 lldb-x86_64-ubuntu-14.04-cmake| 15:50:29
 sanitizer-ppc64be-linux   | 14:46:46
 sanitizer-x86_64-linux| 13:58:07
 clang-with-thin-lto-ubuntu| 13:39:30
 clang-x86_64-linux-selfhost-modules   | 13:10:13
 clang-lld-x86_64-2stage   | 12:01:51
 clang-cmake-aarch64-lld   | 11:12:46
 sanitizer-x86_64-linux-bootstrap  | 11:11:32
 sanitizer-x86_64-linux-fast   | 09:51:43
 llvm-clang-lld-x86_64-debian-fast | 07:33:04
 clang-cmake-armv7-a15 | 07:17:37
 clang-cmake-thumbv7-a15   | 07:17:34
 polly-amd64-linux | 07:11:53
 clang-cmake-x86_64-avx2-linux | 06:50:06
 perf-x86_64-penryn-O3-polly-detect-only   | 06:48:48
 llvm-clang-x86_64-expensive-checks-win| 06:47:03
 llvm-hexagon-elf  | 06:46:59
 clang-x86_64-debian-fast  | 06:46:59
 clang-x64-ninja-win7  | 06:45:57
 clang-hexagon-elf | 06:45:07
 clang-native-arm-lnt  | 06:42:10
 clang-cmake-aarch64-full  | 06:42:09
 clang-with-thin-lto-windows   | 06:29:55
 polly-arm-linux   | 06:29:54
 clang-cmake-x86_64-avx2-linux-perf| 06:04:57
 clang-cmake-aarch64-quick | 05:28:48
 libcxx-libcxxabi-libunwind-x86_64-linux-debian| 05:03:54
 sanitizer-x86_64-linux-autoconf   | 04:39:58
 lld-x86_64-darwin13   | 04:05:16
 lldb-x86_64-ubuntu-14.04-buildserver  | 02:15:56
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan| 01:35:39
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11| 01:27:11
 clang-x86_64-linux-abi-test   | 01:25:16
 lldb-x86-windows-msvc2015 | 01:23:50
 libcxx-libcxxabi-libunwind-arm-linux-noexceptions | 01:23:12
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14| 01:22:22
 lldb-amd6