[PATCH] D66964: Sort Java imports without newline

2019-08-29 Thread Yannic Bonenberger via Phabricator via cfe-commits
yannic created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D66964

Files:
  clang/unittests/Format/SortImportsTestJava.cpp


Index: clang/unittests/Format/SortImportsTestJava.cpp
===
--- clang/unittests/Format/SortImportsTestJava.cpp
+++ clang/unittests/Format/SortImportsTestJava.cpp
@@ -285,6 +285,25 @@
   sortIncludes(FmtStyle, Code, GetCodeRange(Code), "input.java").empty());
 }
 
+TEST_F(SortImportsTestJava, NoNewlineBetweenImports) {
+  EXPECT_EQ("import org.a;\n"
+"import org.b;",
+sort("import org.a;import org.b;"));
+  EXPECT_EQ("import org.a;\n"
+"import org.b;",
+sort("import org.b;import org.a;"));
+  EXPECT_EQ("import org.a;\n"
+"import org.b;\n"
+"import org.c",
+sort("import org.b;import org.a;\n"
+ "import org.c;"));
+  EXPECT_EQ("import org.a;\n"
+"import org.b;\n"
+"import org.c",
+sort("import org.c;\n"
+ "import org.b;import org.a;"));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang


Index: clang/unittests/Format/SortImportsTestJava.cpp
===
--- clang/unittests/Format/SortImportsTestJava.cpp
+++ clang/unittests/Format/SortImportsTestJava.cpp
@@ -285,6 +285,25 @@
   sortIncludes(FmtStyle, Code, GetCodeRange(Code), "input.java").empty());
 }
 
+TEST_F(SortImportsTestJava, NoNewlineBetweenImports) {
+  EXPECT_EQ("import org.a;\n"
+"import org.b;",
+sort("import org.a;import org.b;"));
+  EXPECT_EQ("import org.a;\n"
+"import org.b;",
+sort("import org.b;import org.a;"));
+  EXPECT_EQ("import org.a;\n"
+"import org.b;\n"
+"import org.c",
+sort("import org.b;import org.a;\n"
+ "import org.c;"));
+  EXPECT_EQ("import org.a;\n"
+"import org.b;\n"
+"import org.c",
+sort("import org.c;\n"
+ "import org.b;import org.a;"));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66964: Sort Java imports without newline

2019-08-29 Thread Yannic Bonenberger via Phabricator via cfe-commits
yannic added reviewers: SamMaier, thakis.
yannic added a comment.

Right now, this change only adds a test that shows the broken behavior.

SamMaier@ you're the author of https://reviews.llvm.org/D52800 which 
implemented Java import sorting. Is there a reason to not sort imports when 
there's more than one in a line?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66964/new/

https://reviews.llvm.org/D66964



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


[PATCH] D76234: [AST] Simplify implementation of Type::isXXXType()

2020-03-27 Thread Yannic Bonenberger via Phabricator via cfe-commits
yannic added a comment.

sammccall, hokein: you've recently created or reviewed changes in this area. 
Can you help review this change?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76234/new/

https://reviews.llvm.org/D76234



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


[PATCH] D76234: [AST] Simplify implementation of Type::isXXXType()

2020-03-27 Thread Yannic Bonenberger via Phabricator via cfe-commits
yannic added a comment.

Thank you! I don't have commit access, would you mind committing this for me?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76234/new/

https://reviews.llvm.org/D76234



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


[PATCH] D76234: clang: Simplify implementation of Type::isXXXType()

2020-03-16 Thread Yannic Bonenberger via Phabricator via cfe-commits
yannic created this revision.
yannic added reviewers: klimek, rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76234

Files:
  clang/include/clang/AST/Type.h


Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -6777,9 +6777,9 @@
 }
 
 inline bool Type::isSpecificBuiltinType(unsigned K) const {
-  if (const BuiltinType *BT = getAs())
-if (BT->getKind() == (BuiltinType::Kind) K)
-  return true;
+  if (const BuiltinType *BT = getAs()) {
+return BT->getKind() == static_cast(K);
+  }
   return false;
 }
 
@@ -6798,9 +6798,7 @@
 
 inline bool Type::isSpecificPlaceholderType(unsigned K) const {
   assert(BuiltinType::isPlaceholderTypeKind((BuiltinType::Kind) K));
-  if (const auto *BT = dyn_cast(this))
-return (BT->getKind() == (BuiltinType::Kind) K);
-  return false;
+  return isSpecificBuiltinType(K);
 }
 
 inline bool Type::isNonOverloadPlaceholderType() const {
@@ -6810,34 +6808,24 @@
 }
 
 inline bool Type::isVoidType() const {
-  if (const auto *BT = dyn_cast(CanonicalType))
-return BT->getKind() == BuiltinType::Void;
-  return false;
+  return isSpecificBuiltinType(BuiltinType::Void);
 }
 
 inline bool Type::isHalfType() const {
-  if (const auto *BT = dyn_cast(CanonicalType))
-return BT->getKind() == BuiltinType::Half;
   // FIXME: Should we allow complex __fp16? Probably not.
-  return false;
+  return isSpecificBuiltinType(BuiltinType::Half);
 }
 
 inline bool Type::isFloat16Type() const {
-  if (const auto *BT = dyn_cast(CanonicalType))
-return BT->getKind() == BuiltinType::Float16;
-  return false;
+  return isSpecificBuiltinType(BuiltinType::Float16);
 }
 
 inline bool Type::isFloat128Type() const {
-  if (const auto *BT = dyn_cast(CanonicalType))
-return BT->getKind() == BuiltinType::Float128;
-  return false;
+  return isSpecificBuiltinType(BuiltinType::Float128);
 }
 
 inline bool Type::isNullPtrType() const {
-  if (const auto *BT = getAs())
-return BT->getKind() == BuiltinType::NullPtr;
-  return false;
+  return isSpecificBuiltinType(BuiltinType::NullPtr);
 }
 
 bool IsEnumDeclComplete(EnumDecl *);


Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -6777,9 +6777,9 @@
 }
 
 inline bool Type::isSpecificBuiltinType(unsigned K) const {
-  if (const BuiltinType *BT = getAs())
-if (BT->getKind() == (BuiltinType::Kind) K)
-  return true;
+  if (const BuiltinType *BT = getAs()) {
+return BT->getKind() == static_cast(K);
+  }
   return false;
 }
 
@@ -6798,9 +6798,7 @@
 
 inline bool Type::isSpecificPlaceholderType(unsigned K) const {
   assert(BuiltinType::isPlaceholderTypeKind((BuiltinType::Kind) K));
-  if (const auto *BT = dyn_cast(this))
-return (BT->getKind() == (BuiltinType::Kind) K);
-  return false;
+  return isSpecificBuiltinType(K);
 }
 
 inline bool Type::isNonOverloadPlaceholderType() const {
@@ -6810,34 +6808,24 @@
 }
 
 inline bool Type::isVoidType() const {
-  if (const auto *BT = dyn_cast(CanonicalType))
-return BT->getKind() == BuiltinType::Void;
-  return false;
+  return isSpecificBuiltinType(BuiltinType::Void);
 }
 
 inline bool Type::isHalfType() const {
-  if (const auto *BT = dyn_cast(CanonicalType))
-return BT->getKind() == BuiltinType::Half;
   // FIXME: Should we allow complex __fp16? Probably not.
-  return false;
+  return isSpecificBuiltinType(BuiltinType::Half);
 }
 
 inline bool Type::isFloat16Type() const {
-  if (const auto *BT = dyn_cast(CanonicalType))
-return BT->getKind() == BuiltinType::Float16;
-  return false;
+  return isSpecificBuiltinType(BuiltinType::Float16);
 }
 
 inline bool Type::isFloat128Type() const {
-  if (const auto *BT = dyn_cast(CanonicalType))
-return BT->getKind() == BuiltinType::Float128;
-  return false;
+  return isSpecificBuiltinType(BuiltinType::Float128);
 }
 
 inline bool Type::isNullPtrType() const {
-  if (const auto *BT = getAs())
-return BT->getKind() == BuiltinType::NullPtr;
-  return false;
+  return isSpecificBuiltinType(BuiltinType::NullPtr);
 }
 
 bool IsEnumDeclComplete(EnumDecl *);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits