r249982 - Keep the IfStmt node even if the condition is invalid

2015-10-11 Thread Olivier Goffart via cfe-commits
Author: ogoffart
Date: Sun Oct 11 12:27:29 2015
New Revision: 249982

URL: http://llvm.org/viewvc/llvm-project?rev=249982=rev
Log:
Keep the IfStmt node even if the condition is invalid

This is important to keep the information in IDE or other tools
even if the code contains a few errors

Modified:
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/Misc/ast-dump-invalid.cpp

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=249982=249981=249982=diff
==
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Sun Oct 11 12:27:29 2015
@@ -483,13 +483,6 @@ StmtResult
 Sema::ActOnIfStmt(SourceLocation IfLoc, FullExprArg CondVal, Decl *CondVar,
   Stmt *thenStmt, SourceLocation ElseLoc,
   Stmt *elseStmt) {
-  // If the condition was invalid, discard the if statement.  We could recover
-  // better by replacing it with a valid expr, but don't do that yet.
-  if (!CondVal.get() && !CondVar) {
-getCurFunction()->setHasDroppedStmt();
-return StmtError();
-  }
-
   ExprResult CondResult(CondVal.release());
 
   VarDecl *ConditionVar = nullptr;
@@ -497,22 +490,23 @@ Sema::ActOnIfStmt(SourceLocation IfLoc,
 ConditionVar = cast(CondVar);
 CondResult = CheckConditionVariable(ConditionVar, IfLoc, true);
 CondResult = ActOnFinishFullExpr(CondResult.get(), IfLoc);
-if (CondResult.isInvalid())
-  return StmtError();
   }
   Expr *ConditionExpr = CondResult.getAs();
-  if (!ConditionExpr)
-return StmtError();
+  if (ConditionExpr) {
+DiagnoseUnusedExprResult(thenStmt);
 
-  DiagnoseUnusedExprResult(thenStmt);
-
-  if (!elseStmt) {
-DiagnoseEmptyStmtBody(ConditionExpr->getLocEnd(), thenStmt,
-  diag::warn_empty_if_body);
+if (!elseStmt) {
+  DiagnoseEmptyStmtBody(ConditionExpr->getLocEnd(), thenStmt,
+diag::warn_empty_if_body);
+}
+
+DiagnoseUnusedExprResult(elseStmt);
+  } else {
+// Create a dummy Expr for the condition for error recovery
+ConditionExpr = new (Context) OpaqueValueExpr(SourceLocation(),
+  Context.BoolTy, VK_RValue);
   }
 
-  DiagnoseUnusedExprResult(elseStmt);
-
   return new (Context) IfStmt(Context, IfLoc, ConditionVar, ConditionExpr,
   thenStmt, ElseLoc, elseStmt);
 }

Modified: cfe/trunk/test/Misc/ast-dump-invalid.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-dump-invalid.cpp?rev=249982=249981=249982=diff
==
--- cfe/trunk/test/Misc/ast-dump-invalid.cpp (original)
+++ cfe/trunk/test/Misc/ast-dump-invalid.cpp Sun Oct 11 12:27:29 2015
@@ -18,3 +18,26 @@ void f(T i, T j) {
 // CHECK-NEXT: `-CXXUnresolvedConstructExpr {{.*}}  'T'
 // CHECK-NEXT:   |-DeclRefExpr {{.*}}  'T' lvalue ParmVar 
{{.*}} 'i' 'T'
 // CHECK-NEXT:   `-DeclRefExpr {{.*}}  'T' lvalue ParmVar 
{{.*}} 'j' 'T'
+
+
+namespace TestInvalidIf {
+int g(int i) {
+  if (invalid_condition)
+return 4;
+  else
+return i;
+}
+}
+// CHECK: NamespaceDecl {{.*}} <{{.*}}> {{.*}} TestInvalidIf
+// CHECK-NEXT: `-FunctionDecl
+// CHECK-NEXT:   |-ParmVarDecl
+// CHECK-NEXT:   `-CompoundStmt
+// CHECK-NEXT: `-IfStmt {{.*}} 
+// CHECK-NEXT:   |-<<>>
+// CHECK-NEXT:   |-OpaqueValueExpr {{.*}} <> '_Bool'
+// CHECK-NEXT:   |-ReturnStmt {{.*}} 
+// CHECK-NEXT:   | `-IntegerLiteral {{.*}}  'int' 4
+// CHECK-NEXT:   `-ReturnStmt {{.*}} 
+// CHECK-NEXT: `-ImplicitCastExpr {{.*}}  'int' 

+// CHECK-NEXT:   `-DeclRefExpr {{.*}}  'int' lvalue ParmVar 
{{.*}} 'i' 'int'
+


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


Re: [PATCH] D13344: Keep the IfStmt node even if the condition is invalid

2015-10-11 Thread Olivier Goffart via cfe-commits
ogoffart abandoned this revision.
ogoffart marked an inline comment as done.
ogoffart added a comment.

commited as r249982. (I forgot to add the link to reviews.llvm.org in the 
commit message. I'll do it next time)


http://reviews.llvm.org/D13344



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


r249995 - [Sema] Allow C conversions in C overload logic

2015-10-11 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Sun Oct 11 15:13:20 2015
New Revision: 249995

URL: http://llvm.org/viewvc/llvm-project?rev=249995=rev
Log:
[Sema] Allow C conversions in C overload logic

C allows for some implicit conversions that C++ does not, e.g. void* ->
char*. This patch teaches clang that these conversions are okay when
dealing with overloads in C.

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

Modified:
cfe/trunk/include/clang/Sema/Overload.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/Sema/overloadable.c

Modified: cfe/trunk/include/clang/Sema/Overload.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=249995=249994=249995=diff
==
--- cfe/trunk/include/clang/Sema/Overload.h (original)
+++ cfe/trunk/include/clang/Sema/Overload.h Sun Oct 11 15:13:20 2015
@@ -83,7 +83,8 @@ namespace clang {
 ICK_TransparentUnionConversion, ///< Transparent Union Conversions
 ICK_Writeback_Conversion,  ///< Objective-C ARC writeback conversion
 ICK_Zero_Event_Conversion, ///< Zero constant to event (OpenCL1.2 6.12.10)
-ICK_Num_Conversion_Kinds   ///< The number of conversion kinds
+ICK_C_Only_Conversion, ///< Conversions allowed in C, but not C++
+ICK_Num_Conversion_Kinds,  ///< The number of conversion kinds
   };
 
   /// ImplicitConversionRank - The rank of an implicit conversion
@@ -95,7 +96,9 @@ namespace clang {
 ICR_Promotion,   ///< Promotion
 ICR_Conversion,  ///< Conversion
 ICR_Complex_Real_Conversion, ///< Complex <-> Real conversion
-ICR_Writeback_Conversion ///< ObjC ARC writeback conversion
+ICR_Writeback_Conversion,///< ObjC ARC writeback conversion
+ICR_C_Conversion ///< Conversion only allowed in the C 
standard.
+ ///  (e.g. void* to char*)
   };
 
   ImplicitConversionRank GetConversionRank(ImplicitConversionKind Kind);

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=249995=249994=249995=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Sun Oct 11 15:13:20 2015
@@ -8292,19 +8292,23 @@ public:
QualType LHSType,
QualType RHSType);
 
-  /// Check assignment constraints and prepare for a conversion of the
-  /// RHS to the LHS type.
+  /// Check assignment constraints and optionally prepare for a conversion of
+  /// the RHS to the LHS type. The conversion is prepared for if ConvertRHS
+  /// is true.
   AssignConvertType CheckAssignmentConstraints(QualType LHSType,
ExprResult ,
-   CastKind );
+   CastKind ,
+   bool ConvertRHS = true);
 
   // CheckSingleAssignmentConstraints - Currently used by
   // CheckAssignmentOperands, and ActOnReturnStmt. Prior to type checking,
-  // this routine performs the default function/array converions.
+  // this routine performs the default function/array converions, if ConvertRHS
+  // is true.
   AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType,
  ExprResult ,
  bool Diagnose = true,
- bool DiagnoseCFAudited = 
false);
+ bool DiagnoseCFAudited = 
false,
+ bool ConvertRHS = true);
 
   // \brief If the lhs type is a transparent union, check whether we
   // can initialize the transparent union with the given expression.

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=249995=249994=249995=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sun Oct 11 15:13:20 2015
@@ -5376,13 +5376,13 @@ CastKind Sema::PrepareScalarCast(ExprRes
   return CK_IntegralToFloating;
 case Type::STK_IntegralComplex:
   Src = ImpCastExprToType(Src.get(),
-  DestTy->castAs()->getElementType(),
-  CK_IntegralCast);
+  DestTy->castAs()->getElementType(),
+  CK_IntegralCast);
   return CK_IntegralRealToComplex;
 case Type::STK_FloatingComplex:
   Src = ImpCastExprToType(Src.get(),
-  

Re: [PATCH] D13604: Fix to allow C conversions on arguments passed to functions with __attribute__((overloadable)) in C

2015-10-11 Thread George Burgess IV via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL249995: [Sema] Allow C conversions in C overload logic 
(authored by gbiv).

Changed prior to commit:
  http://reviews.llvm.org/D13604?vs=36986=37062#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13604

Files:
  cfe/trunk/include/clang/Sema/Overload.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/test/Sema/overloadable.c

Index: cfe/trunk/include/clang/Sema/Overload.h
===
--- cfe/trunk/include/clang/Sema/Overload.h
+++ cfe/trunk/include/clang/Sema/Overload.h
@@ -83,7 +83,8 @@
 ICK_TransparentUnionConversion, ///< Transparent Union Conversions
 ICK_Writeback_Conversion,  ///< Objective-C ARC writeback conversion
 ICK_Zero_Event_Conversion, ///< Zero constant to event (OpenCL1.2 6.12.10)
-ICK_Num_Conversion_Kinds   ///< The number of conversion kinds
+ICK_C_Only_Conversion, ///< Conversions allowed in C, but not C++
+ICK_Num_Conversion_Kinds,  ///< The number of conversion kinds
   };
 
   /// ImplicitConversionRank - The rank of an implicit conversion
@@ -95,7 +96,9 @@
 ICR_Promotion,   ///< Promotion
 ICR_Conversion,  ///< Conversion
 ICR_Complex_Real_Conversion, ///< Complex <-> Real conversion
-ICR_Writeback_Conversion ///< ObjC ARC writeback conversion
+ICR_Writeback_Conversion,///< ObjC ARC writeback conversion
+ICR_C_Conversion ///< Conversion only allowed in the C standard.
+ ///  (e.g. void* to char*)
   };
 
   ImplicitConversionRank GetConversionRank(ImplicitConversionKind Kind);
Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -8292,19 +8292,23 @@
QualType LHSType,
QualType RHSType);
 
-  /// Check assignment constraints and prepare for a conversion of the
-  /// RHS to the LHS type.
+  /// Check assignment constraints and optionally prepare for a conversion of
+  /// the RHS to the LHS type. The conversion is prepared for if ConvertRHS
+  /// is true.
   AssignConvertType CheckAssignmentConstraints(QualType LHSType,
ExprResult ,
-   CastKind );
+   CastKind ,
+   bool ConvertRHS = true);
 
   // CheckSingleAssignmentConstraints - Currently used by
   // CheckAssignmentOperands, and ActOnReturnStmt. Prior to type checking,
-  // this routine performs the default function/array converions.
+  // this routine performs the default function/array converions, if ConvertRHS
+  // is true.
   AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType,
  ExprResult ,
  bool Diagnose = true,
- bool DiagnoseCFAudited = false);
+ bool DiagnoseCFAudited = false,
+ bool ConvertRHS = true);
 
   // \brief If the lhs type is a transparent union, check whether we
   // can initialize the transparent union with the given expression.
Index: cfe/trunk/test/Sema/overloadable.c
===
--- cfe/trunk/test/Sema/overloadable.c
+++ cfe/trunk/test/Sema/overloadable.c
@@ -85,3 +85,17 @@
 void after_local_1(int) __attribute__((overloadable)); // expected-error {{conflicting types}}
 void after_local_2(int); // expected-error {{must have the 'overloadable' attribute}}
 void after_local_3(int) __attribute__((overloadable));
+
+// Make sure we allow C-specific conversions in C.
+void conversions() {
+  void foo(char *c) __attribute__((overloadable));
+  void foo(char *c) __attribute__((overloadable, enable_if(c, "nope.jpg")));
+
+  void *ptr;
+  foo(ptr);
+
+  void multi_type(unsigned char *c) __attribute__((overloadable));
+  void multi_type(signed char *c) __attribute__((overloadable));
+  unsigned char *c;
+  multi_type(c);
+}
Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -5376,13 +5376,13 @@
   return CK_IntegralToFloating;
 case Type::STK_IntegralComplex:
   Src = ImpCastExprToType(Src.get(),
-  DestTy->castAs()->getElementType(),
-  CK_IntegralCast);
+  DestTy->castAs()->getElementType(),
+   

Re: [PATCH] D13639: Add decayedType and hasDecayedType AST matchers

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

Add test


http://reviews.llvm.org/D13639

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -4109,6 +4109,11 @@
   EXPECT_TRUE(matches("const int a = 0;", qualType(isInteger(;
 }
 
+TEST(TypeMatching, DecayedType) {
+  EXPECT_TRUE(matches("void f(int i[]);", 
valueDecl(hasType(decayedType(hasDecayedType(pointerType()));
+  EXPECT_TRUE(notMatches("int i[7];", decayedType()));
+}
+
 TEST(TypeMatching, MatchesComplexTypes) {
   EXPECT_TRUE(matches("_Complex float f;", complexType()));
   EXPECT_TRUE(matches(
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -152,6 +152,7 @@
   REGISTER_MATCHER(cxxThrowExpr);
   REGISTER_MATCHER(cxxTryStmt);
   REGISTER_MATCHER(cxxUnresolvedConstructExpr);
+  REGISTER_MATCHER(decayedType);
   REGISTER_MATCHER(decl);
   REGISTER_MATCHER(declaratorDecl);
   REGISTER_MATCHER(declCountIs);
@@ -199,6 +200,7 @@
   REGISTER_MATCHER(hasCaseConstant);
   REGISTER_MATCHER(hasCondition);
   REGISTER_MATCHER(hasConditionVariableStatement);
+  REGISTER_MATCHER(hasDecayedType);
   REGISTER_MATCHER(hasDeclaration);
   REGISTER_MATCHER(hasDeclContext);
   REGISTER_MATCHER(hasDeducedType);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -4123,6 +4123,24 @@
 /// \endcode
 AST_TYPE_MATCHER(InjectedClassNameType, injectedClassNameType);
 
+/// \brief Matches decayed type
+/// Example matches i[] in declaration of f.
+/// (matcher = 
valueDecl(hasType(decayedType(hasDecayedType(pointerType())
+/// Example matches i[1].
+/// (matcher = expr(hasType(decayedType(hasDecayedType(pointerType())
+/// \code
+///   void f(int i[]) {
+/// i[1] = 0;
+///   }
+/// \endcode
+AST_TYPE_MATCHER(DecayedType, decayedType);
+
+/// \brief Matches the decayed type, whos decayed type matches \c InnerMatcher
+AST_MATCHER_P(DecayedType, hasDecayedType, internal::Matcher,
+  InnerType) {
+  return InnerType.matches(Node.getDecayedType(), Finder, Builder);
+}
+
 /// \brief Matches declarations whose declaration context, interpreted as a
 /// Decl, matches \c InnerMatcher.
 ///


Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -4109,6 +4109,11 @@
   EXPECT_TRUE(matches("const int a = 0;", qualType(isInteger(;
 }
 
+TEST(TypeMatching, DecayedType) {
+  EXPECT_TRUE(matches("void f(int i[]);", valueDecl(hasType(decayedType(hasDecayedType(pointerType()));
+  EXPECT_TRUE(notMatches("int i[7];", decayedType()));
+}
+
 TEST(TypeMatching, MatchesComplexTypes) {
   EXPECT_TRUE(matches("_Complex float f;", complexType()));
   EXPECT_TRUE(matches(
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -152,6 +152,7 @@
   REGISTER_MATCHER(cxxThrowExpr);
   REGISTER_MATCHER(cxxTryStmt);
   REGISTER_MATCHER(cxxUnresolvedConstructExpr);
+  REGISTER_MATCHER(decayedType);
   REGISTER_MATCHER(decl);
   REGISTER_MATCHER(declaratorDecl);
   REGISTER_MATCHER(declCountIs);
@@ -199,6 +200,7 @@
   REGISTER_MATCHER(hasCaseConstant);
   REGISTER_MATCHER(hasCondition);
   REGISTER_MATCHER(hasConditionVariableStatement);
+  REGISTER_MATCHER(hasDecayedType);
   REGISTER_MATCHER(hasDeclaration);
   REGISTER_MATCHER(hasDeclContext);
   REGISTER_MATCHER(hasDeducedType);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -4123,6 +4123,24 @@
 /// \endcode
 AST_TYPE_MATCHER(InjectedClassNameType, injectedClassNameType);
 
+/// \brief Matches decayed type
+/// Example matches i[] in declaration of f.
+/// (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType())
+/// Example matches i[1].
+/// (matcher = expr(hasType(decayedType(hasDecayedType(pointerType())
+/// \code
+///   void f(int i[]) {
+/// i[1] = 0;
+///   }
+/// \endcode
+AST_TYPE_MATCHER(DecayedType, decayedType);
+
+/// \brief Matches the decayed type, whos decayed type matches \c InnerMatcher
+AST_MATCHER_P(DecayedType, hasDecayedType, internal::Matcher,
+  InnerType) {
+  return 

[clang-tools-extra] r250002 - Test commit

2015-10-11 Thread Matthias Gehre via cfe-commits
Author: mgehre
Date: Sun Oct 11 17:55:29 2015
New Revision: 250002

URL: http://llvm.org/viewvc/llvm-project?rev=250002=rev
Log:
Test commit

Modified:

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

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp?rev=250002=250001=250002=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 Sun Oct 11 17:55:29 2015
@@ -17,6 +17,7 @@ namespace clang {
 namespace tidy {
 namespace cppcoreguidelines {
 
+/// A module containing checks of the C++ Core Guidelines
 class CppCoreGuidelinesModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories ) override {


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


[PATCH] D13639: Add decayedType and hasDecayedType AST matchers

2015-10-11 Thread Matthias Gehre via cfe-commits
mgehre created this revision.
mgehre added a reviewer: klimek.
mgehre added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Add decayedType and hasDecayedType AST matchers

http://reviews.llvm.org/D13639

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp

Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -152,6 +152,7 @@
   REGISTER_MATCHER(cxxThrowExpr);
   REGISTER_MATCHER(cxxTryStmt);
   REGISTER_MATCHER(cxxUnresolvedConstructExpr);
+  REGISTER_MATCHER(decayedType);
   REGISTER_MATCHER(decl);
   REGISTER_MATCHER(declaratorDecl);
   REGISTER_MATCHER(declCountIs);
@@ -199,6 +200,7 @@
   REGISTER_MATCHER(hasCaseConstant);
   REGISTER_MATCHER(hasCondition);
   REGISTER_MATCHER(hasConditionVariableStatement);
+  REGISTER_MATCHER(hasDecayedType);
   REGISTER_MATCHER(hasDeclaration);
   REGISTER_MATCHER(hasDeclContext);
   REGISTER_MATCHER(hasDeducedType);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -4123,6 +4123,24 @@
 /// \endcode
 AST_TYPE_MATCHER(InjectedClassNameType, injectedClassNameType);
 
+/// \brief Matches decayed type
+/// Example matches i[] in declaration of f.
+/// (matcher = 
valueDecl(hasType(decayedType(hasDecayedType(pointerType())
+/// Example matches i[1].
+/// (matcher = expr(hasType(decayedType(hasDecayedType(pointerType())
+/// \code
+///   void f(int i[]) {
+/// i[1] = 0;
+///   }
+/// \endcode
+AST_TYPE_MATCHER(DecayedType, decayedType);
+
+/// \brief Matches the decayed type, whos decayed type matches \c InnerMatcher
+AST_MATCHER_P(DecayedType, hasDecayedType, internal::Matcher,
+  InnerType) {
+  return InnerType.matches(Node.getDecayedType(), Finder, Builder);
+}
+
 /// \brief Matches declarations whose declaration context, interpreted as a
 /// Decl, matches \c InnerMatcher.
 ///


Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -152,6 +152,7 @@
   REGISTER_MATCHER(cxxThrowExpr);
   REGISTER_MATCHER(cxxTryStmt);
   REGISTER_MATCHER(cxxUnresolvedConstructExpr);
+  REGISTER_MATCHER(decayedType);
   REGISTER_MATCHER(decl);
   REGISTER_MATCHER(declaratorDecl);
   REGISTER_MATCHER(declCountIs);
@@ -199,6 +200,7 @@
   REGISTER_MATCHER(hasCaseConstant);
   REGISTER_MATCHER(hasCondition);
   REGISTER_MATCHER(hasConditionVariableStatement);
+  REGISTER_MATCHER(hasDecayedType);
   REGISTER_MATCHER(hasDeclaration);
   REGISTER_MATCHER(hasDeclContext);
   REGISTER_MATCHER(hasDeducedType);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -4123,6 +4123,24 @@
 /// \endcode
 AST_TYPE_MATCHER(InjectedClassNameType, injectedClassNameType);
 
+/// \brief Matches decayed type
+/// Example matches i[] in declaration of f.
+/// (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType())
+/// Example matches i[1].
+/// (matcher = expr(hasType(decayedType(hasDecayedType(pointerType())
+/// \code
+///   void f(int i[]) {
+/// i[1] = 0;
+///   }
+/// \endcode
+AST_TYPE_MATCHER(DecayedType, decayedType);
+
+/// \brief Matches the decayed type, whos decayed type matches \c InnerMatcher
+AST_MATCHER_P(DecayedType, hasDecayedType, internal::Matcher,
+  InnerType) {
+  return InnerType.matches(Node.getDecayedType(), Finder, Builder);
+}
+
 /// \brief Matches declarations whose declaration context, interpreted as a
 /// Decl, matches \c InnerMatcher.
 ///
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r249997 - Fix warning caused by r249995

2015-10-11 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Sun Oct 11 15:37:14 2015
New Revision: 249997

URL: http://llvm.org/viewvc/llvm-project?rev=249997=rev
Log:
Fix warning caused by r249995


Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=249997=249996=249997=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Sun Oct 11 15:37:14 2015
@@ -3445,6 +3445,7 @@ Sema::PerformImplicitConversion(Expr *Fr
   case ICK_Function_To_Pointer:
   case ICK_Qualification:
   case ICK_Num_Conversion_Kinds:
+  case ICK_C_Only_Conversion:
 llvm_unreachable("Improper second standard conversion");
   }
 


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


[PATCH] D13640: [clang-tidy] Add new check cppcoreguidelines-pro-bounds-array-to-pointer-decay

2015-10-11 Thread Matthias Gehre via cfe-commits
mgehre created this revision.
mgehre added reviewers: alexfh, sbenza, bkramer, aaron.ballman.
mgehre added a subscriber: cfe-commits.

This check flags all array to pointer decays.

Pointers should not be used as arrays. array_view is a bounds-checked,
safe alternative to using pointers to access arrays.

This rule is part of the "Bounds safety" profile of the C++ Core
Guidelines, see
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-bounds3-no-array-to-pointer-decay

http://reviews.llvm.org/D13640

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
  clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h
  docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-array-to-pointer-decay.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
@@ -0,0 +1,26 @@
+// RUN: %python %S/check_clang_tidy.py %s cppcoreguidelines-pro-bounds-array-to-pointer-decay %t
+
+void pointerfun(int* p);
+void arrayfun(int p[]);
+
+void f()
+{
+  int a[5];
+  pointerfun(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: do not (implicitly) convert an array to a pointer [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
+  pointerfun((int*)a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: do not (implicitly) convert an array to a pointer
+  arrayfun(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: do not (implicitly) convert an array to a pointer
+
+  int i = a[0]; // OK
+  pointerfun([0]); // OK
+
+  for(auto e : a ) // OK, iteration internally decays array to pointer
+;
+}
+
+const char* g()
+{
+return "clang"; // OK, decay string literal to pointer
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -4,6 +4,7 @@
 .. toctree::
cert-setlongjmp
cert-variadic-function-def
+   cppcoreguidelines-pro-bounds-array-to-pointer-decay
cppcoreguidelines-pro-type-const-cast
cppcoreguidelines-pro-type-reinterpret-cast
google-build-explicit-make-pair
Index: docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-array-to-pointer-decay.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-array-to-pointer-decay.rst
@@ -0,0 +1,9 @@
+cppcoreguidelines-pro-bounds-array-to-pointer-decay
+===
+
+This check flags all array to pointer decays.
+
+Pointers should not be used as arrays. array_view is a bounds-checked, safe alternative to using pointers to access arrays.
+
+This rule is part of the "Bounds safety" profile of the C++ Core Guidelines, see
+https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-bounds3-no-array-to-pointer-decay
Index: clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h
===
--- /dev/null
+++ clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h
@@ -0,0 +1,34 @@
+//===--- ProBoundsArrayToPointerDecayCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_BOUNDS_ARRAY_TO_POINTER_DECAY_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_BOUNDS_ARRAY_TO_POINTER_DECAY_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+
+/// This check flags all array to pointer decays
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-pro-bounds-array-to-pointer-decay.html
+class ProBoundsArrayToPointerDecayCheck : public ClangTidyCheck {
+public:
+  ProBoundsArrayToPointerDecayCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_BOUNDS_ARRAY_TO_POINTER_DECAY_H
+
Index: clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
===
--- /dev/null
+++ 

[PATCH] D13641: clang-format: [JS] handle character classes in regexes.

2015-10-11 Thread Martin Probst via cfe-commits
mprobst created this revision.
mprobst added a reviewer: djasper.
mprobst added subscribers: cfe-commits, klimek.

Slashes in regular expressions do not need to be escaped and do not terminate
the regular expression even without a preceding backslash.

http://reviews.llvm.org/D13641

Files:
  lib/Format/Format.cpp
  unittests/Format/FormatTestJS.cpp

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -617,9 +617,15 @@
   verifyFormat("var regex = /x|y/;");
   verifyFormat("var regex = /a{2}/;");
   verifyFormat("var regex = /a{1,3}/;");
+
   verifyFormat("var regex = /[abc]/;");
   verifyFormat("var regex = /[^abc]/;");
   verifyFormat("var regex = /[\\b]/;");
+  verifyFormat("var regex = /[/]/;");
+  verifyFormat("var regex = /[\\/]/;");
+  verifyFormat("var regex = /\\[/;");
+  verifyFormat("var regex = /[/]/;");
+
   verifyFormat("var regex = /\\b/;");
   verifyFormat("var regex = /\\B/;");
   verifyFormat("var regex = /\\d/;");
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -876,12 +876,23 @@
   return false;
 
 unsigned TokenCount = 0;
+auto InCharacterClass = false;
 for (auto I = Tokens.rbegin() + 1, E = Tokens.rend(); I != E; ++I) {
   ++TokenCount;
   auto Prev = I + 1;
   while (Prev != E && Prev[0]->is(tok::comment))
 ++Prev;
-  if (I[0]->isOneOf(tok::slash, tok::slashequal) &&
+  // Slashes in character classes (delimited by [ and ]) do not need
+  // escaping. Escaping of the squares themselves is already handled by
+  // \c tryMergeEscapeSequence(), a plain tok::r_square must be 
non-escaped.
+  if (I[0]->is(tok::r_square))
+InCharacterClass = true;
+  if (I[0]->is(tok::l_square)) {
+if (!InCharacterClass)
+  return false;
+InCharacterClass = false;
+  }
+  if (!InCharacterClass && I[0]->isOneOf(tok::slash, tok::slashequal) &&
   (Prev == E ||
((Prev[0]->isOneOf(tok::l_paren, tok::semi, tok::l_brace,
   tok::r_brace, tok::exclaim, tok::l_square,


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -617,9 +617,15 @@
   verifyFormat("var regex = /x|y/;");
   verifyFormat("var regex = /a{2}/;");
   verifyFormat("var regex = /a{1,3}/;");
+
   verifyFormat("var regex = /[abc]/;");
   verifyFormat("var regex = /[^abc]/;");
   verifyFormat("var regex = /[\\b]/;");
+  verifyFormat("var regex = /[/]/;");
+  verifyFormat("var regex = /[\\/]/;");
+  verifyFormat("var regex = /\\[/;");
+  verifyFormat("var regex = /[/]/;");
+
   verifyFormat("var regex = /\\b/;");
   verifyFormat("var regex = /\\B/;");
   verifyFormat("var regex = /\\d/;");
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -876,12 +876,23 @@
   return false;
 
 unsigned TokenCount = 0;
+auto InCharacterClass = false;
 for (auto I = Tokens.rbegin() + 1, E = Tokens.rend(); I != E; ++I) {
   ++TokenCount;
   auto Prev = I + 1;
   while (Prev != E && Prev[0]->is(tok::comment))
 ++Prev;
-  if (I[0]->isOneOf(tok::slash, tok::slashequal) &&
+  // Slashes in character classes (delimited by [ and ]) do not need
+  // escaping. Escaping of the squares themselves is already handled by
+  // \c tryMergeEscapeSequence(), a plain tok::r_square must be non-escaped.
+  if (I[0]->is(tok::r_square))
+InCharacterClass = true;
+  if (I[0]->is(tok::l_square)) {
+if (!InCharacterClass)
+  return false;
+InCharacterClass = false;
+  }
+  if (!InCharacterClass && I[0]->isOneOf(tok::slash, tok::slashequal) &&
   (Prev == E ||
((Prev[0]->isOneOf(tok::l_paren, tok::semi, tok::l_brace,
   tok::r_brace, tok::exclaim, tok::l_square,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13607: [Fix] Make it an error to take the address of (most) enable_if functions.

2015-10-11 Thread George Burgess IV via cfe-commits
george.burgess.iv added inline comments.


Comment at: lib/Sema/SemaInit.cpp:4978-4990
@@ -4977,1 +4977,15 @@
 
+// As an extension, C can have overloaded functions. We need to add the
+// address resolution step.
+if (Initializer->getType() == Context.OverloadTy) {
+  bool MultipleCandidates;
+  DeclAccessPair DAP;
+  if (FunctionDecl *FD = S.ResolveAddressOfOverloadedFunction(
+  Initializer, DestType, false, DAP, )) {
+AddAddressOverloadResolutionStep(FD, DAP, MultipleCandidates);
+  } else {
+SetFailed(InitializationSequence::FK_AddressOfOverloadFailed);
+return;
+  }
+}
+

rsmith wrote:
> It would seem better to handle this in the assignment rules rather than 
> duplicating it between here and the binary operator case.
I tried that initially, and it failed. Turns out the error in my initial 
attempt was just me being dumb. :)

Thanks for catching that.


http://reviews.llvm.org/D13607



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


Re: [PATCH] D11740: ABI versioning macros for libc++

2015-10-11 Thread Eric Fiselier via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

LGTM but this is still blocked by http://reviews.llvm.org/D13407. Ill let you 
know once that has landed.



Comment at: include/__config:251
@@ +250,3 @@
+ !defined(__arm__)) || 
\
+defined(_LIBCPP_ALTERNATE_STRING_LAYOUT)
+#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT

Is this the last remaining reference to `_LIBCPP_ALTERNATIVE_STRING_LAYOUT`?
If so please leave a note about how this is the old name and is used here to be 
backward compatible.


Comment at: include/__config:252
@@ -246,1 +251,3 @@
+defined(_LIBCPP_ALTERNATE_STRING_LAYOUT)
+#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
 #endif

I think he's demonstrating the patches functionality and intended usage by 
converting an existing option. Future ABI options should probably start with 
the macro prefix '_LIBCPP_ABI' anyway. 


Repository:
  rL LLVM

http://reviews.llvm.org/D11740



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


Re: [PATCH] D12512: [libcxxabi] Manually align pointers in __cxa_allocate_exception - Fixes PR24604

2015-10-11 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Whats preventing this from landing? @joerg @danalbert Do we want to use 
"posix_memalign" on Android or not?


http://reviews.llvm.org/D12512



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


[libcxx] r250003 - [Darwin] Need to add -isysroot on OS X otherwise the tests will fail if you don't have the command line tools package installed.

2015-10-11 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Sun Oct 11 19:49:56 2015
New Revision: 250003

URL: http://llvm.org/viewvc/llvm-project?rev=250003=rev
Log:
[Darwin] Need to add -isysroot on OS X otherwise the tests will fail if you 
don't have the command line tools package installed.

This mirrors how other LLVM suites are configured for running on OS X.

Modified:
libcxx/trunk/test/libcxx/test/config.py

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=250003=250002=250003=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Sun Oct 11 19:49:56 2015
@@ -6,6 +6,7 @@ import pkgutil
 import re
 import shlex
 import sys
+import subprocess
 
 import lit.Test  # pylint: disable=import-error,no-name-in-module
 import lit.util  # pylint: disable=import-error,no-name-in-module
@@ -42,6 +43,24 @@ def loadSiteConfig(lit_config, config, p
 ld_fn(config, site_cfg)
 lit_config.load_config = ld_fn
 
+def getSysrootFlagsOnDarwin(config, lit_config):
+# On Darwin, support relocatable SDKs by providing Clang with a
+# default system root path.
+if 'darwin' in config.target_triple:
+try:
+cmd = subprocess.Popen(['xcrun', '--show-sdk-path'],
+   stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
+out, err = cmd.communicate()
+out = out.strip()
+res = cmd.wait()
+except OSError:
+res = -1
+if res == 0 and out:
+sdk_path = out
+lit_config.note('using SDKROOT: %r' % sdk_path)
+return ["-isysroot", sdk_path]
+return []
+
 
 class Configuration(object):
 # pylint: disable=redefined-outer-name
@@ -339,6 +358,8 @@ class Configuration(object):
 # Configure extra flags
 compile_flags_str = self.get_lit_conf('compile_flags', '')
 self.cxx.compile_flags += shlex.split(compile_flags_str)
+sysroot_flags = getSysrootFlagsOnDarwin(self.config, self.lit_config)
+self.cxx.compile_flags.extend(sysroot_flags)
 
 def configure_default_compile_flags(self):
 # Try and get the std version from the command line. Fall back to


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


Re: [libcxx] r250003 - [Darwin] Need to add -isysroot on OS X otherwise the tests will fail if you don't have the command line tools package installed.

2015-10-11 Thread Eric Fiselier via cfe-commits
Do we need to do with while building libc++ as well? Also please reuse
lit.util.capture or lit.util.executeCommand instead of subprocess.

/Eric

On Sun, Oct 11, 2015 at 6:49 PM, Chris Bieneman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: cbieneman
> Date: Sun Oct 11 19:49:56 2015
> New Revision: 250003
>
> URL: http://llvm.org/viewvc/llvm-project?rev=250003=rev
> Log:
> [Darwin] Need to add -isysroot on OS X otherwise the tests will fail if
> you don't have the command line tools package installed.
>
> This mirrors how other LLVM suites are configured for running on OS X.
>
> Modified:
> libcxx/trunk/test/libcxx/test/config.py
>
> Modified: libcxx/trunk/test/libcxx/test/config.py
> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=250003=250002=250003=diff
>
> ==
> --- libcxx/trunk/test/libcxx/test/config.py (original)
> +++ libcxx/trunk/test/libcxx/test/config.py Sun Oct 11 19:49:56 2015
> @@ -6,6 +6,7 @@ import pkgutil
>  import re
>  import shlex
>  import sys
> +import subprocess
>
>  import lit.Test  # pylint: disable=import-error,no-name-in-module
>  import lit.util  # pylint: disable=import-error,no-name-in-module
> @@ -42,6 +43,24 @@ def loadSiteConfig(lit_config, config, p
>  ld_fn(config, site_cfg)
>  lit_config.load_config = ld_fn
>
> +def getSysrootFlagsOnDarwin(config, lit_config):
> +# On Darwin, support relocatable SDKs by providing Clang with a
> +# default system root path.
> +if 'darwin' in config.target_triple:
> +try:
> +cmd = subprocess.Popen(['xcrun', '--show-sdk-path'],
> +   stdout=subprocess.PIPE,
> stderr=subprocess.PIPE)
> +out, err = cmd.communicate()
> +out = out.strip()
> +res = cmd.wait()
> +except OSError:
> +res = -1
> +if res == 0 and out:
> +sdk_path = out
> +lit_config.note('using SDKROOT: %r' % sdk_path)
> +return ["-isysroot", sdk_path]
> +return []
> +
>
>  class Configuration(object):
>  # pylint: disable=redefined-outer-name
> @@ -339,6 +358,8 @@ class Configuration(object):
>  # Configure extra flags
>  compile_flags_str = self.get_lit_conf('compile_flags', '')
>  self.cxx.compile_flags += shlex.split(compile_flags_str)
> +sysroot_flags = getSysrootFlagsOnDarwin(self.config,
> self.lit_config)
> +self.cxx.compile_flags.extend(sysroot_flags)
>
>  def configure_default_compile_flags(self):
>  # Try and get the std version from the command line. Fall back to
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13641: clang-format: [JS] handle character classes in regexes.

2015-10-11 Thread Daniel Jasper via cfe-commits
djasper closed this revision.
djasper added a comment.

Submitted as r250009.


http://reviews.llvm.org/D13641



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


Re: [PATCH] D10834: Added functions to retrieve information about variable storage in libclang and its python bindings.

2015-10-11 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added inline comments.


Comment at: include/clang-c/Index.h:3815-3823
@@ -3814,2 +3814,11 @@
 
 /**
+ * \brief Returns true if a variable with function scope is a non-static local 
variable.
+ */
+CINDEX_LINKAGE bool clang_Cursor_hasLocalStorage(CXCursor C);
+
+/*
+ * \brief  Returns true if a variable with function scope is a static local 
variable.
+ */
+CINDEX_LINKAGE bool clang_Cursor_isStaticLocal(CXCursor C);
+

rsmith wrote:
> It might be better to combine these into a single function 
> (`getLocalVarKind`?) returning an enum { not local, non-static local, static 
> local }.
Combining these into one function with an enum is much more work when porting 
to python (which is also den in this patch). Therefore unless there are reasons 
beyond stylistic ones i'd prefer to keep them separate.

IMHO this also increases the friendliness as you can directly infer from the 
documentation at http://clang.llvm.org/doxygen/ what they should do as they 
just forward the calls..


http://reviews.llvm.org/D10834



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


Re: [libcxx] r250003 - [Darwin] Need to add -isysroot on OS X otherwise the tests will fail if you don't have the command line tools package installed.

2015-10-11 Thread Chris Bieneman via cfe-commits
CMake handles doing it while building. I will update to use lit.util.*

-Chris

> On Oct 11, 2015, at 6:04 PM, Eric Fiselier  wrote:
> 
> Do we need to do with while building libc++ as well? Also please reuse 
> lit.util.capture or lit.util.executeCommand instead of subprocess.
> 
> /Eric
> 
> On Sun, Oct 11, 2015 at 6:49 PM, Chris Bieneman via cfe-commits 
> > wrote:
> Author: cbieneman
> Date: Sun Oct 11 19:49:56 2015
> New Revision: 250003
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=250003=rev 
> 
> Log:
> [Darwin] Need to add -isysroot on OS X otherwise the tests will fail if you 
> don't have the command line tools package installed.
> 
> This mirrors how other LLVM suites are configured for running on OS X.
> 
> Modified:
> libcxx/trunk/test/libcxx/test/config.py
> 
> Modified: libcxx/trunk/test/libcxx/test/config.py
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=250003=250002=250003=diff
>  
> 
> ==
> --- libcxx/trunk/test/libcxx/test/config.py (original)
> +++ libcxx/trunk/test/libcxx/test/config.py Sun Oct 11 19:49:56 2015
> @@ -6,6 +6,7 @@ import pkgutil
>  import re
>  import shlex
>  import sys
> +import subprocess
> 
>  import lit.Test  # pylint: disable=import-error,no-name-in-module
>  import lit.util  # pylint: disable=import-error,no-name-in-module
> @@ -42,6 +43,24 @@ def loadSiteConfig(lit_config, config, p
>  ld_fn(config, site_cfg)
>  lit_config.load_config = ld_fn
> 
> +def getSysrootFlagsOnDarwin(config, lit_config):
> +# On Darwin, support relocatable SDKs by providing Clang with a
> +# default system root path.
> +if 'darwin' in config.target_triple:
> +try:
> +cmd = subprocess.Popen(['xcrun', '--show-sdk-path'],
> +   stdout=subprocess.PIPE, 
> stderr=subprocess.PIPE)
> +out, err = cmd.communicate()
> +out = out.strip()
> +res = cmd.wait()
> +except OSError:
> +res = -1
> +if res == 0 and out:
> +sdk_path = out
> +lit_config.note('using SDKROOT: %r' % sdk_path)
> +return ["-isysroot", sdk_path]
> +return []
> +
> 
>  class Configuration(object):
>  # pylint: disable=redefined-outer-name
> @@ -339,6 +358,8 @@ class Configuration(object):
>  # Configure extra flags
>  compile_flags_str = self.get_lit_conf('compile_flags', '')
>  self.cxx.compile_flags += shlex.split(compile_flags_str)
> +sysroot_flags = getSysrootFlagsOnDarwin(self.config, self.lit_config)
> +self.cxx.compile_flags.extend(sysroot_flags)
> 
>  def configure_default_compile_flags(self):
>  # Try and get the std version from the command line. Fall back to
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org 
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits 
> 
> 

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


[libcxx] r250007 - [Darwin] Reworking r250003 to use lit.util.capture instead of subprocess.

2015-10-11 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Sun Oct 11 21:54:30 2015
New Revision: 250007

URL: http://llvm.org/viewvc/llvm-project?rev=250007=rev
Log:
[Darwin] Reworking r250003 to use lit.util.capture instead of subprocess.

Modified:
libcxx/trunk/test/libcxx/test/config.py

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=250007=250006=250007=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Sun Oct 11 21:54:30 2015
@@ -6,7 +6,6 @@ import pkgutil
 import re
 import shlex
 import sys
-import subprocess
 
 import lit.Test  # pylint: disable=import-error,no-name-in-module
 import lit.util  # pylint: disable=import-error,no-name-in-module
@@ -48,11 +47,8 @@ def getSysrootFlagsOnDarwin(config, lit_
 # default system root path.
 if 'darwin' in config.target_triple:
 try:
-cmd = subprocess.Popen(['xcrun', '--show-sdk-path'],
-   stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
-out, err = cmd.communicate()
-out = out.strip()
-res = cmd.wait()
+out = lit.util.capture(['xcrun', '--show-sdk-path']).strip()
+res = 0
 except OSError:
 res = -1
 if res == 0 and out:


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


Re: [libcxx] r250003 - [Darwin] Need to add -isysroot on OS X otherwise the tests will fail if you don't have the command line tools package installed.

2015-10-11 Thread Chris Bieneman via cfe-commits
Updated in r250007.

-Chris

> On Oct 11, 2015, at 7:49 PM, Chris Bieneman via cfe-commits 
>  wrote:
> 
> CMake handles doing it while building. I will update to use lit.util.*
> 
> -Chris
> 
>> On Oct 11, 2015, at 6:04 PM, Eric Fiselier > > wrote:
>> 
>> Do we need to do with while building libc++ as well? Also please reuse 
>> lit.util.capture or lit.util.executeCommand instead of subprocess.
>> 
>> /Eric
>> 
>> On Sun, Oct 11, 2015 at 6:49 PM, Chris Bieneman via cfe-commits 
>> > wrote:
>> Author: cbieneman
>> Date: Sun Oct 11 19:49:56 2015
>> New Revision: 250003
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=250003=rev 
>> 
>> Log:
>> [Darwin] Need to add -isysroot on OS X otherwise the tests will fail if you 
>> don't have the command line tools package installed.
>> 
>> This mirrors how other LLVM suites are configured for running on OS X.
>> 
>> Modified:
>> libcxx/trunk/test/libcxx/test/config.py
>> 
>> Modified: libcxx/trunk/test/libcxx/test/config.py
>> URL: 
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=250003=250002=250003=diff
>>  
>> 
>> ==
>> --- libcxx/trunk/test/libcxx/test/config.py (original)
>> +++ libcxx/trunk/test/libcxx/test/config.py Sun Oct 11 19:49:56 2015
>> @@ -6,6 +6,7 @@ import pkgutil
>>  import re
>>  import shlex
>>  import sys
>> +import subprocess
>> 
>>  import lit.Test  # pylint: disable=import-error,no-name-in-module
>>  import lit.util  # pylint: disable=import-error,no-name-in-module
>> @@ -42,6 +43,24 @@ def loadSiteConfig(lit_config, config, p
>>  ld_fn(config, site_cfg)
>>  lit_config.load_config = ld_fn
>> 
>> +def getSysrootFlagsOnDarwin(config, lit_config):
>> +# On Darwin, support relocatable SDKs by providing Clang with a
>> +# default system root path.
>> +if 'darwin' in config.target_triple:
>> +try:
>> +cmd = subprocess.Popen(['xcrun', '--show-sdk-path'],
>> +   stdout=subprocess.PIPE, 
>> stderr=subprocess.PIPE)
>> +out, err = cmd.communicate()
>> +out = out.strip()
>> +res = cmd.wait()
>> +except OSError:
>> +res = -1
>> +if res == 0 and out:
>> +sdk_path = out
>> +lit_config.note('using SDKROOT: %r' % sdk_path)
>> +return ["-isysroot", sdk_path]
>> +return []
>> +
>> 
>>  class Configuration(object):
>>  # pylint: disable=redefined-outer-name
>> @@ -339,6 +358,8 @@ class Configuration(object):
>>  # Configure extra flags
>>  compile_flags_str = self.get_lit_conf('compile_flags', '')
>>  self.cxx.compile_flags += shlex.split(compile_flags_str)
>> +sysroot_flags = getSysrootFlagsOnDarwin(self.config, 
>> self.lit_config)
>> +self.cxx.compile_flags.extend(sysroot_flags)
>> 
>>  def configure_default_compile_flags(self):
>>  # Try and get the std version from the command line. Fall back to
>> 
>> 
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org 
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits 
>> 
>> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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


Re: [PATCH] D12501: [clang-format] Obj-C dictionary literals: Fixed typecast getting put on a separate line from the key

2015-10-11 Thread Daniel Jasper via cfe-commits
djasper closed this revision.
djasper added a comment.

Submitted as r250010.


http://reviews.llvm.org/D12501



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


r250008 - bindings: add new C++ function attribute accessors

2015-10-11 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Sun Oct 11 22:10:20 2015
New Revision: 250008

URL: http://llvm.org/viewvc/llvm-project?rev=250008=rev
Log:
bindings: add new C++ function attribute accessors

Add methods to index Cursor to see if a cxx method is pure_virtual,
virtual or const methods.

Patch by Jonathan B Coe!

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/bindings/python/tests/cindex/test_cursor.py

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=250008=250007=250008=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Sun Oct 11 22:10:20 2015
@@ -1164,12 +1164,30 @@ class Cursor(Structure):
 """
 return conf.lib.clang_isCursorDefinition(self)
 
+def is_const_method(self):
+"""Returns True if the cursor refers to a C++ member function or member
+function template that is declared 'const'.
+"""
+return conf.lib.clang_CXXMethod_isConst(self)
+
+def is_pure_virtual_method(self):
+"""Returns True if the cursor refers to a C++ member function or member
+function template that is declared pure virtual.
+"""
+return conf.lib.clang_CXXMethod_isPureVirtual(self)
+
 def is_static_method(self):
 """Returns True if the cursor refers to a C++ member function or member
 function template that is declared 'static'.
 """
 return conf.lib.clang_CXXMethod_isStatic(self)
 
+def is_virtual_method(self):
+"""Returns True if the cursor refers to a C++ member function or member
+function template that is declared 'virtual'.
+"""
+return conf.lib.clang_CXXMethod_isVirtual(self)
+
 def get_definition(self):
 """
 If the cursor is a reference to a declaration or a declaration of
@@ -2879,6 +2897,10 @@ functionList = [
[Index, c_char_p],
c_object_p),
 
+  ("clang_CXXMethod_isConst",
+   [Cursor],
+   bool),
+
   ("clang_CXXMethod_isPureVirtual",
[Cursor],
bool),

Modified: cfe/trunk/bindings/python/tests/cindex/test_cursor.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_cursor.py?rev=250008=250007=250008=diff
==
--- cfe/trunk/bindings/python/tests/cindex/test_cursor.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_cursor.py Sun Oct 11 22:10:20 
2015
@@ -97,6 +97,21 @@ def test_canonical():
 assert len(cursors) == 3
 assert cursors[1].canonical == cursors[2].canonical
 
+def test_is_const_method():
+"""Ensure Cursor.is_const_method works."""
+source = 'class X { void foo() const; void bar(); };'
+tu = get_tu(source, lang='cpp')
+
+cls = get_cursor(tu, 'X')
+foo = get_cursor(tu, 'foo')
+bar = get_cursor(tu, 'bar')
+assert cls is not None
+assert foo is not None
+assert bar is not None
+
+assert foo.is_const_method()
+assert not bar.is_const_method()
+
 def test_is_static_method():
 """Ensure Cursor.is_static_method works."""
 
@@ -113,6 +128,36 @@ def test_is_static_method():
 assert foo.is_static_method()
 assert not bar.is_static_method()
 
+def test_is_pure_virtual_method():
+"""Ensure Cursor.is_pure_virtual_method works."""
+source = 'class X { virtual void foo() = 0; virtual void bar(); };'
+tu = get_tu(source, lang='cpp')
+
+cls = get_cursor(tu, 'X')
+foo = get_cursor(tu, 'foo')
+bar = get_cursor(tu, 'bar')
+assert cls is not None
+assert foo is not None
+assert bar is not None
+
+assert foo.is_pure_virtual_method()
+assert not bar.is_pure_virtual_method()
+
+def test_is_virtual_method():
+"""Ensure Cursor.is_virtual_method works."""
+source = 'class X { virtual void foo(); void bar(); };'
+tu = get_tu(source, lang='cpp')
+
+cls = get_cursor(tu, 'X')
+foo = get_cursor(tu, 'foo')
+bar = get_cursor(tu, 'bar')
+assert cls is not None
+assert foo is not None
+assert bar is not None
+
+assert foo.is_virtual_method()
+assert not bar.is_virtual_method()
+
 def test_underlying_type():
 tu = get_tu('typedef int foo;')
 typedef = get_cursor(tu, 'foo')


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