r250997 - [MS ABI] Mangle static anonymous unions

2015-10-22 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Thu Oct 22 02:15:56 2015
New Revision: 250997

URL: http://llvm.org/viewvc/llvm-project?rev=250997&view=rev
Log:
[MS ABI] Mangle static anonymous unions

We believed that internal linkage variables at global scope which are
not variable template specializations did not have to be mangled.

However, static anonymous unions have no identifier and therefore must
be mangled.

This fixes PR18204.

Modified:
cfe/trunk/lib/AST/MicrosoftCXXABI.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp

Modified: cfe/trunk/lib/AST/MicrosoftCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftCXXABI.cpp?rev=250997&r1=250996&r2=250997&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftCXXABI.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftCXXABI.cpp Thu Oct 22 02:15:56 2015
@@ -89,17 +89,7 @@ public:
   }
 
   bool isNearlyEmpty(const CXXRecordDecl *RD) const override {
-// FIXME: Audit the corners
-if (!RD->isDynamicClass())
-  return false;
-
-const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
-
-// In the Microsoft ABI, classes can have one or two vtable pointers.
-CharUnits PointerSize =
-
Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerWidth(0));
-return Layout.getNonVirtualSize() == PointerSize ||
-  Layout.getNonVirtualSize() == PointerSize * 2;
+llvm_unreachable("unapplicable to the MS ABI");
   }
 
   void addDefaultArgExprForConstructor(const CXXConstructorDecl *CD,

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=250997&r1=250996&r2=250997&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Thu Oct 22 02:15:56 2015
@@ -365,7 +365,8 @@ bool MicrosoftMangleContextImpl::shouldM
 DC = getEffectiveParentContext(DC);
 
 if (DC->isTranslationUnit() && D->getFormalLinkage() == InternalLinkage &&
-!isa(D))
+!isa(D) &&
+D->getIdentifier() != nullptr)
   return false;
   }
 
@@ -801,7 +802,7 @@ void MicrosoftCXXNameMangler::mangleUnqu
   } else {
 // Otherwise, number the types using a $S prefix.
 Name += "$S";
-Name += llvm::utostr(Context.getAnonymousStructId(TD));
+Name += llvm::utostr(Context.getAnonymousStructId(TD) + 1);
   }
   Name += ">";
   mangleSourceName(Name.str());

Modified: cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp?rev=250997&r1=250996&r2=250997&view=diff
==
--- cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp Thu Oct 22 02:15:56 2015
@@ -277,3 +277,12 @@ void g() {
 // CHECK-DAG: 
@"\01??$f@W4@?1??g@PR24651@@YAXXZ@@PR24651@@YAXW4@?1??g@0@YAXXZ@@Z"
 // CHECK-DAG: 
@"\01??$f@W4@?2??g@PR24651@@YAXXZ@@PR24651@@YAXW4@?2??g@0@YAXXZ@@Z"
 }
+
+namespace PR18204 {
+template 
+int f(T *);
+static union {
+  int n = f(this);
+};
+// CHECK-DAG: 
@"\01??$f@T@PR18204@@@PR18204@@YAHPAT@0@@Z"
+}


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


Re: [PATCH] D13959: Fix crash in EmitDeclMetadata mode

2015-10-22 Thread Pavel Labath via cfe-commits
labath resigned from this revision.
labath removed a reviewer: labath.
labath added a comment.

I'll just observe this one. Someone with more knowledge of clang needs to 
review this.


Repository:
  rL LLVM

http://reviews.llvm.org/D13959



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


Re: [PATCH] D10802: [mips] Interrupt attribute support.

2015-10-22 Thread Simon Dardis via cfe-commits
sdardis updated the summary for this revision.
sdardis updated this revision to Diff 38102.
sdardis marked 3 inline comments as done.
sdardis added a comment.

Nits addressed and XFAIL tests added for functions having arguments and the 
interrupt attribute.

Test added to cover semantic warnings.

Rejects functions with mips16 & interrupt attributes.

Text in the bullet points of MipsInterruptDocs section expanded.


http://reviews.llvm.org/D10802

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/mips-interrupt-attr-arg.c
  test/CodeGen/mips-interrupt-attr.c
  test/Sema/mips-interrupt-attr.c

Index: test/Sema/mips-interrupt-attr.c
===
--- /dev/null
+++ test/Sema/mips-interrupt-attr.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 %s -triple mips-img-elf -verify -fsyntax-only
+
+__attribute__((interrupt("EIC"))) void foo1() {} // expected-warning {{'interrupt' attribute argument not supported: EIC}}
+
+__attribute__((interrupt("eic", 1))) void foo2() {} // expected-error {{'interrupt' attribute takes no more than 1 argument}}
+
+__attribute__((interrupt("eic"))) void foo3(int a) {}
+__attribute__((interrupt("vector=sw0"))) void foo4() {}
+__attribute__((interrupt("vector=hw0"))) void foo5() {}
+__attribute__((interrupt("vector=hw1"))) void foo6() {}
+__attribute__((interrupt("vector=hw2"))) void foo7() {}
+__attribute__((interrupt("vector=hw3"))) void foo8() {}
+__attribute__((interrupt("vector=hw4"))) void foo9() {}
+__attribute__((interrupt("vector=hw5"))) void fooa() {}
+
+__attribute__((interrupt)) void foob() {}
+__attribute__((interrupt())) void fooc() {}
+__attribute__((interrupt(""))) void food() {}
Index: test/CodeGen/mips-interrupt-attr.c
===
--- /dev/null
+++ test/CodeGen/mips-interrupt-attr.c
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -triple mipsel-unknown-linux -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK
+
+void __attribute__ ((interrupt("vector=sw0")))
+isr_sw0 (void)
+{
+  // CHECK: define void @isr_sw0() [[SW0:#[0-9]+]]
+}
+
+void __attribute__ ((interrupt("vector=sw1")))
+isr_sw1 (void)
+{
+  // CHECK: define void @isr_sw1() [[SW1:#[0-9]+]]
+}
+
+void __attribute__ ((interrupt("vector=hw0")))
+isr_hw0 (void)
+{
+  // CHECK: define void @isr_hw0() [[HW0:#[0-9]+]]
+}
+
+void __attribute__ ((interrupt("vector=hw1")))
+isr_hw1 (void)
+{
+  // CHECK: define void @isr_hw1() [[HW1:#[0-9]+]]
+}
+
+void __attribute__ ((interrupt("vector=hw2")))
+isr_hw2 (void)
+{
+  // CHECK: define void @isr_hw2() [[HW2:#[0-9]+]]
+}
+
+void __attribute__ ((interrupt("vector=hw3")))
+isr_hw3 (void)
+{
+  // CHECK: define void @isr_hw3() [[HW3:#[0-9]+]]
+}
+
+void __attribute__ ((interrupt("vector=hw4")))
+isr_hw4 (void)
+{
+  // CHECK: define void @isr_hw4() [[HW4:#[0-9]+]]
+}
+
+void __attribute__ ((interrupt("vector=hw5")))
+isr_hw5 (void)
+{
+  // CHECK: define void @isr_hw5() [[HW5:#[0-9]+]]
+}
+
+void __attribute__ ((interrupt))
+isr_eic (void)
+{
+  // CHECK: define void @isr_eic() [[EIC:#[0-9]+]]
+}
+// CHECK: attributes [[SW0]] = { {{.*}} "interrupt"="sw0" {{.*}} }
+// CHECK: attributes [[SW1]] = { {{.*}} "interrupt"="sw1" {{.*}} }
+// CHECK: attributes [[HW0]] = { {{.*}} "interrupt"="hw0" {{.*}} }
+// CHECK: attributes [[HW1]] = { {{.*}} "interrupt"="hw1" {{.*}} }
+// CHECK: attributes [[HW2]] = { {{.*}} "interrupt"="hw2" {{.*}} }
+// CHECK: attributes [[HW3]] = { {{.*}} "interrupt"="hw3" {{.*}} }
+// CHECK: attributes [[HW4]] = { {{.*}} "interrupt"="hw4" {{.*}} }
+// CHECK: attributes [[HW5]] = { {{.*}} "interrupt"="hw5" {{.*}} }
+// CHECK: attributes [[EIC]] = { {{.*}} "interrupt"="eic" {{.*}} }
Index: test/CodeGen/mips-interrupt-attr-arg.c
===
--- /dev/null
+++ test/CodeGen/mips-interrupt-attr-arg.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple mipsel-unknown-linux -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK
+// XFAIL: *
+
+void __attribute__ ((interrupt("vector=sw0")))
+isr_sw0 (char * a)
+{
+  // CHECK: define void @isr_sw0(i8* %a) [[SW0:#[0-9]+]]
+}
+
+
+// CHECK: attributes [[SW0]] = { {{.*}} "interrupt"="sw0" {{.*}} }
+
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4251,10 +4251,44 @@
   D->addAttr(UsedAttr::CreateImplicit(S.Context));
 }
 
+static void handleMipsInterruptAttr(Sema &S, Decl *D,
+const AttributeList &Attr) {
+  // Only one optional argument permitted.
+  if (Attr.getNumArgs() > 1) {
+S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments)
+<< Attr.getName() << 1;
+return;
+  }
+
+  StringRef Str;
+  SourceLocation ArgLoc;
+
+  if (Attr.getNumArgs() == 0)
+Str = "";
+  else if (!S.checkStringLiteralArgumentAttr(Attr, 0, 

[PATCH] D13975: Make string constants in the modernize module static.

2015-10-22 Thread Angel Garcia via cfe-commits
angelgarcia created this revision.
angelgarcia added a reviewer: klimek.
angelgarcia added a subscriber: cfe-commits.

Add static to global variables, if they are not in an anonymous namespace.

http://reviews.llvm.org/D13975

Files:
  clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tidy/modernize/MakeUniqueCheck.cpp
  clang-tidy/modernize/ReplaceAutoPtrCheck.cpp

Index: clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
===
--- clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
+++ clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
@@ -21,8 +21,8 @@
 namespace tidy {
 namespace modernize {
 
-const char AutoPtrTokenId[] = "AutoPrTokenId";
-const char AutoPtrOwnershipTransferId[] = "AutoPtrOwnershipTransferId";
+static const char AutoPtrTokenId[] = "AutoPrTokenId";
+static const char AutoPtrOwnershipTransferId[] = "AutoPtrOwnershipTransferId";
 
 /// \brief Matches expressions that are lvalues.
 ///
Index: clang-tidy/modernize/MakeUniqueCheck.cpp
===
--- clang-tidy/modernize/MakeUniqueCheck.cpp
+++ clang-tidy/modernize/MakeUniqueCheck.cpp
@@ -18,9 +18,9 @@
 namespace tidy {
 namespace modernize {
 
-const char PointerType[] = "pointerType";
-const char ConstructorCall[] = "constructorCall";
-const char NewExpression[] = "newExpression";
+static const char PointerType[] = "pointerType";
+static const char ConstructorCall[] = "constructorCall";
+static const char NewExpression[] = "newExpression";
 
 void MakeUniqueCheck::registerMatchers(MatchFinder *Finder) {
   if (getLangOpts().CPlusPlus11) {
Index: clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tidy/modernize/LoopConvertCheck.cpp
@@ -19,19 +19,19 @@
 namespace tidy {
 namespace modernize {
 
-const char LoopNameArray[] = "forLoopArray";
-const char LoopNameIterator[] = "forLoopIterator";
-const char LoopNamePseudoArray[] = "forLoopPseudoArray";
-const char ConditionBoundName[] = "conditionBound";
-const char ConditionVarName[] = "conditionVar";
-const char IncrementVarName[] = "incrementVar";
-const char InitVarName[] = "initVar";
-const char BeginCallName[] = "beginCall";
-const char EndCallName[] = "endCall";
-const char ConditionEndVarName[] = "conditionEndVar";
-const char EndVarName[] = "endVar";
-const char DerefByValueResultName[] = "derefByValueResult";
-const char DerefByRefResultName[] = "derefByRefResult";
+static const char LoopNameArray[] = "forLoopArray";
+static const char LoopNameIterator[] = "forLoopIterator";
+static const char LoopNamePseudoArray[] = "forLoopPseudoArray";
+static const char ConditionBoundName[] = "conditionBound";
+static const char ConditionVarName[] = "conditionVar";
+static const char IncrementVarName[] = "incrementVar";
+static const char InitVarName[] = "initVar";
+static const char BeginCallName[] = "beginCall";
+static const char EndCallName[] = "endCall";
+static const char ConditionEndVarName[] = "conditionEndVar";
+static const char EndVarName[] = "endVar";
+static const char DerefByValueResultName[] = "derefByValueResult";
+static const char DerefByRefResultName[] = "derefByRefResult";
 
 // shared matchers
 static const TypeMatcher AnyType = anything();


Index: clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
===
--- clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
+++ clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
@@ -21,8 +21,8 @@
 namespace tidy {
 namespace modernize {
 
-const char AutoPtrTokenId[] = "AutoPrTokenId";
-const char AutoPtrOwnershipTransferId[] = "AutoPtrOwnershipTransferId";
+static const char AutoPtrTokenId[] = "AutoPrTokenId";
+static const char AutoPtrOwnershipTransferId[] = "AutoPtrOwnershipTransferId";
 
 /// \brief Matches expressions that are lvalues.
 ///
Index: clang-tidy/modernize/MakeUniqueCheck.cpp
===
--- clang-tidy/modernize/MakeUniqueCheck.cpp
+++ clang-tidy/modernize/MakeUniqueCheck.cpp
@@ -18,9 +18,9 @@
 namespace tidy {
 namespace modernize {
 
-const char PointerType[] = "pointerType";
-const char ConstructorCall[] = "constructorCall";
-const char NewExpression[] = "newExpression";
+static const char PointerType[] = "pointerType";
+static const char ConstructorCall[] = "constructorCall";
+static const char NewExpression[] = "newExpression";
 
 void MakeUniqueCheck::registerMatchers(MatchFinder *Finder) {
   if (getLangOpts().CPlusPlus11) {
Index: clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tidy/modernize/LoopConvertCheck.cpp
@@ -19,19 +19,19 @@
 namespace tidy {
 namespace modernize {
 
-const char LoopNameArray[] = "forLoopArray";
-const char LoopNameIterator[] = "forLoopIterator";
-const char LoopNamePse

Re: [PATCH] D13975: Make string constants in the modernize module static.

2015-10-22 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D13975



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


[clang-tools-extra] r251005 - Make string constants in the modernize module static.

2015-10-22 Thread Angel Garcia Gomez via cfe-commits
Author: angelgarcia
Date: Thu Oct 22 04:48:23 2015
New Revision: 251005

URL: http://llvm.org/viewvc/llvm-project?rev=251005&view=rev
Log:
Make string constants in the modernize module static.

Summary: Add static to global variables, if they are not in an anonymous 
namespace.

Reviewers: klimek

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp?rev=251005&r1=251004&r2=251005&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp Thu Oct 
22 04:48:23 2015
@@ -19,19 +19,19 @@ namespace clang {
 namespace tidy {
 namespace modernize {
 
-const char LoopNameArray[] = "forLoopArray";
-const char LoopNameIterator[] = "forLoopIterator";
-const char LoopNamePseudoArray[] = "forLoopPseudoArray";
-const char ConditionBoundName[] = "conditionBound";
-const char ConditionVarName[] = "conditionVar";
-const char IncrementVarName[] = "incrementVar";
-const char InitVarName[] = "initVar";
-const char BeginCallName[] = "beginCall";
-const char EndCallName[] = "endCall";
-const char ConditionEndVarName[] = "conditionEndVar";
-const char EndVarName[] = "endVar";
-const char DerefByValueResultName[] = "derefByValueResult";
-const char DerefByRefResultName[] = "derefByRefResult";
+static const char LoopNameArray[] = "forLoopArray";
+static const char LoopNameIterator[] = "forLoopIterator";
+static const char LoopNamePseudoArray[] = "forLoopPseudoArray";
+static const char ConditionBoundName[] = "conditionBound";
+static const char ConditionVarName[] = "conditionVar";
+static const char IncrementVarName[] = "incrementVar";
+static const char InitVarName[] = "initVar";
+static const char BeginCallName[] = "beginCall";
+static const char EndCallName[] = "endCall";
+static const char ConditionEndVarName[] = "conditionEndVar";
+static const char EndVarName[] = "endVar";
+static const char DerefByValueResultName[] = "derefByValueResult";
+static const char DerefByRefResultName[] = "derefByRefResult";
 
 // shared matchers
 static const TypeMatcher AnyType = anything();

Modified: clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp?rev=251005&r1=251004&r2=251005&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp Thu Oct 22 
04:48:23 2015
@@ -18,9 +18,9 @@ namespace clang {
 namespace tidy {
 namespace modernize {
 
-const char PointerType[] = "pointerType";
-const char ConstructorCall[] = "constructorCall";
-const char NewExpression[] = "newExpression";
+static const char PointerType[] = "pointerType";
+static const char ConstructorCall[] = "constructorCall";
+static const char NewExpression[] = "newExpression";
 
 void MakeUniqueCheck::registerMatchers(MatchFinder *Finder) {
   if (getLangOpts().CPlusPlus11) {

Modified: clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp?rev=251005&r1=251004&r2=251005&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp Thu 
Oct 22 04:48:23 2015
@@ -21,8 +21,8 @@ namespace clang {
 namespace tidy {
 namespace modernize {
 
-const char AutoPtrTokenId[] = "AutoPrTokenId";
-const char AutoPtrOwnershipTransferId[] = "AutoPtrOwnershipTransferId";
+static const char AutoPtrTokenId[] = "AutoPrTokenId";
+static const char AutoPtrOwnershipTransferId[] = "AutoPtrOwnershipTransferId";
 
 /// \brief Matches expressions that are lvalues.
 ///


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


Re: [PATCH] D13973: CFG: Delay creating Dtors for CompoundStmts which end in ReturnStmt

2015-10-22 Thread Manuel Klimek via cfe-commits
klimek added a subscriber: klimek.
klimek added a comment.

A test that fails before this patch and passes afterwards is needed :) If you 
need help writing that test, let me know.


http://reviews.llvm.org/D13973



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


[PATCH] D13976: [AST] Store Decl* and Stmt* directly into the ParentMap.

2015-10-22 Thread Benjamin Kramer via cfe-commits
bkramer created this revision.
bkramer added reviewers: klimek, djasper.
bkramer added a subscriber: cfe-commits.

These are by far the most common types to be parents in the AST so it makes
sense to optimize for them. Put them directly into the value of the map.
This currently saves 32 bytes per parent in the map and a pointer
indirection at the cost of some additional complexity in the code.

Sadly this means we cannot return an ArrayRef from getParents anymore, add
a proxy class that can own a single DynTypedNode and otherwise behaves
exactly the same as ArrayRef.

For example on a random large file (X86ISelLowering.cpp) this reduces the size
of the parent map by 24 MB.

http://reviews.llvm.org/D13976

Files:
  include/clang/AST/ASTContext.h
  lib/AST/ASTContext.cpp

Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -797,8 +797,7 @@
   for (const auto &Entry : *AllParents) {
 if (Entry.second.is()) {
   delete Entry.second.get();
-} else {
-  assert(Entry.second.is());
+} else if (Entry.second.is()) {
   delete Entry.second.get();
 }
   }
@@ -8673,6 +8672,15 @@
 
 namespace {
 
+ast_type_traits::DynTypedNode
+getSingleDynTypedNodeFromParentMap(ASTContext::ParentMap::mapped_type U) {
+  if (const auto *D = U.template dyn_cast())
+return ast_type_traits::DynTypedNode::create(*D);
+  if (const auto *S = U.template dyn_cast())
+return ast_type_traits::DynTypedNode::create(*S);
+  return *U.template get();
+}
+
   /// \brief A \c RecursiveASTVisitor that builds a map from nodes to their
   /// parents as defined by the \c RecursiveASTVisitor.
   ///
@@ -8728,16 +8736,23 @@
 // do not have pointer identity.
 auto &NodeOrVector = (*Parents)[Node];
 if (NodeOrVector.isNull()) {
-  NodeOrVector = new ast_type_traits::DynTypedNode(ParentStack.back());
+  if (const auto *D = ParentStack.back().get())
+NodeOrVector = D;
+  else if (const auto *S = ParentStack.back().get())
+NodeOrVector = S;
+  else
+NodeOrVector =
+new ast_type_traits::DynTypedNode(ParentStack.back());
 } else {
-  if (NodeOrVector.template is()) {
-auto *Node =
-NodeOrVector.template get();
-auto *Vector = new ASTContext::ParentVector(1, *Node);
+  if (!NodeOrVector.template is()) {
+auto *Vector = new ASTContext::ParentVector(
+1, getSingleDynTypedNodeFromParentMap(NodeOrVector));
 NodeOrVector = Vector;
-delete Node;
+if (auto *Node =
+NodeOrVector
+.template dyn_cast())
+  delete Node;
   }
-  assert(NodeOrVector.template is());
 
   auto *Vector =
   NodeOrVector.template get();
@@ -8774,7 +8789,7 @@
 
 } // end namespace
 
-ArrayRef
+ASTContext::DynTypedNodeList
 ASTContext::getParents(const ast_type_traits::DynTypedNode &Node) {
   assert(Node.getMemoizationData() &&
  "Invariant broken: only nodes that support memoization may be "
@@ -8787,12 +8802,12 @@
   }
   ParentMap::const_iterator I = AllParents->find(Node.getMemoizationData());
   if (I == AllParents->end()) {
-return None;
+return llvm::ArrayRef();
   }
-  if (auto *N = I->second.dyn_cast()) {
-return llvm::makeArrayRef(N, 1);
+  if (auto *V = I->second.dyn_cast()) {
+return llvm::makeArrayRef(*V);
   }
-  return *I->second.get();
+  return getSingleDynTypedNodeFromParentMap(I->second);
 }
 
 bool
Index: include/clang/AST/ASTContext.h
===
--- include/clang/AST/ASTContext.h
+++ include/clang/AST/ASTContext.h
@@ -453,8 +453,45 @@
 
   /// \brief Maps from a node to its parents.
   typedef llvm::DenseMap> ParentMap;
+ llvm::PointerUnion4> ParentMap;
+
+  /// Container for either a single DynTypedNode or for an ArrayRef to
+  /// DynTypedNode. For use with ParentMap.
+  class DynTypedNodeList {
+typedef ast_type_traits::DynTypedNode DynTypedNode;
+typedef ArrayRef ARef;
+llvm::AlignedCharArrayUnion Storage;
+bool IsSingleNode;
+
+  public:
+DynTypedNodeList(const DynTypedNode &N) : IsSingleNode(true) {
+  new (Storage.buffer) DynTypedNode(N);
+}
+DynTypedNodeList(ARef A) : IsSingleNode(false) {
+  new (Storage.buffer) ARef(A);
+}
+
+const ast_type_traits::DynTypedNode *begin() const {
+  if (!IsSingleNode)
+return reinterpret_cast(Storage.buffer)->begin();
+  return reinterpret_cast(Storage.buffer);
+}
+
+const ast_type_traits::DynTypedNode *end() const {
+  if (!IsSingleNode)
+return reinterpret_cast(Storage.buffer)->end();
+  return reinterpret_cast(Storage.buffer) + 1;
+}
+
+size_t size() const { return end() - begin(); }

[PATCH] D13978: [X86] Support MCU psABI when marking inregs

2015-10-22 Thread Michael Kuperstein via cfe-commits
mkuper created this revision.
mkuper added reviewers: rnk, rafael.
mkuper added a subscriber: cfe-commits.
mkuper added a dependency: D13977: [X86] Add elfiamcu triple support, and a 
workaround for PR3997.
Herald added a subscriber: aemerson.

The  MCU psABI has a calling convention that is somewhat, but not quite, like 
-mregparm 3.
This adds support for this calling convention.

It depends on D13977 which introduces MCU triple support.

http://reviews.llvm.org/D13978

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/x86_32-arguments-iamcu.c

Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -799,6 +799,7 @@
   bool IsRetSmallStructInRegABI;
   bool IsWin32StructABI;
   bool IsSoftFloatABI;
+  bool IsMCUABI;
   unsigned DefaultNumRegisterParameters;
 
   static bool isRegisterSize(unsigned Size) {
@@ -848,22 +849,24 @@
 
   X86_32ABIInfo(CodeGen::CodeGenTypes &CGT, bool DarwinVectorABI,
 bool RetSmallStructInRegABI, bool Win32StructABI,
-unsigned NumRegisterParameters, bool SoftFloatABI)
+unsigned NumRegisterParameters, bool SoftFloatABI,
+bool MCUABI)
 : ABIInfo(CGT), IsDarwinVectorABI(DarwinVectorABI),
   IsRetSmallStructInRegABI(RetSmallStructInRegABI), 
   IsWin32StructABI(Win32StructABI),
-  IsSoftFloatABI(SoftFloatABI),
+  IsSoftFloatABI(SoftFloatABI), IsMCUABI(MCUABI),
   DefaultNumRegisterParameters(NumRegisterParameters) {}
 };
 
 class X86_32TargetCodeGenInfo : public TargetCodeGenInfo {
 public:
   X86_32TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, bool DarwinVectorABI,
   bool RetSmallStructInRegABI, bool Win32StructABI,
-  unsigned NumRegisterParameters, bool SoftFloatABI)
+  unsigned NumRegisterParameters, bool SoftFloatABI,
+  bool MCUABI)
   : TargetCodeGenInfo(new X86_32ABIInfo(
 CGT, DarwinVectorABI, RetSmallStructInRegABI, Win32StructABI,
-NumRegisterParameters, SoftFloatABI)) {}
+NumRegisterParameters, SoftFloatABI, MCUABI)) {}
 
   static bool isStructReturnInRegABI(
   const llvm::Triple &Triple, const CodeGenOptions &Opts);
@@ -986,7 +989,7 @@
 }
 
 /// shouldReturnTypeInRegister - Determine if the given type should be
-/// returned in a register (for the Darwin ABI).
+/// returned in a register (for the Darwin and MCU ABI).
 bool X86_32ABIInfo::shouldReturnTypeInRegister(QualType Ty,
ASTContext &Context) const {
   uint64_t Size = Context.getTypeSize(Ty);
@@ -1226,9 +1229,18 @@
   if (SizeInRegs == 0)
 return false;
 
-  if (SizeInRegs > State.FreeRegs) {
-State.FreeRegs = 0;
-return false;
+  if (!IsMCUABI) {
+if (SizeInRegs > State.FreeRegs) {
+  State.FreeRegs = 0;
+  return false;
+}
+  } else {
+// The MCU psABI allows passing parameters in-reg even if there are
+// earlier, parameters that are passed on the stack. Also,
+// it does not allow passing >8-byte structs in-register,
+// even if there are 3 free registers available.
+if (SizeInRegs > State.FreeRegs || SizeInRegs > 2)
+  return false;
   }
 
   State.FreeRegs -= SizeInRegs;
@@ -1372,6 +1384,8 @@
 State.FreeSSERegs = 6;
   } else if (FI.getHasRegParm())
 State.FreeRegs = FI.getRegParm();
+  else if (IsMCUABI)
+State.FreeRegs = 3;
   else
 State.FreeRegs = DefaultNumRegisterParameters;
 
@@ -1520,7 +1534,7 @@
 return true;
   }
 
-  if (Triple.isOSDarwin())
+  if (Triple.isOSDarwin() || Triple.isEnvironmentIAMCU())
 return true;
 
   switch (Triple.getOS()) {
@@ -1889,7 +1903,7 @@
 bool DarwinVectorABI, bool RetSmallStructInRegABI, bool Win32StructABI,
 unsigned NumRegisterParameters)
 : X86_32TargetCodeGenInfo(CGT, DarwinVectorABI, RetSmallStructInRegABI,
-Win32StructABI, NumRegisterParameters, false) {}
+Win32StructABI, NumRegisterParameters, false, false) {}
 
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule &CGM) const override;
@@ -7402,7 +7416,7 @@
   return *(TheTargetCodeGenInfo = new X86_32TargetCodeGenInfo(
Types, IsDarwinVectorABI, RetSmallStructInRegABI,
IsWin32FloatStructABI, CodeGenOpts.NumRegisterParameters,
-   CodeGenOpts.FloatABI == "soft"));
+   CodeGenOpts.FloatABI == "soft", Triple.isEnvironmentIAMCU()));
 }
   }
 
Index: test/CodeGen/x86_32-arguments-iamcu.c
===
--- test/CodeGen/x86_32-arguments-iamcu.c
+++ test/CodeGen/x86_32-arguments-iamcu.c
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -w -triple i386-pc-elfiamcu -mfloat-abi soft -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: define void 

Re: [PATCH] D13976: [AST] Store Decl* and Stmt* directly into the ParentMap.

2015-10-22 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg



Comment at: include/clang/AST/ASTContext.h:463
@@ +462,3 @@
+  class DynTypedNodeList {
+typedef ast_type_traits::DynTypedNode DynTypedNode;
+typedef ArrayRef ARef;

I think "using" is clearer.


Comment at: include/clang/AST/ASTContext.h:464
@@ +463,3 @@
+typedef ast_type_traits::DynTypedNode DynTypedNode;
+typedef ArrayRef ARef;
+llvm::AlignedCharArrayUnion Storage;

Show me what ArrayRef looks like written out below :)


http://reviews.llvm.org/D13976



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


Re: [PATCH] D13976: [AST] Store Decl* and Stmt* directly into the ParentMap.

2015-10-22 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL251008: [AST] Store Decl* and Stmt* directly into the 
ParentMap. (authored by d0k).

Changed prior to commit:
  http://reviews.llvm.org/D13976?vs=38105&id=38110#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13976

Files:
  cfe/trunk/include/clang/AST/ASTContext.h
  cfe/trunk/lib/AST/ASTContext.cpp

Index: cfe/trunk/lib/AST/ASTContext.cpp
===
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -797,8 +797,7 @@
   for (const auto &Entry : *AllParents) {
 if (Entry.second.is()) {
   delete Entry.second.get();
-} else {
-  assert(Entry.second.is());
+} else if (Entry.second.is()) {
   delete Entry.second.get();
 }
   }
@@ -8673,6 +8672,15 @@
 
 namespace {
 
+ast_type_traits::DynTypedNode
+getSingleDynTypedNodeFromParentMap(ASTContext::ParentMap::mapped_type U) {
+  if (const auto *D = U.template dyn_cast())
+return ast_type_traits::DynTypedNode::create(*D);
+  if (const auto *S = U.template dyn_cast())
+return ast_type_traits::DynTypedNode::create(*S);
+  return *U.template get();
+}
+
   /// \brief A \c RecursiveASTVisitor that builds a map from nodes to their
   /// parents as defined by the \c RecursiveASTVisitor.
   ///
@@ -8728,16 +8736,23 @@
 // do not have pointer identity.
 auto &NodeOrVector = (*Parents)[Node];
 if (NodeOrVector.isNull()) {
-  NodeOrVector = new ast_type_traits::DynTypedNode(ParentStack.back());
+  if (const auto *D = ParentStack.back().get())
+NodeOrVector = D;
+  else if (const auto *S = ParentStack.back().get())
+NodeOrVector = S;
+  else
+NodeOrVector =
+new ast_type_traits::DynTypedNode(ParentStack.back());
 } else {
-  if (NodeOrVector.template is()) {
-auto *Node =
-NodeOrVector.template get();
-auto *Vector = new ASTContext::ParentVector(1, *Node);
+  if (!NodeOrVector.template is()) {
+auto *Vector = new ASTContext::ParentVector(
+1, getSingleDynTypedNodeFromParentMap(NodeOrVector));
 NodeOrVector = Vector;
-delete Node;
+if (auto *Node =
+NodeOrVector
+.template dyn_cast())
+  delete Node;
   }
-  assert(NodeOrVector.template is());
 
   auto *Vector =
   NodeOrVector.template get();
@@ -8774,7 +8789,7 @@
 
 } // end namespace
 
-ArrayRef
+ASTContext::DynTypedNodeList
 ASTContext::getParents(const ast_type_traits::DynTypedNode &Node) {
   assert(Node.getMemoizationData() &&
  "Invariant broken: only nodes that support memoization may be "
@@ -8787,12 +8802,12 @@
   }
   ParentMap::const_iterator I = AllParents->find(Node.getMemoizationData());
   if (I == AllParents->end()) {
-return None;
+return llvm::ArrayRef();
   }
-  if (auto *N = I->second.dyn_cast()) {
-return llvm::makeArrayRef(N, 1);
+  if (auto *V = I->second.dyn_cast()) {
+return llvm::makeArrayRef(*V);
   }
-  return *I->second.get();
+  return getSingleDynTypedNodeFromParentMap(I->second);
 }
 
 bool
Index: cfe/trunk/include/clang/AST/ASTContext.h
===
--- cfe/trunk/include/clang/AST/ASTContext.h
+++ cfe/trunk/include/clang/AST/ASTContext.h
@@ -453,8 +453,47 @@
 
   /// \brief Maps from a node to its parents.
   typedef llvm::DenseMap> ParentMap;
+ llvm::PointerUnion4> ParentMap;
+
+  /// Container for either a single DynTypedNode or for an ArrayRef to
+  /// DynTypedNode. For use with ParentMap.
+  class DynTypedNodeList {
+typedef ast_type_traits::DynTypedNode DynTypedNode;
+llvm::AlignedCharArrayUnion> Storage;
+bool IsSingleNode;
+
+  public:
+DynTypedNodeList(const DynTypedNode &N) : IsSingleNode(true) {
+  new (Storage.buffer) DynTypedNode(N);
+}
+DynTypedNodeList(ArrayRef A) : IsSingleNode(false) {
+  new (Storage.buffer) ArrayRef(A);
+}
+
+const ast_type_traits::DynTypedNode *begin() const {
+  if (!IsSingleNode)
+return reinterpret_cast *>(Storage.buffer)
+->begin();
+  return reinterpret_cast(Storage.buffer);
+}
+
+const ast_type_traits::DynTypedNode *end() const {
+  if (!IsSingleNode)
+return reinterpret_cast *>(Storage.buffer)
+->end();
+  return reinterpret_cast(Storage.buffer) + 1;
+}
+
+size_t size() const { return end() - begin(); }
+bool empty() const { return begin() == end(); }
+const DynTypedNode &operator[](size_t N) const {
+  assert(N < size() && "Out of bounds!");
+  return *(begin() + N);
+}
+  };
 
   /// \brief Returns the parents of the given node.
   ///
@@ -480,13 +519,11 @@
   ///
   /// 'NodeT' c

r251008 - [AST] Store Decl* and Stmt* directly into the ParentMap.

2015-10-22 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Oct 22 06:21:40 2015
New Revision: 251008

URL: http://llvm.org/viewvc/llvm-project?rev=251008&view=rev
Log:
[AST] Store Decl* and Stmt* directly into the ParentMap.

These are by far the most common types to be parents in the AST so it makes
sense to optimize for them. Put them directly into the value of the map.
This currently saves 32 bytes per parent in the map and a pointer
indirection at the cost of some additional complexity in the code.

Sadly this means we cannot return an ArrayRef from getParents anymore, add
a proxy class that can own a single DynTypedNode and otherwise behaves
exactly the same as ArrayRef.

For example on a random large file (X86ISelLowering.cpp) this reduces the
size of the parent map by 24 MB.

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

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=251008&r1=251007&r2=251008&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Oct 22 06:21:40 2015
@@ -453,8 +453,47 @@ public:
 
   /// \brief Maps from a node to its parents.
   typedef llvm::DenseMap> ParentMap;
+ llvm::PointerUnion4> ParentMap;
+
+  /// Container for either a single DynTypedNode or for an ArrayRef to
+  /// DynTypedNode. For use with ParentMap.
+  class DynTypedNodeList {
+typedef ast_type_traits::DynTypedNode DynTypedNode;
+llvm::AlignedCharArrayUnion> Storage;
+bool IsSingleNode;
+
+  public:
+DynTypedNodeList(const DynTypedNode &N) : IsSingleNode(true) {
+  new (Storage.buffer) DynTypedNode(N);
+}
+DynTypedNodeList(ArrayRef A) : IsSingleNode(false) {
+  new (Storage.buffer) ArrayRef(A);
+}
+
+const ast_type_traits::DynTypedNode *begin() const {
+  if (!IsSingleNode)
+return reinterpret_cast *>(Storage.buffer)
+->begin();
+  return reinterpret_cast(Storage.buffer);
+}
+
+const ast_type_traits::DynTypedNode *end() const {
+  if (!IsSingleNode)
+return reinterpret_cast *>(Storage.buffer)
+->end();
+  return reinterpret_cast(Storage.buffer) + 1;
+}
+
+size_t size() const { return end() - begin(); }
+bool empty() const { return begin() == end(); }
+const DynTypedNode &operator[](size_t N) const {
+  assert(N < size() && "Out of bounds!");
+  return *(begin() + N);
+}
+  };
 
   /// \brief Returns the parents of the given node.
   ///
@@ -480,13 +519,11 @@ public:
   ///
   /// 'NodeT' can be one of Decl, Stmt, Type, TypeLoc,
   /// NestedNameSpecifier or NestedNameSpecifierLoc.
-  template 
-  ArrayRef getParents(const NodeT &Node) {
+  template  DynTypedNodeList getParents(const NodeT &Node) {
 return getParents(ast_type_traits::DynTypedNode::create(Node));
   }
 
-  ArrayRef
-  getParents(const ast_type_traits::DynTypedNode &Node);
+  DynTypedNodeList getParents(const ast_type_traits::DynTypedNode &Node);
 
   const clang::PrintingPolicy &getPrintingPolicy() const {
 return PrintingPolicy;

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=251008&r1=251007&r2=251008&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu Oct 22 06:21:40 2015
@@ -797,8 +797,7 @@ void ASTContext::ReleaseParentMapEntries
   for (const auto &Entry : *AllParents) {
 if (Entry.second.is()) {
   delete Entry.second.get();
-} else {
-  assert(Entry.second.is());
+} else if (Entry.second.is()) {
   delete Entry.second.get();
 }
   }
@@ -8673,6 +8672,15 @@ bool ASTContext::AtomicUsesUnsupportedLi
 
 namespace {
 
+ast_type_traits::DynTypedNode
+getSingleDynTypedNodeFromParentMap(ASTContext::ParentMap::mapped_type U) {
+  if (const auto *D = U.template dyn_cast())
+return ast_type_traits::DynTypedNode::create(*D);
+  if (const auto *S = U.template dyn_cast())
+return ast_type_traits::DynTypedNode::create(*S);
+  return *U.template get();
+}
+
   /// \brief A \c RecursiveASTVisitor that builds a map from nodes to their
   /// parents as defined by the \c RecursiveASTVisitor.
   ///
@@ -8728,16 +8736,23 @@ namespace {
 // do not have pointer identity.
 auto &NodeOrVector = (*Parents)[Node];
 if (NodeOrVector.isNull()) {
-  NodeOrVector = new ast_type_traits::DynTypedNode(ParentStack.back());
+  if (const auto *D = ParentStack.back().get())
+NodeOrVector = D;
+  else if (const auto *S = ParentStack.back().get())
+NodeOrVector = S;
+  else
+NodeOrVector =
+new a

r251009 - [AST] Remove redundant template keywords.

2015-10-22 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Oct 22 06:26:35 2015
New Revision: 251009

URL: http://llvm.org/viewvc/llvm-project?rev=251009&view=rev
Log:
[AST] Remove redundant template keywords.

GCC complains about them, clang does not.

Modified:
cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=251009&r1=251008&r2=251009&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu Oct 22 06:26:35 2015
@@ -8674,11 +8674,11 @@ namespace {
 
 ast_type_traits::DynTypedNode
 getSingleDynTypedNodeFromParentMap(ASTContext::ParentMap::mapped_type U) {
-  if (const auto *D = U.template dyn_cast())
+  if (const auto *D = U.dyn_cast())
 return ast_type_traits::DynTypedNode::create(*D);
-  if (const auto *S = U.template dyn_cast())
+  if (const auto *S = U.dyn_cast())
 return ast_type_traits::DynTypedNode::create(*S);
-  return *U.template get();
+  return *U.get();
 }
 
   /// \brief A \c RecursiveASTVisitor that builds a map from nodes to their


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


[clang-tools-extra] r251010 - Add %check_clang_tidy and %clang_tidy_diff.

2015-10-22 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Thu Oct 22 06:31:44 2015
New Revision: 251010

URL: http://llvm.org/viewvc/llvm-project?rev=251010&view=rev
Log:
Add %check_clang_tidy and %clang_tidy_diff.

With this, site specific lit configs can inject parameters into the
test scripts if they need site specific parameters.

Next up: enable check_clang_tidy to take a resource dir to enable
non-standard locations for builtin includes.

Modified:
clang-tools-extra/trunk/test/clang-tidy/cert-setlongjmp.cpp
clang-tools-extra/trunk/test/clang-tidy/cert-variadic-function-def.cpp
clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-const-cast.cpp

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-reinterpret-cast.cpp

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-static-cast-downcast.cpp

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-union-access.cpp

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-vararg.cpp
clang-tools-extra/trunk/test/clang-tidy/google-build-explicit-make-pair.cpp
clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp
clang-tools-extra/trunk/test/clang-tidy/google-overloaded-unary-and.cpp
clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.c
clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.cpp

clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments.cpp
clang-tools-extra/trunk/test/clang-tidy/google-readability-todo.cpp
clang-tools-extra/trunk/test/clang-tidy/google-runtime-int-std.cpp
clang-tools-extra/trunk/test/clang-tidy/google-runtime-int.cpp

clang-tools-extra/trunk/test/clang-tidy/google-runtime-member-string-references.cpp

clang-tools-extra/trunk/test/clang-tidy/google-runtime-memset-zero-length.cpp
clang-tools-extra/trunk/test/clang-tidy/llvm-include-order.cpp
clang-tools-extra/trunk/test/clang-tidy/llvm-twine-local.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-argument-comment.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-assert-side-effect.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-assign-operator-signature.cpp

clang-tools-extra/trunk/test/clang-tidy/misc-bool-pointer-implicit-conversion.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-inaccurate-erase.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-move-constructor-init.cpp

clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-non-copyable-objects.c
clang-tools-extra/trunk/test/clang-tidy/misc-non-copyable-objects.cpp

clang-tools-extra/trunk/test/clang-tidy/misc-repeated-side-effects-in-macro.c
clang-tools-extra/trunk/test/clang-tidy/misc-sizeof-container.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.c
clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-swapped-arguments.cpp

clang-tools-extra/trunk/test/clang-tidy/misc-throw-by-value-catch-by-reference.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-undelegated-constructor.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-uniqueptr-reset-release.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-unused-alias-decls.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.c
clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-unused-raii.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-camelback.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-lowercase.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-negative.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-uppercase.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-replace-auto-ptr.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-shrink-to-fit.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-iterator.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-new.cpp
clan

Re: [PATCH] D10305: [Clang Static Analyzer] Bug identification

2015-10-22 Thread Gábor Horváth via cfe-commits
xazax.hun closed this revision.
xazax.hun added a comment.

Committed in r251011.


http://reviews.llvm.org/D10305



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


Re: [PATCH] D10305: [Clang Static Analyzer] Bug identification

2015-10-22 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

In http://reviews.llvm.org/D10305#272013, @honggyu.kim wrote:

> Hi Gabor,
>
> I was away from the office for 3 weeks so I couldn't catch up the issues but 
> you almost completed the patch now.
>  Thanks for this work!
>
> I just found a tiny problem and described it in the line comment so please 
> have a look at it.


Thank you for spotting this! It is fixed in the committed version.


http://reviews.llvm.org/D10305



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


[PATCH] D13982: Don't use "auto" on loops over fundamental types in modernize-loop-convert.

2015-10-22 Thread Angel Garcia via cfe-commits
angelgarcia created this revision.
angelgarcia added a reviewer: klimek.
angelgarcia added subscribers: cfe-commits, alexfh.

using "auto" on a loop that iterates over ints is kind of an overkill. Use the 
real type name instead.

http://reviews.llvm.org/D13982

Files:
  clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tidy/modernize/LoopConvertCheck.h
  test/clang-tidy/modernize-loop-convert-basic.cpp
  test/clang-tidy/modernize-loop-convert-camelback.cpp
  test/clang-tidy/modernize-loop-convert-extra.cpp
  test/clang-tidy/modernize-loop-convert-lowercase.cpp
  test/clang-tidy/modernize-loop-convert-uppercase.cpp

Index: test/clang-tidy/modernize-loop-convert-uppercase.cpp
===
--- test/clang-tidy/modernize-loop-convert-uppercase.cpp
+++ test/clang-tidy/modernize-loop-convert-uppercase.cpp
@@ -14,61 +14,61 @@
 printf("%d\n", ARR[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead [modernize-loop-convert]
-  // CHECK-FIXES: for (auto & ELEM : ARR)
+  // CHECK-FIXES: for (int & ELEM : ARR)
   // CHECK-FIXES-NEXT: printf("%d\n", ELEM);
 
   for (int I = 0; I < N; ++I) {
 printf("%d\n", NUMS[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & NUM : NUMS)
+  // CHECK-FIXES: for (int & NUM : NUMS)
   // CHECK-FIXES-NEXT: printf("%d\n", NUM);
 
   for (int I = 0; I < N; ++I) {
 printf("%d\n", NUMS_[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & NUM : NUMS_)
+  // CHECK-FIXES: for (int & NUM : NUMS_)
   // CHECK-FIXES-NEXT: printf("%d\n", NUM);
 
   int NUM = 0;
   for (int I = 0; I < N; ++I) {
 printf("%d\n", NUMS[I] + NUM);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & ELEM : NUMS)
+  // CHECK-FIXES: for (int & ELEM : NUMS)
   // CHECK-FIXES-NEXT: printf("%d\n", ELEM + NUM);
 
   int ELEM = 0;
   for (int I = 0; I < N; ++I) {
 printf("%d\n", NUMS[I] + NUM + ELEM);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & NUMS_I : NUMS)
+  // CHECK-FIXES: for (int & NUMS_I : NUMS)
   // CHECK-FIXES-NEXT: printf("%d\n", NUMS_I + NUM + ELEM);
 
   int NUMS_I = 0;
   for (int I = 0; I < N; ++I) {
 printf("%d\n", NUMS[I] + NUM + ELEM + NUMS_I);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & NUMS_ELEM : NUMS)
+  // CHECK-FIXES: for (int & NUMS_ELEM : NUMS)
   // CHECK-FIXES-NEXT: printf("%d\n", NUMS_ELEM + NUM + ELEM + NUMS_I);
 
   int NUMS_ELEM = 0;
   for (int I = 0; I < N; ++I) {
 printf("%d\n", NUMS[I] + NUM + ELEM + NUMS_I + NUMS_ELEM);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & GIVE_ME_NAME_0 : NUMS)
+  // CHECK-FIXES: for (int & GIVE_ME_NAME_0 : NUMS)
   // CHECK-FIXES-NEXT: printf("%d\n", GIVE_ME_NAME_0 + NUM + ELEM + NUMS_I + NUMS_ELEM);
 
   int GIVE_ME_NAME_0 = 0;
   for (int I = 0; I < N; ++I) {
 printf("%d\n", NUMS[I] + NUM + ELEM + NUMS_I + NUMS_ELEM + GIVE_ME_NAME_0);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & GIVE_ME_NAME_1 : NUMS)
+  // CHECK-FIXES: for (int & GIVE_ME_NAME_1 : NUMS)
   // CHECK-FIXES-NEXT: printf("%d\n", GIVE_ME_NAME_1 + NUM + ELEM + NUMS_I + NUMS_ELEM + GIVE_ME_NAME_0);
 
   int NUMS_J = 0;
@@ -79,7 +79,7 @@
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
   // CHECK-MESSAGES: :[[@LINE-5]]:5: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & GIVE_ME_NAME_0 : NUMS)
-  // CHECK-FIXES: for (auto & GIVE_ME_NAME_1 : NUMS)
+  // CHECK-FIXES: for (int & GIVE_ME_NAME_0 : NUMS)
+  // CHECK-FIXES: for (int & GIVE_ME_NAME_1 : NUMS)
   // CHECK-FIXES-NEXT: printf("%d\n", GIVE_ME_NAME_0 + GIVE_ME_NAME_1 + NUM + ELEM + NUMS_I + NUMS_J + NUMS_ELEM);
 }
Index: test/clang-tidy/modernize-loop-convert-lowercase.cpp
===
--- test/clang-tidy/modernize-loop-convert-lowercase.cpp
+++ test/clang-tidy/modernize-loop-convert-lowercase.cpp
@@ -14,61 +14,61 @@
 printf("%d\n", arr[i]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead [modernize-loop-convert]
-  // CHECK-FIXES: for (auto & elem : arr)
+  // CHECK-FIXES: for (int & elem : arr)
   // CHECK-FIXES-NEXT: printf("%d\n", elem);
 
   for (int i = 0; i < n; ++i) {
 printf("%d\n", nums[i]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & num : nums)
+  // CHECK-FIXES: for (int & num : nums)
   // CHECK-FIXES-NEXT: printf("%d\n", num);
 
   for (int i = 0; i < n; ++i) {
 printf("%d\n", nums_[i]);
   }
   // CHECK

Re: [PATCH] D13931: [Tooling] Add a utility function to replace one nested name with another.

2015-10-22 Thread Benjamin Kramer via cfe-commits
bkramer updated this revision to Diff 38117.
bkramer added a comment.

- Removed "fully qualified" in favor of just "qualified" to clarify that the 
name should be qualified but the leading "::" is not necessary.
- Renamed isNameSpecifierGlobal
- Removed always true conditional from test


http://reviews.llvm.org/D13931

Files:
  include/clang/Tooling/Core/Lookup.h
  lib/Tooling/Core/CMakeLists.txt
  lib/Tooling/Core/Lookup.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/LookupTest.cpp

Index: unittests/Tooling/LookupTest.cpp
===
--- /dev/null
+++ unittests/Tooling/LookupTest.cpp
@@ -0,0 +1,91 @@
+//===- unittest/Tooling/LookupTest.cpp ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "TestVisitor.h"
+#include "clang/Tooling/Core/Lookup.h"
+using namespace clang;
+
+namespace {
+struct GetDeclsVisitor : TestVisitor {
+  std::function OnCall;
+
+  bool VisitCallExpr(CallExpr *Expr) {
+OnCall(Expr);
+return true;
+  }
+};
+
+static std::string replaceCallExpr(const CallExpr *Expr,
+   StringRef ReplacementString) {
+  const auto *Callee = cast(Expr->getCallee()->IgnoreImplicit());
+  const ValueDecl *FD = Callee->getDecl();
+  ASTContext &Context = FD->getASTContext();
+  const DeclContext *DC =
+  Context.getParents(ast_type_traits::DynTypedNode::create(*Expr))[0]
+  .get();
+  return tooling::replaceNestedName(Callee->getQualifier(), DC, FD,
+ReplacementString);
+}
+
+TEST(LookupTest, replaceNestedName) {
+  GetDeclsVisitor Visitor;
+
+  Visitor.OnCall = [](CallExpr *Expr) {
+EXPECT_EQ("bar", replaceCallExpr(Expr, "bar"));
+  };
+  Visitor.runOver("namespace a { void foo(); }\n"
+  "namespace a { void f() { foo(); } }\n");
+
+  Visitor.OnCall = [](CallExpr *Expr) {
+EXPECT_EQ("bar", replaceCallExpr(Expr, "a::bar"));
+  };
+  Visitor.runOver("namespace a { void foo(); }\n"
+  "namespace a { void f() { foo(); } }\n");
+
+  Visitor.OnCall = [](CallExpr *Expr) {
+EXPECT_EQ("a::bar", replaceCallExpr(Expr, "a::bar"));
+  };
+  Visitor.runOver("namespace a { void foo(); }\n"
+  "namespace b { void f() { a::foo(); } }\n");
+
+  Visitor.OnCall = [](CallExpr *Expr) {
+EXPECT_EQ("a::bar", replaceCallExpr(Expr, "a::bar"));
+  };
+  Visitor.runOver("namespace a { void foo(); }\n"
+  "namespace b { namespace a { void foo(); }\n"
+  "void f() { a::foo(); } }\n");
+
+  Visitor.OnCall = [](CallExpr *Expr) {
+EXPECT_EQ("bar", replaceCallExpr(Expr, "bar"));
+  };
+  Visitor.runOver("void foo(); void f() { foo(); }\n");
+
+  Visitor.OnCall = [](CallExpr *Expr) {
+EXPECT_EQ("::bar", replaceCallExpr(Expr, "bar"));
+  };
+  Visitor.runOver("void foo(); void f() { ::foo(); }\n");
+
+  Visitor.OnCall = [](CallExpr *Expr) {
+EXPECT_EQ("a::bar", replaceCallExpr(Expr, "a::bar"));
+  };
+  Visitor.runOver("namespace a { void foo(); }\nvoid f() { a::foo(); }\n");
+
+  Visitor.OnCall = [](CallExpr *Expr) {
+EXPECT_EQ("a::bar", replaceCallExpr(Expr, "a::bar"));
+  };
+  Visitor.runOver("namespace a { int foo(); }\nauto f = a::foo()\n");
+
+  Visitor.OnCall = [](CallExpr *Expr) {
+EXPECT_EQ("bar", replaceCallExpr(Expr, "a::bar"));
+  };
+  Visitor.runOver(
+  "namespace a { int foo(); }\nusing a::foo;\nauto f = foo()\n");
+}
+
+} // end anonymous namespace
Index: unittests/Tooling/CMakeLists.txt
===
--- unittests/Tooling/CMakeLists.txt
+++ unittests/Tooling/CMakeLists.txt
@@ -6,6 +6,7 @@
 add_clang_unittest(ToolingTests
   CommentHandlerTest.cpp
   CompilationDatabaseTest.cpp
+  LookupTest.cpp
   ToolingTest.cpp
   RecursiveASTVisitorTest.cpp
   RecursiveASTVisitorTestCallVisitor.cpp
Index: lib/Tooling/Core/Lookup.cpp
===
--- /dev/null
+++ lib/Tooling/Core/Lookup.cpp
@@ -0,0 +1,106 @@
+//===--- Lookup.cpp - Framework for clang refactoring tools ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This file defines helper methods for clang tools performing name lookup.
+//
+//===--===//
+
+#include "clang/Tooling/Core/Lookup.h"
+#include "clang/AST/Decl.h"
+using namespace clang;
+using namespace clang::tooling;
+
+static bool isInsideDifferentNamespaceWithSameName

Re: [PATCH] D13982: Don't use "auto" on loops over fundamental types in modernize-loop-convert.

2015-10-22 Thread Angel Garcia via cfe-commits
angelgarcia updated this revision to Diff 38119.
angelgarcia added a comment.

Add a guard to check that ElemType is not null.


http://reviews.llvm.org/D13982

Files:
  clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tidy/modernize/LoopConvertCheck.h
  test/clang-tidy/modernize-loop-convert-basic.cpp
  test/clang-tidy/modernize-loop-convert-camelback.cpp
  test/clang-tidy/modernize-loop-convert-extra.cpp
  test/clang-tidy/modernize-loop-convert-lowercase.cpp
  test/clang-tidy/modernize-loop-convert-uppercase.cpp

Index: test/clang-tidy/modernize-loop-convert-uppercase.cpp
===
--- test/clang-tidy/modernize-loop-convert-uppercase.cpp
+++ test/clang-tidy/modernize-loop-convert-uppercase.cpp
@@ -14,61 +14,61 @@
 printf("%d\n", ARR[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead [modernize-loop-convert]
-  // CHECK-FIXES: for (auto & ELEM : ARR)
+  // CHECK-FIXES: for (int & ELEM : ARR)
   // CHECK-FIXES-NEXT: printf("%d\n", ELEM);
 
   for (int I = 0; I < N; ++I) {
 printf("%d\n", NUMS[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & NUM : NUMS)
+  // CHECK-FIXES: for (int & NUM : NUMS)
   // CHECK-FIXES-NEXT: printf("%d\n", NUM);
 
   for (int I = 0; I < N; ++I) {
 printf("%d\n", NUMS_[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & NUM : NUMS_)
+  // CHECK-FIXES: for (int & NUM : NUMS_)
   // CHECK-FIXES-NEXT: printf("%d\n", NUM);
 
   int NUM = 0;
   for (int I = 0; I < N; ++I) {
 printf("%d\n", NUMS[I] + NUM);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & ELEM : NUMS)
+  // CHECK-FIXES: for (int & ELEM : NUMS)
   // CHECK-FIXES-NEXT: printf("%d\n", ELEM + NUM);
 
   int ELEM = 0;
   for (int I = 0; I < N; ++I) {
 printf("%d\n", NUMS[I] + NUM + ELEM);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & NUMS_I : NUMS)
+  // CHECK-FIXES: for (int & NUMS_I : NUMS)
   // CHECK-FIXES-NEXT: printf("%d\n", NUMS_I + NUM + ELEM);
 
   int NUMS_I = 0;
   for (int I = 0; I < N; ++I) {
 printf("%d\n", NUMS[I] + NUM + ELEM + NUMS_I);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & NUMS_ELEM : NUMS)
+  // CHECK-FIXES: for (int & NUMS_ELEM : NUMS)
   // CHECK-FIXES-NEXT: printf("%d\n", NUMS_ELEM + NUM + ELEM + NUMS_I);
 
   int NUMS_ELEM = 0;
   for (int I = 0; I < N; ++I) {
 printf("%d\n", NUMS[I] + NUM + ELEM + NUMS_I + NUMS_ELEM);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & GIVE_ME_NAME_0 : NUMS)
+  // CHECK-FIXES: for (int & GIVE_ME_NAME_0 : NUMS)
   // CHECK-FIXES-NEXT: printf("%d\n", GIVE_ME_NAME_0 + NUM + ELEM + NUMS_I + NUMS_ELEM);
 
   int GIVE_ME_NAME_0 = 0;
   for (int I = 0; I < N; ++I) {
 printf("%d\n", NUMS[I] + NUM + ELEM + NUMS_I + NUMS_ELEM + GIVE_ME_NAME_0);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & GIVE_ME_NAME_1 : NUMS)
+  // CHECK-FIXES: for (int & GIVE_ME_NAME_1 : NUMS)
   // CHECK-FIXES-NEXT: printf("%d\n", GIVE_ME_NAME_1 + NUM + ELEM + NUMS_I + NUMS_ELEM + GIVE_ME_NAME_0);
 
   int NUMS_J = 0;
@@ -79,7 +79,7 @@
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
   // CHECK-MESSAGES: :[[@LINE-5]]:5: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & GIVE_ME_NAME_0 : NUMS)
-  // CHECK-FIXES: for (auto & GIVE_ME_NAME_1 : NUMS)
+  // CHECK-FIXES: for (int & GIVE_ME_NAME_0 : NUMS)
+  // CHECK-FIXES: for (int & GIVE_ME_NAME_1 : NUMS)
   // CHECK-FIXES-NEXT: printf("%d\n", GIVE_ME_NAME_0 + GIVE_ME_NAME_1 + NUM + ELEM + NUMS_I + NUMS_J + NUMS_ELEM);
 }
Index: test/clang-tidy/modernize-loop-convert-lowercase.cpp
===
--- test/clang-tidy/modernize-loop-convert-lowercase.cpp
+++ test/clang-tidy/modernize-loop-convert-lowercase.cpp
@@ -14,61 +14,61 @@
 printf("%d\n", arr[i]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead [modernize-loop-convert]
-  // CHECK-FIXES: for (auto & elem : arr)
+  // CHECK-FIXES: for (int & elem : arr)
   // CHECK-FIXES-NEXT: printf("%d\n", elem);
 
   for (int i = 0; i < n; ++i) {
 printf("%d\n", nums[i]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & num : nums)
+  // CHECK-FIXES: for (int & num : nums)
   // CHECK-FIXES-NEXT: printf("%d\n", num);
 
   for (int i = 0; i < n; ++i) {
 printf("%d\n", nums_[i]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & nu

Re: [PATCH] D12906: [RFC] Bug identification("issue_hash") change for CmpRuns.py

2015-10-22 Thread Honggyu Kim via cfe-commits
honggyu.kim added a comment.

Hi Anna,

In http://reviews.llvm.org/D12906#272243, @zaks.anna wrote:

> I think you misunderstood my comment. I am not talking about using the 
> existing HTML files here but rather having an HTML viewer, which you could 
> use to browse source code. This viewer would be extended to read the bug 
> reports from the plist files and display them. Currently, we create an html 
> file with source code + report info for each bug report. This does not scale 
> when you have a lot of reports on a single large file (ex: sqlite).


I know you already mentioned about the scalability issue but I was thinking to 
use the existing implementation since I thought we didn't have the HTML viewer 
you mentioned as of now. (before I saw Daniel's comment)

> What I describe above is a larger project. What workflow are you trying to 
> support? I think adding the issue hash to the HTML file is fine if you find 
> it to be useful for your workflow...


My workflow is as follows:

1. manage buildbot server to get an event whenever a registered action happened 
for Linux kernel
2. when an event is received, run clang static analyzer for the current Linux 
kernel
3. put the each report in the place where anyone can access through web server

Whenever buildbot runs clang static analyzer for Linux kernel and it shows more 
than 600 bugs. I've received many feedback from my colleagues. They want to see 
only diff set in HTML format because it has too many bug reports.

That's why I was thinking about connecting plist info to HTML files regardless 
of using CmpRuns.py or not.


http://reviews.llvm.org/D12906



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


Re: [PATCH] D12906: [RFC] Bug identification("issue_hash") change for CmpRuns.py

2015-10-22 Thread Honggyu Kim via cfe-commits
honggyu.kim added a comment.

In http://reviews.llvm.org/D12906#272257, @dkrupp wrote:

> Hi Anna & Kim,


Hi Daniel,

> we recognized these scalability issues you just described and that's why we 
> created CodeChecker https://github.com/Ericsson/codechecker/

>  tool. A HTML report viewer for Clang SA.

> 

> Reports are stored in a postgresql db. Each source file is only stored once 
> (unlike scanbuild), supports bug suppression and diff view between runs etc.

>  And it works pretty fast with many-million lines of code projects.

> 

> If you have time, give it a try. we are happy to get feedback...


I have installed CodeChecker after fixing some problems due to the 
environmental difference. (I use ubuntu 12.04)

  (checker_env) $ CodeChecker server --dbusername test_user --dbport 5432 -w 
~/checker_workspace -v 8080
  [WARNING] - WARNING! No suppress file was given, suppressed results will be 
only stored in the database.
  [INFO] - Checking for database
  [INFO] - Waiting for client requests on [localhost:8080]

It seems that it works fine with localhost but cannot connect it from remote 
browsers.

  $ curl localhost:8080
 ... works fine ...
  
  $ curl :8080
  curl: (7) couldn't connect to host

Can I use CodeChecker Viewer as a web server and connect it from outside of 
server?
If you give me some more guide, I will have a look at it more.
Thank you!


http://reviews.llvm.org/D12906



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


Re: [PATCH] D12906: [RFC] Bug identification("issue_hash") change for CmpRuns.py

2015-10-22 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

In http://reviews.llvm.org/D12906#273088, @honggyu.kim wrote:

> In http://reviews.llvm.org/D12906#272257, @dkrupp wrote:
>
> > Hi Anna & Kim,
>
>
> Hi Daniel,
>
> > we recognized these scalability issues you just described and that's why we 
> > created CodeChecker https://github.com/Ericsson/codechecker/
>
> >  tool. A HTML report viewer for Clang SA.
>
> > 
>
> > Reports are stored in a postgresql db. Each source file is only stored once 
> > (unlike scanbuild), supports bug suppression and diff view between runs etc.
>
> >  And it works pretty fast with many-million lines of code projects.
>
> > 
>
> > If you have time, give it a try. we are happy to get feedback...
>
>
> I have installed CodeChecker after fixing some problems due to the 
> environmental difference. (I use ubuntu 12.04)
>
>   (checker_env) $ CodeChecker server --dbusername test_user --dbport 5432 -w 
> ~/checker_workspace -v 8080
>   [WARNING] - WARNING! No suppress file was given, suppressed results will be 
> only stored in the database.
>   [INFO] - Checking for database
>   [INFO] - Waiting for client requests on [localhost:8080]
>  
>
>
> It seems that it works fine with localhost but cannot connect it from remote 
> browsers.
>
>   $ curl localhost:8080
>  ... works fine ...
>  
>   $ curl :8080
>   curl: (7) couldn't connect to host
>
>
> Can I use CodeChecker Viewer as a web server and connect it from outside of 
> server?
>  If you give me some more guide, I will have a look at it more.
>  Thank you!


Hi!

By default it is disabled for security reasons. You can enable by passing a 
command line option to the code checker, something like --not-host-only.

Regards,
Gabor


http://reviews.llvm.org/D12906



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


[PATCH] D13983: Correctly print the type in modernize-make-unique.

2015-10-22 Thread Angel Garcia via cfe-commits
angelgarcia created this revision.
angelgarcia added a reviewer: klimek.
angelgarcia added subscribers: cfe-commits, alexfh.

Take into account the current LangOptions the check has to add back the 
template argument.

http://reviews.llvm.org/D13983

Files:
  clang-tidy/modernize/MakeUniqueCheck.cpp
  test/clang-tidy/modernize-make-unique.cpp

Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -163,6 +163,18 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use std::make_unique instead
   // CHECK-FIXES: IntPtr Typedef = std::make_unique();
 
+  // We use 'bool' instead of '_Bool'.
+  typedef std::unique_ptr BoolPtr;
+  BoolPtr BoolType = BoolPtr(new bool);
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: use std::make_unique instead
+  // CHECK-FIXES: BoolPtr BoolType = std::make_unique();
+
+  // We use 'Base' instead of 'struct Base'.
+  typedef std::unique_ptr BasePtr;
+  BasePtr StructType = BasePtr(new Base);
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use std::make_unique instead
+  // CHECK-FIXES: BasePtr StructType = std::make_unique();
+
 #define PTR unique_ptr
   std::unique_ptr Macro = std::PTR(new int);
   // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: use std::make_unique instead
Index: clang-tidy/modernize/MakeUniqueCheck.cpp
===
--- clang-tidy/modernize/MakeUniqueCheck.cpp
+++ clang-tidy/modernize/MakeUniqueCheck.cpp
@@ -79,8 +79,8 @@
 // If the template argument is missing (because it is part of the alias)
 // we have to add it back.
 ConstructCallEnd = ConstructCallStart.getLocWithOffset(ExprStr.size());
-Diag << FixItHint::CreateInsertion(ConstructCallEnd,
-   "<" + Type->getAsString() + ">");
+Diag << FixItHint::CreateInsertion(
+ConstructCallEnd, "<" + Type->getAsString(getLangOpts()) + ">");
   } else {
 ConstructCallEnd = ConstructCallStart.getLocWithOffset(LAngle);
   }


Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -163,6 +163,18 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use std::make_unique instead
   // CHECK-FIXES: IntPtr Typedef = std::make_unique();
 
+  // We use 'bool' instead of '_Bool'.
+  typedef std::unique_ptr BoolPtr;
+  BoolPtr BoolType = BoolPtr(new bool);
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: use std::make_unique instead
+  // CHECK-FIXES: BoolPtr BoolType = std::make_unique();
+
+  // We use 'Base' instead of 'struct Base'.
+  typedef std::unique_ptr BasePtr;
+  BasePtr StructType = BasePtr(new Base);
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use std::make_unique instead
+  // CHECK-FIXES: BasePtr StructType = std::make_unique();
+
 #define PTR unique_ptr
   std::unique_ptr Macro = std::PTR(new int);
   // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: use std::make_unique instead
Index: clang-tidy/modernize/MakeUniqueCheck.cpp
===
--- clang-tidy/modernize/MakeUniqueCheck.cpp
+++ clang-tidy/modernize/MakeUniqueCheck.cpp
@@ -79,8 +79,8 @@
 // If the template argument is missing (because it is part of the alias)
 // we have to add it back.
 ConstructCallEnd = ConstructCallStart.getLocWithOffset(ExprStr.size());
-Diag << FixItHint::CreateInsertion(ConstructCallEnd,
-   "<" + Type->getAsString() + ">");
+Diag << FixItHint::CreateInsertion(
+ConstructCallEnd, "<" + Type->getAsString(getLangOpts()) + ">");
   } else {
 ConstructCallEnd = ConstructCallStart.getLocWithOffset(LAngle);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12906: [RFC] Bug identification("issue_hash") change for CmpRuns.py

2015-10-22 Thread Daniel Krupp via cfe-commits
dkrupp added a comment.

Hi,

its a good idea to include in LLVM/Clang i will propose it

In http://reviews.llvm.org/D12906#272265, @zaks.anna wrote:

> Hi Daniel,
>
> Have you considered contributing this work to clang/llvm?


It's a good idea I will propose this at cfe-dev.

Daniel


http://reviews.llvm.org/D12906



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


Re: [PATCH] D13983: Correctly print the type in modernize-make-unique.

2015-10-22 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D13983



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


[clang-tools-extra] r251013 - Correctly print the type in modernize-make-unique.

2015-10-22 Thread Angel Garcia Gomez via cfe-commits
Author: angelgarcia
Date: Thu Oct 22 08:20:49 2015
New Revision: 251013

URL: http://llvm.org/viewvc/llvm-project?rev=251013&view=rev
Log:
Correctly print the type in modernize-make-unique.

Summary: Take into account the current LangOptions the check has to add back 
the template argument.

Reviewers: klimek

Subscribers: alexfh, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp?rev=251013&r1=251012&r2=251013&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp Thu Oct 22 
08:20:49 2015
@@ -79,8 +79,8 @@ void MakeUniqueCheck::check(const MatchF
 // If the template argument is missing (because it is part of the alias)
 // we have to add it back.
 ConstructCallEnd = ConstructCallStart.getLocWithOffset(ExprStr.size());
-Diag << FixItHint::CreateInsertion(ConstructCallEnd,
-   "<" + Type->getAsString() + ">");
+Diag << FixItHint::CreateInsertion(
+ConstructCallEnd, "<" + Type->getAsString(getLangOpts()) + ">");
   } else {
 ConstructCallEnd = ConstructCallStart.getLocWithOffset(LAngle);
   }

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp?rev=251013&r1=251012&r2=251013&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp Thu Oct 
22 08:20:49 2015
@@ -163,6 +163,18 @@ void aliases() {
   // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use std::make_unique instead
   // CHECK-FIXES: IntPtr Typedef = std::make_unique();
 
+  // We use 'bool' instead of '_Bool'.
+  typedef std::unique_ptr BoolPtr;
+  BoolPtr BoolType = BoolPtr(new bool);
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: use std::make_unique instead
+  // CHECK-FIXES: BoolPtr BoolType = std::make_unique();
+
+  // We use 'Base' instead of 'struct Base'.
+  typedef std::unique_ptr BasePtr;
+  BasePtr StructType = BasePtr(new Base);
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use std::make_unique instead
+  // CHECK-FIXES: BasePtr StructType = std::make_unique();
+
 #define PTR unique_ptr
   std::unique_ptr Macro = std::PTR(new int);
   // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: use std::make_unique instead


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


Re: [PATCH] D13982: Don't use "auto" on loops over fundamental types in modernize-loop-convert.

2015-10-22 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D13982



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


r251014 - Attempt to fix build bot test failures.

2015-10-22 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Thu Oct 22 08:23:18 2015
New Revision: 251014

URL: http://llvm.org/viewvc/llvm-project?rev=251014&view=rev
Log:
Attempt to fix build bot test failures.

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/IssueHash.cpp
cfe/trunk/test/Analysis/inlining/path-notes.m

Modified: cfe/trunk/lib/StaticAnalyzer/Core/IssueHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/IssueHash.cpp?rev=251014&r1=251013&r2=251014&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/IssueHash.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/IssueHash.cpp Thu Oct 22 08:23:18 2015
@@ -51,7 +51,7 @@ static std::string GetSignature(const Fu
   const auto *TargetT =
   llvm::dyn_cast_or_null(Target->getType().getTypePtr());
 
-  if (!TargetT)
+  if (!TargetT || !isa(Target))
 return Signature;
 
   if (TargetT->isConst())

Modified: cfe/trunk/test/Analysis/inlining/path-notes.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/inlining/path-notes.m?rev=251014&r1=251013&r2=251014&view=diff
==
--- cfe/trunk/test/Analysis/inlining/path-notes.m (original)
+++ cfe/trunk/test/Analysis/inlining/path-notes.m Thu Oct 22 08:23:18 2015
@@ -577,7 +577,7 @@ void testNullDereferenceInDispatch() {
 // CHECK-NEXT:typeDereference of null pointer
 // CHECK-NEXT:check_namecore.NullDereference
 // CHECK-NEXT:
-// CHECK-NEXT:
issue_hash_content_of_line_in_contextad3081ebf0d1e26cc4edb01c88faa1c1
+// CHECK-NEXT:
issue_hash_content_of_line_in_context24947a6942bfa6030ab81e53a201d816
 // CHECK-NEXT:   issue_context_kindfunction
 // CHECK-NEXT:   issue_contexttestReturnZeroIfNil
 // CHECK-NEXT:   issue_hash_function_offset1


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


[clang-tools-extra] r251015 - Don't use "auto" on loops over fundamental types in modernize-loop-convert.

2015-10-22 Thread Angel Garcia Gomez via cfe-commits
Author: angelgarcia
Date: Thu Oct 22 08:23:46 2015
New Revision: 251015

URL: http://llvm.org/viewvc/llvm-project?rev=251015&view=rev
Log:
Don't use "auto" on loops over fundamental types in modernize-loop-convert.

Summary: using "auto" on a loop that iterates over ints is kind of an overkill. 
Use the real type name instead.

Reviewers: klimek

Subscribers: alexfh, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.h
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-camelback.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-lowercase.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-uppercase.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp?rev=251015&r1=251014&r2=251015&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp Thu Oct 
22 08:23:46 2015
@@ -405,7 +405,7 @@ static bool containerIsConst(const Expr
 
 LoopConvertCheck::RangeDescriptor::RangeDescriptor()
 : ContainerNeedsDereference(false), DerefByConstRef(false),
-  DerefByValue(false), IsTriviallyCopyable(false) {}
+  DerefByValue(false) {}
 
 LoopConvertCheck::LoopConvertCheck(StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context), TUInfo(new TUTrackingInfo),
@@ -554,30 +554,33 @@ void LoopConvertCheck::doConversion(
   // Now, we need to construct the new range expression.
   SourceRange ParenRange(Loop->getLParenLoc(), Loop->getRParenLoc());
 
-  QualType AutoType = Context->getAutoDeductType();
+  QualType Type = Context->getAutoDeductType();
+  if (!Descriptor.ElemType.isNull() && 
Descriptor.ElemType->isFundamentalType())
+Type = Descriptor.ElemType.getUnqualifiedType();
 
   // If the new variable name is from the aliased variable, then the reference
   // type for the new variable should only be used if the aliased variable was
   // declared as a reference.
+  bool IsTriviallyCopyable =
+  !Descriptor.ElemType.isNull() &&
+  Descriptor.ElemType.isTriviallyCopyableType(*Context);
   bool UseCopy =
-  CanCopy &&
-  ((VarNameFromAlias && !AliasVarIsRef) ||
-   (Descriptor.DerefByConstRef && Descriptor.IsTriviallyCopyable));
+  CanCopy && ((VarNameFromAlias && !AliasVarIsRef) ||
+  (Descriptor.DerefByConstRef && IsTriviallyCopyable));
 
   if (!UseCopy) {
 if (Descriptor.DerefByConstRef) {
-  AutoType =
-  Context->getLValueReferenceType(Context->getConstType(AutoType));
+  Type = Context->getLValueReferenceType(Context->getConstType(Type));
 } else if (Descriptor.DerefByValue) {
-  if (!Descriptor.IsTriviallyCopyable)
-AutoType = Context->getRValueReferenceType(AutoType);
+  if (!IsTriviallyCopyable)
+Type = Context->getRValueReferenceType(Type);
 } else {
-  AutoType = Context->getLValueReferenceType(AutoType);
+  Type = Context->getLValueReferenceType(Type);
 }
   }
 
   StringRef MaybeDereference = Descriptor.ContainerNeedsDereference ? "*" : "";
-  std::string TypeString = AutoType.getAsString();
+  std::string TypeString = Type.getAsString(getLangOpts());
   std::string Range = ("(" + TypeString + " " + VarName + " : " +
MaybeDereference + Descriptor.ContainerString + ")")
   .str();
@@ -633,7 +636,7 @@ void LoopConvertCheck::getArrayLoopQuali
   }
   Type = Type->getPointeeType();
 }
-Descriptor.IsTriviallyCopyable = Type.isTriviallyCopyableType(*Context);
+Descriptor.ElemType = Type;
   }
 }
 
@@ -654,8 +657,7 @@ void LoopConvertCheck::getIteratorLoopQu
 // If the dereference operator returns by value then test for the
 // canonical const qualification of the init variable type.
 Descriptor.DerefByConstRef = CanonicalInitVarType.isConstQualified();
-Descriptor.IsTriviallyCopyable =
-DerefByValueType->isTriviallyCopyableType(*Context);
+Descriptor.ElemType = *DerefByValueType;
   } else {
 if (const auto *DerefType =
 Nodes.getNodeAs(DerefByRefResultName)) {
@@ -665,8 +667,7 @@ void LoopConvertCheck::getIteratorLoopQu
   auto ValueType = DerefType->getNonReferenceType();
 
   Descriptor.DerefByConstRef = ValueType.isConstQualified();
-  Descriptor.IsTriviallyCopyable =
-  ValueType.isTriviallyCopyableType(*Context);
+  Descriptor.ElemType = ValueType;
 } else {
 

Re: [PATCH] D13931: [Tooling] Add a utility function to replace one nested name with another.

2015-10-22 Thread Benjamin Kramer via cfe-commits
bkramer updated this revision to Diff 38122.
bkramer added a comment.

Add more comments and polish test cases.


http://reviews.llvm.org/D13931

Files:
  include/clang/Tooling/Core/Lookup.h
  lib/Tooling/Core/CMakeLists.txt
  lib/Tooling/Core/Lookup.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/LookupTest.cpp

Index: unittests/Tooling/LookupTest.cpp
===
--- /dev/null
+++ unittests/Tooling/LookupTest.cpp
@@ -0,0 +1,102 @@
+//===- unittest/Tooling/LookupTest.cpp ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "TestVisitor.h"
+#include "clang/Tooling/Core/Lookup.h"
+using namespace clang;
+
+namespace {
+struct GetDeclsVisitor : TestVisitor {
+  std::function OnCall;
+  SmallVector DeclStack;
+
+  bool VisitCallExpr(CallExpr *Expr) {
+OnCall(Expr);
+return true;
+  }
+
+  bool TraverseDecl(Decl *D) {
+DeclStack.push_back(D);
+bool Ret = TestVisitor::TraverseDecl(D);
+DeclStack.pop_back();
+return Ret;
+  }
+};
+
+TEST(LookupTest, replaceNestedName) {
+  GetDeclsVisitor Visitor;
+
+  auto replaceCallExpr = [&](const CallExpr *Expr,
+ StringRef ReplacementString) {
+const auto *Callee = cast(Expr->getCallee()->IgnoreImplicit());
+const ValueDecl *FD = Callee->getDecl();
+return tooling::replaceNestedName(
+Callee->getQualifier(), Visitor.DeclStack.back()->getDeclContext(), FD,
+ReplacementString);
+  };
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("bar", replaceCallExpr(Expr, "bar"));
+  };
+  Visitor.runOver("namespace a { void foo(); }\n"
+  "namespace a { void f() { foo(); } }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("bar", replaceCallExpr(Expr, "a::bar"));
+  };
+  Visitor.runOver("namespace a { void foo(); }\n"
+  "namespace a { void f() { foo(); } }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("a::bar", replaceCallExpr(Expr, "a::bar"));
+  };
+  Visitor.runOver("namespace a { void foo(); }\n"
+  "namespace b { void f() { a::foo(); } }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("a::bar", replaceCallExpr(Expr, "a::bar"));
+  };
+  Visitor.runOver("namespace a { void foo(); }\n"
+  "namespace b { namespace a { void foo(); }\n"
+  "void f() { a::foo(); } }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("bar", replaceCallExpr(Expr, "a::bar"));
+  };
+  Visitor.runOver("namespace a { namespace b { void foo(); }\n"
+  "void f() { b::foo(); } }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("bar", replaceCallExpr(Expr, "bar"));
+  };
+  Visitor.runOver("void foo(); void f() { foo(); }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("::bar", replaceCallExpr(Expr, "bar"));
+  };
+  Visitor.runOver("void foo(); void f() { ::foo(); }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("a::bar", replaceCallExpr(Expr, "a::bar"));
+  };
+  Visitor.runOver("namespace a { void foo(); }\nvoid f() { a::foo(); }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("a::bar", replaceCallExpr(Expr, "a::bar"));
+  };
+  Visitor.runOver("namespace a { int foo(); }\nauto f = a::foo();\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("bar", replaceCallExpr(Expr, "a::bar"));
+  };
+  Visitor.runOver(
+  "namespace a { int foo(); }\nusing a::foo;\nauto f = foo();\n");
+}
+
+} // end anonymous namespace
Index: unittests/Tooling/CMakeLists.txt
===
--- unittests/Tooling/CMakeLists.txt
+++ unittests/Tooling/CMakeLists.txt
@@ -6,6 +6,7 @@
 add_clang_unittest(ToolingTests
   CommentHandlerTest.cpp
   CompilationDatabaseTest.cpp
+  LookupTest.cpp
   ToolingTest.cpp
   RecursiveASTVisitorTest.cpp
   RecursiveASTVisitorTestCallVisitor.cpp
Index: lib/Tooling/Core/Lookup.cpp
===
--- /dev/null
+++ lib/Tooling/Core/Lookup.cpp
@@ -0,0 +1,112 @@
+//===--- Lookup.cpp - Framework for clang refactoring tools ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This file defines helper methods for clang tools performing name lookup.
+//
+//===--===//
+
+#include "clang/Tooling/Core/Lookup.h"
+#include "clang/AST/Decl.h"
+using namespace c

Re: [PATCH] D13931: [Tooling] Add a utility function to replace one nested name with another.

2015-10-22 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: include/clang/Tooling/Core/Lookup.h:37-38
@@ +36,4 @@
+/// \param FromDecl The declaration to which the nested name points.
+/// \param ReplacementString The replacement nested name. Should be qualified,
+///  leading "::" is optional.
+/// \returns The new name to be inserted in place of the current nested name.

After some pondering, I think we should require a fully qualified name, as then 
it's really unambiguous from the call site what is happening.


Comment at: unittests/Tooling/LookupTest.cpp:69-73
@@ +68,7 @@
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("bar", replaceCallExpr(Expr, "a::bar"));
+  };
+  Visitor.runOver("namespace a { namespace b { void foo(); }\n"
+  "void f() { b::foo(); } }\n");
+

Do we already have a test that tests c::bar with replaceCallExpr(Expr, 
"a::c::bar"), or do you think that obviously works from this test?


http://reviews.llvm.org/D13931



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


[clang-tools-extra] r251021 - Switch check_clang_tidy to argparse and add a -resource-dir argument.

2015-10-22 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Thu Oct 22 09:54:50 2015
New Revision: 251021

URL: http://llvm.org/viewvc/llvm-project?rev=251021&view=rev
Log:
Switch check_clang_tidy to argparse and add a -resource-dir argument.

-resource-dir can be used to inject non-standard resource dirs via the
lit site config.

Modified:
clang-tools-extra/trunk/test/clang-tidy/cert-setlongjmp.cpp
clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.c
clang-tools-extra/trunk/test/clang-tidy/google-readability-todo.cpp
clang-tools-extra/trunk/test/clang-tidy/google-runtime-int-std.cpp
clang-tools-extra/trunk/test/clang-tidy/llvm-include-order.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-assert-side-effect.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-move-constructor-init.cpp

clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-sizeof-container.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.c

clang-tools-extra/trunk/test/clang-tidy/misc-throw-by-value-catch-by-reference.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.c
clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-camelback.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-lowercase.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-negative.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-uppercase.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-replace-auto-ptr.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-iterator.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr-basic.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-cxx98.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-few-lines.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-same-line.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-single-line.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-function-size.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-simplify-bool-expr-chained-conditional-assignment.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-simplify-bool-expr-chained-conditional-return.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/cert-setlongjmp.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cert-setlongjmp.cpp?rev=251021&r1=251020&r2=251021&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/cert-setlongjmp.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/cert-setlongjmp.cpp Thu Oct 22 
09:54:50 2015
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s cert-err52-cpp %t -- -std=c++11
+// RUN: %check_clang_tidy %s cert-err52-cpp %t -- -- -std=c++11
 
 typedef void *jmp_buf;
 extern int __setjmpimpl(jmp_buf);

Modified: clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py?rev=251021&r1=251020&r2=251021&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py (original)
+++ clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py Thu Oct 22 
09:54:50 2015
@@ -16,13 +16,15 @@ ClangTidy Test Helper
 This script runs clang-tidy in fix mode and verify fixes, messages or both.
 
 Usage:
-  check_clang_tidy.py\
-[optional clang-tidy arguments]
+  check_clang_tidy.py [-resource-dir ] \
+   \
+-- [optional clang-tidy arguments]
 
 Example:
   // RUN: %check_clang_tidy %s llvm-include-order %t -- -isystem $(dirname 
%s)/Inputs/Headers
 """
 
+import argparse
 import re
 import subprocess
 import sys
@@ -34,21 +36,30 @@ def write_file(file_name, text):
 f.truncate()
 
 def main():
-  if len(sys.argv) < 4:
-sys.exit('Not enough arguments.')
+  parser = argparse.ArgumentParser()
+  parser.add_argument('-resource-dir')
+  parser.add_argument('input_file_name')
+  pars

Re: [PATCH] D13931: [Tooling] Add a utility function to replace one nested name with another.

2015-10-22 Thread Benjamin Kramer via cfe-commits
bkramer updated this revision to Diff 38130.
bkramer added a comment.

Enforce :: at the beginning of the new name.


http://reviews.llvm.org/D13931

Files:
  include/clang/Tooling/Core/Lookup.h
  lib/Tooling/Core/CMakeLists.txt
  lib/Tooling/Core/Lookup.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/LookupTest.cpp

Index: unittests/Tooling/LookupTest.cpp
===
--- /dev/null
+++ unittests/Tooling/LookupTest.cpp
@@ -0,0 +1,108 @@
+//===- unittest/Tooling/LookupTest.cpp ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "TestVisitor.h"
+#include "clang/Tooling/Core/Lookup.h"
+using namespace clang;
+
+namespace {
+struct GetDeclsVisitor : TestVisitor {
+  std::function OnCall;
+  SmallVector DeclStack;
+
+  bool VisitCallExpr(CallExpr *Expr) {
+OnCall(Expr);
+return true;
+  }
+
+  bool TraverseDecl(Decl *D) {
+DeclStack.push_back(D);
+bool Ret = TestVisitor::TraverseDecl(D);
+DeclStack.pop_back();
+return Ret;
+  }
+};
+
+TEST(LookupTest, replaceNestedName) {
+  GetDeclsVisitor Visitor;
+
+  auto replaceCallExpr = [&](const CallExpr *Expr,
+ StringRef ReplacementString) {
+const auto *Callee = cast(Expr->getCallee()->IgnoreImplicit());
+const ValueDecl *FD = Callee->getDecl();
+return tooling::replaceNestedName(
+Callee->getQualifier(), Visitor.DeclStack.back()->getDeclContext(), FD,
+ReplacementString);
+  };
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("bar", replaceCallExpr(Expr, "::bar"));
+  };
+  Visitor.runOver("namespace a { void foo(); }\n"
+  "namespace a { void f() { foo(); } }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("bar", replaceCallExpr(Expr, "::a::bar"));
+  };
+  Visitor.runOver("namespace a { void foo(); }\n"
+  "namespace a { void f() { foo(); } }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("a::bar", replaceCallExpr(Expr, "::a::bar"));
+  };
+  Visitor.runOver("namespace a { void foo(); }\n"
+  "namespace b { void f() { a::foo(); } }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("a::bar", replaceCallExpr(Expr, "::a::bar"));
+  };
+  Visitor.runOver("namespace a { void foo(); }\n"
+  "namespace b { namespace a { void foo(); }\n"
+  "void f() { a::foo(); } }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("c::bar", replaceCallExpr(Expr, "::a::c::bar"));
+  };
+  Visitor.runOver("namespace a { namespace b { void foo(); }\n"
+  "void f() { b::foo(); } }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("bar", replaceCallExpr(Expr, "::a::bar"));
+  };
+  Visitor.runOver("namespace a { namespace b { void foo(); }\n"
+  "void f() { b::foo(); } }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("bar", replaceCallExpr(Expr, "::bar"));
+  };
+  Visitor.runOver("void foo(); void f() { foo(); }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("::bar", replaceCallExpr(Expr, "::bar"));
+  };
+  Visitor.runOver("void foo(); void f() { ::foo(); }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("a::bar", replaceCallExpr(Expr, "::a::bar"));
+  };
+  Visitor.runOver("namespace a { void foo(); }\nvoid f() { a::foo(); }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("a::bar", replaceCallExpr(Expr, "::a::bar"));
+  };
+  Visitor.runOver("namespace a { int foo(); }\nauto f = a::foo();\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("bar", replaceCallExpr(Expr, "::a::bar"));
+  };
+  Visitor.runOver(
+  "namespace a { int foo(); }\nusing a::foo;\nauto f = foo();\n");
+}
+
+} // end anonymous namespace
Index: unittests/Tooling/CMakeLists.txt
===
--- unittests/Tooling/CMakeLists.txt
+++ unittests/Tooling/CMakeLists.txt
@@ -6,6 +6,7 @@
 add_clang_unittest(ToolingTests
   CommentHandlerTest.cpp
   CompilationDatabaseTest.cpp
+  LookupTest.cpp
   ToolingTest.cpp
   RecursiveASTVisitorTest.cpp
   RecursiveASTVisitorTestCallVisitor.cpp
Index: lib/Tooling/Core/Lookup.cpp
===
--- /dev/null
+++ lib/Tooling/Core/Lookup.cpp
@@ -0,0 +1,113 @@
+//===--- Lookup.cpp - Framework for clang refactoring tools ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//

Re: [PATCH] D13931: [Tooling] Add a utility function to replace one nested name with another.

2015-10-22 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D13931



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


r251022 - [Tooling] Add a utility function to replace one nested name with another.

2015-10-22 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Oct 22 10:04:10 2015
New Revision: 251022

URL: http://llvm.org/viewvc/llvm-project?rev=251022&view=rev
Log:
[Tooling] Add a utility function to replace one nested name with another.

One problem in clang-tidy and other clang tools face is that there is no
way to lookup an arbitrary name in the AST, that's buried deep inside Sema
and might not even be what the user wants as the new name may be freshly
inserted and not available in the AST.

A common use case for lookups is replacing one nested name with another
while minimizing namespace qualifications, so replacing 'ns::foo' with
'ns::bar' will use just 'bar' if we happen to be inside the namespace 'ns'.
This adds a little helper utility for exactly that use case.

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

Added:
cfe/trunk/include/clang/Tooling/Core/Lookup.h
cfe/trunk/lib/Tooling/Core/Lookup.cpp
cfe/trunk/unittests/Tooling/LookupTest.cpp
Modified:
cfe/trunk/lib/Tooling/Core/CMakeLists.txt
cfe/trunk/unittests/Tooling/CMakeLists.txt

Added: cfe/trunk/include/clang/Tooling/Core/Lookup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/Lookup.h?rev=251022&view=auto
==
--- cfe/trunk/include/clang/Tooling/Core/Lookup.h (added)
+++ cfe/trunk/include/clang/Tooling/Core/Lookup.h Thu Oct 22 10:04:10 2015
@@ -0,0 +1,48 @@
+//===--- Lookup.h - Framework for clang refactoring tools --*- C++ 
-*--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This file defines helper methods for clang tools performing name lookup.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLING_CORE_LOOKUP_H
+#define LLVM_CLANG_TOOLING_CORE_LOOKUP_H
+
+#include "clang/Basic/LLVM.h"
+#include 
+
+namespace clang {
+
+class DeclContext;
+class NamedDecl;
+class NestedNameSpecifier;
+
+namespace tooling {
+
+/// Emulate a lookup to replace one nested name specifier with another using as
+/// few additional namespace qualifications as possible.
+///
+/// This does not perform a full C++ lookup so ADL will not work.
+///
+/// \param Use The nested name to be replaced.
+/// \param UseContext The context in which the nested name is contained. This
+///   will be used to minimize namespace qualifications.
+/// \param FromDecl The declaration to which the nested name points.
+/// \param ReplacementString The replacement nested name. Must be fully
+///  qualified including a leading "::".
+/// \returns The new name to be inserted in place of the current nested name.
+std::string replaceNestedName(const NestedNameSpecifier *Use,
+  const DeclContext *UseContext,
+  const NamedDecl *FromDecl,
+  StringRef ReplacementString);
+
+} // end namespace tooling
+} // end namespace clang
+
+#endif // LLVM_CLANG_TOOLING_CORE_LOOKUP_H

Modified: cfe/trunk/lib/Tooling/Core/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/CMakeLists.txt?rev=251022&r1=251021&r2=251022&view=diff
==
--- cfe/trunk/lib/Tooling/Core/CMakeLists.txt (original)
+++ cfe/trunk/lib/Tooling/Core/CMakeLists.txt Thu Oct 22 10:04:10 2015
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangToolingCore
+  Lookup.cpp
   Replacement.cpp
 
   LINK_LIBS

Added: cfe/trunk/lib/Tooling/Core/Lookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/Lookup.cpp?rev=251022&view=auto
==
--- cfe/trunk/lib/Tooling/Core/Lookup.cpp (added)
+++ cfe/trunk/lib/Tooling/Core/Lookup.cpp Thu Oct 22 10:04:10 2015
@@ -0,0 +1,113 @@
+//===--- Lookup.cpp - Framework for clang refactoring tools 
---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This file defines helper methods for clang tools performing name lookup.
+//
+//===--===//
+
+#include "clang/Tooling/Core/Lookup.h"
+#include "clang/AST/Decl.h"
+using namespace clang;
+using namespace clang::tooling;
+
+static bool isInsideDifferentNamespaceWithSameName(const DeclContext *DeclA,
+   const DeclContext *DeclB) {
+  while (true) {
+// Look past non-namespaces on

Re: [PATCH] D13931: [Tooling] Add a utility function to replace one nested name with another.

2015-10-22 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL251022: [Tooling] Add a utility function to replace one 
nested name with another. (authored by d0k).

Changed prior to commit:
  http://reviews.llvm.org/D13931?vs=38130&id=38131#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13931

Files:
  cfe/trunk/include/clang/Tooling/Core/Lookup.h
  cfe/trunk/lib/Tooling/Core/CMakeLists.txt
  cfe/trunk/lib/Tooling/Core/Lookup.cpp
  cfe/trunk/unittests/Tooling/CMakeLists.txt
  cfe/trunk/unittests/Tooling/LookupTest.cpp

Index: cfe/trunk/unittests/Tooling/CMakeLists.txt
===
--- cfe/trunk/unittests/Tooling/CMakeLists.txt
+++ cfe/trunk/unittests/Tooling/CMakeLists.txt
@@ -6,6 +6,7 @@
 add_clang_unittest(ToolingTests
   CommentHandlerTest.cpp
   CompilationDatabaseTest.cpp
+  LookupTest.cpp
   ToolingTest.cpp
   RecursiveASTVisitorTest.cpp
   RecursiveASTVisitorTestCallVisitor.cpp
Index: cfe/trunk/unittests/Tooling/LookupTest.cpp
===
--- cfe/trunk/unittests/Tooling/LookupTest.cpp
+++ cfe/trunk/unittests/Tooling/LookupTest.cpp
@@ -0,0 +1,108 @@
+//===- unittest/Tooling/LookupTest.cpp ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "TestVisitor.h"
+#include "clang/Tooling/Core/Lookup.h"
+using namespace clang;
+
+namespace {
+struct GetDeclsVisitor : TestVisitor {
+  std::function OnCall;
+  SmallVector DeclStack;
+
+  bool VisitCallExpr(CallExpr *Expr) {
+OnCall(Expr);
+return true;
+  }
+
+  bool TraverseDecl(Decl *D) {
+DeclStack.push_back(D);
+bool Ret = TestVisitor::TraverseDecl(D);
+DeclStack.pop_back();
+return Ret;
+  }
+};
+
+TEST(LookupTest, replaceNestedName) {
+  GetDeclsVisitor Visitor;
+
+  auto replaceCallExpr = [&](const CallExpr *Expr,
+ StringRef ReplacementString) {
+const auto *Callee = cast(Expr->getCallee()->IgnoreImplicit());
+const ValueDecl *FD = Callee->getDecl();
+return tooling::replaceNestedName(
+Callee->getQualifier(), Visitor.DeclStack.back()->getDeclContext(), FD,
+ReplacementString);
+  };
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("bar", replaceCallExpr(Expr, "::bar"));
+  };
+  Visitor.runOver("namespace a { void foo(); }\n"
+  "namespace a { void f() { foo(); } }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("bar", replaceCallExpr(Expr, "::a::bar"));
+  };
+  Visitor.runOver("namespace a { void foo(); }\n"
+  "namespace a { void f() { foo(); } }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("a::bar", replaceCallExpr(Expr, "::a::bar"));
+  };
+  Visitor.runOver("namespace a { void foo(); }\n"
+  "namespace b { void f() { a::foo(); } }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("a::bar", replaceCallExpr(Expr, "::a::bar"));
+  };
+  Visitor.runOver("namespace a { void foo(); }\n"
+  "namespace b { namespace a { void foo(); }\n"
+  "void f() { a::foo(); } }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("c::bar", replaceCallExpr(Expr, "::a::c::bar"));
+  };
+  Visitor.runOver("namespace a { namespace b { void foo(); }\n"
+  "void f() { b::foo(); } }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("bar", replaceCallExpr(Expr, "::a::bar"));
+  };
+  Visitor.runOver("namespace a { namespace b { void foo(); }\n"
+  "void f() { b::foo(); } }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("bar", replaceCallExpr(Expr, "::bar"));
+  };
+  Visitor.runOver("void foo(); void f() { foo(); }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("::bar", replaceCallExpr(Expr, "::bar"));
+  };
+  Visitor.runOver("void foo(); void f() { ::foo(); }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("a::bar", replaceCallExpr(Expr, "::a::bar"));
+  };
+  Visitor.runOver("namespace a { void foo(); }\nvoid f() { a::foo(); }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("a::bar", replaceCallExpr(Expr, "::a::bar"));
+  };
+  Visitor.runOver("namespace a { int foo(); }\nauto f = a::foo();\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("bar", replaceCallExpr(Expr, "::a::bar"));
+  };
+  Visitor.runOver(
+  "namespace a { int foo(); }\nusing a::foo;\nauto f = foo();\n");
+}
+
+} // end anonymous namespace
Index: cfe/trunk/include/clang/Tooling/Core/Lookup.h
===
--- cfe/trunk/include/clang/Tooling/Core/Lookup.h
+++ cfe/trunk/include/clang/Toolin

r251025 - Disable trigraph and escaped newline expansion on all types of raw string literals not just ASCII type.

2015-10-22 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Oct 22 10:35:21 2015
New Revision: 251025

URL: http://llvm.org/viewvc/llvm-project?rev=251025&view=rev
Log:
Disable trigraph and escaped newline expansion on all types of raw string 
literals not just ASCII type.

Modified:
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/test/CodeGen/string-literal.c

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=251025&r1=251024&r2=251025&view=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Thu Oct 22 10:35:21 2015
@@ -235,7 +235,7 @@ static size_t getSpellingSlow(const Toke
   size_t Length = 0;
   const char *BufEnd = BufPtr + Tok.getLength();
 
-  if (Tok.is(tok::string_literal)) {
+  if (tok::isStringLiteral(Tok.getKind())) {
 // Munch the encoding-prefix and opening double-quote.
 while (BufPtr < BufEnd) {
   unsigned Size;

Modified: cfe/trunk/test/CodeGen/string-literal.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/string-literal.c?rev=251025&r1=251024&r2=251025&view=diff
==
--- cfe/trunk/test/CodeGen/string-literal.c (original)
+++ cfe/trunk/test/CodeGen/string-literal.c Thu Oct 22 10:35:21 2015
@@ -102,6 +102,30 @@ def)" "ghi";
 ??=
 def)";
 
+  // CHECK-CXX11: private unnamed_addr constant [13 x i8] 
c"def\5C\0A??=\0Aabc\00", align 1
+  const char *s = u8R\
+"(def\
+??=
+abc)";
+
+  // CHECK-CXX11: private unnamed_addr constant [13 x i16] [i16 97, i16 98, 
i16 99, i16 92, i16 10, i16 63, i16 63, i16 61, i16 10, i16 100, i16 101, i16 
102, i16 0], align 2
+  const char16_t *t = uR\
+"(abc\
+??=
+def)";
+
+  // CHECK-CXX11: private unnamed_addr constant [13 x i32] [i32 97, i32 98, 
i32 99, i32 92, i32 10, i32 63, i32 63, i32 61, i32 10, i32 100, i32 101, i32 
102, i32 0], align 4
+  const char32_t *u = UR\
+"(abc\
+??=
+def)";
+
+  // CHECK-CXX11: private unnamed_addr constant [13 x i32] [i32 100, i32 101, 
i32 102, i32 92, i32 10, i32 63, i32 63, i32 61, i32 10, i32 97, i32 98, i32 
99, i32 0], align 4
+  const wchar_t *v = LR\
+"(def\
+??=
+abc)";
+
 #endif
 #endif
 }


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


r251026 - Unbreak the shared cmake build. libToolingCore now depends on libAST.

2015-10-22 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Oct 22 10:45:54 2015
New Revision: 251026

URL: http://llvm.org/viewvc/llvm-project?rev=251026&view=rev
Log:
Unbreak the shared cmake build. libToolingCore now depends on libAST.

Modified:
cfe/trunk/lib/Tooling/Core/CMakeLists.txt

Modified: cfe/trunk/lib/Tooling/Core/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/CMakeLists.txt?rev=251026&r1=251025&r2=251026&view=diff
==
--- cfe/trunk/lib/Tooling/Core/CMakeLists.txt (original)
+++ cfe/trunk/lib/Tooling/Core/CMakeLists.txt Thu Oct 22 10:45:54 2015
@@ -5,6 +5,7 @@ add_clang_library(clangToolingCore
   Replacement.cpp
 
   LINK_LIBS
+  clangAST
   clangBasic
   clangLex
   clangRewrite


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


Re: [PATCH] D13959: Fix crash in EmitDeclMetadata mode

2015-10-22 Thread John McCall via cfe-commits
rjmccall added a comment.

LGTM.


Repository:
  rL LLVM

http://reviews.llvm.org/D13959



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


[PATCH] D13987: Postpone module macro update until all headers are parsed.

2015-10-22 Thread Serge Pavlov via cfe-commits
sepavloff created this revision.
sepavloff added a subscriber: cfe-commits.

This change fixes performance degradation reported in PR24667. The reason
of the problem is leaving module after each header, even if the next header
is of the same module. With this fix module state record counts the number of
headers parsed within particular module. Macro update starts when this number
reaches the number of headers specified in the module descriptor.

Using script from PR24667 the performance measurement gives numbers (compile
time vs number of headers):

128 0.0362679958344
256 0.0517950057983
512 0.0877501964569
10240.171896934509
20480.393149137497
40961.02584791183
81923.1531829834

While without the fix compiler demonstrates quadratic compile time:

128 0.0541491508484
256 0.121176958084
512 0.330996990204
10241.10708594322
20484.06581497192
409616.0358121395
819266.6967120171

http://reviews.llvm.org/D13987

Files:
  include/clang/Lex/Preprocessor.h
  lib/Lex/PPLexerChange.cpp

Index: lib/Lex/PPLexerChange.cpp
===
--- lib/Lex/PPLexerChange.cpp
+++ lib/Lex/PPLexerChange.cpp
@@ -404,6 +404,8 @@
 
 bool LeavingSubmodule = CurSubmodule && CurLexer;
 if (LeavingSubmodule) {
+  ++CurSubmoduleState->NumCompiledHeaders;
+
   // Notify the parser that we've left the module.
   const char *EndPos = getCurLexerEndPos();
   Result.startToken();
@@ -701,42 +703,47 @@
 
 // This module may have exported a new macro. If so, create a ModuleMacro
 // representing that fact.
-bool ExplicitlyPublic = false;
-for (auto *MD = Macro.second.getLatest(); MD != OldMD;
- MD = MD->getPrevious()) {
-  assert(MD && "broken macro directive chain");
-
-  // Stop on macros defined in other submodules we #included along the way.
-  // There's no point doing this if we're tracking local submodule
-  // visibility, since there can be no such directives in our list.
-  if (!getLangOpts().ModulesLocalVisibility) {
-Module *Mod = getModuleContainingLocation(MD->getLocation());
-if (Mod != LeavingMod)
-  break;
-  }
+// We do this only if when the last module header is compiled, to avoid
+// repeating updates of macro set.
+if (CurSubmoduleState->NumCompiledHeaders >=
+LeavingMod->Headers[Module::HK_Normal].size()) {
+  bool ExplicitlyPublic = false;
+  for (auto *MD = Macro.second.getLatest(); MD != OldMD;
+   MD = MD->getPrevious()) {
+assert(MD && "broken macro directive chain");
+
+// Stop on macros defined in other submodules we #included along the
+// way. There's no point doing this if we're tracking local submodule
+// visibility, since there can be no such directives in our list.
+if (!getLangOpts().ModulesLocalVisibility) {
+  Module *Mod = getModuleContainingLocation(MD->getLocation());
+  if (Mod != LeavingMod)
+break;
+}
 
-  if (auto *VisMD = dyn_cast(MD)) {
-// The latest visibility directive for a name in a submodule affects
-// all the directives that come before it.
-if (VisMD->isPublic())
-  ExplicitlyPublic = true;
-else if (!ExplicitlyPublic)
-  // Private with no following public directive: not exported.
+if (auto *VisMD = dyn_cast(MD)) {
+  // The latest visibility directive for a name in a submodule affects
+  // all the directives that come before it.
+  if (VisMD->isPublic())
+ExplicitlyPublic = true;
+  else if (!ExplicitlyPublic)
+// Private with no following public directive: not exported.
+break;
+} else {
+  MacroInfo *Def = nullptr;
+  if (DefMacroDirective *DefMD = dyn_cast(MD))
+Def = DefMD->getInfo();
+
+  // FIXME: Issue a warning if multiple headers for the same submodule
+  // define a macro, rather than silently ignoring all but the first.
+  bool IsNew;
+  // Don't bother creating a module macro if it would represent a #undef
+  // that doesn't override anything.
+  if (Def || !Macro.second.getOverriddenMacros().empty())
+addModuleMacro(LeavingMod, II, Def,
+   Macro.second.getOverriddenMacros(), IsNew);
   break;
-  } else {
-MacroInfo *Def = nullptr;
-if (DefMacroDirective *DefMD = dyn_cast(MD))
-  Def = DefMD->getInfo();
-
-// FIXME: Issue a warning if multiple headers for the same submodule
-// define a macro, rather than silently ignoring all but the first.
-bool IsNew;
-// Don't bother creating a module macro if it would represent a #undef
-// that doesn't override anything.
-if (Def || !Macro.second.getOverriddenMacros().empty())
-  addModuleM

[PATCH] D13980: Add "x87" in x86 target feature map

2015-10-22 Thread Andrey Turetskiy via cfe-commits
aturetsk created this revision.
aturetsk added a reviewer: rsmith.
aturetsk added a subscriber: cfe-commits.

Add 'x87' in x86 target feature map

http://reviews.llvm.org/D13980

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/attr-target-x86-mmx.c
  test/CodeGen/attr-target-x86.c

Index: test/CodeGen/attr-target-x86.c
===
--- test/CodeGen/attr-target-x86.c
+++ test/CodeGen/attr-target-x86.c
@@ -31,9 +31,9 @@
 // CHECK: qux{{.*}} #1
 // CHECK: qax{{.*}} #4
 // CHECK: qq{{.*}} #5
-// CHECK: #0 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+sse,+sse2"
-// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+xsave,+xsaveopt"
-// CHECK: #2 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+sse,-aes,-avx,-avx2,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512pf,-avx512vl,-f16c,-fma,-fma4,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-xop,-xsave,-xsaveopt"
-// CHECK: #3 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3"
-// CHECK: #4 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+xsave,+xsaveopt,-aes"
-// CHECK: #5 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+sse,+sse2,-3dnow,-3dnowa,-mmx"
+// CHECK: #0 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+sse,+sse2,+x87"
+// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"
+// CHECK: #2 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+sse,+x87,-aes,-avx,-avx2,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512pf,-avx512vl,-f16c,-fma,-fma4,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-xop,-xsave,-xsaveopt"
+// CHECK: #3 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87"
+// CHECK: #4 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt,-aes"
+// CHECK: #5 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+sse,+sse2,+x87,-3dnow,-3dnowa,-mmx"
Index: test/CodeGen/attr-target-x86-mmx.c
===
--- test/CodeGen/attr-target-x86-mmx.c
+++ test/CodeGen/attr-target-x86-mmx.c
@@ -19,4 +19,4 @@
   _mm_srai_pi32(a, c);
 }
 
-// CHECK: "target-features"="+mmx,+sse"
+// CHECK: "target-features"="+mmx,+sse,+x87"
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2513,6 +2513,9 @@
   if (getTriple().getArch() == llvm::Triple::x86_64)
 setFeatureEnabledImpl(Features, "sse2", true);
 
+  // X86 always has X87.
+  setFeatureEnabledImpl(Features, "x87", true);
+
   switch (getCPUKind(CPU)) {
   case CK_Generic:
   case CK_i386:


Index: test/CodeGen/attr-target-x86.c
===
--- test/CodeGen/attr-target-x86.c
+++ test/CodeGen/attr-target-x86.c
@@ -31,9 +31,9 @@
 // CHECK: qux{{.*}} #1
 // CHECK: qax{{.*}} #4
 // CHECK: qq{{.*}} #5
-// CHECK: #0 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2"
-// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" "target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+xsave,+xsaveopt"
-// CHECK: #2 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,-aes,-avx,-avx2,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512pf,-avx512vl,-f16c,-fma,-fma4,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-xop,-xsave,-xsaveopt"
-// CHECK: #3 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3"
-// CHECK: #4 = {{.*}}"target-cpu"="ivybridge" "target-features"="+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+xsave,+xsaveopt,-aes"
-// CHECK: #5 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+sse,+sse2,-3dnow,-3dnowa,-mmx"
+// CHECK: #0 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87"
+// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" "target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"
+// CHECK: #2 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+x87,-aes,-avx,-avx2,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512pf,-avx512vl,-f16c,-fma,-fma4,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-xop,-xsave,-xsaveopt"
+/

Re: [PATCH] D13978: [X86] Support MCU psABI when marking inregs

2015-10-22 Thread David Kreitzer via cfe-commits
DavidKreitzer added inline comments.


Comment at: lib/CodeGen/TargetInfo.cpp:1239
@@ +1238,3 @@
+// The MCU psABI allows passing parameters in-reg even if there are
+// earlier, parameters that are passed on the stack. Also,
+// it does not allow passing >8-byte structs in-register,

Minor nit - you don't need the comma after "earlier".


Comment at: test/CodeGen/x86_32-arguments-iamcu.c:1
@@ +1,2 @@
+// RUN: %clang_cc1 -w -triple i386-pc-elfiamcu -mfloat-abi soft -emit-llvm -o 
- %s | FileCheck %s
+

Good test!

I think it would be a good idea to add a varargs function & verify that the 
args do not get marked inreg.


http://reviews.llvm.org/D13978



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


r251036 - [MS ABI] Don't crash when inheriting from base with trailing empty array member

2015-10-22 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Thu Oct 22 13:04:22 2015
New Revision: 251036

URL: http://llvm.org/viewvc/llvm-project?rev=251036&view=rev
Log:
[MS ABI] Don't crash when inheriting from base with trailing empty array member

We got this right for Itanium but not MSVC because CGRecordLayoutBuilder
was checking if the base's size was zero when it should have been
checking the non-virtual size.

This fixes PR21040.

Modified:
cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
cfe/trunk/test/Layout/ms-x86-empty-nonvirtual-bases.cpp

Modified: cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp?rev=251036&r1=251035&r2=251036&view=diff
==
--- cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp Thu Oct 22 13:04:22 2015
@@ -454,7 +454,7 @@ void CGRecordLowering::accumulateBases()
 // contain only a trailing array member.
 const CXXRecordDecl *BaseDecl = Base.getType()->getAsCXXRecordDecl();
 if (!BaseDecl->isEmpty() &&
-!Context.getASTRecordLayout(BaseDecl).getSize().isZero())
+!Context.getASTRecordLayout(BaseDecl).getNonVirtualSize().isZero())
   Members.push_back(MemberInfo(Layout.getBaseClassOffset(BaseDecl),
   MemberInfo::Base, getStorageType(BaseDecl), BaseDecl));
   }

Modified: cfe/trunk/test/Layout/ms-x86-empty-nonvirtual-bases.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Layout/ms-x86-empty-nonvirtual-bases.cpp?rev=251036&r1=251035&r2=251036&view=diff
==
--- cfe/trunk/test/Layout/ms-x86-empty-nonvirtual-bases.cpp (original)
+++ cfe/trunk/test/Layout/ms-x86-empty-nonvirtual-bases.cpp Thu Oct 22 13:04:22 
2015
@@ -159,6 +159,28 @@ struct __declspec(align(32)) H : B0, B1,
 // CHECK-NEXT:  | [sizeof=64, align=32
 // CHECK-NEXT:  |  nvsize=40, nvalign=32]
 
+struct I {
+  int i0[0];
+};
+
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct I
+// CHECK-NEXT:0 |   int [0] i0
+// CHECK-NEXT:  | [sizeof={{1|4}}, align=4,
+// CHECK-NEXT:  |  nvsize=0, nvalign=4]
+
+struct J : I {
+  int j;
+};
+
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT:   0 | struct J
+// CHECK-NEXT:   0 |   struct I (base)
+// CHECK-NEXT:   0 | int [0] i0
+// CHECK-NEXT:   0 |   int j
+// CHECK-NEXT: | [sizeof=4, align=4,
+// CHECK-NEXT: |  nvsize=4, nvalign=4]
+
 int a[
 sizeof(A)+
 sizeof(B)+
@@ -167,4 +189,6 @@ sizeof(D)+
 sizeof(E)+
 sizeof(F)+
 sizeof(G)+
-sizeof(H)];
+sizeof(H)+
+sizeof(I)+
+sizeof(J)];


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


r251041 - Define weak and __weak to mean ARC-style weak references, even in MRC.

2015-10-22 Thread John McCall via cfe-commits
Author: rjmccall
Date: Thu Oct 22 13:38:17 2015
New Revision: 251041

URL: http://llvm.org/viewvc/llvm-project?rev=251041&view=rev
Log:
Define weak and __weak to mean ARC-style weak references, even in MRC.

Previously, __weak was silently accepted and ignored in MRC mode.
That makes this a potentially source-breaking change that we have to
roll out cautiously.  Accordingly, for the time being, actual support
for __weak references in MRC is experimental, and the compiler will
reject attempts to actually form such references.  The intent is to
eventually enable the feature by default in all non-GC modes.
(It is, of course, incompatible with ObjC GC's interpretation of
__weak.)

If you like, you can enable this feature with
  -Xclang -fobjc-weak
but like any -Xclang option, this option may be removed at any point,
e.g. if/when it is eventually enabled by default.

This patch also enables the use of the ARC __unsafe_unretained qualifier
in MRC.  Unlike __weak, this is being enabled immediately.  Since
variables are essentially __unsafe_unretained by default in MRC,
the only practical uses are (1) communication and (2) changing the
default behavior of by-value block capture.

As an implementation matter, this means that the ObjC ownership
qualifiers may appear in any ObjC language mode, and so this patch
removes a number of checks for getLangOpts().ObjCAutoRefCount
that were guarding the processing of these qualifiers.  I don't
expect this to be a significant drain on performance; it may even
be faster to just check for these qualifiers directly on a type
(since it's probably in a register anyway) than to do N dependent
loads to grab the LangOptions.

rdar://9674298

Added:
cfe/trunk/test/CodeGenObjC/mrc-weak.m
cfe/trunk/test/SemaObjC/mrc-weak.m
Removed:
cfe/trunk/test/SemaObjC/nonarc-weak.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/lib/ARCMigrate/ARCMT.cpp
cfe/trunk/lib/ARCMigrate/Transforms.cpp
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/ARCMT/GC-no-arc-runtime.m
cfe/trunk/test/CodeGenObjC/blocks.m
cfe/trunk/test/CodeGenObjC/mrr-captured-block-var-inlined-layout.m
cfe/trunk/test/Index/complete-property-flags.m
cfe/trunk/test/SemaObjC/attr-objc-gc.m
cfe/trunk/test/SemaObjC/no-gc-weak-test.m
cfe/trunk/test/SemaObjC/property-in-class-extension-1.m
cfe/trunk/test/SemaObjC/synthesized-ivar.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=251041&r1=251040&r2=251041&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Thu Oct 22 13:38:17 
2015
@@ -108,6 +108,10 @@ def err_arc_unsupported_on_runtime : Err
   "-fobjc-arc is not supported on platforms using the legacy runtime">;
 def err_arc_unsupported_on_toolchain : Error< // feel free to generalize this
   "-fobjc-arc is not supported on versions of OS X prior to 10.6">;
+def err_objc_weak_with_gc : Error<
+  "-fobjc-weak is not supported in Objective-C garbage collection">;
+def err_objc_weak_unsupported : Error<
+  "-fobjc-weak is not supported on the current deployment target">;
 def err_drv_mg_requires_m_or_mm : Error<
   "option '-MG' requires '-M' or '-MM'">;
 def err_drv_unknown_objc_runtime : Error<

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=251041&r1=251040&r2=251041&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Oct 22 13:38:17 
2015
@@ -907,8 +907,6 @@ def error_bad_property_context : Error<
 def error_missing_property_ivar_decl : Error<
   "synthesized property %0 must either be named the same as a compatible"
   " instance variable or must explicitly name an instance

Re: [libcxx] r250319 - [libcxx] Make it drastically simpler to link libc++.

2015-10-22 Thread Alexey Samsonov via cfe-commits
After this change I am unable to configure libcxx as external project from
compiler-rt with extra build flags.
The problem is gen_link_script.py is invoked with incorrect number of
arguments: LIBCXX_CXX_ABI_LIBNAME is automatically deduced to be "none",
and LIBCXX_CXX_ABI_LIBRARY which is passed to gen_link_script.py is then
empty.

I can suppress this by using condition
  if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT AND LIBCXX_CXX_ABI_LIBRARY)
in libcxx/lib/CMakeLists.txt, but I don't think this fix is clean enough. I
can also pass -DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=OFF when I configure libc++,
but probably this should be deduced automatically...


On Wed, Oct 21, 2015 at 5:44 PM, Eric Fiselier via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Thanks. I'll look to see if any other LLVM projects have bumped the CMake
> version to 3 yet. If so that's the direction I will head.
>
>
>
>
> On Oct 20, 2015 9:39 PM, "Hahnfeld, Jonas" 
> wrote:
>
>> > -Original Message-
>> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
>> > Of Eric Fiselier via cfe-commits
>> > Sent: Wednesday, October 14, 2015 9:54 PM
>> > To: cfe-commits@lists.llvm.org
>> > Subject: [libcxx] r250319 - [libcxx] Make it drastically simpler to link
>> > libc++.
>> >
>> > Author: ericwf
>> > Date: Wed Oct 14 14:54:03 2015
>> > New Revision: 250319
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=250319&view=rev
>> > Log:
>> > [libcxx] Make it drastically simpler to link libc++.
>> [...]
>> >  if (LIBCXX_INSTALL_LIBRARY)
>> >install(TARGETS cxx
>> >  LIBRARY DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT libcxx
>> >  ARCHIVE DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT libcxx
>> >  )
>> > +  # NOTE: This install command must go after the cxx install command
>> > + otherwise  # it will not be executed after the library symlinks are
>> > installed.
>> > +  if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
>> > +install(FILES "$"
>> > +  DESTINATION lib${LIBCXX_LIBDIR_SUFFIX}
>> > +  COMPONENT libcxx)
>> > +  endif()
>> >  endif()
>>
>> Generator expressions in install(FILES) are only allowed since CMake 3.0
>> (https://cmake.org/cmake/help/v3.0/release/3.0.0.html#commands).
>> The current minimum for libcxx is 2.8, so this should either be raised or
>> we
>> have to find another possibility of writing this install command...
>>
>> Greetings
>> Jonas
>>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>


-- 
Alexey Samsonov
vonos...@gmail.com
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13973: CFG: Delay creating Dtors for CompoundStmts which end in ReturnStmt

2015-10-22 Thread Matthias Gehre via cfe-commits
mgehre updated this revision to Diff 38157.
mgehre added a comment.

Add test case


http://reviews.llvm.org/D13973

Files:
  lib/Analysis/CFG.cpp
  test/Analysis/no-unreachable-dtors.cpp

Index: test/Analysis/no-unreachable-dtors.cpp
===
--- /dev/null
+++ test/Analysis/no-unreachable-dtors.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.Stats -verify 
-Wno-unreachable-code %s
+
+struct S {
+  ~S();
+};
+
+// the return at the end of an CompoundStmt does not lead to an unreachable 
block containing the dtors
+void test() { // expected-warning-re{{test -> Total CFGBlocks: {{[0-9]+}} | 
Unreachable CFGBlocks: 0 | Exhausted Block: no | Empty WorkList: yes}}
+  S s;
+  return;
+}
Index: lib/Analysis/CFG.cpp
===
--- lib/Analysis/CFG.cpp
+++ lib/Analysis/CFG.cpp
@@ -1942,7 +1942,15 @@
 
 
 CFGBlock *CFGBuilder::VisitCompoundStmt(CompoundStmt *C) {
-  addLocalScopeAndDtors(C);
+  LocalScope::const_iterator scopeBeginPos = ScopePos;
+  if (BuildOpts.AddImplicitDtors) {
+addLocalScopeForStmt(C);
+  }
+  if(!C->body_empty() && !dyn_cast(*C->body_rbegin())) {
+// If the body ends with a ReturnStmt, the dtors will be added in 
VisitReturnStmt
+addAutomaticObjDtors(ScopePos, scopeBeginPos, C);
+  }
+
   CFGBlock *LastBlock = Block;
 
   for (CompoundStmt::reverse_body_iterator I=C->body_rbegin(), 
E=C->body_rend();


Index: test/Analysis/no-unreachable-dtors.cpp
===
--- /dev/null
+++ test/Analysis/no-unreachable-dtors.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.Stats -verify -Wno-unreachable-code %s
+
+struct S {
+  ~S();
+};
+
+// the return at the end of an CompoundStmt does not lead to an unreachable block containing the dtors
+void test() { // expected-warning-re{{test -> Total CFGBlocks: {{[0-9]+}} | Unreachable CFGBlocks: 0 | Exhausted Block: no | Empty WorkList: yes}}
+  S s;
+  return;
+}
Index: lib/Analysis/CFG.cpp
===
--- lib/Analysis/CFG.cpp
+++ lib/Analysis/CFG.cpp
@@ -1942,7 +1942,15 @@
 
 
 CFGBlock *CFGBuilder::VisitCompoundStmt(CompoundStmt *C) {
-  addLocalScopeAndDtors(C);
+  LocalScope::const_iterator scopeBeginPos = ScopePos;
+  if (BuildOpts.AddImplicitDtors) {
+addLocalScopeForStmt(C);
+  }
+  if(!C->body_empty() && !dyn_cast(*C->body_rbegin())) {
+// If the body ends with a ReturnStmt, the dtors will be added in VisitReturnStmt
+addAutomaticObjDtors(ScopePos, scopeBeginPos, C);
+  }
+
   CFGBlock *LastBlock = Block;
 
   for (CompoundStmt::reverse_body_iterator I=C->body_rbegin(), E=C->body_rend();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13959: Fix crash in EmitDeclMetadata mode

2015-10-22 Thread Keno Fischer via cfe-commits
loladiro added a comment.

Can you provide insight as to why this is looking at MangledDeclNames rather 
than the StaticLocalDeclMap? I'd like to extend the comment with an explanation.


Repository:
  rL LLVM

http://reviews.llvm.org/D13959



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


[libcxx] r251062 - Disable linker scripts when the ABI library is not specified or is none.

2015-10-22 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Oct 22 15:50:07 2015
New Revision: 251062

URL: http://llvm.org/viewvc/llvm-project?rev=251062&view=rev
Log:
Disable linker scripts when the ABI library is not specified or is none.

Modified:
libcxx/trunk/CMakeLists.txt

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=251062&r1=251061&r2=251062&view=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Thu Oct 22 15:50:07 2015
@@ -74,9 +74,12 @@ option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY
 # Generate and install a linker script inplace of libc++.so. The linker script
 # will link libc++ to the correct ABI library. This option is on by default
 # On UNIX platforms other than Apple unless 'LIBCXX_ENABLE_STATIC_ABI_LIBRARY'
-# is on.
+# is on. This option is also disabled when the ABI library is not specified
+# or is specified to be "none".
 set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF)
 if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_ENABLE_STATIC_ABI_LIBRARY
+  AND LIBCXX_CXX_ABI
+  AND NOT LIBCXX_CXX_ABI STREQUAL "none"
   AND PYTHONINTERP_FOUND)
 set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON)
 endif()


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


[libcxx] r251063 - Only disable linker script when LIBCXX_CXX_ABI_LIBNAME is none

2015-10-22 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Oct 22 15:54:27 2015
New Revision: 251063

URL: http://llvm.org/viewvc/llvm-project?rev=251063&view=rev
Log:
Only disable linker script when LIBCXX_CXX_ABI_LIBNAME is none

Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=251063&r1=251062&r2=251063&view=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Thu Oct 22 15:54:27 2015
@@ -67,6 +67,20 @@ set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" C
 set(CXXABIS none libcxxabi libcxxrt libstdc++ libsupc++)
 set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
 
+# Setup the default options if LIBCXX_CXX_ABI is not specified.
+if (NOT LIBCXX_CXX_ABI)
+  if (NOT DEFINED LIBCXX_BUILT_STANDALONE AND
+  IS_DIRECTORY "${CMAKE_SOURCE_DIR}/projects/libcxxabi")
+set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi")
+set(LIBCXX_CXX_ABI_INCLUDE_PATHS 
"${CMAKE_SOURCE_DIR}/projects/libcxxabi/include")
+set(LIBCXX_CXX_ABI_INTREE 1)
+  else ()
+set(LIBCXX_CXX_ABI_LIBNAME "none")
+  endif ()
+else ()
+  set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}")
+endif ()
+
 # Use a static copy of the ABI library when linking libc++. This option
 # cannot be used with LIBCXX_ENABLE_ABI_LINKER_SCRIPT.
 option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF)
@@ -78,8 +92,7 @@ option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY
 # or is specified to be "none".
 set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF)
 if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_ENABLE_STATIC_ABI_LIBRARY
-  AND LIBCXX_CXX_ABI
-  AND NOT LIBCXX_CXX_ABI STREQUAL "none"
+  AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "none"
   AND PYTHONINTERP_FOUND)
 set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON)
 endif()

Modified: libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake?rev=251063&r1=251062&r2=251063&view=diff
==
--- libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake (original)
+++ libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake Thu Oct 22 15:54:27 2015
@@ -61,19 +61,6 @@ macro(setup_abi_lib abidefines abilib ab
 
 endmacro()
 
-# Setup the default options if LIBCXX_CXX_ABI is not specified.
-if (NOT LIBCXX_CXX_ABI)
-  if (NOT DEFINED LIBCXX_BUILT_STANDALONE AND
-  IS_DIRECTORY "${CMAKE_SOURCE_DIR}/projects/libcxxabi")
-set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi")
-set(LIBCXX_CXX_ABI_INCLUDE_PATHS 
"${CMAKE_SOURCE_DIR}/projects/libcxxabi/include")
-set(LIBCXX_CXX_ABI_INTREE 1)
-  else ()
-set(LIBCXX_CXX_ABI_LIBNAME "none")
-  endif ()
-else ()
-  set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}")
-endif ()
 
 # Configure based on the selected ABI library.
 if ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libstdc++" OR


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


Re: [libcxx] r251062 - Disable linker scripts when the ABI library is not specified or is none.

2015-10-22 Thread Jonathan Roelofs via cfe-commits



On 10/22/15 2:50 PM, Eric Fiselier via cfe-commits wrote:

Author: ericwf
Date: Thu Oct 22 15:50:07 2015
New Revision: 251062

URL: http://llvm.org/viewvc/llvm-project?rev=251062&view=rev
Log:
Disable linker scripts when the ABI library is not specified or is none.

Modified:
 libcxx/trunk/CMakeLists.txt

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=251062&r1=251061&r2=251062&view=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Thu Oct 22 15:50:07 2015
@@ -74,9 +74,12 @@ option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY
  # Generate and install a linker script inplace of libc++.so. The linker script
  # will link libc++ to the correct ABI library. This option is on by default
  # On UNIX platforms other than Apple unless 'LIBCXX_ENABLE_STATIC_ABI_LIBRARY'
-# is on.
+# is on. This option is also disabled when the ABI library is not specified
+# or is specified to be "none".
  set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF)
  if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_ENABLE_STATIC_ABI_LIBRARY
+  AND LIBCXX_CXX_ABI
+  AND NOT LIBCXX_CXX_ABI STREQUAL "none"


I remember suggesting in a review that this be called "auto" rather than 
"none"... but now I can't find that review. Thoughts?


Jon


AND PYTHONINTERP_FOUND)
  set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON)
  endif()


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



--
Jon Roelofs
jonat...@codesourcery.com
CodeSourcery / Mentor Embedded
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r250319 - [libcxx] Make it drastically simpler to link libc++.

2015-10-22 Thread Eric Fiselier via cfe-commits
Hi Alexey,

Please confirm that this works for you now after r251063. Sorry for the
breakage.

/Eric

On Thu, Oct 22, 2015 at 9:23 AM, Alexey Samsonov  wrote:

> After this change I am unable to configure libcxx as external project from
> compiler-rt with extra build flags.
> The problem is gen_link_script.py is invoked with incorrect number of
> arguments: LIBCXX_CXX_ABI_LIBNAME is automatically deduced to be "none",
> and LIBCXX_CXX_ABI_LIBRARY which is passed to gen_link_script.py is then
> empty.
>
> I can suppress this by using condition
>   if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT AND LIBCXX_CXX_ABI_LIBRARY)
> in libcxx/lib/CMakeLists.txt, but I don't think this fix is clean enough.
> I can also pass -DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=OFF when I configure
> libc++,
> but probably this should be deduced automatically...
>
>
> On Wed, Oct 21, 2015 at 5:44 PM, Eric Fiselier via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Thanks. I'll look to see if any other LLVM projects have bumped the CMake
>> version to 3 yet. If so that's the direction I will head.
>>
>>
>>
>>
>> On Oct 20, 2015 9:39 PM, "Hahnfeld, Jonas" 
>> wrote:
>>
>>> > -Original Message-
>>> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On
>>> Behalf
>>> > Of Eric Fiselier via cfe-commits
>>> > Sent: Wednesday, October 14, 2015 9:54 PM
>>> > To: cfe-commits@lists.llvm.org
>>> > Subject: [libcxx] r250319 - [libcxx] Make it drastically simpler to
>>> link
>>> > libc++.
>>> >
>>> > Author: ericwf
>>> > Date: Wed Oct 14 14:54:03 2015
>>> > New Revision: 250319
>>> >
>>> > URL: http://llvm.org/viewvc/llvm-project?rev=250319&view=rev
>>> > Log:
>>> > [libcxx] Make it drastically simpler to link libc++.
>>> [...]
>>> >  if (LIBCXX_INSTALL_LIBRARY)
>>> >install(TARGETS cxx
>>> >  LIBRARY DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT libcxx
>>> >  ARCHIVE DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT libcxx
>>> >  )
>>> > +  # NOTE: This install command must go after the cxx install command
>>> > + otherwise  # it will not be executed after the library symlinks are
>>> > installed.
>>> > +  if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
>>> > +install(FILES "$"
>>> > +  DESTINATION lib${LIBCXX_LIBDIR_SUFFIX}
>>> > +  COMPONENT libcxx)
>>> > +  endif()
>>> >  endif()
>>>
>>> Generator expressions in install(FILES) are only allowed since CMake 3.0
>>> (https://cmake.org/cmake/help/v3.0/release/3.0.0.html#commands).
>>> The current minimum for libcxx is 2.8, so this should either be raised
>>> or we
>>> have to find another possibility of writing this install command...
>>>
>>> Greetings
>>> Jonas
>>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>>
>
>
> --
> Alexey Samsonov
> vonos...@gmail.com
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r251062 - Disable linker scripts when the ABI library is not specified or is none.

2015-10-22 Thread Eric Fiselier via cfe-commits
Yeah, that review hasn't landed yet. It should be called auto, but we need
to make it actually "automatic". Currently "none" really means don't help
me, not that we will automatically figure it out for you. I agree with your
requested change, it's just a bunch of work that should probably be done on
it's own.



On Thu, Oct 22, 2015 at 10:57 AM, Jonathan Roelofs <
jonat...@codesourcery.com> wrote:

>
>
> On 10/22/15 2:50 PM, Eric Fiselier via cfe-commits wrote:
>
>> Author: ericwf
>> Date: Thu Oct 22 15:50:07 2015
>> New Revision: 251062
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=251062&view=rev
>> Log:
>> Disable linker scripts when the ABI library is not specified or is none.
>>
>> Modified:
>>  libcxx/trunk/CMakeLists.txt
>>
>> Modified: libcxx/trunk/CMakeLists.txt
>> URL:
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=251062&r1=251061&r2=251062&view=diff
>>
>> ==
>> --- libcxx/trunk/CMakeLists.txt (original)
>> +++ libcxx/trunk/CMakeLists.txt Thu Oct 22 15:50:07 2015
>> @@ -74,9 +74,12 @@ option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY
>>   # Generate and install a linker script inplace of libc++.so. The linker
>> script
>>   # will link libc++ to the correct ABI library. This option is on by
>> default
>>   # On UNIX platforms other than Apple unless
>> 'LIBCXX_ENABLE_STATIC_ABI_LIBRARY'
>> -# is on.
>> +# is on. This option is also disabled when the ABI library is not
>> specified
>> +# or is specified to be "none".
>>   set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF)
>>   if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT
>> LIBCXX_ENABLE_STATIC_ABI_LIBRARY
>> +  AND LIBCXX_CXX_ABI
>> +  AND NOT LIBCXX_CXX_ABI STREQUAL "none"
>>
>
> I remember suggesting in a review that this be called "auto" rather than
> "none"... but now I can't find that review. Thoughts?
>
> Jon
>
>
> AND PYTHONINTERP_FOUND)
>>   set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON)
>>   endif()
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>>
> --
> Jon Roelofs
> jonat...@codesourcery.com
> CodeSourcery / Mentor Embedded
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r251062 - Disable linker scripts when the ABI library is not specified or is none.

2015-10-22 Thread Jonathan Roelofs via cfe-commits



On 10/22/15 2:59 PM, Eric Fiselier wrote:

Yeah, that review hasn't landed yet. It should be called auto, but we
need to make it actually "automatic". Currently "none" really means
don't help me, not that we will automatically figure it out for you. I
agree with your requested change, it's just a bunch of work that should
probably be done on it's own.



Sounds good.




On Thu, Oct 22, 2015 at 10:57 AM, Jonathan Roelofs
mailto:jonat...@codesourcery.com>> wrote:



On 10/22/15 2:50 PM, Eric Fiselier via cfe-commits wrote:

Author: ericwf
Date: Thu Oct 22 15:50:07 2015
New Revision: 251062

URL: http://llvm.org/viewvc/llvm-project?rev=251062&view=rev
Log:
Disable linker scripts when the ABI library is not specified or
is none.

Modified:
  libcxx/trunk/CMakeLists.txt

Modified: libcxx/trunk/CMakeLists.txt
URL:

http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=251062&r1=251061&r2=251062&view=diff

==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Thu Oct 22 15:50:07 2015
@@ -74,9 +74,12 @@ option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY
   # Generate and install a linker script inplace of libc++.so.
The linker script
   # will link libc++ to the correct ABI library. This option is
on by default
   # On UNIX platforms other than Apple unless
'LIBCXX_ENABLE_STATIC_ABI_LIBRARY'
-# is on.
+# is on. This option is also disabled when the ABI library is
not specified
+# or is specified to be "none".
   set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF)
   if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT
LIBCXX_ENABLE_STATIC_ABI_LIBRARY
+  AND LIBCXX_CXX_ABI
+  AND NOT LIBCXX_CXX_ABI STREQUAL "none"


I remember suggesting in a review that this be called "auto" rather
than "none"... but now I can't find that review. Thoughts?

Jon


 AND PYTHONINTERP_FOUND)
   set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON)
   endif()


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


--
Jon Roelofs
jonat...@codesourcery.com 
CodeSourcery / Mentor Embedded




--
Jon Roelofs
jonat...@codesourcery.com
CodeSourcery / Mentor Embedded
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r251065 - Dont required CMake 3 to install a linker script

2015-10-22 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Oct 22 16:24:01 2015
New Revision: 251065

URL: http://llvm.org/viewvc/llvm-project?rev=251065&view=rev
Log:
Dont required CMake 3 to install a linker script

Modified:
libcxx/trunk/lib/CMakeLists.txt

Modified: libcxx/trunk/lib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=251065&r1=251064&r2=251065&view=diff
==
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Thu Oct 22 16:24:01 2015
@@ -154,7 +154,6 @@ if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
   )
 endif()
 
-
 if (LIBCXX_INSTALL_LIBRARY)
   install(TARGETS cxx
 LIBRARY DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT libcxx
@@ -163,7 +162,9 @@ if (LIBCXX_INSTALL_LIBRARY)
   # NOTE: This install command must go after the cxx install command otherwise
   # it will not be executed after the library symlinks are installed.
   if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
-install(FILES "$"
+# Replace the libc++ filename with $
+# after we required CMake 3.0.
+install(FILES 
"${CMAKE_CURRENT_BINARY_DIR}/libc++${CMAKE_SHARED_LIBRARY_SUFFIX}"
   DESTINATION lib${LIBCXX_LIBDIR_SUFFIX}
   COMPONENT libcxx)
   endif()


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


Re: [libcxx] r250319 - [libcxx] Make it drastically simpler to link libc++.

2015-10-22 Thread Alexey Samsonov via cfe-commits
Seems to work now, thanks for the quick fix!

On Thu, Oct 22, 2015 at 1:57 PM, Eric Fiselier  wrote:

> Hi Alexey,
>
> Please confirm that this works for you now after r251063. Sorry for the
> breakage.
>
> /Eric
>
> On Thu, Oct 22, 2015 at 9:23 AM, Alexey Samsonov 
> wrote:
>
>> After this change I am unable to configure libcxx as external project
>> from compiler-rt with extra build flags.
>> The problem is gen_link_script.py is invoked with incorrect number of
>> arguments: LIBCXX_CXX_ABI_LIBNAME is automatically deduced to be "none",
>> and LIBCXX_CXX_ABI_LIBRARY which is passed to gen_link_script.py is then
>> empty.
>>
>> I can suppress this by using condition
>>   if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT AND LIBCXX_CXX_ABI_LIBRARY)
>> in libcxx/lib/CMakeLists.txt, but I don't think this fix is clean enough.
>> I can also pass -DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=OFF when I configure
>> libc++,
>> but probably this should be deduced automatically...
>>
>>
>> On Wed, Oct 21, 2015 at 5:44 PM, Eric Fiselier via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Thanks. I'll look to see if any other LLVM projects have bumped the
>>> CMake version to 3 yet. If so that's the direction I will head.
>>>
>>>
>>>
>>>
>>> On Oct 20, 2015 9:39 PM, "Hahnfeld, Jonas" 
>>> wrote:
>>>
 > -Original Message-
 > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On
 Behalf
 > Of Eric Fiselier via cfe-commits
 > Sent: Wednesday, October 14, 2015 9:54 PM
 > To: cfe-commits@lists.llvm.org
 > Subject: [libcxx] r250319 - [libcxx] Make it drastically simpler to
 link
 > libc++.
 >
 > Author: ericwf
 > Date: Wed Oct 14 14:54:03 2015
 > New Revision: 250319
 >
 > URL: http://llvm.org/viewvc/llvm-project?rev=250319&view=rev
 > Log:
 > [libcxx] Make it drastically simpler to link libc++.
 [...]
 >  if (LIBCXX_INSTALL_LIBRARY)
 >install(TARGETS cxx
 >  LIBRARY DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT libcxx
 >  ARCHIVE DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT libcxx
 >  )
 > +  # NOTE: This install command must go after the cxx install command
 > + otherwise  # it will not be executed after the library symlinks are
 > installed.
 > +  if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
 > +install(FILES "$"
 > +  DESTINATION lib${LIBCXX_LIBDIR_SUFFIX}
 > +  COMPONENT libcxx)
 > +  endif()
 >  endif()

 Generator expressions in install(FILES) are only allowed since CMake 3.0
 (https://cmake.org/cmake/help/v3.0/release/3.0.0.html#commands).
 The current minimum for libcxx is 2.8, so this should either be raised
 or we
 have to find another possibility of writing this install command...

 Greetings
 Jonas

>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>>
>>
>>
>> --
>> Alexey Samsonov
>> vonos...@gmail.com
>>
>
>


-- 
Alexey Samsonov
vonos...@gmail.com
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r251072 - Use newly introduced interfaces in LLVM (NFC)

2015-10-22 Thread Xinliang David Li via cfe-commits
Author: davidxl
Date: Thu Oct 22 17:25:11 2015
New Revision: 251072

URL: http://llvm.org/viewvc/llvm-project?rev=251072&view=rev
Log:
Use newly introduced interfaces in LLVM (NFC)

Replaced references to raw strings in instrumentation
and coverage code.

Modified:
cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=251072&r1=251071&r2=251072&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Thu Oct 22 17:25:11 2015
@@ -73,7 +73,7 @@ void CodeGenPGO::createFuncNameVar(llvm:
   llvm::ConstantDataArray::getString(CGM.getLLVMContext(), FuncName, 
false);
   FuncNameVar =
   new llvm::GlobalVariable(CGM.getModule(), Value->getType(), true, 
Linkage,
-   Value, "__llvm_profile_name_" + FuncName);
+   Value, llvm::getInstrProfNameVarPrefix() + 
FuncName);
 
   // Hide the symbol so that we correctly get a copy for each executable.
   if (!llvm::GlobalValue::isLocalLinkage(FuncNameVar->getLinkage()))

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=251072&r1=251071&r2=251072&view=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Thu Oct 22 17:25:11 2015
@@ -879,7 +879,7 @@ static bool isMachO(const CodeGenModule
 }
 
 static StringRef getCoverageSection(const CodeGenModule &CGM) {
-  return isMachO(CGM) ? "__DATA,__llvm_covmap" : "__llvm_covmap";
+  return llvm::getInstrProfCoverageSectionName(isMachO(CGM));
 }
 
 static void dump(llvm::raw_ostream &OS, StringRef FunctionName,
@@ -1011,7 +1011,7 @@ void CoverageMappingModuleGen::emit() {
   auto CovData = new llvm::GlobalVariable(CGM.getModule(), CovDataTy, true,
   llvm::GlobalValue::InternalLinkage,
   CovDataVal,
-  "__llvm_coverage_mapping");
+  llvm::getCoverageMappingVarName());
 
   CovData->setSection(getCoverageSection(CGM));
   CovData->setAlignment(8);


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


[PATCH] D14000: [CUDA] Allow code generation for functions with target attributes that don't match compilation mode.

2015-10-22 Thread Artem Belevich via cfe-commits
tra created this revision.
tra added reviewers: eliben, jingyue, jpienaar, echristo.
tra added a subscriber: cfe-commits.

Currently -fcuda-disable-target-call-checks option enables parsing of code that 
calls across host/device boundary.
However, we don't emit any IR for functions that don't have attributes 
appropriate for the current compilation mode, so such cross-calls always fail 
at runtime due to unresolved references.

The patch allows CodeGen to emit non-matching functions if they are needed to 
resolve references in the current module.

This feature is enabled by -fcuda-disable-target-call-checks

The patch makes it possible for device side to use host unmodified includes 
that provide unattributed functions. 
For instance, it allows use of larger subset of standard C++ library headers.


http://reviews.llvm.org/D14000

Files:
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGenCUDA/cross-call.cu
  test/CodeGenCUDA/host-device-calls-host.cu

Index: test/CodeGenCUDA/host-device-calls-host.cu
===
--- test/CodeGenCUDA/host-device-calls-host.cu
+++ test/CodeGenCUDA/host-device-calls-host.cu
@@ -1,4 +1,15 @@
-// RUN: %clang_cc1 %s -triple nvptx-unknown-unknown -fcuda-allow-host-calls-from-host-device -fcuda-is-device -Wno-cuda-compat -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple nvptx-unknown-unknown -fcuda-is-device \
+// RUN:-fcuda-allow-host-calls-from-host-device \
+// RUN:-Wno-cuda-compat -emit-llvm -o - \
+// RUN:| FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-NORMAL
+
+// Enabling target overloads and disabling target call checks allows
+// cross-calling between host/device. We expect to emit IR for used
+// host functions in this case.
+// RUN: %clang_cc1 %s -triple nvptx-unknown-unknown -fcuda-is-device \
+// RUN:-fcuda-target-overloads -fcuda-disable-target-call-checks \
+// RUN:-Wno-cuda-compat -emit-llvm -o - \
+// RUN:| FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-HDMIX
 
 #include "Inputs/cuda.h"
 
@@ -12,7 +23,8 @@
   host_function();
 }
 
-// CHECK: declare void @host_function
+// CHECK-NORMAL-LABEL: declare void @host_function
+// CHECK-HDMIX-LABEL: define void @host_function
 
 // CHECK-LABEL: define void @hd_function_b
 extern "C"
Index: test/CodeGenCUDA/cross-call.cu
===
--- /dev/null
+++ test/CodeGenCUDA/cross-call.cu
@@ -0,0 +1,48 @@
+// Check handling of code generation for calls crossing host/device boundary.
+// Calls crossing host/device boundary must prefer overload variant that
+// matches current compilation mode. Make sure that we do emit intermediary
+// functions, whether they are host or device.
+
+// RUN: %clang_cc1 -DNOCHECKS -triple x86_64-unknown-linux-gnu -emit-llvm \
+// RUN:-fcuda-disable-target-call-checks -fcuda-target-overloads -o - %s \
+// RUN: | FileCheck -check-prefix=CHECK-BOTH -check-prefix=CHECK-HOST %s
+//
+// RUN: %clang_cc1 -DNOCHECKS -triple nvptx64-nvidia-cuda -emit-llvm \
+// RUN:-fcuda-disable-target-call-checks -fcuda-target-overloads \
+// RUN:-fcuda-is-device -o - %s \
+// RUN: | FileCheck -check-prefix=CHECK-BOTH -check-prefix=CHECK-DEVICE %s
+
+#include "Inputs/cuda.h"
+
+static __device__ int cross_leaf() { return 41; };
+static __host__ int cross_leaf() { return 42; };
+
+// Here we should pick leaf function that matches compilation mode.
+static __host__ int cross_gate() { return cross_leaf(); }
+
+// two levels of host/device cross-calls to verify that we can deal
+// with cross-calls in both directions in all compilation modes.
+static __host__ int cross_hbridge() { return cross_gate(); }
+static __device__ int cross_dbridge() { return cross_gate(); }
+static __host__ int cross_hbridge2() { return cross_dbridge(); }
+static __device__ int cross_dbridge2() { return cross_hbridge(); }
+
+__host__ int cross_host() { return cross_dbridge2(); }
+__device__ int cross_device() { return cross_hbridge2(); }
+
+// Make sure we only emit globals for current compilation mode.
+// CHECK-HOST: define i32 @_Z10cross_hostv
+// CHECK-DEVICE-NOT: define i32 @_Z10cross_hostv
+// CHECK-DEVICE: define i32 @_Z12cross_devicev
+// CHECK-HOST-NOT: define i32 @_Z12cross_devicev
+
+// .. but allow non-matching ones if they are used.
+// CHECK-HOST-DAG: define internal i32 @_ZL13cross_hbridgev()
+// CHECK-HOST-DAG: define internal i32 @_ZL14cross_dbridge2v()
+// CHECK-DEVICE-DAG: define internal i32 @_ZL13cross_dbridgev()
+// CHECK-DEVICE-DAG: define internal i32 @_ZL14cross_hbridge2v()
+
+// .. and that we pick the leaf function that matches compilation mode.
+// CHECK-BOTH: define internal i32 @_ZL10cross_leafv()
+// CHECK-DEVICE: ret i32 41
+// CHECK-HOST:   ret i32 42
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ 

Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2015-10-22 Thread Nathan Wilson via cfe-commits
nwilson added inline comments.


Comment at: include/clang/AST/Decl.h:1577
@@ -1576,2 +1576,3 @@
   bool IsConstexpr : 1;
+  bool IsConcept : 1;
 

faisalv wrote:
> My inclination would have been to add this bit to FunctionTemplateDecl, 
> instead of to every FunctionDecl - since not every kind of FunctionDecl can 
> be a concept ...  My first instinct would have been to add an enum to 
> TemplateKind, and then forward isConcept() to check if we are a template and 
> if so, through it, if concept is specified?  
> 
> But I suppose that adds more complexity, and you trade space for speed - For 
> my own edification, could I ask you or Richard to comment on the cons of that 
> approach - and why the current approach is preferred? (i.e. simplicity over 
> complexity or space over time etc.)
Sorry for the slow reply. Yeah, I thought it was a little more straightforward 
having isConcept as a member function of FunctionDecl (and the bit). It also 
seemed that we'd be okay in terms of size since 17 bits are already being used 
here and adding one more wouldn't go over a byte boundary. Maybe Richard has 
other thoughts though?


http://reviews.llvm.org/D13357



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


RE: [libcxx] r251065 - Dont required CMake 3 to install a linker script

2015-10-22 Thread Hahnfeld, Jonas via cfe-commits
Hi,

thanks for the attempt to fix this, but this isn't working for in-tree builds 
of libcxx:
CMake Error at projects/libcxx/lib/cmake_install.cmake:56 (FILE):
  file INSTALL cannot find
  "<<>>/projects/libcxx/lib/libc++.so"

It is located at <<>>/lib/libc++.so. CMake version is 2.8.12.2 which 
should be the minimum required version when building all LLVM projects.

Cheers,
Jonas

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
> Of Eric Fiselier via cfe-commits
> Sent: Thursday, October 22, 2015 11:24 PM
> To: cfe-commits@lists.llvm.org
> Subject: [libcxx] r251065 - Dont required CMake 3 to install a linker script
>
> Author: ericwf
> Date: Thu Oct 22 16:24:01 2015
> New Revision: 251065
>
> URL: http://llvm.org/viewvc/llvm-project?rev=251065&view=rev
> Log:
> Dont required CMake 3 to install a linker script
>
> Modified:
> libcxx/trunk/lib/CMakeLists.txt
>
> Modified: libcxx/trunk/lib/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-
> project/libcxx/trunk/lib/CMakeLists.txt?rev=251065&r1=251064&r2=251065&
> view=diff
> ==
> 
> --- libcxx/trunk/lib/CMakeLists.txt (original)
> +++ libcxx/trunk/lib/CMakeLists.txt Thu Oct 22 16:24:01 2015
> @@ -154,7 +154,6 @@ if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
>)
>  endif()
>
> -
>  if (LIBCXX_INSTALL_LIBRARY)
>install(TARGETS cxx
>  LIBRARY DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT libcxx
> @@ -163,7 +162,9 @@ if (LIBCXX_INSTALL_LIBRARY)
># NOTE: This install command must go after the cxx install command
> otherwise
># it will not be executed after the library symlinks are installed.
>if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
> -install(FILES "$"
> +# Replace the libc++ filename with $
> +# after we required CMake 3.0.
> +install(FILES
> "${CMAKE_CURRENT_BINARY_DIR}/libc++${CMAKE_SHARED_LIBRARY_SUFF
> IX}"
>DESTINATION lib${LIBCXX_LIBDIR_SUFFIX}
>COMPONENT libcxx)
>endif()
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


smime.p7s
Description: S/MIME cryptographic signature
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11085: compiler-rt: add support for mingw-w64 in builtins

2015-10-22 Thread Vadim Chugunov via cfe-commits
vadimcn added a subscriber: vadimcn.
vadimcn added a comment.

Hi!
So apparently LLVM lowers `alloca`'s of large buffers into a call to `_alloca` 
(makes sense I guess - if the buffer is larger than a page).
Why wasn't it added along with `_chkstk`?   Is `_alloca` available from some 
other mingw library?


Repository:
  rL LLVM

http://reviews.llvm.org/D11085



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