[PATCH] D34972: [CodeGen] Propagate dllexport to thunks

2017-07-03 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.

Under Windows Itanium, we need to export virtual and non-virtual thunks
if the functions being thunked are exported. These thunks would
previously inherit their dllexport attribute from the declaration, but
r298330 changed declarations to not have dllexport attributes. We
therefore need to add the dllexport attribute to the definition
ourselves now. This is consistent with MinGW GCC's behavior.

This redoes r306770 but limits the logic to Itanium. MicrosoftCXXABI's
setThunkLinkage ensures that thunks aren't exported under that ABI, so
I'm handling this in ItaniumCXXABI's setThunkLinkage for symmetry.


https://reviews.llvm.org/D34972

Files:
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/dllexport-vtable-thunks.cpp


Index: test/CodeGenCXX/dllexport-vtable-thunks.cpp
===
--- /dev/null
+++ test/CodeGenCXX/dllexport-vtable-thunks.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -fdeclspec -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-windows-itanium -fdeclspec -emit-llvm -o - 
%s | FileCheck %s
+
+struct __declspec(dllexport) A {
+  virtual void m();
+};
+struct __declspec(dllexport) B {
+  virtual void m();
+};
+struct __declspec(dllexport) C : A, B {
+  virtual void m();
+};
+void C::m() {}
+// CHECK: define dllexport void @_ZThn8_N1C1mEv
+
+struct Base {
+  virtual void m();
+};
+struct __declspec(dllexport) Derived : virtual Base {
+  virtual void m();
+};
+void Derived::m() {}
+// CHECK: define dllexport void @_ZTv0_n24_N7Derived1mEv
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -284,6 +284,11 @@
 // linkage together with vtables when needed.
 if (ForVTable && !Thunk->hasLocalLinkage())
   Thunk->setLinkage(llvm::GlobalValue::AvailableExternallyLinkage);
+
+// Propagate dllexport storage.
+const CXXMethodDecl *MD = cast(GD.getDecl());
+if (MD->hasAttr())
+  Thunk->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
   }
 
   llvm::Value *performThisAdjustment(CodeGenFunction , Address This,


Index: test/CodeGenCXX/dllexport-vtable-thunks.cpp
===
--- /dev/null
+++ test/CodeGenCXX/dllexport-vtable-thunks.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -fdeclspec -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-windows-itanium -fdeclspec -emit-llvm -o - %s | FileCheck %s
+
+struct __declspec(dllexport) A {
+  virtual void m();
+};
+struct __declspec(dllexport) B {
+  virtual void m();
+};
+struct __declspec(dllexport) C : A, B {
+  virtual void m();
+};
+void C::m() {}
+// CHECK: define dllexport void @_ZThn8_N1C1mEv
+
+struct Base {
+  virtual void m();
+};
+struct __declspec(dllexport) Derived : virtual Base {
+  virtual void m();
+};
+void Derived::m() {}
+// CHECK: define dllexport void @_ZTv0_n24_N7Derived1mEv
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -284,6 +284,11 @@
 // linkage together with vtables when needed.
 if (ForVTable && !Thunk->hasLocalLinkage())
   Thunk->setLinkage(llvm::GlobalValue::AvailableExternallyLinkage);
+
+// Propagate dllexport storage.
+const CXXMethodDecl *MD = cast(GD.getDecl());
+if (MD->hasAttr())
+  Thunk->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
   }
 
   llvm::Value *performThisAdjustment(CodeGenFunction , Address This,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r307052 - [CodeGen] Check key function for typeinfo import

2017-07-03 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Mon Jul  3 18:02:19 2017
New Revision: 307052

URL: http://llvm.org/viewvc/llvm-project?rev=307052=rev
Log:
[CodeGen] Check key function for typeinfo import

If the imported class does not have a key function, we should emit its
typeinfo locally instead of attempting to import it.

Modified:
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGenCXX/windows-itanium-type-info.cpp

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=307052=307051=307052=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Mon Jul  3 18:02:19 2017
@@ -2732,7 +2732,9 @@ static bool ShouldUseExternalRTTIDescrip
 // function.
 bool IsDLLImport = RD->hasAttr();
 if (CGM.getVTables().isVTableExternal(RD))
-  return IsDLLImport ? false : true;
+  return IsDLLImport && !CGM.getTriple().isWindowsItaniumEnvironment()
+ ? false
+ : true;
 
 if (IsDLLImport)
   return true;
@@ -2968,7 +2970,8 @@ static llvm::GlobalVariable::LinkageType
   if (RD->hasAttr())
 return llvm::GlobalValue::WeakODRLinkage;
   if (CGM.getTriple().isWindowsItaniumEnvironment())
-if (RD->hasAttr())
+if (RD->hasAttr() &&
+ShouldUseExternalRTTIDescriptor(CGM, Ty))
   return llvm::GlobalValue::ExternalLinkage;
   if (RD->isDynamicClass()) {
 llvm::GlobalValue::LinkageTypes LT = CGM.getVTableLinkage(RD);
@@ -3181,7 +3184,8 @@ llvm::Constant *ItaniumRTTIBuilder::Buil
 if (DLLExport || (RD && RD->hasAttr())) {
   TypeName->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
   GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
-} else if (CGM.getLangOpts().RTTI && RD && RD->hasAttr()) {
+} else if (RD && RD->hasAttr() &&
+   ShouldUseExternalRTTIDescriptor(CGM, Ty)) {
   TypeName->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
   GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
 

Modified: cfe/trunk/test/CodeGenCXX/windows-itanium-type-info.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/windows-itanium-type-info.cpp?rev=307052=307051=307052=diff
==
--- cfe/trunk/test/CodeGenCXX/windows-itanium-type-info.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/windows-itanium-type-info.cpp Mon Jul  3 18:02:19 
2017
@@ -32,9 +32,15 @@ void f() {
 // CHECK-DAG: @_ZTV7derived = dllexport unnamed_addr constant
 
 // CHECK-DAG: @_ZTI4base = external dllimport constant
-// CHECK-DAG: @_ZTS4base = external dllimport constant
-// CHECK-NOT: @_ZTV4base = external dllimport constant
 
 // CHECK-EH-IMPORT: @_ZTS4base = linkonce_odr constant
 // CHECK-EH-IMPORT: @_ZTI4base = linkonce_odr constant
 
+struct __declspec(dllimport) gatekeeper {};
+struct zuul : gatekeeper {
+  virtual ~zuul();
+};
+zuul::~zuul() {}
+
+// CHECK-DAG: @_ZTI10gatekeeper = linkonce_odr constant
+// CHECK-DAG: @_ZTS10gatekeeper = linkonce_odr constant


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


[PATCH] D34568: [Sema] Make BreakContinueFinder handle nested loops.

2017-07-03 Thread Eli Friedman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL307051: [Sema] Make BreakContinueFinder handle nested loops. 
(authored by efriedma).

Changed prior to commit:
  https://reviews.llvm.org/D34568?vs=103761=105128#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34568

Files:
  cfe/trunk/lib/Sema/SemaStmt.cpp
  cfe/trunk/test/Sema/loop-control.c
  cfe/trunk/test/SemaCXX/warn-loop-analysis.cpp

Index: cfe/trunk/lib/Sema/SemaStmt.cpp
===
--- cfe/trunk/lib/Sema/SemaStmt.cpp
+++ cfe/trunk/lib/Sema/SemaStmt.cpp
@@ -1544,23 +1544,78 @@
 
   // A visitor to determine if a continue or break statement is a
   // subexpression.
-  class BreakContinueFinder : public EvaluatedExprVisitor {
+  class BreakContinueFinder : public ConstEvaluatedExprVisitor {
 SourceLocation BreakLoc;
 SourceLocation ContinueLoc;
+bool InSwitch = false;
+
   public:
-BreakContinueFinder(Sema , Stmt* Body) :
+BreakContinueFinder(Sema , const Stmt* Body) :
 Inherited(S.Context) {
   Visit(Body);
 }
 
-typedef EvaluatedExprVisitor Inherited;
+typedef ConstEvaluatedExprVisitor Inherited;
 
-void VisitContinueStmt(ContinueStmt* E) {
+void VisitContinueStmt(const ContinueStmt* E) {
   ContinueLoc = E->getContinueLoc();
 }
 
-void VisitBreakStmt(BreakStmt* E) {
-  BreakLoc = E->getBreakLoc();
+void VisitBreakStmt(const BreakStmt* E) {
+  if (!InSwitch)
+BreakLoc = E->getBreakLoc();
+}
+
+void VisitSwitchStmt(const SwitchStmt* S) {
+  if (const Stmt *Init = S->getInit())
+Visit(Init);
+  if (const Stmt *CondVar = S->getConditionVariableDeclStmt())
+Visit(CondVar);
+  if (const Stmt *Cond = S->getCond())
+Visit(Cond);
+
+  // Don't return break statements from the body of a switch.
+  InSwitch = true;
+  if (const Stmt *Body = S->getBody())
+Visit(Body);
+  InSwitch = false;
+}
+
+void VisitForStmt(const ForStmt *S) {
+  // Only visit the init statement of a for loop; the body
+  // has a different break/continue scope.
+  if (const Stmt *Init = S->getInit())
+Visit(Init);
+}
+
+void VisitWhileStmt(const WhileStmt *) {
+  // Do nothing; the children of a while loop have a different
+  // break/continue scope.
+}
+
+void VisitDoStmt(const DoStmt *) {
+  // Do nothing; the children of a while loop have a different
+  // break/continue scope.
+}
+
+void VisitCXXForRangeStmt(const CXXForRangeStmt *S) {
+  // Only visit the initialization of a for loop; the body
+  // has a different break/continue scope.
+  if (const Stmt *Range = S->getRangeStmt())
+Visit(Range);
+  if (const Stmt *Begin = S->getBeginStmt())
+Visit(Begin);
+  if (const Stmt *End = S->getEndStmt())
+Visit(End);
+}
+
+void VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S) {
+  // Only visit the initialization of a for loop; the body
+  // has a different break/continue scope.
+  if (const Stmt *Element = S->getElement())
+Visit(Element);
+  if (const Stmt *Collection = S->getCollection())
+Visit(Collection);
 }
 
 bool ContinueFound() { return ContinueLoc.isValid(); }
Index: cfe/trunk/test/SemaCXX/warn-loop-analysis.cpp
===
--- cfe/trunk/test/SemaCXX/warn-loop-analysis.cpp
+++ cfe/trunk/test/SemaCXX/warn-loop-analysis.cpp
@@ -202,6 +202,12 @@
 if (true) continue;
 i--;
   }
+
+  // But do warn if the continue is in a nested loop.
+  for (;;i--) { // expected-note{{decremented here}}
+for (int j = 0; j < 10; ++j) continue;
+i--; // expected-warning{{decremented both}}
+  }
 }
 
 struct iterator {
@@ -259,6 +265,12 @@
 if (true) continue;
 i--;
   }
+
+  // But do warn if the continue is in a nested loop.
+  for (;;i--) { // expected-note{{decremented here}}
+for (int j = 0; j < 10; ++j) continue;
+i--; // expected-warning{{decremented both}}
+  }
 }
 
 int f(int);
Index: cfe/trunk/test/Sema/loop-control.c
===
--- cfe/trunk/test/Sema/loop-control.c
+++ cfe/trunk/test/Sema/loop-control.c
@@ -119,3 +119,51 @@
 for ( ; ({ ++y; break; y;}); ++y) {} // expected-warning{{'break' is bound to loop, GCC binds it to switch}}
   }
 }
+
+void pr32648_1(int x, int y) {
+  switch(x) {
+  case 1:
+for ( ; ({ ++y; switch (y) { case 0: break; } y;}); ++y) {} // no warning
+  }
+}
+
+void pr32648_2(int x, int y) {
+  while(x) {
+for ( ; ({ ++y; switch (y) { case 0: continue; } y;}); ++y) {}  // expected-warning {{'continue' is bound to current loop, GCC binds it to the enclosing loop}}
+  }
+}
+
+void pr32648_3(int x, int y) {
+  switch(x) {
+  case 1:
+for ( ; ({ ++y; for (; y; y++) { break; } y;}); ++y) {} 

r307051 - [Sema] Make BreakContinueFinder handle nested loops.

2017-07-03 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Mon Jul  3 17:52:24 2017
New Revision: 307051

URL: http://llvm.org/viewvc/llvm-project?rev=307051=rev
Log:
[Sema] Make BreakContinueFinder handle nested loops.

We don't care about break or continue statements that aren't
associated with the current loop, so make sure the visitor
doesn't find them.

Fixes https://bugs.llvm.org/show_bug.cgi?id=32648 .

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


Modified:
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/Sema/loop-control.c
cfe/trunk/test/SemaCXX/warn-loop-analysis.cpp

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=307051=307050=307051=diff
==
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Mon Jul  3 17:52:24 2017
@@ -1544,23 +1544,78 @@ namespace {
 
   // A visitor to determine if a continue or break statement is a
   // subexpression.
-  class BreakContinueFinder : public EvaluatedExprVisitor 
{
+  class BreakContinueFinder : public 
ConstEvaluatedExprVisitor {
 SourceLocation BreakLoc;
 SourceLocation ContinueLoc;
+bool InSwitch = false;
+
   public:
-BreakContinueFinder(Sema , Stmt* Body) :
+BreakContinueFinder(Sema , const Stmt* Body) :
 Inherited(S.Context) {
   Visit(Body);
 }
 
-typedef EvaluatedExprVisitor Inherited;
+typedef ConstEvaluatedExprVisitor Inherited;
 
-void VisitContinueStmt(ContinueStmt* E) {
+void VisitContinueStmt(const ContinueStmt* E) {
   ContinueLoc = E->getContinueLoc();
 }
 
-void VisitBreakStmt(BreakStmt* E) {
-  BreakLoc = E->getBreakLoc();
+void VisitBreakStmt(const BreakStmt* E) {
+  if (!InSwitch)
+BreakLoc = E->getBreakLoc();
+}
+
+void VisitSwitchStmt(const SwitchStmt* S) {
+  if (const Stmt *Init = S->getInit())
+Visit(Init);
+  if (const Stmt *CondVar = S->getConditionVariableDeclStmt())
+Visit(CondVar);
+  if (const Stmt *Cond = S->getCond())
+Visit(Cond);
+
+  // Don't return break statements from the body of a switch.
+  InSwitch = true;
+  if (const Stmt *Body = S->getBody())
+Visit(Body);
+  InSwitch = false;
+}
+
+void VisitForStmt(const ForStmt *S) {
+  // Only visit the init statement of a for loop; the body
+  // has a different break/continue scope.
+  if (const Stmt *Init = S->getInit())
+Visit(Init);
+}
+
+void VisitWhileStmt(const WhileStmt *) {
+  // Do nothing; the children of a while loop have a different
+  // break/continue scope.
+}
+
+void VisitDoStmt(const DoStmt *) {
+  // Do nothing; the children of a while loop have a different
+  // break/continue scope.
+}
+
+void VisitCXXForRangeStmt(const CXXForRangeStmt *S) {
+  // Only visit the initialization of a for loop; the body
+  // has a different break/continue scope.
+  if (const Stmt *Range = S->getRangeStmt())
+Visit(Range);
+  if (const Stmt *Begin = S->getBeginStmt())
+Visit(Begin);
+  if (const Stmt *End = S->getEndStmt())
+Visit(End);
+}
+
+void VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S) {
+  // Only visit the initialization of a for loop; the body
+  // has a different break/continue scope.
+  if (const Stmt *Element = S->getElement())
+Visit(Element);
+  if (const Stmt *Collection = S->getCollection())
+Visit(Collection);
 }
 
 bool ContinueFound() { return ContinueLoc.isValid(); }

Modified: cfe/trunk/test/Sema/loop-control.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/loop-control.c?rev=307051=307050=307051=diff
==
--- cfe/trunk/test/Sema/loop-control.c (original)
+++ cfe/trunk/test/Sema/loop-control.c Mon Jul  3 17:52:24 2017
@@ -119,3 +119,51 @@ void pr8880_23(int x, int y) {
 for ( ; ({ ++y; break; y;}); ++y) {} // expected-warning{{'break' is bound 
to loop, GCC binds it to switch}}
   }
 }
+
+void pr32648_1(int x, int y) {
+  switch(x) {
+  case 1:
+for ( ; ({ ++y; switch (y) { case 0: break; } y;}); ++y) {} // no warning
+  }
+}
+
+void pr32648_2(int x, int y) {
+  while(x) {
+for ( ; ({ ++y; switch (y) { case 0: continue; } y;}); ++y) {}  // 
expected-warning {{'continue' is bound to current loop, GCC binds it to the 
enclosing loop}}
+  }
+}
+
+void pr32648_3(int x, int y) {
+  switch(x) {
+  case 1:
+for ( ; ({ ++y; for (; y; y++) { break; } y;}); ++y) {} // no warning
+  }
+}
+
+void pr32648_4(int x, int y) {
+  switch(x) {
+  case 1:
+for ( ; ({ ++y; for (({ break; }); y; y++) { } y;}); ++y) {} // 
expected-warning{{'break' is bound to loop, GCC binds it to switch}}
+  }
+}
+
+void pr32648_5(int x, int y) {
+  switch(x) {
+  case 1:
+for ( ; ({ ++y; while 

[PATCH] D34937: Suppressing Reference Counting Diagnostics for Functions Containing 'rc_ownership_trusted_implementation' Annotate Attribute

2017-07-03 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

This looks good! You will need to add tests though. I would suggest adding them 
to "test/Analysis/retain-release-inline.m"




Comment at: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp:1898
+bool
+isAnnotatedToSkipDiagnostics(const LocationContext *LCtx) {
+  while (LCtx) {

Naming-wise, I think it is probably better to describe the high-level semantics 
of this function rather than how it is intended to be used. I would suggest 
something like "isTrustedReferenceCountImplementation" for this function 
instead.

Also, let's break with tradition and add a doxygen style comment describing 
what the function does.


Repository:
  rL LLVM

https://reviews.llvm.org/D34937



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


[PATCH] D34770: [Bash-autocompletion] Auto complete cc1 options if -cc1 is specified

2017-07-03 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd accepted this revision.
compnerd added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Driver/Driver.cpp:1236
+// We want to show cc1-only options only when clang is invoked as "clang 
-cc1".
+// When clang is invoked as "clang -cc1", we add "#" to ther beginning of 
an --autocomplete
+// option so that the clang driver can distinguish whether it is requested 
to show cc1-only options or not.

Typo: `ther` -> `the`.



Comment at: clang/utils/bash-autocomplete.sh:16
+  if [[ "${COMP_WORDS[1]}" == "-cc1" || "$w1" == "-Xclang" ]]; then
+arg="#"
+  fi

`prefix` may be a better term?


https://reviews.llvm.org/D34770



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


[PATCH] D33102: [clang] Implement -Wcast-qual for C++

2017-07-03 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL307045: [clang] Implement -Wcast-qual for C++ (authored by 
lebedevri).

Changed prior to commit:
  https://reviews.llvm.org/D33102?vs=105103=105108#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33102

Files:
  cfe/trunk/docs/ReleaseNotes.rst
  cfe/trunk/lib/Sema/SemaCast.cpp
  cfe/trunk/test/Sema/warn-cast-qual.c
  cfe/trunk/test/SemaCXX/warn-cast-qual.cpp

Index: cfe/trunk/lib/Sema/SemaCast.cpp
===
--- cfe/trunk/lib/Sema/SemaCast.cpp
+++ cfe/trunk/lib/Sema/SemaCast.cpp
@@ -143,6 +143,9 @@
   };
 }
 
+static void DiagnoseCastQual(Sema , const ExprResult ,
+ QualType DestType);
+
 // The Try functions attempt a specific way of casting. If they succeed, they
 // return TC_Success. If their way of casting is not appropriate for the given
 // arguments, they return TC_NotApplicable and *may* set diag to a diagnostic
@@ -427,6 +430,10 @@
 /// the same kind of pointer (plain or to-member). Unlike the Sema function,
 /// this one doesn't care if the two pointers-to-member don't point into the
 /// same class. This is because CastsAwayConstness doesn't care.
+/// And additionally, it handles C++ references. If both the types are
+/// references, then their pointee types are returned,
+/// else if only one of them is reference, it's pointee type is returned,
+/// and the other type is returned as-is.
 static bool UnwrapDissimilarPointerTypes(QualType& T1, QualType& T2) {
   const PointerType *T1PtrType = T1->getAs(),
 *T2PtrType = T2->getAs();
@@ -475,6 +482,26 @@
 return true;
   }
   
+  const LValueReferenceType *T1RefType = T1->getAs(),
+*T2RefType = T2->getAs();
+  if (T1RefType && T2RefType) {
+T1 = T1RefType->getPointeeType();
+T2 = T2RefType->getPointeeType();
+return true;
+  }
+
+  if (T1RefType) {
+T1 = T1RefType->getPointeeType();
+// T2 = T2;
+return true;
+  }
+
+  if (T2RefType) {
+// T1 = T1;
+T2 = T2RefType->getPointeeType();
+return true;
+  }
+
   return false;
 }
 
@@ -503,11 +530,13 @@
   // the rules are non-trivial. So first we construct Tcv *...cv* as described
   // in C++ 5.2.11p8.
   assert((SrcType->isAnyPointerType() || SrcType->isMemberPointerType() ||
-  SrcType->isBlockPointerType()) &&
+  SrcType->isBlockPointerType() ||
+  DestType->isLValueReferenceType()) &&
  "Source type is not pointer or pointer to member.");
   assert((DestType->isAnyPointerType() || DestType->isMemberPointerType() ||
-  DestType->isBlockPointerType()) &&
- "Destination type is not pointer or pointer to member.");
+  DestType->isBlockPointerType() ||
+  DestType->isLValueReferenceType()) &&
+ "Destination type is not pointer or pointer to member, or reference.");
 
   QualType UnwrappedSrcType = Self.Context.getCanonicalType(SrcType), 
UnwrappedDestType = Self.Context.getCanonicalType(DestType);
@@ -2177,6 +2206,8 @@
 
 void CastOperation::CheckCXXCStyleCast(bool FunctionalStyle,
bool ListInitialization) {
+  assert(Self.getLangOpts().CPlusPlus);
+
   // Handle placeholders.
   if (isPlaceholder()) {
 // C-style casts can resolve __unknown_any types.
@@ -2580,30 +2611,42 @@
 
   if (Kind == CK_BitCast)
 checkCastAlign();
+}
+
+/// DiagnoseCastQual - Warn whenever casts discards a qualifiers, be it either
+/// const, volatile or both.
+static void DiagnoseCastQual(Sema , const ExprResult ,
+ QualType DestType) {
+  if (SrcExpr.isInvalid())
+return;
+
+  QualType SrcType = SrcExpr.get()->getType();
+  if (!((SrcType->isAnyPointerType() && DestType->isAnyPointerType()) ||
+DestType->isLValueReferenceType()))
+return;
 
-  // -Wcast-qual
   QualType TheOffendingSrcType, TheOffendingDestType;
   Qualifiers CastAwayQualifiers;
-  if (SrcType->isAnyPointerType() && DestType->isAnyPointerType() &&
-  CastsAwayConstness(Self, SrcType, DestType, true, false,
- , ,
- )) {
-int qualifiers = -1;
-if (CastAwayQualifiers.hasConst() && CastAwayQualifiers.hasVolatile()) {
-  qualifiers = 0;
-} else if (CastAwayQualifiers.hasConst()) {
-  qualifiers = 1;
-} else if (CastAwayQualifiers.hasVolatile()) {
-  qualifiers = 2;
-}
-// This is a variant of int **x; const int **y = (const int **)x;
-if (qualifiers == -1)
-  Self.Diag(SrcExpr.get()->getLocStart(), diag::warn_cast_qual2) <<
-SrcType << DestType;
-else
-  Self.Diag(SrcExpr.get()->getLocStart(), diag::warn_cast_qual) <<
-TheOffendingSrcType << TheOffendingDestType << qualifiers;
-  }
+  if (!CastsAwayConstness(Self, SrcType, DestType, true, false,
+  , ,
+  

r307045 - [clang] Implement -Wcast-qual for C++

2017-07-03 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Mon Jul  3 10:59:22 2017
New Revision: 307045

URL: http://llvm.org/viewvc/llvm-project?rev=307045=rev
Log:
[clang] Implement -Wcast-qual for C++

Summary:
This way, the behavior of that warning flag
more closely resembles that of GCC.

Do note that there is at least one false-negative (see FIXME in tests).

Fixes PR4802.

Testing:
```
ninja check-clang-sema check-clang-semacxx
```

Reviewers: dblaikie, majnemer, rnk

Reviewed By: dblaikie, rnk

Subscribers: mclow.lists, cfe-commits, alexfh, rnk

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

Added:
cfe/trunk/test/SemaCXX/warn-cast-qual.cpp
Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/test/Sema/warn-cast-qual.c

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=307045=307044=307045=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Mon Jul  3 10:59:22 2017
@@ -52,6 +52,9 @@ Major New Features
 Improvements to Clang's diagnostics
 ^^^
 
+-  -Wcast-qual was implemented for C++. C-style casts are now properly
+   diagnosed.
+
 -  -Wunused-lambda-capture warns when a variable explicitly captured
by a lambda is not used in the body of the lambda.
 

Modified: cfe/trunk/lib/Sema/SemaCast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=307045=307044=307045=diff
==
--- cfe/trunk/lib/Sema/SemaCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCast.cpp Mon Jul  3 10:59:22 2017
@@ -143,6 +143,9 @@ namespace {
   };
 }
 
+static void DiagnoseCastQual(Sema , const ExprResult ,
+ QualType DestType);
+
 // The Try functions attempt a specific way of casting. If they succeed, they
 // return TC_Success. If their way of casting is not appropriate for the given
 // arguments, they return TC_NotApplicable and *may* set diag to a diagnostic
@@ -427,6 +430,10 @@ static void diagnoseBadCast(Sema , uns
 /// the same kind of pointer (plain or to-member). Unlike the Sema function,
 /// this one doesn't care if the two pointers-to-member don't point into the
 /// same class. This is because CastsAwayConstness doesn't care.
+/// And additionally, it handles C++ references. If both the types are
+/// references, then their pointee types are returned,
+/// else if only one of them is reference, it's pointee type is returned,
+/// and the other type is returned as-is.
 static bool UnwrapDissimilarPointerTypes(QualType& T1, QualType& T2) {
   const PointerType *T1PtrType = T1->getAs(),
 *T2PtrType = T2->getAs();
@@ -475,6 +482,26 @@ static bool UnwrapDissimilarPointerTypes
 return true;
   }
   
+  const LValueReferenceType *T1RefType = T1->getAs(),
+*T2RefType = T2->getAs();
+  if (T1RefType && T2RefType) {
+T1 = T1RefType->getPointeeType();
+T2 = T2RefType->getPointeeType();
+return true;
+  }
+
+  if (T1RefType) {
+T1 = T1RefType->getPointeeType();
+// T2 = T2;
+return true;
+  }
+
+  if (T2RefType) {
+// T1 = T1;
+T2 = T2RefType->getPointeeType();
+return true;
+  }
+
   return false;
 }
 
@@ -503,11 +530,13 @@ CastsAwayConstness(Sema , QualType
   // the rules are non-trivial. So first we construct Tcv *...cv* as described
   // in C++ 5.2.11p8.
   assert((SrcType->isAnyPointerType() || SrcType->isMemberPointerType() ||
-  SrcType->isBlockPointerType()) &&
+  SrcType->isBlockPointerType() ||
+  DestType->isLValueReferenceType()) &&
  "Source type is not pointer or pointer to member.");
   assert((DestType->isAnyPointerType() || DestType->isMemberPointerType() ||
-  DestType->isBlockPointerType()) &&
- "Destination type is not pointer or pointer to member.");
+  DestType->isBlockPointerType() ||
+  DestType->isLValueReferenceType()) &&
+ "Destination type is not pointer or pointer to member, or 
reference.");
 
   QualType UnwrappedSrcType = Self.Context.getCanonicalType(SrcType), 
UnwrappedDestType = Self.Context.getCanonicalType(DestType);
@@ -2177,6 +2206,8 @@ static TryCastResult TryReinterpretCast(
 
 void CastOperation::CheckCXXCStyleCast(bool FunctionalStyle,
bool ListInitialization) {
+  assert(Self.getLangOpts().CPlusPlus);
+
   // Handle placeholders.
   if (isPlaceholder()) {
 // C-style casts can resolve __unknown_any types.
@@ -2580,30 +2611,42 @@ void CastOperation::CheckCStyleCast() {
 
   if (Kind == CK_BitCast)
 checkCastAlign();
+}
+
+/// DiagnoseCastQual - Warn whenever casts discards a qualifiers, be it either
+/// const, volatile or both.
+static void DiagnoseCastQual(Sema , const ExprResult ,
+

[PATCH] D34329: [clang-diff] Initial implementation.

2017-07-03 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes added a comment.

In https://reviews.llvm.org/D34329#798377, @arphaman wrote:

> @johannes 
>  Are you planning to work on integration with the `StmtDataCollector` in this 
> patch or would you prefer to follow-up with additional patches?


Later would be better


https://reviews.llvm.org/D34329



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


[PATCH] D33102: [clang] Implement -Wcast-qual for C++

2017-07-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 105103.
lebedev.ri added a comment.

Rebased before commit.


Repository:
  rL LLVM

https://reviews.llvm.org/D33102

Files:
  docs/ReleaseNotes.rst
  lib/Sema/SemaCast.cpp
  test/Sema/warn-cast-qual.c
  test/SemaCXX/warn-cast-qual.cpp

Index: test/SemaCXX/warn-cast-qual.cpp
===
--- /dev/null
+++ test/SemaCXX/warn-cast-qual.cpp
@@ -0,0 +1,140 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -Wcast-qual -verify %s
+
+#include 
+
+// do *NOT* warn on const_cast<>()
+// use clang-tidy's cppcoreguidelines-pro-type-const-cast for that.
+void foo_ptr() {
+  const char *const ptr = 0;
+  char *t0 = const_cast(ptr); // no warning
+
+  volatile char *ptr2 = 0;
+  char *t1 = const_cast(ptr2); // no warning
+
+  const volatile char *ptr3 = 0;
+  char *t2 = const_cast(ptr3); // no warning
+}
+
+void cstr() {
+  void* p0 = (void*)(const void*)"txt"; // expected-warning {{cast from 'const void *' to 'void *' drops const qualifier}}
+  void* p1 = (void*)"txt"; // FIXME
+  char* p2 = (char*)"txt"; // expected-warning {{cast from 'const char *' to 'char *' drops const qualifier}}
+}
+
+void foo_0() {
+  const int a = 0;
+
+  const int  = a;  // no warning
+  const int  = (const int &)a; // no warning
+
+  int  = (int &)a;  // expected-warning {{cast from 'const int' to 'int &' drops const qualifier}}
+  const int  = (int &)a;// expected-warning {{cast from 'const int' to 'int &' drops const qualifier}}
+  int  = (int &)((const int &)a);   // expected-warning {{cast from 'const int' to 'int &' drops const qualifier}}
+  int  = (int &)((int &)a); // expected-warning {{cast from 'const int' to 'int &' drops const qualifier}}
+  const int  = (int &)((int &)a);   // expected-warning {{cast from 'const int' to 'int &' drops const qualifier}}
+  const int  = (int &)((const int &)a); // expected-warning {{cast from 'const int' to 'int &' drops const qualifier}}
+  const int  = (const int &)((int &)a); // expected-warning {{cast from 'const int' to 'int &' drops const qualifier}}
+}
+
+void foo_1() {
+  volatile int a = 0;
+
+  volatile int  = a; // no warning
+  volatile int  = (volatile int &)a; // no warning
+
+  int  = (int &)a;// expected-warning {{cast from 'volatile int' to 'int &' drops volatile qualifier}}
+  volatile int  = (int &)a;   // expected-warning {{cast from 'volatile int' to 'int &' drops volatile qualifier}}
+  int  = (int &)((volatile int &)a);  // expected-warning {{cast from 'volatile int' to 'int &' drops volatile qualifier}}
+  int  = (int &)((int &)a);   // expected-warning {{cast from 'volatile int' to 'int &' drops volatile qualifier}}
+  volatile int  = (int &)((int &)a);  // expected-warning {{cast from 'volatile int' to 'int &' drops volatile qualifier}}
+  volatile int  = (int &)((volatile int &)a); // expected-warning {{cast from 'volatile int' to 'int &' drops volatile qualifier}}
+  volatile int  = (volatile int &)((int &)a); // expected-warning {{cast from 'volatile int' to 'int &' drops volatile qualifier}}
+}
+
+void foo_2() {
+  const volatile int a = 0;
+
+  const volatile int  = a;   // no warning
+  const volatile int  = (const volatile int &)a; // no warning
+
+  int  = (int &)a;// expected-warning {{cast from 'const volatile int' to 'int &' drops const and volatile qualifiers}}
+  const volatile int  = (int &)a; // expected-warning {{cast from 'const volatile int' to 'int &' drops const and volatile qualifiers}}
+  int  = (int &)((const volatile int &)a);// expected-warning {{cast from 'const volatile int' to 'int &' drops const and volatile qualifiers}}
+  int  = (int &)((int &)a);   // expected-warning {{cast from 'const volatile int' to 'int &' drops const and volatile qualifiers}}
+  const volatile int  = (int &)((int &)a);// expected-warning {{cast from 'const volatile int' to 'int &' drops const and volatile qualifiers}}
+  const volatile int  = (int &)((const volatile int &)a); // expected-warning {{cast from 'const volatile int' to 'int &' drops const and volatile qualifiers}}
+  const volatile int  = (const volatile int &)((int &)a); // expected-warning {{cast from 'const volatile int' to 'int &' drops const and volatile qualifiers}}
+}
+
+void bar_0() {
+  const int *_a = 0;
+  const int **a = &_a;
+
+  int **a0 = (int **)((const int **)a); // expected-warning {{cast from 'const int *' to 'int *' drops const qualifier}}
+  int **a1 = (int **)((int **)a);   // expected-warning {{cast from 'const int *' to 'int *' drops const qualifier}}
+
+  // const int **a2 = (int **)((int **)a);
+  // const int **a3 = (int **)((const int **)a);
+
+  const int **a4 = 

[PATCH] D34932: [clang-tidy] Resolve cppcoreguidelines-pro-type-member-init false positive

2017-07-03 Thread Jonas Devlieghere via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL307040: [clang-tidy] Resolve 
cppcoreguidelines-pro-type-member-init false positive (authored by 
JDevlieghere).

Changed prior to commit:
  https://reviews.llvm.org/D34932?vs=105023=105102#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34932

Files:
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp


Index: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -449,6 +449,9 @@
 
   // Remove any bases that were explicitly written in the initializer list.
   if (Ctor) {
+if (Ctor->isImplicit())
+  return;
+
 for (const CXXCtorInitializer *Init : Ctor->inits()) {
   if (Init->isBaseInitializer() && Init->isWritten())
 BasesToInit.erase(Init->getBaseClass()->getAsCXXRecordDecl());
Index: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -473,3 +473,16 @@
   unsigned F : 5;
   unsigned G : 5;
 };
+
+struct NegativeImplicitInheritedCtorBase {
+  NegativeImplicitInheritedCtorBase(unsigned F) : F(F) {}
+  unsigned F;
+};
+
+struct NegativeImplicitInheritedCtor : NegativeImplicitInheritedCtorBase {
+  using NegativeImplicitInheritedCtorBase::NegativeImplicitInheritedCtorBase;
+};
+
+void Bug33557() {
+  NegativeImplicitInheritedCtor I(5);
+}


Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -449,6 +449,9 @@
 
   // Remove any bases that were explicitly written in the initializer list.
   if (Ctor) {
+if (Ctor->isImplicit())
+  return;
+
 for (const CXXCtorInitializer *Init : Ctor->inits()) {
   if (Init->isBaseInitializer() && Init->isWritten())
 BasesToInit.erase(Init->getBaseClass()->getAsCXXRecordDecl());
Index: clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -473,3 +473,16 @@
   unsigned F : 5;
   unsigned G : 5;
 };
+
+struct NegativeImplicitInheritedCtorBase {
+  NegativeImplicitInheritedCtorBase(unsigned F) : F(F) {}
+  unsigned F;
+};
+
+struct NegativeImplicitInheritedCtor : NegativeImplicitInheritedCtorBase {
+  using NegativeImplicitInheritedCtorBase::NegativeImplicitInheritedCtorBase;
+};
+
+void Bug33557() {
+  NegativeImplicitInheritedCtor I(5);
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r307040 - [clang-tidy] Resolve cppcoreguidelines-pro-type-member-init false positive

2017-07-03 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Mon Jul  3 09:46:46 2017
New Revision: 307040

URL: http://llvm.org/viewvc/llvm-project?rev=307040=rev
Log:
[clang-tidy] Resolve cppcoreguidelines-pro-type-member-init false positive

Summary: https://bugs.llvm.org/show_bug.cgi?id=33557

Reviewers: Eugene.Zelenko, alexfh, aaron.ballman, hokein

Reviewed By: aaron.ballman, hokein

Subscribers: cfe-commits, nemanjai, xazax.hun, kbarton

Tags: #clang-tools-extra

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

Modified:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp?rev=307040=307039=307040=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
Mon Jul  3 09:46:46 2017
@@ -449,6 +449,9 @@ void ProTypeMemberInitCheck::checkMissin
 
   // Remove any bases that were explicitly written in the initializer list.
   if (Ctor) {
+if (Ctor->isImplicit())
+  return;
+
 for (const CXXCtorInitializer *Init : Ctor->inits()) {
   if (Init->isBaseInitializer() && Init->isWritten())
 BasesToInit.erase(Init->getBaseClass()->getAsCXXRecordDecl());

Modified: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp?rev=307040=307039=307040=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
 Mon Jul  3 09:46:46 2017
@@ -473,3 +473,16 @@ struct NegativeInitializedBitfieldMember
   unsigned F : 5;
   unsigned G : 5;
 };
+
+struct NegativeImplicitInheritedCtorBase {
+  NegativeImplicitInheritedCtorBase(unsigned F) : F(F) {}
+  unsigned F;
+};
+
+struct NegativeImplicitInheritedCtor : NegativeImplicitInheritedCtorBase {
+  using NegativeImplicitInheritedCtorBase::NegativeImplicitInheritedCtorBase;
+};
+
+void Bug33557() {
+  NegativeImplicitInheritedCtor I(5);
+}


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


[PATCH] D34329: [clang-diff] Initial implementation.

2017-07-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

@johannes 
Are you planning to work on integration with the `StmtDataCollector` in this 
patch or would you prefer to follow-up with additional patches?


https://reviews.llvm.org/D34329



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


[PATCH] D34955: [Basic] Detect Git submodule version in CMake

2017-07-03 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose requested changes to this revision.
jordan_rose added a comment.
This revision now requires changes to proceed.

If I'm remembering correctly from when I set this up, this isn't just about 
detecting which version control system you're using; it's about finding a file 
//that will change on every commit.// Otherwise, the generated Version.cpp 
won't be rebuilt after you update.

If you don't want to go looking for a better choice for this that would handle 
submodules, a stopgap answer would be to add a second entry that just looks for 
`.git` in addition to the one looking for `HEAD`.


https://reviews.llvm.org/D34955



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


[PATCH] D34948: [OpenCL] Generalise err_opencl_enqueue_kernel_expected_type to be used with other builtins

2017-07-03 Thread Joey Gouly via Phabricator via cfe-commits
joey added a comment.

In https://reviews.llvm.org/D34948#798332, @bader wrote:

> LGTM.
>  Do you have another built-in in mind which can use this diagnostic message?
>  If so, it would make sense to re-use it in the same patch.


This is split off from https://reviews.llvm.org/D33945, which I will be 
rebasing/re-uploading once this patch is committed.


https://reviews.llvm.org/D34948



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


[PATCH] D34948: [OpenCL] Generalise err_opencl_enqueue_kernel_expected_type to be used with other builtins

2017-07-03 Thread Alexey Bader via Phabricator via cfe-commits
bader accepted this revision.
bader added a comment.
This revision is now accepted and ready to land.

LGTM.
Do you have another built-in in mind which can use this diagnostic message?
If so, it would make sense to re-use it in the same patch.


https://reviews.llvm.org/D34948



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


[PATCH] D34955: [Basic] Detect Git submodule version in CMake

2017-07-03 Thread Brian Gesiak via Phabricator via cfe-commits
modocache created this revision.
Herald added a subscriber: mgorny.

When searching for Git version control information, libBasic's CMake
checks for the path '.git/logs/HEAD'. However, when LLVM is included as
a Git submodule, this path does not exist. Instead, it contains a '.git'
file with the following:

  gitdir: ../../.git/modules/external/llvm

Where '../..' is the relative path to the root repository that contains
the LLVM Git submodule.

Because of this discrepancy, `clang --version` does not output source
control information if built from a Git submodule.

The full '.git/logs/HEAD' path is only used to gate the invocation of LLVM
CMake's GetSVN.cmake script, which is invoked using the `LLVM_MAIN_SRC_DIR`
and `CLANG_SOURCE_DIR` paths, which point to the right places even when
Clang is built as a submodule. Once invoked with these paths, GetSVN.cmake
works just fine, and correct version control information is retrieved, even
when Clang is built as a submodule.

To work around the problem, truncate the path being checked for: just
'.git' instead of '.git/logs/HEAD'.

Test Plan:

1. Before applying this change, build Clang as a Git submodule in a repository 
that places it in external/clang, and confirm no revision information is output 
when `clang --version` is invoked (just "clang 5.0.0" is output, no Git hashes).
2. Apply these changes and build Clang as a Git repository nested under 
llvm/tools/clang, and confirm that `clang --version` displays correct version 
information.
3. Apply these changes and build Clang as a Git submodule using the structure 
described in (1), and confirm version control information is output as in (2).


https://reviews.llvm.org/D34955

Files:
  lib/Basic/CMakeLists.txt


Index: lib/Basic/CMakeLists.txt
===
--- lib/Basic/CMakeLists.txt
+++ lib/Basic/CMakeLists.txt
@@ -16,7 +16,7 @@
 
 macro(find_first_existing_vc_file out_var path)
   find_first_existing_file(${out_var}
-"${path}/.git/logs/HEAD" # Git
+"${path}/.git"   # Git
 "${path}/.svn/wc.db" # SVN 1.7
 "${path}/.svn/entries"   # SVN 1.6
 )


Index: lib/Basic/CMakeLists.txt
===
--- lib/Basic/CMakeLists.txt
+++ lib/Basic/CMakeLists.txt
@@ -16,7 +16,7 @@
 
 macro(find_first_existing_vc_file out_var path)
   find_first_existing_file(${out_var}
-"${path}/.git/logs/HEAD" # Git
+"${path}/.git"   # Git
 "${path}/.svn/wc.db" # SVN 1.7
 "${path}/.svn/entries"   # SVN 1.6
 )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34949: [refactor][rename] Use a single base class for class that finds a declaration at location and for class that searches for all occurrences of a specific declaration

2017-07-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 105084.
arphaman added a comment.

Small fixup.


Repository:
  rL LLVM

https://reviews.llvm.org/D34949

Files:
  include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
  include/clang/Tooling/Refactoring/Rename/USRFinder.h
  include/clang/module.modulemap
  lib/Tooling/Refactoring/Rename/USRFinder.cpp
  lib/Tooling/Refactoring/Rename/USRLocFinder.cpp

Index: lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
===
--- lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
+++ lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
@@ -22,6 +22,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Tooling/Core/Lookup.h"
+#include "clang/Tooling/Refactoring/RecursiveSymbolVisitor.h"
 #include "clang/Tooling/Refactoring/Rename/USRFinder.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
@@ -40,70 +41,27 @@
 // \brief This visitor recursively searches for all instances of a USR in a
 // translation unit and stores them for later usage.
 class USRLocFindingASTVisitor
-: public clang::RecursiveASTVisitor {
+: public RecursiveSymbolVisitor {
 public:
   explicit USRLocFindingASTVisitor(const std::vector ,
StringRef PrevName,
const ASTContext )
-  : USRSet(USRs.begin(), USRs.end()), PrevName(PrevName), Context(Context) {
+  : RecursiveSymbolVisitor(Context.getSourceManager(),
+   Context.getLangOpts()),
+USRSet(USRs.begin(), USRs.end()), PrevName(PrevName), Context(Context) {
   }
 
-  // Declaration visitors:
-
-  bool VisitCXXConstructorDecl(clang::CXXConstructorDecl *ConstructorDecl) {
-for (const auto *Initializer : ConstructorDecl->inits()) {
-  // Ignore implicit initializers.
-  if (!Initializer->isWritten())
-continue;
-  if (const clang::FieldDecl *FieldDecl = Initializer->getMember()) {
-if (USRSet.find(getUSRForDecl(FieldDecl)) != USRSet.end())
-  LocationsFound.push_back(Initializer->getSourceLocation());
-  }
-}
-return true;
-  }
-
-  bool VisitNamedDecl(const NamedDecl *Decl) {
-if (USRSet.find(getUSRForDecl(Decl)) != USRSet.end())
-  checkAndAddLocation(Decl->getLocation());
-return true;
-  }
-
-  // Expression visitors:
-
-  bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
-const NamedDecl *Decl = Expr->getFoundDecl();
-
-if (USRSet.find(getUSRForDecl(Decl)) != USRSet.end()) {
-  const SourceManager  = Decl->getASTContext().getSourceManager();
-  SourceLocation Location = Manager.getSpellingLoc(Expr->getLocation());
-  checkAndAddLocation(Location);
-}
-
-return true;
-  }
-
-  bool VisitMemberExpr(const MemberExpr *Expr) {
-const NamedDecl *Decl = Expr->getFoundDecl().getDecl();
-if (USRSet.find(getUSRForDecl(Decl)) != USRSet.end()) {
-  const SourceManager  = Decl->getASTContext().getSourceManager();
-  SourceLocation Location = Manager.getSpellingLoc(Expr->getMemberLoc());
-  checkAndAddLocation(Location);
-}
-return true;
-  }
-
-  // Other visitors:
-
-  bool VisitTypeLoc(const TypeLoc Loc) {
-if (USRSet.find(getUSRForDecl(Loc.getType()->getAsCXXRecordDecl())) !=
-USRSet.end())
-  checkAndAddLocation(Loc.getBeginLoc());
-if (const auto *TemplateTypeParm =
-dyn_cast(Loc.getType())) {
-  if (USRSet.find(getUSRForDecl(TemplateTypeParm->getDecl())) !=
-  USRSet.end())
-checkAndAddLocation(Loc.getBeginLoc());
+  bool visitSymbolOccurrence(const NamedDecl *ND,
+ ArrayRef NameRanges) {
+if (USRSet.find(getUSRForDecl(ND)) != USRSet.end()) {
+  assert(NameRanges.size() == 1 &&
+ "Multiple name pieces are not supported yet!");
+  SourceLocation Loc = NameRanges[0].getBegin();
+  const SourceManager  = Context.getSourceManager();
+  // TODO: Deal with macro occurrences correctly.
+  if (Loc.isMacroID())
+Loc = SM.getSpellingLoc(Loc);
+  checkAndAddLocation(Loc);
 }
 return true;
   }
@@ -116,17 +74,6 @@
 return LocationsFound;
   }
 
-  // Namespace traversal:
-  void handleNestedNameSpecifierLoc(NestedNameSpecifierLoc NameLoc) {
-while (NameLoc) {
-  const NamespaceDecl *Decl =
-  NameLoc.getNestedNameSpecifier()->getAsNamespace();
-  if (Decl && USRSet.find(getUSRForDecl(Decl)) != USRSet.end())
-checkAndAddLocation(NameLoc.getLocalBeginLoc());
-  NameLoc = NameLoc.getPrefix();
-}
-  }
-
 private:
   void checkAndAddLocation(SourceLocation Loc) {
 const SourceLocation BeginLoc = Loc;
@@ -449,11 +396,6 @@
Decl *Decl) {
   USRLocFindingASTVisitor Visitor(USRs, PrevName, Decl->getASTContext());
   Visitor.TraverseDecl(Decl);
-  NestedNameSpecifierLocFinder Finder(Decl->getASTContext());
-
-  for (const auto  : 

r307034 - Revert "clang-format: [JS] space between pseudo keywords and template literals."

2017-07-03 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Mon Jul  3 08:31:28 2017
New Revision: 307034

URL: http://llvm.org/viewvc/llvm-project?rev=307034=rev
Log:
Revert "clang-format: [JS] space between pseudo keywords and template literals."

This reverts commit 71d3b5cd916106005ef23467e3f6c7fbca7bc499.

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=307034=307033=307034=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Jul  3 08:31:28 2017
@@ -2319,11 +2319,7 @@ bool TokenAnnotator::spaceRequiredBefore
 if ((Left.is(TT_TemplateString) && Left.TokenText.endswith("${")) ||
 (Right.is(TT_TemplateString) && Right.TokenText.startswith("}")))
   return false;
-// In tagged template literals ("html`bar baz`"), there is no space between
-// the tag identifier and the template string. getIdentifierInfo makes sure
-// that the identifier is not a pseudo keyword like `yield`, either.
-if (Left.is(tok::identifier) && Left.Tok.getIdentifierInfo() == nullptr &&
-Right.is(TT_TemplateString))
+if (Left.is(tok::identifier) && Right.is(TT_TemplateString))
   return false;
 if (Right.is(tok::star) &&
 Left.isOneOf(Keywords.kw_function, Keywords.kw_yield))

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=307034=307033=307034=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Jul  3 08:31:28 2017
@@ -1564,7 +1564,6 @@ TEST_F(FormatTestJS, TemplateStrings) {
"   a(  //\n"
"   a)\n"
" })`);");
-  verifyFormat("yield `hello`;");
 }
 
 TEST_F(FormatTestJS, TemplateStringMultiLineExpression) {


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


[PATCH] D34949: [refactor][rename] Use a single base class for class that finds a declaration at location and for class that searches for all occurrences of a specific declaration

2017-07-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

This is meant to be NFC btw.


Repository:
  rL LLVM

https://reviews.llvm.org/D34949



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


[PATCH] D34949: [refactor][rename] Use a single base class for class that finds a declaration at location and for class that searches for all occurrences of a specific declaration

2017-07-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

- Use single `RecursiveSymbolVisitor` class for both `USRLocFindingASTVisitor` 
and `NamedDeclOccurrenceFindingVisitor` to avoid duplicate visiting code.
- Traverse nested name specifier locs in the new class and remove the separate 
matching step.
- New class `NamedDeclFindingVisitor` handles search for a declaration by name. 
We don't have to visit each occurrence to find the declaration, so a simple 
NamedDecl search should be enough.


Repository:
  rL LLVM

https://reviews.llvm.org/D34949

Files:
  include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
  include/clang/Tooling/Refactoring/Rename/USRFinder.h
  include/clang/module.modulemap
  lib/Tooling/Refactoring/Rename/USRFinder.cpp
  lib/Tooling/Refactoring/Rename/USRLocFinder.cpp

Index: lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
===
--- lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
+++ lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
@@ -22,6 +22,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Tooling/Core/Lookup.h"
+#include "clang/Tooling/Refactoring/RecursiveSymbolVisitor.h"
 #include "clang/Tooling/Refactoring/Rename/USRFinder.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
@@ -40,70 +41,27 @@
 // \brief This visitor recursively searches for all instances of a USR in a
 // translation unit and stores them for later usage.
 class USRLocFindingASTVisitor
-: public clang::RecursiveASTVisitor {
+: public RecursiveSymbolVisitor {
 public:
   explicit USRLocFindingASTVisitor(const std::vector ,
StringRef PrevName,
const ASTContext )
-  : USRSet(USRs.begin(), USRs.end()), PrevName(PrevName), Context(Context) {
+  : RecursiveSymbolVisitor(Context.getSourceManager(),
+   Context.getLangOpts()),
+USRSet(USRs.begin(), USRs.end()), PrevName(PrevName), Context(Context) {
   }
 
-  // Declaration visitors:
-
-  bool VisitCXXConstructorDecl(clang::CXXConstructorDecl *ConstructorDecl) {
-for (const auto *Initializer : ConstructorDecl->inits()) {
-  // Ignore implicit initializers.
-  if (!Initializer->isWritten())
-continue;
-  if (const clang::FieldDecl *FieldDecl = Initializer->getMember()) {
-if (USRSet.find(getUSRForDecl(FieldDecl)) != USRSet.end())
-  LocationsFound.push_back(Initializer->getSourceLocation());
-  }
-}
-return true;
-  }
-
-  bool VisitNamedDecl(const NamedDecl *Decl) {
-if (USRSet.find(getUSRForDecl(Decl)) != USRSet.end())
-  checkAndAddLocation(Decl->getLocation());
-return true;
-  }
-
-  // Expression visitors:
-
-  bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
-const NamedDecl *Decl = Expr->getFoundDecl();
-
-if (USRSet.find(getUSRForDecl(Decl)) != USRSet.end()) {
-  const SourceManager  = Decl->getASTContext().getSourceManager();
-  SourceLocation Location = Manager.getSpellingLoc(Expr->getLocation());
-  checkAndAddLocation(Location);
-}
-
-return true;
-  }
-
-  bool VisitMemberExpr(const MemberExpr *Expr) {
-const NamedDecl *Decl = Expr->getFoundDecl().getDecl();
-if (USRSet.find(getUSRForDecl(Decl)) != USRSet.end()) {
-  const SourceManager  = Decl->getASTContext().getSourceManager();
-  SourceLocation Location = Manager.getSpellingLoc(Expr->getMemberLoc());
-  checkAndAddLocation(Location);
-}
-return true;
-  }
-
-  // Other visitors:
-
-  bool VisitTypeLoc(const TypeLoc Loc) {
-if (USRSet.find(getUSRForDecl(Loc.getType()->getAsCXXRecordDecl())) !=
-USRSet.end())
-  checkAndAddLocation(Loc.getBeginLoc());
-if (const auto *TemplateTypeParm =
-dyn_cast(Loc.getType())) {
-  if (USRSet.find(getUSRForDecl(TemplateTypeParm->getDecl())) !=
-  USRSet.end())
-checkAndAddLocation(Loc.getBeginLoc());
+  bool visitSymbolOccurrence(const NamedDecl *ND,
+ ArrayRef NameRanges) {
+if (USRSet.find(getUSRForDecl(ND)) != USRSet.end()) {
+  assert(NameRanges.size() == 1 &&
+ "Multiple name pieces are not supported yet!");
+  SourceLocation Loc = NameRanges[0].getBegin();
+  const SourceManager  = Context.getSourceManager();
+  // TODO: Deal with macro occurrences correctly.
+  if (Loc.isMacroID())
+Loc = SM.getSpellingLoc(Loc);
+  checkAndAddLocation(Loc);
 }
 return true;
   }
@@ -116,17 +74,6 @@
 return LocationsFound;
   }
 
-  // Namespace traversal:
-  void handleNestedNameSpecifierLoc(NestedNameSpecifierLoc NameLoc) {
-while (NameLoc) {
-  const NamespaceDecl *Decl =
-  NameLoc.getNestedNameSpecifier()->getAsNamespace();
-  if (Decl && USRSet.find(getUSRForDecl(Decl)) != USRSet.end())
-checkAndAddLocation(NameLoc.getLocalBeginLoc());
-  NameLoc = 

[PATCH] D34404: [Clang-Tidy] Preserve Message, FileOffset, FilePath in Clang-Tidy YAML output

2017-07-03 Thread Vladimir Plyashkun via Phabricator via cfe-commits
vladimir.plyashkun updated this revision to Diff 105078.
vladimir.plyashkun added a comment.
Herald added a subscriber: JDevlieghere.

- fixed `No newline at end of file` problem
- provided test-case to check that diagnostics with no fixes will be applied 
correctly


Repository:
  rL LLVM

https://reviews.llvm.org/D34404

Files:
  include/clang/Tooling/DiagnosticsYaml.h
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/DiagnosticsYamlTest.cpp
  unittests/clang-apply-replacements/ApplyReplacementsTest.cpp
  unittests/clang-apply-replacements/CMakeLists.txt

Index: unittests/Tooling/DiagnosticsYamlTest.cpp
===
--- /dev/null
+++ unittests/Tooling/DiagnosticsYamlTest.cpp
@@ -0,0 +1,183 @@
+//===- unittests/Tooling/DiagnosticsYamlTest.cpp - Serialization tests ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Tests for serialization of Diagnostics.
+//
+//===--===//
+
+#include "clang/Tooling/Core/Diagnostic.h"
+#include "clang/Tooling/DiagnosticsYaml.h"
+#include "clang/Tooling/ReplacementsYaml.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace clang::tooling;
+
+TEST(DiagnosticsYamlTest, SerializesDiagnostics) {
+  TranslationUnitDiagnostics TUD;
+  TUD.MainSourceFile = "path/to/source.cpp";
+  DiagnosticMessage Message1;
+  Message1.Message = "message #1";
+  Message1.FileOffset = 55;
+  Message1.FilePath = "path/to/source.cpp";
+  StringMap Fix1{
+{ "path/to/source.cpp", Replacements(Replacement("path/to/source.cpp", 100,
+12, "replacement #1")) } };
+  DiagnosticMessage Message2;
+  Message2.Message = "message #2";
+  Message2.FileOffset = 60;
+  Message2.FilePath = "path/to/header.h";
+  StringMap Fix2{
+{ "path/to/header.h",
+Replacements(Replacement("path/to/header.h", 62, 2, "replacement #2")) } };
+  SmallVector EmptyNotes;
+  TUD.Diagnostics.emplace_back("diagnostic#1", Message1, Fix1, EmptyNotes,
+   Diagnostic::Warning, "path/to/build/directory");
+  TUD.Diagnostics.emplace_back("diagnostic#2", Message2, Fix2, EmptyNotes,
+   Diagnostic::Error, "path/to/another/build/directory");
+
+  std::string YamlContent;
+  raw_string_ostream YamlContentStream(YamlContent);
+
+  yaml::Output YAML(YamlContentStream);
+  YAML << TUD;
+
+  ASSERT_STREQ("---\n"
+"MainSourceFile:  path/to/source.cpp\n"
+"Diagnostics: \n"
+"  - DiagnosticName:  'diagnostic#1\'\n"
+"Message: 'message #1'\n"
+"FileOffset:  55\n"
+"FilePath:path/to/source.cpp\n"
+"Replacements:\n"
+"  - FilePath:path/to/source.cpp\n"
+"Offset:  100\n"
+"Length:  12\n"
+"ReplacementText: 'replacement #1'\n"
+"  - DiagnosticName:  'diagnostic#2'\n"
+"Message: 'message #2'\n"
+"FileOffset:  60\n"
+"FilePath:path/to/header.h\n"
+"Replacements:\n"
+"  - FilePath:path/to/header.h\n"
+"Offset:  62\n"
+"Length:  2\n"
+"ReplacementText: 'replacement #2'\n"
+"...\n",
+  YamlContentStream.str().c_str());
+}
+
+TEST(DiagnosticsYamlTest, SerializesDiagnosticWithNoFix) {
+  TranslationUnitDiagnostics TUD;
+  TUD.MainSourceFile = "path/to/source.cpp";
+  DiagnosticMessage Message;
+  Message.Message = "message #1";
+  Message.FileOffset = 55;
+  Message.FilePath = "path/to/source.cpp";
+  StringMap EmptyReplacements;
+  SmallVector EmptyNotes;
+  TUD.Diagnostics.emplace_back("diagnostic#1", Message, EmptyReplacements,
+   EmptyNotes, Diagnostic::Warning,
+   "path/to/build/directory");
+
+  std::string YamlContent;
+  raw_string_ostream YamlContentStream(YamlContent);
+
+  yaml::Output YAML(YamlContentStream);
+  YAML << TUD;
+
+  ASSERT_STREQ("---\n"
+"MainSourceFile:  path/to/source.cpp\n"
+"Diagnostics: \n"
+"  - DiagnosticName:  'diagnostic#1'\n"
+"Message: 'message #1'\n"
+"FileOffset:  55\n"
+"FilePath:path/to/source.cpp\n"
+"Replacements:\n"
+"...\n",
+  YamlContentStream.str().c_str());
+}
+
+TEST(DiagnosticsYamlTest, DeserializesDiagnostics) {
+std::string YamlContent = "---\n"
+  "MainSourceFile:  path/to/source.cpp\n"
+  "Diagnostics: \n"
+  "  - DiagnosticName:  'diagnostic#1'\n"
+  "Message: 'message #1'\n"
+  "FileOffset:  55\n"
+  "FilePath:path/to/source.cpp\n"
+  "

[PATCH] D34441: [clang-format] Support text proto messages

2017-07-03 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL307029: [clang-format] Support text proto messages (authored 
by krasimir).

Repository:
  rL LLVM

https://reviews.llvm.org/D34441

Files:
  cfe/trunk/include/clang/Format/Format.h
  cfe/trunk/lib/Format/ContinuationIndenter.cpp
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/lib/Format/FormatToken.h
  cfe/trunk/lib/Format/TokenAnnotator.cpp
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/unittests/Format/CMakeLists.txt
  cfe/trunk/unittests/Format/FormatTestTextProto.cpp

Index: cfe/trunk/lib/Format/FormatToken.h
===
--- cfe/trunk/lib/Format/FormatToken.h
+++ cfe/trunk/lib/Format/FormatToken.h
@@ -466,7 +466,8 @@
(is(tok::l_brace) &&
 (BlockKind == BK_Block || is(TT_DictLiteral) ||
  (!Style.Cpp11BracedListStyle && NestingLevel == 0))) ||
-   (is(tok::less) && Style.Language == FormatStyle::LK_Proto);
+   (is(tok::less) && (Style.Language == FormatStyle::LK_Proto ||
+  Style.Language == FormatStyle::LK_TextProto));
   }
 
   /// \brief Same as opensBlockOrBlockTypeList, but for the closing token.
Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -286,7 +286,10 @@
   !Line->InPPDirective && Style.Language != FormatStyle::LK_JavaScript;
   ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack,
   MustBeDeclaration);
-  parseLevel(/*HasOpeningBrace=*/false);
+  if (Style.Language == FormatStyle::LK_TextProto)
+parseBracedList();
+  else
+parseLevel(/*HasOpeningBrace=*/false);
   // Make sure to format the remaining tokens.
   flushComments(true);
   addUnwrappedLine();
@@ -832,6 +835,7 @@
   case tok::at:
 nextToken();
 if (FormatTok->Tok.is(tok::l_brace)) {
+  nextToken();
   parseBracedList();
   break;
 }
@@ -996,8 +1000,10 @@
 switch (FormatTok->Tok.getKind()) {
 case tok::at:
   nextToken();
-  if (FormatTok->Tok.is(tok::l_brace))
+  if (FormatTok->Tok.is(tok::l_brace)) {
+nextToken();
 parseBracedList();
+  }
   break;
 case tok::kw_enum:
   // Ignore if this is part of "template Tok.is(tok::l_brace))
+  if (FormatTok->Tok.is(tok::l_brace)) {
+nextToken();
 parseBracedList();
-  else if (Style.Language == FormatStyle::LK_Proto &&
-   FormatTok->Tok.is(tok::less))
+  } else if (Style.Language == FormatStyle::LK_Proto &&
+   FormatTok->Tok.is(tok::less)) {
+nextToken();
 parseBracedList(/*ContinueOnSemicolons=*/false,
 /*ClosingBraceKind=*/tok::greater);
+  }
   break;
 case tok::l_square:
   parseSquare();
@@ -1345,14 +1354,14 @@
   assert(FormatTok->BlockKind != BK_Unknown);
   if (FormatTok->BlockKind == BK_Block)
 return false;
+  nextToken();
   parseBracedList();
   return true;
 }
 
 bool UnwrappedLineParser::parseBracedList(bool ContinueOnSemicolons,
   tok::TokenKind ClosingBraceKind) {
   bool HasError = false;
-  nextToken();
 
   // FIXME: Once we have an expression parser in the UnwrappedLineParser,
   // replace this by using parseAssigmentExpression() inside.
@@ -1407,6 +1416,7 @@
   // Assume there are no blocks inside a braced init list apart
   // from the ones we explicitly parse out (like lambdas).
   FormatTok->BlockKind = BK_BracedInit;
+  nextToken();
   parseBracedList();
   break;
 case tok::semi:
@@ -1459,8 +1469,10 @@
   break;
 case tok::at:
   nextToken();
-  if (FormatTok->Tok.is(tok::l_brace))
+  if (FormatTok->Tok.is(tok::l_brace)) {
+nextToken();
 parseBracedList();
+  }
   break;
 case tok::kw_class:
   if (Style.Language == FormatStyle::LK_JavaScript)
@@ -1508,8 +1520,10 @@
 }
 case tok::at:
   nextToken();
-  if (FormatTok->Tok.is(tok::l_brace))
+  if (FormatTok->Tok.is(tok::l_brace)) {
+nextToken();
 parseBracedList();
+  }
   break;
 default:
   nextToken();
@@ -1836,6 +1850,7 @@
   }
 
   // Parse enum body.
+  nextToken();
   bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true);
   if (HasError) {
 if (FormatTok->is(tok::semi))
@@ -1870,6 +1885,7 @@
   FormatTok = Tokens->setPosition(StoredPosition);
 
   if (IsSimple) {
+nextToken();
 parseBracedList();
 addUnwrappedLine();
 return;
@@ -2081,6 +2097,7 @@
 }
 if (FormatTok->is(tok::l_brace)) {
   FormatTok->BlockKind = BK_Block;
+  nextToken();
   parseBracedList();
 } else {
   nextToken();
Index: 

r307029 - [clang-format] Support text proto messages

2017-07-03 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Mon Jul  3 08:05:14 2017
New Revision: 307029

URL: http://llvm.org/viewvc/llvm-project?rev=307029=rev
Log:
[clang-format] Support text proto messages

Summary: This patch adds support for textual protocol buffer messages.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek, mgorny

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

Added:
cfe/trunk/unittests/Format/FormatTestTextProto.cpp
Modified:
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/FormatToken.h
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/CMakeLists.txt

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=307029=307028=307029=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Mon Jul  3 08:05:14 2017
@@ -1120,7 +1120,10 @@ struct FormatStyle {
 /// (https://developers.google.com/protocol-buffers/).
 LK_Proto,
 /// Should be used for TableGen code.
-LK_TableGen
+LK_TableGen,
+/// Should be used for Protocol Buffer messages in text format
+/// (https://developers.google.com/protocol-buffers/).
+LK_TextProto
   };
   bool isCpp() const { return Language == LK_Cpp || Language == LK_ObjC; }
 

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=307029=307028=307029=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Mon Jul  3 08:05:14 2017
@@ -66,6 +66,16 @@ static bool startsNextParameter(const Fo
!Style.BreakBeforeInheritanceComma));
 }
 
+static bool opensProtoMessageField(const FormatToken ,
+   const FormatStyle ) {
+  if (LessTok.isNot(tok::less))
+return false;
+  return Style.Language == FormatStyle::LK_TextProto ||
+ (Style.Language == FormatStyle::LK_Proto &&
+  (LessTok.NestingLevel > 0 ||
+   (LessTok.Previous && LessTok.Previous->is(tok::equal;
+}
+
 ContinuationIndenter::ContinuationIndenter(const FormatStyle ,
const AdditionalKeywords ,
const SourceManager ,
@@ -94,6 +104,13 @@ LineState ContinuationIndenter::getIniti
   State.LowestLevelOnLine = 0;
   State.IgnoreStackForComparison = false;
 
+  if (Style.Language == FormatStyle::LK_TextProto) {
+// We need this in order to deal with the bin packing of text fields at
+// global scope.
+State.Stack.back().AvoidBinPacking = true;
+State.Stack.back().BreakBeforeParameter = true;
+  }
+
   // The first token has already been indented and thus consumed.
   moveStateToNextToken(State, DryRun, /*Newline=*/false);
   return State;
@@ -176,7 +193,8 @@ bool ContinuationIndenter::mustBreak(con
 return true;
   if (((Previous.is(TT_DictLiteral) && Previous.is(tok::l_brace)) ||
(Previous.is(TT_ArrayInitializerLSquare) &&
-Previous.ParameterCount > 1)) &&
+Previous.ParameterCount > 1) ||
+   opensProtoMessageField(Previous, Style)) &&
   Style.ColumnLimit > 0 &&
   getLengthToMatchingParen(Previous) + State.Column - 1 >
   getColumnLimit(State))
@@ -501,13 +519,6 @@ void ContinuationIndenter::addTokenOnCur
   }
 }
 
-static bool lessOpensProtoMessageField(const FormatToken ,
-   const LineState ) {
-  assert(LessTok.is(tok::less));
-  return LessTok.NestingLevel > 0 ||
- (LessTok.Previous && LessTok.Previous->is(tok::equal));
-}
-
 unsigned ContinuationIndenter::addTokenOnNewLine(LineState ,
  bool DryRun) {
   FormatToken  = *State.NextToken;
@@ -650,9 +661,7 @@ unsigned ContinuationIndenter::addTokenO
   // before the corresponding } or ].
   if (PreviousNonComment &&
   (PreviousNonComment->isOneOf(tok::l_brace, TT_ArrayInitializerLSquare) ||
-  (Style.Language == FormatStyle::LK_Proto &&
-   PreviousNonComment->is(tok::less) &&
-   lessOpensProtoMessageField(*PreviousNonComment, State)) ||
+   opensProtoMessageField(*PreviousNonComment, Style) ||
(PreviousNonComment->is(TT_TemplateString) &&
 PreviousNonComment->opensScope(
 State.Stack.back().BreakBeforeClosingBrace = true;
@@ -695,7 +704,9 @@ unsigned ContinuationIndenter::getNewLin
 return Current.NestingLevel == 0 ? State.FirstIndent
  : State.Stack.back().Indent;
   if ((Current.isOneOf(tok::r_brace, tok::r_square) ||
-   

[PATCH] D34932: [clang-tidy] Resolve cppcoreguidelines-pro-type-member-init false positive

2017-07-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM!


Repository:
  rL LLVM

https://reviews.llvm.org/D34932



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


[PATCH] D34932: [clang-tidy] Resolve cppcoreguidelines-pro-type-member-init false positive

2017-07-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM, thanks.




Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:452
   if (Ctor) {
+if(Ctor->isImplicit())
+  return;

nit: a space after `if`.


Repository:
  rL LLVM

https://reviews.llvm.org/D34932



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


[PATCH] D34948: [OpenCL] Generalise err_opencl_enqueue_kernel_expected_type to be used with other builtins

2017-07-03 Thread Joey Gouly via Phabricator via cfe-commits
joey created this revision.
Herald added subscribers: Anastasia, yaxunl.

Refactor err_opencl_enqueue_kernel_expected_type so that other builtins can use 
the same diagnostic.


https://reviews.llvm.org/D34948

Files:
  Sema/SemaChecking.cpp
  SemaOpenCL/cl20-device-side-enqueue.cl
  clang/Basic/DiagnosticSemaKinds.td

Index: SemaOpenCL/cl20-device-side-enqueue.cl
===
--- SemaOpenCL/cl20-device-side-enqueue.cl
+++ SemaOpenCL/cl20-device-side-enqueue.cl
@@ -19,19 +19,19 @@
 return 0;
   });
 
-  enqueue_kernel(vptr, flags, ndrange, ^(void) { // expected-error{{illegal call to enqueue_kernel, expected 'queue_t' argument type}}
+  enqueue_kernel(vptr, flags, ndrange, ^(void) { // expected-error{{illegal call to 'enqueue_kernel', expected 'queue_t' argument type}}
 return 0;
   });
 
-  enqueue_kernel(default_queue, vptr, ndrange, ^(void) { // expected-error{{illegal call to enqueue_kernel, expected 'kernel_enqueue_flags_t' (i.e. uint) argument type}}
+  enqueue_kernel(default_queue, vptr, ndrange, ^(void) { // expected-error{{illegal call to 'enqueue_kernel', expected 'kernel_enqueue_flags_t' (i.e. uint) argument type}}
 return 0;
   });
 
-  enqueue_kernel(default_queue, flags, vptr, ^(void) { // expected-error{{illegal call to enqueue_kernel, expected 'ndrange_t' argument type}}
+  enqueue_kernel(default_queue, flags, vptr, ^(void) { // expected-error{{illegal call to 'enqueue_kernel', expected 'ndrange_t' argument type}}
 return 0;
   });
 
-  enqueue_kernel(default_queue, flags, ndrange, vptr); // expected-error{{illegal call to enqueue_kernel, expected block argument}}
+  enqueue_kernel(default_queue, flags, ndrange, vptr); // expected-error{{illegal call to 'enqueue_kernel', expected block argument}}
 
   enqueue_kernel(default_queue, flags, ndrange, ^(int i) { // expected-error{{blocks with parameters are not accepted in this prototype of enqueue_kernel call}}
 return 0;
@@ -46,21 +46,21 @@
return 0;
  });
 
-  enqueue_kernel(default_queue, flags, ndrange, vptr, _wait_list, , ^(void) { // expected-error{{illegal call to enqueue_kernel, expected integer argument type}}
+  enqueue_kernel(default_queue, flags, ndrange, vptr, _wait_list, , ^(void) { // expected-error{{illegal call to 'enqueue_kernel', expected integer argument type}}
 return 0;
   });
 
-  enqueue_kernel(default_queue, flags, ndrange, 1, vptr, , ^(void) // expected-error{{illegal call to enqueue_kernel, expected 'clk_event_t *' argument type}}
+  enqueue_kernel(default_queue, flags, ndrange, 1, vptr, , ^(void) // expected-error{{illegal call to 'enqueue_kernel', expected 'clk_event_t *' argument type}}
{
  return 0;
});
 
-  enqueue_kernel(default_queue, flags, ndrange, 1, _wait_list, vptr, ^(void) // expected-error{{illegal call to enqueue_kernel, expected 'clk_event_t *' argument type}}
+  enqueue_kernel(default_queue, flags, ndrange, 1, _wait_list, vptr, ^(void) // expected-error{{illegal call to 'enqueue_kernel', expected 'clk_event_t *' argument type}}
{
  return 0;
});
 
-  enqueue_kernel(default_queue, flags, ndrange, 1, _wait_list, , vptr); // expected-error{{illegal call to enqueue_kernel, expected block argument}}
+  enqueue_kernel(default_queue, flags, ndrange, 1, _wait_list, , vptr); // expected-error{{illegal call to 'enqueue_kernel', expected block argument}}
 
   // Testing the third overload type
   enqueue_kernel(default_queue, flags, ndrange,
Index: Sema/SemaChecking.cpp
===
--- Sema/SemaChecking.cpp
+++ Sema/SemaChecking.cpp
@@ -309,7 +309,8 @@
   Expr *BlockArg = TheCall->getArg(0);
   if (!isBlockPointer(BlockArg)) {
 S.Diag(BlockArg->getLocStart(),
-   diag::err_opencl_enqueue_kernel_expected_type) << "block";
+   diag::err_opencl_builtin_expected_type)
+<< TheCall->getDirectCallee() << "block";
 return true;
   }
   return checkOpenCLBlockArgs(S, BlockArg);
@@ -394,34 +395,34 @@
   // First argument always needs to be a queue_t type.
   if (!Arg0->getType()->isQueueT()) {
 S.Diag(TheCall->getArg(0)->getLocStart(),
-   diag::err_opencl_enqueue_kernel_expected_type)
-<< S.Context.OCLQueueTy;
+   diag::err_opencl_builtin_expected_type)
+<< TheCall->getDirectCallee() << S.Context.OCLQueueTy;
 return true;
   }
 
   // Second argument always needs to be a 

[clang-tools-extra] r307025 - [clangd] Add -ffreestanding on VFS tests.

2017-07-03 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon Jul  3 07:46:03 2017
New Revision: 307025

URL: http://llvm.org/viewvc/llvm-project?rev=307025=rev
Log:
[clangd] Add -ffreestanding on VFS tests.

Summary:
They don't provide proper gcc installations and may fail on implicit
 include.

Reviewers: klimek, krasimir, bkramer

Reviewed By: krasimir

Subscribers: klimek, cfe-commits

Tags: #clang-tools-extra

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

Modified:
clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp

Modified: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp?rev=307025=307024=307025=diff
==
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp Mon Jul  3 
07:46:03 2017
@@ -164,6 +164,13 @@ private:
 
 class MockCompilationDatabase : public GlobalCompilationDatabase {
 public:
+  MockCompilationDatabase(bool AddFreestandingFlag) {
+// We have to add -ffreestanding to VFS-specific tests to avoid errors on
+// implicit includes of stdc-predef.h.
+if (AddFreestandingFlag)
+  ExtraClangFlags.push_back("-ffreestanding");
+  }
+
   std::vector
   getCompileCommands(PathRef File) override {
 if (ExtraClangFlags.empty())
@@ -259,7 +266,7 @@ protected:
   bool ExpectErrors = false) {
 MockFSProvider FS;
 ErrorCheckingDiagConsumer DiagConsumer;
-MockCompilationDatabase CDB;
+MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 ClangdServer Server(CDB, DiagConsumer, FS,
 /*RunSynchronously=*/false);
 for (const auto  : ExtraFiles)
@@ -315,7 +322,7 @@ int b = a;
 TEST_F(ClangdVFSTest, Reparse) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
-  MockCompilationDatabase CDB;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS,
   /*RunSynchronously=*/false);
 
@@ -350,7 +357,7 @@ int b = a;
 TEST_F(ClangdVFSTest, ReparseOnHeaderChange) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
-  MockCompilationDatabase CDB;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS,
   /*RunSynchronously=*/false);
@@ -388,7 +395,7 @@ int b = a;
 TEST_F(ClangdVFSTest, CheckVersions) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
-  MockCompilationDatabase CDB;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS,
   /*RunSynchronously=*/true);
 
@@ -414,8 +421,10 @@ TEST_F(ClangdVFSTest, SearchLibDir) {
   // Checks that searches for GCC installation is done through vfs.
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
-  MockCompilationDatabase CDB;
-  CDB.ExtraClangFlags = {"-xc++", "-target", "x86_64-linux-unknown", "-m64"};
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
+  CDB.ExtraClangFlags.insert(
+  CDB.ExtraClangFlags.end(),
+  {"-xc++", "-target", "x86_64-linux-unknown", "-m64"});
   ClangdServer Server(CDB, DiagConsumer, FS,
   /*RunSynchronously=*/true);
 
@@ -472,7 +481,7 @@ protected:
 TEST_F(ClangdCompletionTest, CheckContentsOverride) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
-  MockCompilationDatabase CDB;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS,
   /*RunSynchronously=*/false);


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


[PATCH] D34936: [clangd] Add -ffreestanding on VFS tests.

2017-07-03 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL307025: [clangd] Add -ffreestanding on VFS tests. (authored 
by ibiryukov).

Repository:
  rL LLVM

https://reviews.llvm.org/D34936

Files:
  clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp


Index: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
@@ -164,6 +164,13 @@
 
 class MockCompilationDatabase : public GlobalCompilationDatabase {
 public:
+  MockCompilationDatabase(bool AddFreestandingFlag) {
+// We have to add -ffreestanding to VFS-specific tests to avoid errors on
+// implicit includes of stdc-predef.h.
+if (AddFreestandingFlag)
+  ExtraClangFlags.push_back("-ffreestanding");
+  }
+
   std::vector
   getCompileCommands(PathRef File) override {
 if (ExtraClangFlags.empty())
@@ -259,7 +266,7 @@
   bool ExpectErrors = false) {
 MockFSProvider FS;
 ErrorCheckingDiagConsumer DiagConsumer;
-MockCompilationDatabase CDB;
+MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 ClangdServer Server(CDB, DiagConsumer, FS,
 /*RunSynchronously=*/false);
 for (const auto  : ExtraFiles)
@@ -315,7 +322,7 @@
 TEST_F(ClangdVFSTest, Reparse) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
-  MockCompilationDatabase CDB;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS,
   /*RunSynchronously=*/false);
 
@@ -350,7 +357,7 @@
 TEST_F(ClangdVFSTest, ReparseOnHeaderChange) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
-  MockCompilationDatabase CDB;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS,
   /*RunSynchronously=*/false);
@@ -388,7 +395,7 @@
 TEST_F(ClangdVFSTest, CheckVersions) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
-  MockCompilationDatabase CDB;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS,
   /*RunSynchronously=*/true);
 
@@ -414,8 +421,10 @@
   // Checks that searches for GCC installation is done through vfs.
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
-  MockCompilationDatabase CDB;
-  CDB.ExtraClangFlags = {"-xc++", "-target", "x86_64-linux-unknown", "-m64"};
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
+  CDB.ExtraClangFlags.insert(
+  CDB.ExtraClangFlags.end(),
+  {"-xc++", "-target", "x86_64-linux-unknown", "-m64"});
   ClangdServer Server(CDB, DiagConsumer, FS,
   /*RunSynchronously=*/true);
 
@@ -472,7 +481,7 @@
 TEST_F(ClangdCompletionTest, CheckContentsOverride) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
-  MockCompilationDatabase CDB;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS,
   /*RunSynchronously=*/false);


Index: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
@@ -164,6 +164,13 @@
 
 class MockCompilationDatabase : public GlobalCompilationDatabase {
 public:
+  MockCompilationDatabase(bool AddFreestandingFlag) {
+// We have to add -ffreestanding to VFS-specific tests to avoid errors on
+// implicit includes of stdc-predef.h.
+if (AddFreestandingFlag)
+  ExtraClangFlags.push_back("-ffreestanding");
+  }
+
   std::vector
   getCompileCommands(PathRef File) override {
 if (ExtraClangFlags.empty())
@@ -259,7 +266,7 @@
   bool ExpectErrors = false) {
 MockFSProvider FS;
 ErrorCheckingDiagConsumer DiagConsumer;
-MockCompilationDatabase CDB;
+MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 ClangdServer Server(CDB, DiagConsumer, FS,
 /*RunSynchronously=*/false);
 for (const auto  : ExtraFiles)
@@ -315,7 +322,7 @@
 TEST_F(ClangdVFSTest, Reparse) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
-  MockCompilationDatabase CDB;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS,
   /*RunSynchronously=*/false);
 
@@ -350,7 +357,7 @@
 TEST_F(ClangdVFSTest, ReparseOnHeaderChange) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
-  MockCompilationDatabase CDB;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS,
   /*RunSynchronously=*/false);
@@ -388,7 +395,7 @@
 TEST_F(ClangdVFSTest, CheckVersions) {
 

[PATCH] D33102: [clang] Implement -Wcast-qual for C++

2017-07-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Will land this shortly..


Repository:
  rL LLVM

https://reviews.llvm.org/D33102



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


[PATCH] D34937: Suppressing Reference Counting Diagnostics for Functions Containing 'rc_ownership_trusted_implementation' Annotate Attribute

2017-07-03 Thread Malhar Thakkar via Phabricator via cfe-commits
malhar1995 created this revision.

As part of my Google Summer of Code project, I am working on adding support for 
Integer Set Library (ISL) annotations to the current RetainCountChecker.
Hence, to begin with, Dr. Devin Coughlin gave me a task to suppress reference 
counting diagnostics for all ISL functions by preceding them with some annotate 
attribute.
The attached diff aims to do that by not emitting reports if any function on 
the call stack has 'rc_ownership_trusted_implementation' annotate attribute.

Note about ISL:
ISL has annotations __isl_give and __isl_take which are analogous to 
cf_returns_retained and cf_consumed but in case of ISL, annotations precede 
datatypes of function parameters.

Let me know your thoughts on the same.


Repository:
  rL LLVM

https://reviews.llvm.org/D34937

Files:
  lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp

Index: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
@@ -1894,6 +1894,22 @@
   return SFC->getAnalysisDeclContext()->isBodyAutosynthesized();
 }
 
+bool
+isAnnotatedToSkipDiagnostics(const LocationContext *LCtx) {
+  while (LCtx) {
+if (const StackFrameContext *SFC = dyn_cast(LCtx)) {
+  const Decl *D = SFC->getDecl();
+  for (const auto *Ann : D->specific_attrs()){
+if (Ann->getAnnotation() == "rc_ownership_trusted_implementation") {
+  return true;
+}
+  }
+}
+LCtx = LCtx->getParent();
+  }
+  return false;
+}
+
 std::shared_ptr
 CFRefReportVisitor::VisitNode(const ExplodedNode *N, const ExplodedNode *PrevN,
   BugReporterContext , BugReport ) {
@@ -3345,11 +3361,13 @@
   }
 
   assert(BT);
-  auto report = std::unique_ptr(
-  new CFRefReport(*BT, C.getASTContext().getLangOpts(), C.isObjCGCEnabled(),
-  SummaryLog, N, Sym));
-  report->addRange(ErrorRange);
-  C.emitReport(std::move(report));
+  if (!isAnnotatedToSkipDiagnostics(N->getLocationContext())){
+auto report = std::unique_ptr(
+new CFRefReport(*BT, C.getASTContext().getLangOpts(), C.isObjCGCEnabled(),
+SummaryLog, N, Sym));
+report->addRange(ErrorRange);
+C.emitReport(std::move(report));
+  }
 }
 
 //===--===//
@@ -3579,9 +3597,10 @@
 if (N) {
   const LangOptions  = C.getASTContext().getLangOpts();
   bool GCEnabled = C.isObjCGCEnabled();
-  C.emitReport(std::unique_ptr(new CFRefLeakReport(
-  *getLeakAtReturnBug(LOpts, GCEnabled), LOpts, GCEnabled,
-  SummaryLog, N, Sym, C, IncludeAllocationLine)));
+  if (!isAnnotatedToSkipDiagnostics(N->getLocationContext()))
+C.emitReport(std::unique_ptr(new CFRefLeakReport(
+*getLeakAtReturnBug(LOpts, GCEnabled), LOpts, GCEnabled,
+SummaryLog, N, Sym, C, IncludeAllocationLine)));
 }
   }
 }
@@ -3606,9 +3625,10 @@
   if (!returnNotOwnedForOwned)
 returnNotOwnedForOwned.reset(new ReturnedNotOwnedForOwned(this));
 
-  C.emitReport(std::unique_ptr(new CFRefReport(
-  *returnNotOwnedForOwned, C.getASTContext().getLangOpts(),
-  C.isObjCGCEnabled(), SummaryLog, N, Sym)));
+  if (!isAnnotatedToSkipDiagnostics(N->getLocationContext()))
+C.emitReport(std::unique_ptr(new CFRefReport(
+*returnNotOwnedForOwned, C.getASTContext().getLangOpts(),
+C.isObjCGCEnabled(), SummaryLog, N, Sym)));
 }
   }
 }
@@ -3811,9 +3831,10 @@
   overAutorelease.reset(new OverAutorelease(this));
 
 const LangOptions  = Ctx.getASTContext().getLangOpts();
-Ctx.emitReport(std::unique_ptr(
-new CFRefReport(*overAutorelease, LOpts, /* GCEnabled = */ false,
-SummaryLog, N, Sym, os.str(;
+if (!isAnnotatedToSkipDiagnostics(N->getLocationContext()))
+  Ctx.emitReport(std::unique_ptr(
+  new CFRefReport(*overAutorelease, LOpts, /* GCEnabled = */ false,
+  SummaryLog, N, Sym, os.str(;
   }
 
   return nullptr;
@@ -3865,9 +3886,10 @@
   : getLeakAtReturnBug(LOpts, GCEnabled);
   assert(BT && "BugType not initialized.");
 
-  Ctx.emitReport(std::unique_ptr(
-  new CFRefLeakReport(*BT, LOpts, GCEnabled, SummaryLog, N, *I, Ctx,
-  IncludeAllocationLine)));
+  if (!isAnnotatedToSkipDiagnostics(N->getLocationContext()))
+Ctx.emitReport(std::unique_ptr(
+new CFRefLeakReport(*BT, LOpts, GCEnabled, SummaryLog, N, *I, Ctx,
+IncludeAllocationLine)));
 }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D34886: Add a fixit for -Wobjc-protocol-property-synthesis

2017-07-03 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
arphaman marked an inline comment as done.
Closed by commit rL307014: Add a fixit for -Wobjc-protocol-property-synthesis 
(authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D34886?vs=104859=105069#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34886

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Parse/ParseObjc.cpp
  cfe/trunk/lib/Sema/SemaObjCProperty.cpp
  cfe/trunk/test/FixIt/fixit-add-synthesize-to-property.m
  cfe/trunk/test/SemaObjC/default-synthesize-3.m
  cfe/trunk/test/SemaObjC/default-synthesize.m
  cfe/trunk/test/SemaObjC/forward-protocol-incomplete-impl-warn.m

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -3358,9 +3358,10 @@
 
   /// DefaultSynthesizeProperties - This routine default synthesizes all
   /// properties which must be synthesized in the class's \@implementation.
-  void DefaultSynthesizeProperties (Scope *S, ObjCImplDecl* IMPDecl,
-ObjCInterfaceDecl *IDecl);
-  void DefaultSynthesizeProperties(Scope *S, Decl *D);
+  void DefaultSynthesizeProperties(Scope *S, ObjCImplDecl *IMPDecl,
+   ObjCInterfaceDecl *IDecl,
+   SourceLocation AtEnd);
+  void DefaultSynthesizeProperties(Scope *S, Decl *D, SourceLocation AtEnd);
 
   /// IvarBacksCurrentMethodAccessor - This routine returns 'true' if 'IV' is
   /// an ivar synthesized for 'Method' and 'Method' is a property accessor
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1029,6 +1029,8 @@
   "auto property synthesis will not synthesize property %0"
   " declared in protocol %1">,
   InGroup>;
+def note_add_synthesize_directive : Note<
+  "add a '@synthesize' directive">;
 def warn_no_autosynthesis_shared_ivar_property : Warning <
   "auto property synthesis will not synthesize property "
   "%0 because it cannot share an ivar with another synthesized property">,
Index: cfe/trunk/test/SemaObjC/default-synthesize.m
===
--- cfe/trunk/test/SemaObjC/default-synthesize.m
+++ cfe/trunk/test/SemaObjC/default-synthesize.m
@@ -137,7 +137,7 @@
 @end
  
 @implementation MyClass // expected-warning {{auto property synthesis will not synthesize property 'requiredString' declared in protocol 'MyProtocol'}}
-@end
+@end // expected-note {{add a '@synthesize' directive}}
 
 // rdar://18152478
 @protocol NSObject @end
Index: cfe/trunk/test/SemaObjC/forward-protocol-incomplete-impl-warn.m
===
--- cfe/trunk/test/SemaObjC/forward-protocol-incomplete-impl-warn.m
+++ cfe/trunk/test/SemaObjC/forward-protocol-incomplete-impl-warn.m
@@ -17,4 +17,4 @@
 
 @implementation IBImageCatalogDocument // expected-warning {{auto property synthesis will not synthesize property 'Prop' declared in protocol 'DVTInvalidation'}} \
    // expected-warning {{method 'invalidate' in protocol 'DVTInvalidation' not implemented}}
-@end
+@end // expected-note {{add a '@synthesize' directive}}
Index: cfe/trunk/test/SemaObjC/default-synthesize-3.m
===
--- cfe/trunk/test/SemaObjC/default-synthesize-3.m
+++ cfe/trunk/test/SemaObjC/default-synthesize-3.m
@@ -173,13 +173,13 @@
 @end
 
 @implementation Okay // expected-warning {{auto property synthesis will not synthesize property 'muahahaha' declared in protocol 'Fooing'}} expected-warning {{auto property synthesis will not synthesize property 'hoho' declared in protocol 'SubFooling'}}
-@end
+@end // expected-note 2 {{add a '@synthesize' directive}}
 
 @interface Fail : FooObject
 @end
 
 @implementation Fail // expected-warning {{auto property synthesis will not synthesize property 'muahahaha' declared in protocol 'Fooing'}} expected-warning {{auto property synthesis will not synthesize property 'hoho' declared in protocol 'SubFooling'}}
-@end
+@end // expected-note 2 {{add a '@synthesize' directive}}
 
 // rdar://16089191
 @class NSURL;
Index: cfe/trunk/test/FixIt/fixit-add-synthesize-to-property.m
===
--- cfe/trunk/test/FixIt/fixit-add-synthesize-to-property.m
+++ cfe/trunk/test/FixIt/fixit-add-synthesize-to-property.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+@protocol P1
+
+@property int prop;
+
+@end
+
+@interface I 
+
+@end
+
+@implementation I
+@end // CHECK: 

[PATCH] D34441: [clang-format] Support text proto messages

2017-07-03 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: lib/Format/ContinuationIndenter.cpp:107
 
+  if (Style.Language == FormatStyle::LK_TextProto) {
+State.Stack.back().AvoidBinPacking = true;

djasper wrote:
> Do we need to set this explicitly here? Is it not enough to set 
> FormatStyle.BinPackParameters to false?
BinPackParameters doesn't work at global scope. We set these explicitly to deal 
with the message formatting at global scope.



Comment at: lib/Format/TokenAnnotator.cpp:657
+if (Style.Language == FormatStyle::LK_TextProto) {
+  FormatToken *Previous =Tok->getPreviousNonComment();
+  if (Previous && Previous->Type != TT_DictLiteral)

djasper wrote:
> Missing space...
I don't understand? This has been formatted with clang-format.


https://reviews.llvm.org/D34441



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


[PATCH] D34329: [clang-diff] Initial implementation.

2017-07-03 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 105059.
johannes edited the summary of this revision.

https://reviews.llvm.org/D34329

Files:
  include/clang/Tooling/ASTDiff/ASTDiff.h
  include/clang/Tooling/ASTDiff/ASTDiffInternal.h
  lib/Tooling/ASTDiff/ASTDiff.cpp
  lib/Tooling/ASTDiff/CMakeLists.txt
  lib/Tooling/CMakeLists.txt
  test/Tooling/clang-diff-basic.cpp
  tools/CMakeLists.txt
  tools/clang-diff/CMakeLists.txt
  tools/clang-diff/ClangDiff.cpp

Index: tools/clang-diff/ClangDiff.cpp
===
--- /dev/null
+++ tools/clang-diff/ClangDiff.cpp
@@ -0,0 +1,110 @@
+//===- ClangDiff.cpp - compare source files by AST nodes --*- C++ -*- -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file implements a tool for syntax tree based comparison using
+// Tooling/ASTDiff.
+//
+//===--===//
+
+#include "clang/Tooling/ASTDiff/ASTDiff.h"
+#include "clang/Tooling/CommonOptionsParser.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Support/CommandLine.h"
+
+using namespace llvm;
+using namespace clang;
+using namespace clang::tooling;
+
+static cl::OptionCategory ClangDiffCategory("clang-diff options");
+
+static cl::opt
+DumpAST("ast-dump",
+cl::desc("Print the internal representation of the AST as JSON."),
+cl::init(false), cl::cat(ClangDiffCategory));
+
+static cl::opt NoCompilationDatabase(
+"no-compilation-database",
+cl::desc(
+"Do not attempt to load build settings from a compilation database"),
+cl::init(false), cl::cat(ClangDiffCategory));
+
+static cl::opt SourcePath(cl::Positional, cl::desc(""),
+   cl::Required,
+   cl::cat(ClangDiffCategory));
+
+static cl::opt DestinationPath(cl::Positional,
+cl::desc(""),
+cl::Optional,
+cl::cat(ClangDiffCategory));
+
+static std::unique_ptr getAST(const StringRef Filename) {
+  std::string ErrorMessage;
+  std::unique_ptr Compilations;
+  if (!NoCompilationDatabase)
+Compilations =
+CompilationDatabase::autoDetectFromSource(Filename, ErrorMessage);
+  if (!Compilations) {
+if (!NoCompilationDatabase)
+  llvm::errs()
+  << "Error while trying to load a compilation database, running "
+ "without flags.\n"
+  << ErrorMessage;
+Compilations = llvm::make_unique(
+".", std::vector());
+  }
+  std::array Files = {{Filename}};
+  ClangTool Tool(*Compilations, Files);
+  std::vector ASTs;
+  Tool.buildASTs(ASTs);
+  if (ASTs.size() != Files.size())
+return nullptr;
+  return std::move(ASTs[0]);
+}
+
+int main(int argc, const char **argv) {
+  cl::HideUnrelatedOptions(ClangDiffCategory);
+  if (!cl::ParseCommandLineOptions(argc, argv)) {
+cl::PrintOptionValues();
+return 1;
+  }
+
+  if (DumpAST) {
+if (!DestinationPath.empty()) {
+  llvm::errs() << "Error: Please specify exactly one filename.\n";
+  return 1;
+}
+std::unique_ptr AST = getAST(SourcePath);
+if (!AST)
+  return 1;
+diff::SyntaxTree Tree(AST->getASTContext());
+Tree.printAsJson(llvm::outs());
+return 0;
+  }
+
+  if (DestinationPath.empty()) {
+llvm::errs() << "Error: Exactly two paths are required.\n";
+return 1;
+  }
+
+  std::unique_ptr Src = getAST(SourcePath);
+  std::unique_ptr Dst = getAST(DestinationPath);
+  if (!Src || !Dst)
+return 1;
+
+  diff::ComparisonOptions Options;
+  diff::SyntaxTree SrcTree(Src->getASTContext());
+  diff::SyntaxTree DstTree(Dst->getASTContext());
+  diff::ASTDiff DiffTool(SrcTree, DstTree, Options);
+  for (const auto  : DiffTool.getMatches())
+DiffTool.printMatch(llvm::outs(), Match);
+  for (const auto  : DiffTool.getChanges())
+DiffTool.printChange(llvm::outs(), Change);
+
+  return 0;
+}
Index: tools/clang-diff/CMakeLists.txt
===
--- /dev/null
+++ tools/clang-diff/CMakeLists.txt
@@ -0,0 +1,13 @@
+set(LLVM_LINK_COMPONENTS
+  Support
+  )
+
+add_clang_executable(clang-diff
+  ClangDiff.cpp
+  )
+
+target_link_libraries(clang-diff
+  clangFrontend
+  clangTooling
+  clangToolingASTDiff
+  )
Index: tools/CMakeLists.txt
===
--- tools/CMakeLists.txt
+++ tools/CMakeLists.txt
@@ -2,6 +2,7 @@
 
 add_clang_subdirectory(diagtool)
 add_clang_subdirectory(driver)
+add_clang_subdirectory(clang-diff)
 add_clang_subdirectory(clang-format)
 add_clang_subdirectory(clang-format-vs)
 

[PATCH] D34912: Handle cases where the value is too large to fit into the underlying type.

2017-07-03 Thread Axel Naumann via Phabricator via cfe-commits
karies added a comment.

Two comments:

- I think the part `Val.getBitWidth() == 64` likely needs rewording, although I 
don't know how
- I can show the motivation, not sure whether that qualifies as a test case:

  $ echo 'template  struct S{}; S<(unsigned long long)-1> s 
= 42;' | clang++ -fsyntax-only -std=c++14 -x c++ -
  :1:69: error: no viable conversion from 'int' to 'S<(unsigned long 
long)-1>'
  template  struct S{}; S<(unsigned long long)-1> s = 42;
  ^   ~~
  :1:38: note: candidate constructor (the implicit copy constructor) not 
viable: no known conversion from 'int' to 'const S<18446744073709551615> &' for 
1st argument
  template  struct S{}; S<(unsigned long long)-1> s = 42;
   ^  ~~
  :1:38: note: candidate constructor (the implicit move constructor) not 
viable: no known conversion from 'int' to 'S<18446744073709551615> &&' for 1st 
argument
  template  struct S{}; S<(unsigned long long)-1> s = 42;
   ^  ~~
  1 error generated.

The following shows that the name clang usew for diagnostics 
(`S<18446744073709551615> &`) is actually invalid:

  $ echo 'template  struct S{}; S<18446744073709551615> a;' 
| clang++ -fsyntax-only -std=c++14 -x c++ -
  :1:45: warning: integer literal is too large to be represented in a 
signed integer type, interpreting as unsigned [-Wimplicitly-unsigned-literal]
  template  struct S{}; S<18446744073709551615> a;
  ^
  1 warning generated.

My goal is for clang to print a valid class name, which means this should be 
spelled S<18446744073709551615ull>`.


Repository:
  rL LLVM

https://reviews.llvm.org/D34912



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


[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis

2017-07-03 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 105053.
xazax.hun added a comment.

- Patch scan-build instead of using custom scripts
- Rebase patch based on the proposed LibTooling CTU code


https://reviews.llvm.org/D30691

Files:
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/CMakeLists.txt
  lib/StaticAnalyzer/Core/CallEvent.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  lib/StaticAnalyzer/Frontend/CMakeLists.txt
  test/Analysis/Inputs/ctu-chain.cpp
  test/Analysis/Inputs/ctu-other.cpp
  test/Analysis/Inputs/externalFnMap.txt
  test/Analysis/ctu-main.cpp
  tools/scan-build-py/libscanbuild/__init__.py
  tools/scan-build-py/libscanbuild/analyze.py
  tools/scan-build-py/libscanbuild/arguments.py
  tools/scan-build-py/libscanbuild/clang.py
  tools/scan-build-py/libscanbuild/report.py
  tools/scan-build-py/tests/unit/test_analyze.py
  tools/scan-build-py/tests/unit/test_clang.py

Index: tools/scan-build-py/tests/unit/test_clang.py
===
--- tools/scan-build-py/tests/unit/test_clang.py
+++ tools/scan-build-py/tests/unit/test_clang.py
@@ -92,3 +92,16 @@
 self.assertEqual('Checker One description', result.get('checker.one'))
 self.assertTrue('checker.two' in result)
 self.assertEqual('Checker Two description', result.get('checker.two'))
+
+
+class ClangIsCtuCapableTest(unittest.TestCase):
+def test_ctu_not_found(self):
+is_ctu = sut.is_ctu_capable('not-found-clang',
+'not-found-clang-func-mapping')
+self.assertFalse(is_ctu)
+
+
+class ClangGetTripleArchTest(unittest.TestCase):
+def test_arch_is_not_empty(self):
+arch = sut.get_triple_arch(['clang', '-E', '-'], '.')
+self.assertTrue(len(arch) > 0)
Index: tools/scan-build-py/tests/unit/test_analyze.py
===
--- tools/scan-build-py/tests/unit/test_analyze.py
+++ tools/scan-build-py/tests/unit/test_analyze.py
@@ -4,12 +4,12 @@
 # This file is distributed under the University of Illinois Open Source
 # License. See LICENSE.TXT for details.
 
-import libear
-import libscanbuild.analyze as sut
 import unittest
 import re
 import os
 import os.path
+import libear
+import libscanbuild.analyze as sut
 
 
 class ReportDirectoryTest(unittest.TestCase):
@@ -333,3 +333,83 @@
 
 def test_method_exception_not_caught(self):
 self.assertRaises(Exception, method_exception_from_inside, dict())
+
+
+class PrefixWithTest(unittest.TestCase):
+
+def test_gives_empty_on_empty(self):
+res = sut.prefix_with(0, [])
+self.assertFalse(res)
+
+def test_interleaves_prefix(self):
+res = sut.prefix_with(0, [1, 2, 3])
+self.assertListEqual([0, 1, 0, 2, 0, 3], res)
+
+
+class MergeCtuMapTest(unittest.TestCase):
+
+def test_no_map_gives_empty(self):
+pairs = sut.create_global_ctu_function_map([])
+self.assertFalse(pairs)
+
+def test_multiple_maps_merged(self):
+concat_map = ['_Z1fun1i@x86_64 ast/x86_64/fun1.c.ast',
+  '_Z1fun2i@x86_64 ast/x86_64/fun2.c.ast',
+  '_Z1fun3i@x86_64 ast/x86_64/fun3.c.ast']
+pairs = sut.create_global_ctu_function_map(concat_map)
+self.assertTrue(('_Z1fun1i@x86_64', 'ast/x86_64/fun1.c.ast') in pairs)
+self.assertTrue(('_Z1fun2i@x86_64', 'ast/x86_64/fun2.c.ast') in pairs)
+self.assertTrue(('_Z1fun3i@x86_64', 'ast/x86_64/fun3.c.ast') in pairs)
+self.assertEqual(3, len(pairs))
+
+def test_not_unique_func_left_out(self):
+concat_map = ['_Z1fun1i@x86_64 ast/x86_64/fun1.c.ast',
+  '_Z1fun2i@x86_64 ast/x86_64/fun2.c.ast',
+  '_Z1fun1i@x86_64 ast/x86_64/fun7.c.ast']
+pairs = sut.create_global_ctu_function_map(concat_map)
+self.assertFalse(('_Z1fun1i@x86_64', 'ast/x86_64/fun1.c.ast') in pairs)
+self.assertFalse(('_Z1fun1i@x86_64', 'ast/x86_64/fun7.c.ast') in pairs)
+self.assertTrue(('_Z1fun2i@x86_64', 'ast/x86_64/fun2.c.ast') in pairs)
+self.assertEqual(1, len(pairs))
+
+def test_duplicates_are_kept(self):
+concat_map = ['_Z1fun1i@x86_64 ast/x86_64/fun1.c.ast',
+  '_Z1fun2i@x86_64 ast/x86_64/fun2.c.ast',
+  '_Z1fun1i@x86_64 ast/x86_64/fun1.c.ast']
+pairs = sut.create_global_ctu_function_map(concat_map)
+self.assertTrue(('_Z1fun1i@x86_64', 'ast/x86_64/fun1.c.ast') in pairs)
+self.assertTrue(('_Z1fun2i@x86_64', 'ast/x86_64/fun2.c.ast') in pairs)
+self.assertEqual(2, len(pairs))
+
+def test_space_handled_in_source(self):
+

[PATCH] D34441: [clang-format] Support text proto messages

2017-07-03 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 105044.
krasimir marked 3 inline comments as done.
krasimir added a comment.

- Address review comments


https://reviews.llvm.org/D34441

Files:
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/TokenAnnotator.cpp
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/CMakeLists.txt
  unittests/Format/FormatTestTextProto.cpp

Index: unittests/Format/FormatTestTextProto.cpp
===
--- /dev/null
+++ unittests/Format/FormatTestTextProto.cpp
@@ -0,0 +1,251 @@
+//===- unittest/Format/FormatTestProto.cpp ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "FormatTestUtils.h"
+#include "clang/Format/Format.h"
+#include "llvm/Support/Debug.h"
+#include "gtest/gtest.h"
+
+#define DEBUG_TYPE "format-test"
+
+namespace clang {
+namespace format {
+
+class FormatTestTextProto : public ::testing::Test {
+protected:
+  static std::string format(llvm::StringRef Code, unsigned Offset,
+unsigned Length, const FormatStyle ) {
+DEBUG(llvm::errs() << "---\n");
+DEBUG(llvm::errs() << Code << "\n\n");
+std::vector Ranges(1, tooling::Range(Offset, Length));
+tooling::Replacements Replaces = reformat(Style, Code, Ranges);
+auto Result = applyAllReplacements(Code, Replaces);
+EXPECT_TRUE(static_cast(Result));
+DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
+return *Result;
+  }
+
+  static std::string format(llvm::StringRef Code) {
+FormatStyle Style = getGoogleStyle(FormatStyle::LK_TextProto);
+Style.ColumnLimit = 60; // To make writing tests easier.
+return format(Code, 0, Code.size(), Style);
+  }
+
+  static void verifyFormat(llvm::StringRef Code) {
+EXPECT_EQ(Code.str(), format(test::messUp(Code)));
+  }
+};
+
+TEST_F(FormatTestTextProto, KeepsTopLevelEntriesFittingALine) {
+  verifyFormat("field_a: OK field_b: OK field_c: OK field_d: OK field_e: OK");
+}
+
+TEST_F(FormatTestTextProto, SupportsMessageFields) {
+  verifyFormat("msg_field: {}");
+
+  verifyFormat("msg_field: {field_a: A}");
+
+  verifyFormat("msg_field: {field_a: \"OK\" field_b: 123}");
+
+  verifyFormat("msg_field: {\n"
+   "  field_a: 1\n"
+   "  field_b: OK\n"
+   "  field_c: \"OK\"\n"
+   "  field_d: 123\n"
+   "  field_e: 23\n"
+   "}");
+
+  verifyFormat("msg_field{}");
+
+  verifyFormat("msg_field{field_a: A}");
+
+  verifyFormat("msg_field{field_a: \"OK\" field_b: 123}");
+
+  verifyFormat("msg_field{\n"
+   "  field_a: 1\n"
+   "  field_b: OK\n"
+   "  field_c: \"OK\"\n"
+   "  field_d: 123\n"
+   "  field_e: 23.0\n"
+   "  field_f: false\n"
+   "  field_g: 'lala'\n"
+   "  field_h: 1234.567e-89\n"
+   "}");
+
+  verifyFormat("msg_field: {msg_field{field_a: 1}}");
+
+  verifyFormat("id: \"ala.bala\"\n"
+   "item{type: ITEM_A rank: 1 score: 90.0}\n"
+   "item{type: ITEM_B rank: 2 score: 70.5}\n"
+   "item{\n"
+   "  type: ITEM_A\n"
+   "  rank: 3\n"
+   "  score: 20.0\n"
+   "  description: \"the third item has a description\"\n"
+   "}");
+}
+
+TEST_F(FormatTestTextProto, AvoidsTopLevelBinPacking) {
+  verifyFormat("field_a: OK\n"
+   "field_b: OK\n"
+   "field_c: OK\n"
+   "field_d: OK\n"
+   "field_e: OK\n"
+   "field_f: OK");
+
+  verifyFormat("field_a: OK\n"
+   "field_b: \"OK\"\n"
+   "field_c: \"OK\"\n"
+   "msg_field: {field_d: 123}\n"
+   "field_e: OK\n"
+   "field_f: OK");
+
+  verifyFormat("field_a: OK\n"
+   "field_b: \"OK\"\n"
+   "field_c: \"OK\"\n"
+   "msg_field: {field_d: 123 field_e: OK}");
+
+  verifyFormat("a: {\n"
+   "  field_a: OK\n"
+   "  field_b{field_c: OK}\n"
+   "  field_d: OKOKOK\n"
+   "  field_e: OK\n"
+   "}");
+
+  verifyFormat("field_a: OK,\n"
+   "field_b{field_c: OK},\n"
+   "field_d: OKOKOK,\n"
+   "field_e: OK");
+}
+
+TEST_F(FormatTestTextProto, AddsNewlinesAfterTrailingComments) {
+  verifyFormat("field_a: OK  // Comment\n"
+   "field_b: 1");
+
+  verifyFormat("field_a: OK\n"
+   "msg_field: {\n"
+   "  field_b: OK  // Comment\n"
+   "}");
+
+  verifyFormat("field_a: OK\n"
+   "msg_field{\n"
+   "  

[PATCH] D34936: [clangd] Add -ffreestanding on VFS tests.

2017-07-03 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Implicit `stdc-predef.h` include is not yet there, but will appear after 
https://reviews.llvm.org/D34158 has landed.


https://reviews.llvm.org/D34936



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


[PATCH] D34886: Add a fixit for -Wobjc-protocol-property-synthesis

2017-07-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman marked an inline comment as done.
arphaman added inline comments.



Comment at: include/clang/Sema/Sema.h:3351
+   ObjCInterfaceDecl *IDecl, SourceRange 
AtEnd);
+  void DefaultSynthesizeProperties(Scope *S, Decl *D, SourceRange AtEnd);
 

vsk wrote:
> Is a range required? We're only using a single sloc.
No, I'll pass the loc only. Thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D34886



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


[PATCH] D33644: Add default values for function parameter chunks

2017-07-03 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan updated this revision to Diff 105045.
yvvan added a comment.

Add tests, append tests with default values. Move all default value handling to 
GetDefaultValueString


https://reviews.llvm.org/D33644

Files:
  lib/Sema/SemaCodeComplete.cpp
  test/CodeCompletion/functions.cpp
  test/Index/code-completion.cpp
  test/Index/complete-optional-params.cpp

Index: test/Index/complete-optional-params.cpp
===
--- test/Index/complete-optional-params.cpp
+++ test/Index/complete-optional-params.cpp
@@ -6,15 +6,19 @@
 void baz(int a = 42, ...);
 struct S{ S(int a = 42, int = 42) {} };
 
+class Bar1 { public: Bar1() {} }; class Bar2;
+void foo_2(Bar1 b1 = Bar1(), Bar2 b2 = Bar2());
+
 int main() {
 foo(42, 42);
 bar(42, 42, 42);
 baz(42, 42, 42);
 S s(42, 42);
+foo_2();
 }
 
-// RUN: c-index-test -code-completion-at=%s:10:9 %s | FileCheck -check-prefix=CHECK-CC1 %s
-// CHECK-CC1: OverloadCandidate:{ResultType void}{Text foo}{LeftParen (}{Optional {CurrentParameter int a}{Optional {Comma , }{Placeholder int}}}{RightParen )} (1)
+// RUN: c-index-test -code-completion-at=%s:13:9 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: OverloadCandidate:{ResultType void}{Text foo}{LeftParen (}{Optional {CurrentParameter int a = 42}{Optional {Comma , }{Placeholder int = 42}}}{RightParen )} (1)
 // CHECK-CC1: Completion contexts:
 // CHECK-CC1-NEXT: Any type
 // CHECK-CC1-NEXT: Any value
@@ -25,8 +29,8 @@
 // CHECK-CC1-NEXT: Nested name specifier
 // CHECK-CC1-NEXT: Objective-C interface
 
-// RUN: c-index-test -code-completion-at=%s:11:9 %s | FileCheck -check-prefix=CHECK-CC2 %s
-// CHECK-CC2: OverloadCandidate:{ResultType void}{Text bar}{LeftParen (}{CurrentParameter int a}{Optional {Comma , }{Placeholder int b}{Optional {Comma , }{Placeholder int c}}}{RightParen )} (1)
+// RUN: c-index-test -code-completion-at=%s:14:9 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: OverloadCandidate:{ResultType void}{Text bar}{LeftParen (}{CurrentParameter int a}{Optional {Comma , }{Placeholder int b = 42}{Optional {Comma , }{Placeholder int c = 42}}}{RightParen )} (1)
 // CHECK-CC2: Completion contexts:
 // CHECK-CC2-NEXT: Any type
 // CHECK-CC2-NEXT: Any value
@@ -37,8 +41,8 @@
 // CHECK-CC2-NEXT: Nested name specifier
 // CHECK-CC2-NEXT: Objective-C interface
 
-// RUN: c-index-test -code-completion-at=%s:11:16 %s | FileCheck -check-prefix=CHECK-CC3 %s
-// CHECK-CC3: OverloadCandidate:{ResultType void}{Text bar}{LeftParen (}{Placeholder int a}{Optional {Comma , }{Placeholder int b}{Optional {Comma , }{CurrentParameter int c}}}{RightParen )} (1)
+// RUN: c-index-test -code-completion-at=%s:14:16 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: OverloadCandidate:{ResultType void}{Text bar}{LeftParen (}{Placeholder int a}{Optional {Comma , }{Placeholder int b = 42}{Optional {Comma , }{CurrentParameter int c = 42}}}{RightParen )} (1)
 // CHECK-CC3: Completion contexts:
 // CHECK-CC3-NEXT: Any type
 // CHECK-CC3-NEXT: Any value
@@ -49,8 +53,8 @@
 // CHECK-CC3-NEXT: Nested name specifier
 // CHECK-CC3-NEXT: Objective-C interface
 
-// RUN: c-index-test -code-completion-at=%s:12:16 %s | FileCheck -check-prefix=CHECK-CC4 %s
-// CHECK-CC4: OverloadCandidate:{ResultType void}{Text baz}{LeftParen (}{Optional {Placeholder int a}{Optional {Comma , }{CurrentParameter ...}}}{RightParen )} (1)
+// RUN: c-index-test -code-completion-at=%s:15:16 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: OverloadCandidate:{ResultType void}{Text baz}{LeftParen (}{Optional {Placeholder int a = 42}{Optional {Comma , }{CurrentParameter ...}}}{RightParen )} (1)
 // CHECK-CC4: Completion contexts:
 // CHECK-CC4-NEXT: Any type
 // CHECK-CC4-NEXT: Any value
@@ -61,8 +65,8 @@
 // CHECK-CC4-NEXT: Nested name specifier
 // CHECK-CC4-NEXT: Objective-C interface
 
-// RUN: c-index-test -code-completion-at=%s:13:9 %s | FileCheck -check-prefix=CHECK-CC5 %s
-// CHECK-CC5: OverloadCandidate:{Text S}{LeftParen (}{Optional {CurrentParameter int a}{Optional {Comma , }{Placeholder int}}}{RightParen )} (1)
+// RUN: c-index-test -code-completion-at=%s:16:9 %s | FileCheck -check-prefix=CHECK-CC5 %s
+// CHECK-CC5: OverloadCandidate:{Text S}{LeftParen (}{Optional {CurrentParameter int a = 42}{Optional {Comma , }{Placeholder int = 42}}}{RightParen )} (1)
 // CHECK-CC5: OverloadCandidate:{Text S}{LeftParen (}{CurrentParameter const S &}{RightParen )} (1)
 // CHECK-CC5: Completion contexts:
 // CHECK-CC5-NEXT: Any type
@@ -73,3 +77,15 @@
 // CHECK-CC5-NEXT: Class name
 // CHECK-CC5-NEXT: Nested name specifier
 // CHECK-CC5-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:17:11 %s | FileCheck -check-prefix=CHECK-CC6 %s
+// CHECK-CC6: FunctionDecl:{ResultType void}{TypedText foo_2}{LeftParen (}{Optional {Placeholder Bar1 b1 = Bar1()}{Optional {Comma , }{Placeholder Bar2 b2}}}{RightParen )} (50)
+// CHECK-CC6: Completion contexts:
+// CHECK-CC6-NEXT: Any type

[PATCH] D34158: to support gcc 4.8 (and newer) compatibility on Linux, preinclude

2017-07-03 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Here's a patch to fix ClangdTests: https://reviews.llvm.org/D34936
We should probably land it before your patch to avoid ClangdTests failures 
between those llvm and clang-tools-extra revisions.


Repository:
  rL LLVM

https://reviews.llvm.org/D34158



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


[PATCH] D34158: to support gcc 4.8 (and newer) compatibility on Linux, preinclude

2017-07-03 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

In https://reviews.llvm.org/D34158#797170, @mibintc wrote:

> The other test that fails is my own new test! It fails because I don't know 
> how to set it up so the test thinks it has a gcc toolchain with version > 
> 4.8. I tried using gcc-toolchain set to various other Linux toolchains that i 
> see in the test/Driver/Inputs - none of them cause the gcc version to be in 
> the range. I also tried using -ccc-installation=Inputs/ which I see being 
> used for gcc version parsing. How can I set up the test so that the 
> GCCInstallation has a Version >= 4.8?  I test the new functionality from the 
> console on Linux and can confirm it's working.


You could try adding a completely new directory in `Inputs/`. Add the directory 
`usr/lib/gcc/x86_64-unknown-linux/4.9.0` underneath which //should// be 
recognized as the version. Maybe you have to add some more files, I'm not 
really familiar with the detection mechanism...




Comment at: lib/Driver/ToolChains/Gnu.cpp:2332-2343
+void Generic_GCC::addGnuIncludeArgs(const ArgList , 
+ArgStringList ) const {
+  const Generic_GCC::GCCVersion  = GCCInstallation.getVersion();
+  if (!DriverArgs.hasArg(options::OPT_ffreestanding) &&
+  !DriverArgs.hasArg(clang::driver::options::OPT_nostdinc) &&
+  !Version.isOlderThan(4, 8, 0)) {
+// For gcc >= 4.8.x, gcc will preinclude 

I think this can still be moved to Linux...



Comment at: test/Driver/gcc-predef.c:27
+#if defined( DUMMY_STDC_PREDEF )
+  #error "stdc-predef.h should not be preincluded for gcc < 4.8.x"
+#endif

Maybe it's better to run clang with `-###` and checking that it passes 
`-include` to cc1?

Then you can have:
```
// CHECK-PREDEF: "-include" "stdc-predef.h"
// CHECK-NO-PREDEF-NOT: "-include" "stdc-predef.h"
```
and pass the corresponding prefixes to FileCheck. Could you also add a test 
that it the file is not included if it does not exist? This can be done with 
the current `basic_linux_tree`


Repository:
  rL LLVM

https://reviews.llvm.org/D34158



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


[PATCH] D34937: Suppressing Reference Counting Diagnostics for Functions Containing 'rc_ownership_trusted_implementation' Annotate Attribute

2017-07-03 Thread Malhar Thakkar via Phabricator via cfe-commits
malhar1995 updated this revision to Diff 105043.

Repository:
  rL LLVM

https://reviews.llvm.org/D34937

Files:
  lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp

Index: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
@@ -1894,6 +1894,22 @@
   return SFC->getAnalysisDeclContext()->isBodyAutosynthesized();
 }
 
+bool
+isAnnotatedToSkipDiagnostics(const LocationContext *LCtx) {
+  while (LCtx) {
+if (const StackFrameContext *SFC = dyn_cast(LCtx)) {
+  const Decl *D = SFC->getDecl();
+  for (const auto *Ann : D->specific_attrs()){
+if (Ann->getAnnotation() == "rc_ownership_trusted_implementation") {
+  return true;
+}
+  }
+}
+LCtx = LCtx->getParent();
+  }
+  return false;
+}
+
 std::shared_ptr
 CFRefReportVisitor::VisitNode(const ExplodedNode *N, const ExplodedNode *PrevN,
   BugReporterContext , BugReport ) {
@@ -3345,11 +3361,13 @@
   }
 
   assert(BT);
-  auto report = std::unique_ptr(
-  new CFRefReport(*BT, C.getASTContext().getLangOpts(), C.isObjCGCEnabled(),
-  SummaryLog, N, Sym));
-  report->addRange(ErrorRange);
-  C.emitReport(std::move(report));
+  if (!isAnnotatedToSkipDiagnostics(N->getLocationContext())){
+auto report = std::unique_ptr(
+new CFRefReport(*BT, C.getASTContext().getLangOpts(), C.isObjCGCEnabled(),
+SummaryLog, N, Sym));
+report->addRange(ErrorRange);
+C.emitReport(std::move(report));
+  }
 }
 
 //===--===//
@@ -3579,9 +3597,10 @@
 if (N) {
   const LangOptions  = C.getASTContext().getLangOpts();
   bool GCEnabled = C.isObjCGCEnabled();
-  C.emitReport(std::unique_ptr(new CFRefLeakReport(
-  *getLeakAtReturnBug(LOpts, GCEnabled), LOpts, GCEnabled,
-  SummaryLog, N, Sym, C, IncludeAllocationLine)));
+  if (!isAnnotatedToSkipDiagnostics(N->getLocationContext()))
+C.emitReport(std::unique_ptr(new CFRefLeakReport(
+*getLeakAtReturnBug(LOpts, GCEnabled), LOpts, GCEnabled,
+SummaryLog, N, Sym, C, IncludeAllocationLine)));
 }
   }
 }
@@ -3606,9 +3625,10 @@
   if (!returnNotOwnedForOwned)
 returnNotOwnedForOwned.reset(new ReturnedNotOwnedForOwned(this));
 
-  C.emitReport(std::unique_ptr(new CFRefReport(
-  *returnNotOwnedForOwned, C.getASTContext().getLangOpts(),
-  C.isObjCGCEnabled(), SummaryLog, N, Sym)));
+  if (!isAnnotatedToSkipDiagnostics(N->getLocationContext()))
+C.emitReport(std::unique_ptr(new CFRefReport(
+*returnNotOwnedForOwned, C.getASTContext().getLangOpts(),
+C.isObjCGCEnabled(), SummaryLog, N, Sym)));
 }
   }
 }
@@ -3811,9 +3831,10 @@
   overAutorelease.reset(new OverAutorelease(this));
 
 const LangOptions  = Ctx.getASTContext().getLangOpts();
-Ctx.emitReport(std::unique_ptr(
-new CFRefReport(*overAutorelease, LOpts, /* GCEnabled = */ false,
-SummaryLog, N, Sym, os.str(;
+if (!isAnnotatedToSkipDiagnostics(N->getLocationContext()))
+  Ctx.emitReport(std::unique_ptr(
+  new CFRefReport(*overAutorelease, LOpts, /* GCEnabled = */ false,
+  SummaryLog, N, Sym, os.str(;
   }
 
   return nullptr;
@@ -3865,9 +3886,10 @@
   : getLeakAtReturnBug(LOpts, GCEnabled);
   assert(BT && "BugType not initialized.");
 
-  Ctx.emitReport(std::unique_ptr(
-  new CFRefLeakReport(*BT, LOpts, GCEnabled, SummaryLog, N, *I, Ctx,
-  IncludeAllocationLine)));
+  if (!isAnnotatedToSkipDiagnostics(N->getLocationContext()))
+Ctx.emitReport(std::unique_ptr(
+new CFRefLeakReport(*BT, LOpts, GCEnabled, SummaryLog, N, *I, Ctx,
+IncludeAllocationLine)));
 }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34936: [clangd] Add -ffreestanding on VFS tests.

2017-07-03 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.
This revision is now accepted and ready to land.

Looks good.


https://reviews.llvm.org/D34936



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


[PATCH] D34936: [clangd] Add -ffreestanding on VFS tests.

2017-07-03 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.

They don't provide proper gcc installations and may fail on implicit
 include.


https://reviews.llvm.org/D34936

Files:
  unittests/clangd/ClangdTests.cpp


Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -164,6 +164,13 @@
 
 class MockCompilationDatabase : public GlobalCompilationDatabase {
 public:
+  MockCompilationDatabase(bool AddFreestandingFlag) {
+// We have to add -ffreestanding to VFS-specific tests to avoid errors on
+// implicit includes of stdc-predef.h.
+if (AddFreestandingFlag)
+  ExtraClangFlags.push_back("-ffreestanding");
+  }
+
   std::vector
   getCompileCommands(PathRef File) override {
 if (ExtraClangFlags.empty())
@@ -259,7 +266,7 @@
   bool ExpectErrors = false) {
 MockFSProvider FS;
 ErrorCheckingDiagConsumer DiagConsumer;
-MockCompilationDatabase CDB;
+MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 ClangdServer Server(CDB, DiagConsumer, FS,
 /*RunSynchronously=*/false);
 for (const auto  : ExtraFiles)
@@ -315,7 +322,7 @@
 TEST_F(ClangdVFSTest, Reparse) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
-  MockCompilationDatabase CDB;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS,
   /*RunSynchronously=*/false);
 
@@ -350,7 +357,7 @@
 TEST_F(ClangdVFSTest, ReparseOnHeaderChange) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
-  MockCompilationDatabase CDB;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS,
   /*RunSynchronously=*/false);
@@ -388,7 +395,7 @@
 TEST_F(ClangdVFSTest, CheckVersions) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
-  MockCompilationDatabase CDB;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS,
   /*RunSynchronously=*/true);
 
@@ -414,8 +421,10 @@
   // Checks that searches for GCC installation is done through vfs.
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
-  MockCompilationDatabase CDB;
-  CDB.ExtraClangFlags = {"-xc++", "-target", "x86_64-linux-unknown", "-m64"};
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
+  CDB.ExtraClangFlags.insert(
+  CDB.ExtraClangFlags.end(),
+  {"-xc++", "-target", "x86_64-linux-unknown", "-m64"});
   ClangdServer Server(CDB, DiagConsumer, FS,
   /*RunSynchronously=*/true);
 
@@ -472,7 +481,7 @@
 TEST_F(ClangdCompletionTest, CheckContentsOverride) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
-  MockCompilationDatabase CDB;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS,
   /*RunSynchronously=*/false);


Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -164,6 +164,13 @@
 
 class MockCompilationDatabase : public GlobalCompilationDatabase {
 public:
+  MockCompilationDatabase(bool AddFreestandingFlag) {
+// We have to add -ffreestanding to VFS-specific tests to avoid errors on
+// implicit includes of stdc-predef.h.
+if (AddFreestandingFlag)
+  ExtraClangFlags.push_back("-ffreestanding");
+  }
+
   std::vector
   getCompileCommands(PathRef File) override {
 if (ExtraClangFlags.empty())
@@ -259,7 +266,7 @@
   bool ExpectErrors = false) {
 MockFSProvider FS;
 ErrorCheckingDiagConsumer DiagConsumer;
-MockCompilationDatabase CDB;
+MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 ClangdServer Server(CDB, DiagConsumer, FS,
 /*RunSynchronously=*/false);
 for (const auto  : ExtraFiles)
@@ -315,7 +322,7 @@
 TEST_F(ClangdVFSTest, Reparse) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
-  MockCompilationDatabase CDB;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS,
   /*RunSynchronously=*/false);
 
@@ -350,7 +357,7 @@
 TEST_F(ClangdVFSTest, ReparseOnHeaderChange) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
-  MockCompilationDatabase CDB;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS,
   /*RunSynchronously=*/false);
@@ -388,7 +395,7 @@
 TEST_F(ClangdVFSTest, CheckVersions) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
-  MockCompilationDatabase CDB;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS,
   

[PATCH] D34810: [Sema] -Wcomma should not warn for expressions that return void

2017-07-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman abandoned this revision.
arphaman added a comment.

Abandoning. The current behaviour makes sense. Thanks for the responses!


Repository:
  rL LLVM

https://reviews.llvm.org/D34810



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


r307023 - clang-format: [JS] space between pseudo keywords and template literals.

2017-07-03 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Mon Jul  3 07:29:13 2017
New Revision: 307023

URL: http://llvm.org/viewvc/llvm-project?rev=307023=rev
Log:
clang-format: [JS] space between pseudo keywords and template literals.

Summary:
Before:
yield`foo`;

After:
yield `foo`;

Reviewers: djasper

Subscribers: klimek

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

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=307023=307022=307023=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Jul  3 07:29:13 2017
@@ -2300,7 +2300,11 @@ bool TokenAnnotator::spaceRequiredBefore
 if ((Left.is(TT_TemplateString) && Left.TokenText.endswith("${")) ||
 (Right.is(TT_TemplateString) && Right.TokenText.startswith("}")))
   return false;
-if (Left.is(tok::identifier) && Right.is(TT_TemplateString))
+// In tagged template literals ("html`bar baz`"), there is no space between
+// the tag identifier and the template string. getIdentifierInfo makes sure
+// that the identifier is not a pseudo keyword like `yield`, either.
+if (Left.is(tok::identifier) && Left.Tok.getIdentifierInfo() == nullptr &&
+Right.is(TT_TemplateString))
   return false;
 if (Right.is(tok::star) &&
 Left.isOneOf(Keywords.kw_function, Keywords.kw_yield))

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=307023=307022=307023=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Jul  3 07:29:13 2017
@@ -1564,6 +1564,7 @@ TEST_F(FormatTestJS, TemplateStrings) {
"   a(  //\n"
"   a)\n"
" })`);");
+  verifyFormat("yield `hello`;");
 }
 
 TEST_F(FormatTestJS, TemplateStringMultiLineExpression) {


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


r307016 - [index] Remove 'implicit' role for message sends in implicit ObjC

2017-07-03 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Jul  3 03:34:46 2017
New Revision: 307016

URL: http://llvm.org/viewvc/llvm-project?rev=307016=rev
Log:
[index] Remove 'implicit' role for message sends in implicit ObjC
property references

rdar://32375673

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

Modified: cfe/trunk/lib/Index/IndexBody.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexBody.cpp?rev=307016=307015=307016=diff
==
--- cfe/trunk/lib/Index/IndexBody.cpp (original)
+++ cfe/trunk/lib/Index/IndexBody.cpp Mon Jul  3 03:34:46 2017
@@ -230,7 +230,31 @@ public:
   SmallVector Relations;
   addCallRole(Roles, Relations);
   Stmt *Containing = getParentStmt();
-  if (E->isImplicit() || (Containing && isa(Containing)))
+
+  auto IsImplicitProperty = [](const PseudoObjectExpr *POE) -> bool {
+const auto *E = POE->getSyntacticForm();
+if (const auto *BinOp = dyn_cast(E))
+  E = BinOp->getLHS();
+const auto *PRE = dyn_cast(E);
+if (!PRE)
+  return false;
+if (PRE->isExplicitProperty())
+  return false;
+if (const ObjCMethodDecl *Getter = PRE->getImplicitPropertyGetter()) {
+  // Class properties that are explicitly defined using @property
+  // declarations are represented implicitly as there is no ivar for
+  // class properties.
+  if (Getter->isClassMethod() &&
+  Getter->getCanonicalDecl()->findPropertyDecl())
+return false;
+}
+return true;
+  };
+  bool IsPropCall = Containing && isa(Containing);
+  // Implicit property message sends are not 'implicit'.
+  if ((E->isImplicit() || IsPropCall) &&
+  !(IsPropCall &&
+IsImplicitProperty(cast(Containing
 Roles |= (unsigned)SymbolRole::Implicit;
 
   if (isDynamic(E)) {

Modified: cfe/trunk/test/Index/Core/index-source.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.m?rev=307016=307015=307016=diff
==
--- cfe/trunk/test/Index/Core/index-source.m (original)
+++ cfe/trunk/test/Index/Core/index-source.m Mon Jul  3 03:34:46 2017
@@ -413,3 +413,28 @@ void classReceivers() {
   (void)ClassReceivers.implicit;
 // CHECK: [[@LINE-1]]:9 | class/ObjC | ClassReceivers | 
c:objc(cs)ClassReceivers | _OBJC_CLASS_$_ClassReceivers | Ref,RelCont | rel: 1
 }
+
+@interface ImplicitProperties
+
+- (int)implicit;
+- (void)setImplicit:(int)x;
+
++ (int)classImplicit;
++ (void)setClassImplicit:(int)y;
+
+@end
+
+void testImplicitProperties(ImplicitProperties *c) {
+  c.implicit = 0;
+// CHECK: [[@LINE-1]]:5 | instance-method/ObjC | setImplicit: | 
c:objc(cs)ImplicitProperties(im)setImplicit: | -[ImplicitProperties 
setImplicit:] | Ref,Call,Dyn,RelRec,RelCall,RelCont | rel: 2
+// CHECK-NEXT: RelCall,RelCont | testImplicitProperties | 
c:@F@testImplicitProperties
+  c.implicit;
+// CHECK: [[@LINE-1]]:5 | instance-method/ObjC | implicit | 
c:objc(cs)ImplicitProperties(im)implicit | -[ImplicitProperties implicit] | 
Ref,Call,Dyn,RelRec,RelCall,RelCont | rel: 2
+// CHECK-NEXT: RelCall,RelCont | testImplicitProperties | 
c:@F@testImplicitProperties
+  ImplicitProperties.classImplicit = 1;
+// CHECK: [[@LINE-1]]:22 | class-method/ObjC | setClassImplicit: | 
c:objc(cs)ImplicitProperties(cm)setClassImplicit: | +[ImplicitProperties 
setClassImplicit:] | Ref,Call,RelCall,RelCont | rel: 1
+// CHECK-NEXT: RelCall,RelCont | testImplicitProperties | 
c:@F@testImplicitProperties
+  ImplicitProperties.classImplicit;
+// CHECK: [[@LINE-1]]:22 | class-method/ObjC | classImplicit | 
c:objc(cs)ImplicitProperties(cm)classImplicit | +[ImplicitProperties 
classImplicit] | Ref,Call,RelCall,RelCont | rel: 1
+// CHECK-NEXT: RelCall,RelCont | testImplicitProperties | 
c:@F@testImplicitProperties
+}


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


r307014 - Add a fixit for -Wobjc-protocol-property-synthesis

2017-07-03 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Jul  3 03:12:24 2017
New Revision: 307014

URL: http://llvm.org/viewvc/llvm-project?rev=307014=rev
Log:
Add a fixit for -Wobjc-protocol-property-synthesis

rdar://32132756

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

Added:
cfe/trunk/test/FixIt/fixit-add-synthesize-to-property.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/test/SemaObjC/default-synthesize-3.m
cfe/trunk/test/SemaObjC/default-synthesize.m
cfe/trunk/test/SemaObjC/forward-protocol-incomplete-impl-warn.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=307014=307013=307014=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Jul  3 03:12:24 
2017
@@ -1029,6 +1029,8 @@ def warn_auto_synthesizing_protocol_prop
   "auto property synthesis will not synthesize property %0"
   " declared in protocol %1">,
   InGroup>;
+def note_add_synthesize_directive : Note<
+  "add a '@synthesize' directive">;
 def warn_no_autosynthesis_shared_ivar_property : Warning <
   "auto property synthesis will not synthesize property "
   "%0 because it cannot share an ivar with another synthesized property">,

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=307014=307013=307014=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Jul  3 03:12:24 2017
@@ -3358,9 +3358,10 @@ public:
 
   /// DefaultSynthesizeProperties - This routine default synthesizes all
   /// properties which must be synthesized in the class's \@implementation.
-  void DefaultSynthesizeProperties (Scope *S, ObjCImplDecl* IMPDecl,
-ObjCInterfaceDecl *IDecl);
-  void DefaultSynthesizeProperties(Scope *S, Decl *D);
+  void DefaultSynthesizeProperties(Scope *S, ObjCImplDecl *IMPDecl,
+   ObjCInterfaceDecl *IDecl,
+   SourceLocation AtEnd);
+  void DefaultSynthesizeProperties(Scope *S, Decl *D, SourceLocation AtEnd);
 
   /// IvarBacksCurrentMethodAccessor - This routine returns 'true' if 'IV' is
   /// an ivar synthesized for 'Method' and 'Method' is a property accessor

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=307014=307013=307014=diff
==
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Mon Jul  3 03:12:24 2017
@@ -2255,7 +2255,7 @@ Parser::ObjCImplParsingDataRAII::~ObjCIm
 
 void Parser::ObjCImplParsingDataRAII::finish(SourceRange AtEnd) {
   assert(!Finished);
-  P.Actions.DefaultSynthesizeProperties(P.getCurScope(), Dcl);
+  P.Actions.DefaultSynthesizeProperties(P.getCurScope(), Dcl, 
AtEnd.getBegin());
   for (size_t i = 0; i < LateParsedObjCMethods.size(); ++i)
 P.ParseLexedObjCMethodDefs(*LateParsedObjCMethods[i], 
true/*Methods*/);

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=307014=307013=307014=diff
==
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Mon Jul  3 03:12:24 2017
@@ -1676,8 +1676,9 @@ static bool SuperClassImplementsProperty
 
 /// \brief Default synthesizes all properties which must be synthesized
 /// in class's \@implementation.
-void Sema::DefaultSynthesizeProperties(Scope *S, ObjCImplDecl* IMPDecl,
-   ObjCInterfaceDecl *IDecl) {
+void Sema::DefaultSynthesizeProperties(Scope *S, ObjCImplDecl *IMPDecl,
+   ObjCInterfaceDecl *IDecl,
+   SourceLocation AtEnd) {
   ObjCInterfaceDecl::PropertyMap PropMap;
   ObjCInterfaceDecl::PropertyDeclOrder PropertyOrder;
   IDecl->collectPropertiesToImplement(PropMap, PropertyOrder);
@@ -1725,6 +1726,10 @@ void Sema::DefaultSynthesizeProperties(S
  diag::warn_auto_synthesizing_protocol_property)
   << Prop << Proto;
 Diag(Prop->getLocation(), diag::note_property_declare);
+std::string FixIt =
+(Twine("@synthesize ") + Prop->getName() + ";\n\n").str();
+Diag(AtEnd, diag::note_add_synthesize_directive)
+<< 

r307007 - fix trivial typos in comments; NFC

2017-07-03 Thread Hiroshi Inoue via cfe-commits
Author: inouehrs
Date: Mon Jul  3 01:49:44 2017
New Revision: 307007

URL: http://llvm.org/viewvc/llvm-project?rev=307007=rev
Log:
fix trivial typos in comments; NFC

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
cfe/trunk/www/analyzer/scripts/expandcollapse.js

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=307007=307006=307007=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Mon Jul  3 01:49:44 2017
@@ -782,7 +782,7 @@ CursorKind.CONVERSION_FUNCTION = CursorK
 # A C++ template type parameter
 CursorKind.TEMPLATE_TYPE_PARAMETER = CursorKind(27)
 
-# A C++ non-type template paramater.
+# A C++ non-type template parameter.
 CursorKind.TEMPLATE_NON_TYPE_PARAMETER = CursorKind(28)
 
 # A C++ template template parameter.

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=307007=307006=307007=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Mon Jul  3 01:49:44 2017
@@ -1255,7 +1255,7 @@ CodeGenFunction::GenerateBlockFunction(G
 
   // For OpenCL passed block pointer can be private AS local variable or
   // global AS program scope variable (for the case with and without captures).
-  // Generic AS is used therefore to be able to accomodate both private and
+  // Generic AS is used therefore to be able to accommodate both private and
   // generic AS in one implementation.
   if (getLangOpts().OpenCL)
 selfTy = getContext().getPointerType(getContext().getAddrSpaceQualType(

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=307007=307006=307007=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Mon Jul  3 01:49:44 2017
@@ -129,7 +129,7 @@ static void addExtParameterInfosForCall(
   paramInfos.resize(totalArgs);
 }
 
-/// Adds the formal paramaters in FPT to the given prefix. If any parameter in
+/// Adds the formal parameters in FPT to the given prefix. If any parameter in
 /// FPT has pass_object_size attrs, then we'll add parameters for those, too.
 static void appendParameterTypes(const CodeGenTypes ,
  SmallVectorImpl ,

Modified: cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp?rev=307007=307006=307007=diff
==
--- cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp (original)
+++ cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp Mon Jul  3 01:49:44 
2017
@@ -6068,7 +6068,7 @@ void RewriteModernObjC::Initialize(ASTCo
   Preamble += "\n#define __OFFSETOFIVAR__(TYPE, MEMBER) ((long long) &((TYPE 
*)0)->MEMBER)\n";
 }
 
-/// RewriteIvarOffsetComputation - This rutine synthesizes computation of
+/// RewriteIvarOffsetComputation - This routine synthesizes computation of
 /// ivar offset.
 void RewriteModernObjC::RewriteIvarOffsetComputation(ObjCIvarDecl *ivar,
  std::string ) {

Modified: cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp?rev=307007=307006=307007=diff
==
--- cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp (original)
+++ cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp Mon Jul  3 01:49:44 2017
@@ -5052,7 +5052,7 @@ void RewriteObjCFragileABI::Initialize(A
   Preamble += "\n#define __OFFSETOFIVAR__(TYPE, MEMBER) ((long long) &((TYPE 
*)0)->MEMBER)\n";
 }
 
-/// RewriteIvarOffsetComputation - This rutine synthesizes computation of
+/// RewriteIvarOffsetComputation - This routine synthesizes computation of
 /// ivar offset.
 void RewriteObjCFragileABI::RewriteIvarOffsetComputation(ObjCIvarDecl *ivar,
  std::string ) {

Modified: cfe/trunk/www/analyzer/scripts/expandcollapse.js
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/analyzer/scripts/expandcollapse.js?rev=307007=307006=307007=diff
==
--- cfe/trunk/www/analyzer/scripts/expandcollapse.js (original)
+++ cfe/trunk/www/analyzer/scripts/expandcollapse.js Mon Jul  3 01:49:44 2017
@@ -81,7