[PATCH] D157566: [SEH] fix assertion when -fasy-exceptions is used.

2023-08-10 Thread Aaron Smith via Phabricator via cfe-commits
asmith accepted this revision.
asmith added inline comments.



Comment at: clang/test/CodeGen/windows-seh-async-exceptions.cpp:21
+{
+devif_Warning("");
+return 0;

nit; spacing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157566

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


[PATCH] D80344: [Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1

2021-05-13 Thread Aaron Smith via Phabricator via cfe-commits
asmith accepted this revision.
asmith added a comment.

Thanks everyone for the great feedback!
We'll move forward with landing this first patch and start the review of the 
next one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80344

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


[PATCH] D80344: [Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1

2021-04-06 Thread Aaron Smith via Phabricator via cfe-commits
asmith added a comment.

@rjmccall @rsmith Thanks for your help. Do you have any additional feedback 
before we commit?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80344

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


[PATCH] D80344: [Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1

2021-04-06 Thread Aaron Smith via Phabricator via cfe-commits
asmith added a comment.



In D80344#2671157 , @lebedev.ri wrote:

> It would be good for @rjmccall / @rsmith / etc to actually finish reviewing 
> this and accept it.
> I would personally want to see the next patches - what changes are needed for 
> llvm analysis, transforms?

All changes were provided a year ago and discussed on llvm-dev. I’m inclined to 
move forward unless any of the reviewers have additional comments???


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80344

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


[PATCH] D80344: [Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1

2021-03-09 Thread Aaron Smith via Phabricator via cfe-commits
asmith added a comment.

Hi John, how does this look now?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80344

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


[PATCH] D80344: [Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1

2021-01-12 Thread Aaron Smith via Phabricator via cfe-commits
asmith added a comment.

This patch looks ready to land. Are there any other concerns or feedback?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80344

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


[PATCH] D80344: [Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1

2020-09-23 Thread Aaron Smith via Phabricator via cfe-commits
asmith added a comment.

> @rjmccall wrote:
>  I think you're missing what I'm asking.  If LLVM accepts this feature, it 
> will become our collective responsibility as a project to keep it working.  
> You have a large external correctness test suite for this feature.  It does 
> not sound like you intend to open-source that test suite; instead, you intend 
> to extract a small number of unit tests from it and add those to the LLVM 
> test suite.  So I'm asking if you're at least going to have an external CI 
> bot which will run the full test suite for this feature to ensure it hasn't 
> been broken by the last day of commits.  It does not seem reasonable to 
> expect that the few unit tests you extract will themselves be sufficient to 
> keep the feature tested.

Microsoft's SEH tests are open source and there was a suggestion in one of the 
threads on llvm-dev to run them on the buildbots. We can look into that as a 
follow on to this patch.

https://lists.llvm.org/pipermail/llvm-dev/2019-November/136695.html
https://lists.llvm.org/pipermail/llvm-dev/2020-April/140614.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80344

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


[PATCH] D80344: [Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1

2020-09-03 Thread Aaron Smith via Phabricator via cfe-commits
asmith added a comment.

Yes there was an RFC and discussion and several requests for comments.
http://lists.llvm.org/pipermail/llvm-dev/2020-March/140541.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80344

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


[PATCH] D77982: [Windows SEH] Fix the frame-ptr of a nested-filter within a _finally

2020-07-01 Thread Aaron Smith via Phabricator via cfe-commits
asmith added a comment.

Thanks for all the helpful feedback. Before we commit this just want to double 
check there are no final comments?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77982



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


[PATCH] D80344: [Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC option -EHa)

2020-05-22 Thread Aaron Smith via Phabricator via cfe-commits
asmith added inline comments.



Comment at: clang/lib/CodeGen/CGDecl.cpp:2003
 
+// : Under -EHa, Invoke llvm.eha.scope.begin() right after
+//  Ctor is emitted and EHStack.pushCleanup

Nit - remove name



Comment at: clang/lib/CodeGen/CGException.cpp:603
+
+  //  For IsEHa catch(...) must handle HW exception
+  //  Adjective = HT_IsStdDotDot (0x40), only catch C++ exceptions

nit - extra space after //



Comment at: clang/lib/CodeGen/CGException.cpp:1677
+  }
+} // end of for
+  }

nit -- comment about closing brace



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:600
 
+  if (LangOpts.EHAsynch) {
+getModule().addModuleFlag(llvm::Module::Warning, "eh-asynch", 1);

nit - braces around single statement


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80344



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


[PATCH] D76077: [ARM] Add __bf16 as new Bfloat16 C Type

2020-05-06 Thread Aaron Smith via Phabricator via cfe-commits
asmith added a comment.

really happy for native bfloat support!




Comment at: clang/include/clang/AST/ASTContext.h:965
   CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
+  CanQualType BFloat16Ty; // ARM NEON
   CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3

Maybe the comment is unnecessary. I can imagine other targets besides ARM NEON 
using BFloat



Comment at: clang/include/clang/AST/Type.h:1982
   bool isFloat16Type() const;  // C11 extension ISO/IEC TS 18661
+  bool isBFloat16Type() const; // ARM BFloat
   bool isFloat128Type() const;

don't think this comment adds anything




Comment at: clang/lib/AST/ASTContext.cpp:5907
   case BuiltinType::Float128:   return Float128Rank;
+  case BuiltinType::BFloat16: return BFloat16Rank;
   }

extra spaces



Comment at: clang/lib/AST/ItaniumMangle.cpp:3186
 case BuiltinType::Half:  EltName = "float16_t";break;
+case BuiltinType::BFloat16:  EltName = "bfloat16x1_t";break;
 default:

Add a space before break and on the line above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76077



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


[PATCH] D77936: [Windows SEH] Fix abnormal-exits in _try

2020-04-30 Thread Aaron Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4eabd0061254: [Windows SEH] Fix abnormal-exits in _try 
(authored by asmith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77936

Files:
  clang/lib/CodeGen/CGCleanup.cpp
  clang/lib/CodeGen/CGException.cpp
  clang/lib/CodeGen/EHScopeStack.h
  clang/test/CodeGen/windows-seh-abnormal-exits.c

Index: clang/test/CodeGen/windows-seh-abnormal-exits.c
===
--- /dev/null
+++ clang/test/CodeGen/windows-seh-abnormal-exits.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -triple x86_64-windows -fms-extensions -Wno-implicit-function-declaration -S -emit-llvm %s -o - | FileCheck %s
+
+// CHECK: %[[src:[0-9-]+]] = call i8* @llvm.localaddress()
+// CHECK-NEXT: %cleanup.dest = load i32, i32* %cleanup.dest.slot, align 4
+// CHECK-NEXT: %[[src2:[0-9-]+]] = icmp ne i32 %cleanup.dest, 0
+// CHECK-NEXT: %[[src3:[0-9-]+]] = zext i1 %[[src2]] to i8
+// CHECK-NEXT: call void @"?fin$0@0@seh_abnormal_exits@@"(i8 %[[src3]], i8* %[[src]])
+
+void seh_abnormal_exits(int *Counter) {
+  for (int i = 0; i < 5; i++) {
+__try {
+  if (i == 0)
+continue;   // abnormal termination
+  else if (i == 1)
+goto t10;   // abnormal termination
+  else if (i == 2)
+__leave;  // normal execution
+  else if (i == 4)
+return;  // abnormal termination
+}
+__finally {
+  if (AbnormalTermination()) {
+*Counter += 1;
+  }
+}
+  t10:;
+  }
+  return; // *Counter == 3
+}
+
Index: clang/lib/CodeGen/EHScopeStack.h
===
--- clang/lib/CodeGen/EHScopeStack.h
+++ clang/lib/CodeGen/EHScopeStack.h
@@ -158,9 +158,10 @@
 /// Generation flags.
 class Flags {
   enum {
-F_IsForEH = 0x1,
+F_IsForEH = 0x1,
 F_IsNormalCleanupKind = 0x2,
-F_IsEHCleanupKind = 0x4
+F_IsEHCleanupKind = 0x4,
+F_HasExitSwitch = 0x8,
   };
   unsigned flags;
 
@@ -179,8 +180,10 @@
   /// cleanup.
   bool isEHCleanupKind() const { return flags & F_IsEHCleanupKind; }
   void setIsEHCleanupKind() { flags |= F_IsEHCleanupKind; }
-};
 
+  bool hasExitSwitch() const { return flags & F_HasExitSwitch; }
+  void setHasExitSwitch() { flags |= F_HasExitSwitch; }
+};
 
 /// Emit the cleanup.  For normal cleanups, this is run in the
 /// same EH context as when the cleanup was pushed, i.e. the
Index: clang/lib/CodeGen/CGException.cpp
===
--- clang/lib/CodeGen/CGException.cpp
+++ clang/lib/CodeGen/CGException.cpp
@@ -1639,6 +1639,19 @@
 
 llvm::Value *IsForEH =
 llvm::ConstantInt::get(CGF.ConvertType(ArgTys[0]), F.isForEHCleanup());
+
+// Except _leave and fall-through at the end, all other exits in a _try
+//   (return/goto/continue/break) are considered as abnormal terminations
+//   since _leave/fall-through is always Indexed 0,
+//   just use NormalCleanupDestSlot (>= 1 for goto/return/..),
+//   as 1st Arg to indicate abnormal termination
+if (!F.isForEHCleanup() && F.hasExitSwitch()) {
+  Address Addr = CGF.getNormalCleanupDestSlot();
+  llvm::Value *Load = CGF.Builder.CreateLoad(Addr, "cleanup.dest");
+  llvm::Value *Zero = llvm::Constant::getNullValue(CGM.Int32Ty);
+  IsForEH = CGF.Builder.CreateICmpNE(Load, Zero);
+}
+
 Args.add(RValue::get(IsForEH), ArgTys[0]);
 Args.add(RValue::get(FP), ArgTys[1]);
 
Index: clang/lib/CodeGen/CGCleanup.cpp
===
--- clang/lib/CodeGen/CGCleanup.cpp
+++ clang/lib/CodeGen/CGCleanup.cpp
@@ -860,6 +860,9 @@
 // TODO: base this on the number of branch-afters and fixups
 const unsigned SwitchCapacity = 10;
 
+// pass the abnormal exit flag to Fn (SEH cleanup)
+cleanupFlags.setHasExitSwitch();
+
 llvm::LoadInst *Load =
   createLoadInstBefore(getNormalCleanupDestSlot(), "cleanup.dest",
nullptr);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78982: [clang-format] Fix Microsoft style for enums

2020-04-30 Thread Aaron Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG292058a5d6d7: [clang-format] Fix Microsoft style for enums 
(authored by asmith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78982

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/FormatTestCSharp.cpp

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -343,7 +343,13 @@
 }
 
 TEST_F(FormatTestCSharp, CSharpKeyWordEscaping) {
-  verifyFormat("public enum var { none, @string, bool, @enum }");
+  verifyFormat("public enum var\n"
+   "{\n"
+   "none,\n"
+   "@string,\n"
+   "bool,\n"
+   "@enum\n"
+   "}");
 }
 
 TEST_F(FormatTestCSharp, CSharpNullCoalescing) {
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1298,6 +1298,20 @@
"}");
 }
 
+TEST_F(FormatTest, ShortEnums) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AllowShortEnumsOnASingleLine = true;
+  verifyFormat("enum { A, B, C } ShortEnum1, ShortEnum2;", Style);
+  Style.AllowShortEnumsOnASingleLine = false;
+  verifyFormat("enum\n"
+   "{\n"
+   "  A,\n"
+   "  B,\n"
+   "  C\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
+}
+
 TEST_F(FormatTest, ShortCaseLabels) {
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortCaseLabelsOnASingleLine = true;
@@ -12959,6 +12973,7 @@
   CHECK_PARSE_BOOL(AllowAllConstructorInitializersOnNextLine);
   CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);
   CHECK_PARSE_BOOL(AllowShortCaseLabelsOnASingleLine);
+  CHECK_PARSE_BOOL(AllowShortEnumsOnASingleLine);
   CHECK_PARSE_BOOL(AllowShortLoopsOnASingleLine);
   CHECK_PARSE_BOOL(BinPackArguments);
   CHECK_PARSE_BOOL(BinPackParameters);
Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -98,7 +98,7 @@
   void readTokenWithJavaScriptASI();
   void parseStructuralElement();
   bool tryToParseBracedList();
-  bool parseBracedList(bool ContinueOnSemicolons = false,
+  bool parseBracedList(bool ContinueOnSemicolons = false, bool IsEnum = false,
tok::TokenKind ClosingBraceKind = tok::r_brace);
   void parseParens();
   void parseSquare(bool LambdaIntroducer = false);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1745,6 +1745,7 @@
 }
 
 bool UnwrappedLineParser::parseBracedList(bool ContinueOnSemicolons,
+  bool IsEnum,
   tok::TokenKind ClosingBraceKind) {
   bool HasError = false;
 
@@ -1785,6 +1786,8 @@
   }
 }
 if (FormatTok->Tok.getKind() == ClosingBraceKind) {
+  if (IsEnum && !Style.AllowShortEnumsOnASingleLine)
+addUnwrappedLine();
   nextToken();
   return !HasError;
 }
@@ -1843,6 +1846,8 @@
   break;
 case tok::comma:
   nextToken();
+  if (IsEnum && !Style.AllowShortEnumsOnASingleLine)
+addUnwrappedLine();
   break;
 default:
   nextToken();
@@ -2301,9 +2306,18 @@
 return true;
   }
 
+  if (!Style.AllowShortEnumsOnASingleLine)
+addUnwrappedLine();
   // Parse enum body.
   nextToken();
-  bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true);
+  if (!Style.AllowShortEnumsOnASingleLine) {
+addUnwrappedLine();
+Line->Level += 1;
+  }
+  bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true,
+   /*IsEnum=*/true);
+  if (!Style.AllowShortEnumsOnASingleLine)
+Line->Level -= 1;
   if (HasError) {
 if (FormatTok->is(tok::semi))
   nextToken();
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -399,6 +399,8 @@
Style.AllowAllConstructorInitializersOnNextLine);
 IO.mapOptional("AllowAllParametersOfDeclarationOnNextLine",
Style.AllowAllParametersOfDeclarationOnNextLine);
+IO.mapOptional("AllowShortEnumsOnASingleLine",
+   

[PATCH] D78982: [clang-format] Fix Microsoft style for enums

2020-04-30 Thread Aaron Smith via Phabricator via cfe-commits
asmith added a comment.

In D78982#2012992 , @MyDeveloperDay 
wrote:

> LGTM


Thanks for the help!


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

https://reviews.llvm.org/D78982



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


[PATCH] D78982: [clang-format] Fix Microsoft style for enums

2020-04-30 Thread Aaron Smith via Phabricator via cfe-commits
asmith updated this revision to Diff 261247.

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

https://reviews.llvm.org/D78982

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/FormatTestCSharp.cpp

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -343,7 +343,13 @@
 }
 
 TEST_F(FormatTestCSharp, CSharpKeyWordEscaping) {
-  verifyFormat("public enum var { none, @string, bool, @enum }");
+  verifyFormat("public enum var\n"
+   "{\n"
+   "none,\n"
+   "@string,\n"
+   "bool,\n"
+   "@enum\n"
+   "}");
 }
 
 TEST_F(FormatTestCSharp, CSharpNullCoalescing) {
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1298,6 +1298,20 @@
"}");
 }
 
+TEST_F(FormatTest, ShortEnums) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AllowShortEnumsOnASingleLine = true;
+  verifyFormat("enum { A, B, C } ShortEnum1, ShortEnum2;", Style);
+  Style.AllowShortEnumsOnASingleLine = false;
+  verifyFormat("enum\n"
+   "{\n"
+   "  A,\n"
+   "  B,\n"
+   "  C\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
+}
+
 TEST_F(FormatTest, ShortCaseLabels) {
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortCaseLabelsOnASingleLine = true;
@@ -12959,6 +12973,7 @@
   CHECK_PARSE_BOOL(AllowAllConstructorInitializersOnNextLine);
   CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);
   CHECK_PARSE_BOOL(AllowShortCaseLabelsOnASingleLine);
+  CHECK_PARSE_BOOL(AllowShortEnumsOnASingleLine);
   CHECK_PARSE_BOOL(AllowShortLoopsOnASingleLine);
   CHECK_PARSE_BOOL(BinPackArguments);
   CHECK_PARSE_BOOL(BinPackParameters);
Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -98,7 +98,7 @@
   void readTokenWithJavaScriptASI();
   void parseStructuralElement();
   bool tryToParseBracedList();
-  bool parseBracedList(bool ContinueOnSemicolons = false,
+  bool parseBracedList(bool ContinueOnSemicolons = false, bool IsEnum = false,
tok::TokenKind ClosingBraceKind = tok::r_brace);
   void parseParens();
   void parseSquare(bool LambdaIntroducer = false);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1745,6 +1745,7 @@
 }
 
 bool UnwrappedLineParser::parseBracedList(bool ContinueOnSemicolons,
+  bool IsEnum,
   tok::TokenKind ClosingBraceKind) {
   bool HasError = false;
 
@@ -1785,6 +1786,8 @@
   }
 }
 if (FormatTok->Tok.getKind() == ClosingBraceKind) {
+  if (IsEnum && !Style.AllowShortEnumsOnASingleLine)
+addUnwrappedLine();
   nextToken();
   return !HasError;
 }
@@ -1843,6 +1846,8 @@
   break;
 case tok::comma:
   nextToken();
+  if (IsEnum && !Style.AllowShortEnumsOnASingleLine)
+addUnwrappedLine();
   break;
 default:
   nextToken();
@@ -2301,9 +2306,18 @@
 return true;
   }
 
+  if (!Style.AllowShortEnumsOnASingleLine)
+addUnwrappedLine();
   // Parse enum body.
   nextToken();
-  bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true);
+  if (!Style.AllowShortEnumsOnASingleLine) {
+addUnwrappedLine();
+Line->Level += 1;
+  }
+  bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true,
+   /*IsEnum=*/true);
+  if (!Style.AllowShortEnumsOnASingleLine)
+Line->Level -= 1;
   if (HasError) {
 if (FormatTok->is(tok::semi))
   nextToken();
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -399,6 +399,8 @@
Style.AllowAllConstructorInitializersOnNextLine);
 IO.mapOptional("AllowAllParametersOfDeclarationOnNextLine",
Style.AllowAllParametersOfDeclarationOnNextLine);
+IO.mapOptional("AllowShortEnumsOnASingleLine",
+   Style.AllowShortEnumsOnASingleLine);
 IO.mapOptional("AllowShortBlocksOnASingleLine",
Style.AllowShortBlocksOnASingleLine);
 

[PATCH] D78982: [clang-format] Fix Microsoft style for enums

2020-04-30 Thread Aaron Smith via Phabricator via cfe-commits
asmith updated this revision to Diff 261246.

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

https://reviews.llvm.org/D78982

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/FormatTestCSharp.cpp

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -343,7 +343,13 @@
 }
 
 TEST_F(FormatTestCSharp, CSharpKeyWordEscaping) {
-  verifyFormat("public enum var { none, @string, bool, @enum }");
+  verifyFormat("public enum var\n"
+   "{\n"
+   "none,\n"
+   "@string,\n"
+   "bool,\n"
+   "@enum\n"
+   "}");
 }
 
 TEST_F(FormatTestCSharp, CSharpNullCoalescing) {
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1298,6 +1298,20 @@
"}");
 }
 
+TEST_F(FormatTest, ShortEnums) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AllowShortEnumsOnASingleLine = true;
+  verifyFormat("enum { A, B, C } ShortEnum1, ShortEnum2;", Style);
+  Style.AllowShortEnumsOnASingleLine = false;
+  verifyFormat("enum\n"
+   "{\n"
+   "  A,\n"
+   "  B,\n"
+   "  C\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
+}
+
 TEST_F(FormatTest, ShortCaseLabels) {
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortCaseLabelsOnASingleLine = true;
@@ -12959,6 +12973,7 @@
   CHECK_PARSE_BOOL(AllowAllConstructorInitializersOnNextLine);
   CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);
   CHECK_PARSE_BOOL(AllowShortCaseLabelsOnASingleLine);
+  CHECK_PARSE_BOOL(AllowShortEnumsOnASingleLine);
   CHECK_PARSE_BOOL(AllowShortLoopsOnASingleLine);
   CHECK_PARSE_BOOL(BinPackArguments);
   CHECK_PARSE_BOOL(BinPackParameters);
Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -98,7 +98,7 @@
   void readTokenWithJavaScriptASI();
   void parseStructuralElement();
   bool tryToParseBracedList();
-  bool parseBracedList(bool ContinueOnSemicolons = false,
+  bool parseBracedList(bool ContinueOnSemicolons = false, bool IsEnum = false,
tok::TokenKind ClosingBraceKind = tok::r_brace);
   void parseParens();
   void parseSquare(bool LambdaIntroducer = false);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1745,6 +1745,7 @@
 }
 
 bool UnwrappedLineParser::parseBracedList(bool ContinueOnSemicolons,
+  bool IsEnum,
   tok::TokenKind ClosingBraceKind) {
   bool HasError = false;
 
@@ -1785,6 +1786,8 @@
   }
 }
 if (FormatTok->Tok.getKind() == ClosingBraceKind) {
+  if (IsEnum && !Style.AllowShortEnumsOnASingleLine)
+addUnwrappedLine();
   nextToken();
   return !HasError;
 }
@@ -1843,6 +1846,8 @@
   break;
 case tok::comma:
   nextToken();
+  if (IsEnum && !Style.AllowShortEnumsOnASingleLine)
+addUnwrappedLine();
   break;
 default:
   nextToken();
@@ -2301,9 +2306,18 @@
 return true;
   }
 
+  if (!Style.AllowShortEnumsOnASingleLine)
+addUnwrappedLine();
   // Parse enum body.
   nextToken();
-  bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true);
+  if (!Style.AllowShortEnumsOnASingleLine) {
+addUnwrappedLine();
+Line->Level += 1;
+  }
+  bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true,
+   /*IsEnum=*/true);
+  if (!Style.AllowShortEnumsOnASingleLine)
+Line->Level -= 1;
   if (HasError) {
 if (FormatTok->is(tok::semi))
   nextToken();
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -399,6 +399,8 @@
Style.AllowAllConstructorInitializersOnNextLine);
 IO.mapOptional("AllowAllParametersOfDeclarationOnNextLine",
Style.AllowAllParametersOfDeclarationOnNextLine);
+IO.mapOptional("AllowShortEnumsOnASingleLine",
+   Style.AllowShortEnumsOnASingleLine);
 IO.mapOptional("AllowShortBlocksOnASingleLine",
Style.AllowShortBlocksOnASingleLine);
 

[PATCH] D78982: [clang-format] Fix Microsoft style for enums

2020-04-30 Thread Aaron Smith via Phabricator via cfe-commits
asmith updated this revision to Diff 261239.
asmith marked an inline comment as done.

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

https://reviews.llvm.org/D78982

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/FormatTestCSharp.cpp

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -343,7 +343,13 @@
 }
 
 TEST_F(FormatTestCSharp, CSharpKeyWordEscaping) {
-  verifyFormat("public enum var { none, @string, bool, @enum }");
+  verifyFormat("public enum var\n"
+   "{\n"
+   "none,\n"
+   "@string,\n"
+   "bool,\n"
+   "@enum\n"
+   "}");
 }
 
 TEST_F(FormatTestCSharp, CSharpNullCoalescing) {
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1298,6 +1298,20 @@
"}");
 }
 
+TEST_F(FormatTest, ShortEnums) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AllowShortEnumsOnASingleLine = true;
+  verifyFormat("enum { A, B, C } ShortEnum1, ShortEnum2;", Style);
+  Style.AllowShortEnumsOnASingleLine = false;
+  verifyFormat("enum\n"
+   "{\n"
+   "  A,\n"
+   "  B,\n"
+   "  C\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
+}
+  
 TEST_F(FormatTest, ShortCaseLabels) {
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortCaseLabelsOnASingleLine = true;
@@ -12959,6 +12973,7 @@
   CHECK_PARSE_BOOL(AllowAllConstructorInitializersOnNextLine);
   CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);
   CHECK_PARSE_BOOL(AllowShortCaseLabelsOnASingleLine);
+  CHECK_PARSE_BOOL(AllowShortEnumsOnASingleLine);
   CHECK_PARSE_BOOL(AllowShortLoopsOnASingleLine);
   CHECK_PARSE_BOOL(BinPackArguments);
   CHECK_PARSE_BOOL(BinPackParameters);
Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -98,7 +98,7 @@
   void readTokenWithJavaScriptASI();
   void parseStructuralElement();
   bool tryToParseBracedList();
-  bool parseBracedList(bool ContinueOnSemicolons = false,
+  bool parseBracedList(bool ContinueOnSemicolons = false, bool IsEnum = false,
tok::TokenKind ClosingBraceKind = tok::r_brace);
   void parseParens();
   void parseSquare(bool LambdaIntroducer = false);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1745,6 +1745,7 @@
 }
 
 bool UnwrappedLineParser::parseBracedList(bool ContinueOnSemicolons,
+  bool IsEnum,
   tok::TokenKind ClosingBraceKind) {
   bool HasError = false;
 
@@ -1785,6 +1786,8 @@
   }
 }
 if (FormatTok->Tok.getKind() == ClosingBraceKind) {
+  if (IsEnum && !Style.AllowShortEnumsOnASingleLine)
+addUnwrappedLine();
   nextToken();
   return !HasError;
 }
@@ -1843,6 +1846,8 @@
   break;
 case tok::comma:
   nextToken();
+  if (IsEnum && !Style.AllowShortEnumsOnASingleLine)
+addUnwrappedLine();
   break;
 default:
   nextToken();
@@ -2301,9 +2306,18 @@
 return true;
   }
 
+  if (!Style.AllowShortEnumsOnASingleLine)
+addUnwrappedLine();
   // Parse enum body.
   nextToken();
-  bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true);
+  if (!Style.AllowShortEnumsOnASingleLine) {
+addUnwrappedLine();
+Line->Level += 1;
+  }
+  bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true,
+   /*IsEnum=*/true);
+  if (!Style.AllowShortEnumsOnASingleLine)
+Line->Level -= 1;
   if (HasError) {
 if (FormatTok->is(tok::semi))
   nextToken();
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -399,6 +399,8 @@
Style.AllowAllConstructorInitializersOnNextLine);
 IO.mapOptional("AllowAllParametersOfDeclarationOnNextLine",
Style.AllowAllParametersOfDeclarationOnNextLine);
+IO.mapOptional("AllowShortEnumsOnASingleLine",
+   Style.AllowShortEnumsOnASingleLine);
 IO.mapOptional("AllowShortBlocksOnASingleLine",

[PATCH] D78982: [clang-format] Fix Microsoft style for enums

2020-04-29 Thread Aaron Smith via Phabricator via cfe-commits
asmith marked 2 inline comments as done.
asmith added inline comments.



Comment at: clang/lib/Format/Format.cpp:1143
   Style.PenaltyReturnTypeOnItsOwnLine = 1000;
+  Style.AllowShortEnumsOnASingleLine = (Language != FormatStyle::LK_Cpp);
   Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;

MyDeveloperDay wrote:
> asmith wrote:
> > MyDeveloperDay wrote:
> > > I think its ok to leave it was, just if up the unit tests
> > > 
> > > (the fact you didn't see this suggests you are not running the unit tests 
> > > please ensure you are)
> > You need to use the latest changes. The is only applied when the style is 
> > Msft and C++. See the GetMicrosoftStyle() method.
> I don't think you should change the style based on the language here, either 
> on or off, but not changing based on language because what about "ObjectiveC"?
> 
> As I added the Microsoft style to allow C# development I think its ok to set 
> this to what you originally had, but fix up the tests
Ive enabled this for C#. I don't see the connection between ObjectiveC and 
Microsoft Style.


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

https://reviews.llvm.org/D78982



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


[PATCH] D78982: [clang-format] Fix Microsoft style for enums

2020-04-29 Thread Aaron Smith via Phabricator via cfe-commits
asmith updated this revision to Diff 260932.
asmith retitled this revision from "[clang-format] Fix Microsoft style for C++ 
enums" to "[clang-format] Fix Microsoft style for enums".
asmith edited the summary of this revision.
asmith added a comment.

Enable for C#


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

https://reviews.llvm.org/D78982

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/FormatTestCSharp.cpp

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -343,7 +343,13 @@
 }
 
 TEST_F(FormatTestCSharp, CSharpKeyWordEscaping) {
-  verifyFormat("public enum var { none, @string, bool, @enum }");
+  verifyFormat("public enum var\n"
+   "{\n"
+   "none,\n"
+   "@string,\n"
+   "bool,\n"
+   "@enum\n"
+   "}");
 }
 
 TEST_F(FormatTestCSharp, CSharpNullCoalescing) {
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1298,6 +1298,20 @@
"}");
 }
 
+TEST_F(FormatTest, ShortEnums) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AllowShortEnumsOnASingleLine = true;
+  verifyFormat("enum { A, B, C } ShortEnum1, ShortEnum2;", Style);
+  Style.AllowShortEnumsOnASingleLine = false;
+  verifyFormat("enum\n"
+   "{\n"
+   "  A,\n"
+   "  B,\n"
+   "  C\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
+}
+  
 TEST_F(FormatTest, ShortCaseLabels) {
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortCaseLabelsOnASingleLine = true;
@@ -12934,6 +12948,7 @@
   CHECK_PARSE_BOOL(AllowAllConstructorInitializersOnNextLine);
   CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);
   CHECK_PARSE_BOOL(AllowShortCaseLabelsOnASingleLine);
+  CHECK_PARSE_BOOL(AllowShortEnumsOnASingleLine);
   CHECK_PARSE_BOOL(AllowShortLoopsOnASingleLine);
   CHECK_PARSE_BOOL(BinPackArguments);
   CHECK_PARSE_BOOL(BinPackParameters);
Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -98,7 +98,7 @@
   void readTokenWithJavaScriptASI();
   void parseStructuralElement();
   bool tryToParseBracedList();
-  bool parseBracedList(bool ContinueOnSemicolons = false,
+  bool parseBracedList(bool ContinueOnSemicolons = false, bool IsEnum = false,
tok::TokenKind ClosingBraceKind = tok::r_brace);
   void parseParens();
   void parseSquare(bool LambdaIntroducer = false);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1724,6 +1724,7 @@
 }
 
 bool UnwrappedLineParser::parseBracedList(bool ContinueOnSemicolons,
+  bool IsEnum,
   tok::TokenKind ClosingBraceKind) {
   bool HasError = false;
   
@@ -1764,6 +1765,8 @@
   }
 }
 if (FormatTok->Tok.getKind() == ClosingBraceKind) {
+  if (IsEnum && !Style.AllowShortEnumsOnASingleLine)
+addUnwrappedLine();
   nextToken();
   return !HasError;
 }
@@ -1822,6 +1825,8 @@
   break;
 case tok::comma:
   nextToken();
+  if (IsEnum && !Style.AllowShortEnumsOnASingleLine)
+addUnwrappedLine();
   break;
 default:
   nextToken();
@@ -2280,9 +2285,18 @@
 return true;
   }
 
+  if (!Style.AllowShortEnumsOnASingleLine)
+addUnwrappedLine();
   // Parse enum body.
   nextToken();
-  bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true);
+  if (!Style.AllowShortEnumsOnASingleLine) {
+addUnwrappedLine();
+Line->Level += 1;
+  }
+  bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true,
+   /*IsEnum=*/true);
+  if (!Style.AllowShortEnumsOnASingleLine)
+Line->Level -= 1;
   if (HasError) {
 if (FormatTok->is(tok::semi))
   nextToken();
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -397,6 +397,8 @@
Style.AllowAllConstructorInitializersOnNextLine);
 IO.mapOptional("AllowAllParametersOfDeclarationOnNextLine",
Style.AllowAllParametersOfDeclarationOnNextLine);
+

[PATCH] D78982: [clang-format] Fix Microsoft style for C++ enums

2020-04-29 Thread Aaron Smith via Phabricator via cfe-commits
asmith added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:721
-
-**InsertTrailingCommas** (``TrailingCommaStyle``) can be set to ``TCS_Wrapped``
-  to insert trailing commas in container literals (arrays and objects) that 
wrap

MyDeveloperDay wrote:
> MyDeveloperDay wrote:
> > asmith wrote:
> > > MyDeveloperDay wrote:
> > > > ? are you removing something?
> > > These are changes from running the python script to regenerate the docs. 
> > > Someone forgot to run the script. This info is no longer in the header.
> > If a change isn't related to your feature, simply ignore it, but don't 
> > include other changes in yours. If this has truly gone then we need to 
> > handle that separately
> This is from {D73768} we may need to determine why the code was not put into 
> Format.h but that can be handled by a separate revision
This is generated by a script. I don't think it's a good idea to edit an 
automatically generated file. I can exclude the change to the RST completely 
and someone can regenerate the RST in a follow on patch.


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

https://reviews.llvm.org/D78982



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


[PATCH] D78982: [clang-format] Fix Microsoft style for C++ enums

2020-04-29 Thread Aaron Smith via Phabricator via cfe-commits
asmith marked 6 inline comments as done.
asmith added a comment.

The is done unless there are other comments.




Comment at: clang/docs/ClangFormatStyleOptions.rst:721
-
-**InsertTrailingCommas** (``TrailingCommaStyle``) can be set to ``TCS_Wrapped``
-  to insert trailing commas in container literals (arrays and objects) that 
wrap

MyDeveloperDay wrote:
> ? are you removing something?
These are changes from running the python script to regenerate the docs. 
Someone forgot to run the script. This info is no longer in the header.



Comment at: clang/docs/ClangFormatStyleOptions.rst:2062
  {
- [self.test1 t:self w:self callback:^(typeof(self) self, NSNumber *u, 
NSNumber *v) {
+ [self.test1 t:self w:self callback:^(typeof(self) self, NSNumber
+ *u, NSNumber *v) {

MyDeveloperDay wrote:
> unrelated change
Not my change. The column is too long so looks like someone manually edited the 
file.



Comment at: clang/lib/Format/Format.cpp:1143
   Style.PenaltyReturnTypeOnItsOwnLine = 1000;
+  Style.AllowShortEnumsOnASingleLine = (Language != FormatStyle::LK_Cpp);
   Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;

MyDeveloperDay wrote:
> I think its ok to leave it was, just if up the unit tests
> 
> (the fact you didn't see this suggests you are not running the unit tests 
> please ensure you are)
You need to use the latest changes. The is only applied when the style is Msft 
and C++. See the GetMicrosoftStyle() method.


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

https://reviews.llvm.org/D78982



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


[PATCH] D78982: [clang-format] Fix Microsoft style for C++ enums

2020-04-28 Thread Aaron Smith via Phabricator via cfe-commits
asmith updated this revision to Diff 260814.

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

https://reviews.llvm.org/D78982

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1298,6 +1298,20 @@
"}");
 }
 
+TEST_F(FormatTest, ShortEnums) {
+  FormatStyle Style = getMicrosoftStyle(FormatStyle::LK_Cpp);
+  Style.AllowShortEnumsOnASingleLine = true;
+  verifyFormat("enum { A, B, C } ShortEnum1, ShortEnum2;", Style);
+  Style.AllowShortEnumsOnASingleLine = false;
+  verifyFormat("enum\n"
+   "{\n"
+   "A,\n"
+   "B,\n"
+   "C\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
+}
+  
 TEST_F(FormatTest, ShortCaseLabels) {
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortCaseLabelsOnASingleLine = true;
@@ -12934,6 +12948,7 @@
   CHECK_PARSE_BOOL(AllowAllConstructorInitializersOnNextLine);
   CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);
   CHECK_PARSE_BOOL(AllowShortCaseLabelsOnASingleLine);
+  CHECK_PARSE_BOOL(AllowShortEnumsOnASingleLine);
   CHECK_PARSE_BOOL(AllowShortLoopsOnASingleLine);
   CHECK_PARSE_BOOL(BinPackArguments);
   CHECK_PARSE_BOOL(BinPackParameters);
Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -98,7 +98,7 @@
   void readTokenWithJavaScriptASI();
   void parseStructuralElement();
   bool tryToParseBracedList();
-  bool parseBracedList(bool ContinueOnSemicolons = false,
+  bool parseBracedList(bool ContinueOnSemicolons = false, bool IsEnum = false,
tok::TokenKind ClosingBraceKind = tok::r_brace);
   void parseParens();
   void parseSquare(bool LambdaIntroducer = false);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1724,6 +1724,7 @@
 }
 
 bool UnwrappedLineParser::parseBracedList(bool ContinueOnSemicolons,
+  bool IsEnum,
   tok::TokenKind ClosingBraceKind) {
   bool HasError = false;
   
@@ -1764,6 +1765,8 @@
   }
 }
 if (FormatTok->Tok.getKind() == ClosingBraceKind) {
+  if (IsEnum && !Style.AllowShortEnumsOnASingleLine)
+addUnwrappedLine();
   nextToken();
   return !HasError;
 }
@@ -1822,6 +1825,8 @@
   break;
 case tok::comma:
   nextToken();
+  if (IsEnum && !Style.AllowShortEnumsOnASingleLine)
+addUnwrappedLine();
   break;
 default:
   nextToken();
@@ -2280,9 +2285,18 @@
 return true;
   }
 
+  if (!Style.AllowShortEnumsOnASingleLine)
+addUnwrappedLine();
   // Parse enum body.
   nextToken();
-  bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true);
+  if (!Style.AllowShortEnumsOnASingleLine) {
+addUnwrappedLine();
+Line->Level += 1;
+  }
+  bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true,
+   /*IsEnum=*/true);
+  if (!Style.AllowShortEnumsOnASingleLine)
+Line->Level -= 1;
   if (HasError) {
 if (FormatTok->is(tok::semi))
   nextToken();
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -397,6 +397,8 @@
Style.AllowAllConstructorInitializersOnNextLine);
 IO.mapOptional("AllowAllParametersOfDeclarationOnNextLine",
Style.AllowAllParametersOfDeclarationOnNextLine);
+IO.mapOptional("AllowShortEnumsOnASingleLine",
+   Style.AllowShortEnumsOnASingleLine);
 IO.mapOptional("AllowShortBlocksOnASingleLine",
Style.AllowShortBlocksOnASingleLine);
 IO.mapOptional("AllowShortCaseLabelsOnASingleLine",
@@ -752,6 +754,7 @@
   LLVMStyle.AllowAllArgumentsOnNextLine = true;
   LLVMStyle.AllowAllConstructorInitializersOnNextLine = true;
   LLVMStyle.AllowAllParametersOfDeclarationOnNextLine = true;
+  LLVMStyle.AllowShortEnumsOnASingleLine = true;
   LLVMStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
   LLVMStyle.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
   LLVMStyle.AllowShortCaseLabelsOnASingleLine = false;
@@ -1137,6 +1140,7 @@
   Style.BraceWrapping.BeforeCatch = true;
   Style.BraceWrapping.BeforeElse = true;
   Style.PenaltyReturnTypeOnItsOwnLine = 1000;
+  

[PATCH] D78982: [clang-format] Fix Microsoft style for C++ enums

2020-04-28 Thread Aaron Smith via Phabricator via cfe-commits
asmith updated this revision to Diff 260812.
asmith retitled this revision from "[clang-format] Fix Microsoft style for 
enums" to "[clang-format] Fix Microsoft style for C++ enums".
asmith edited the summary of this revision.

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

https://reviews.llvm.org/D78982

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1298,6 +1298,20 @@
"}");
 }
 
+TEST_F(FormatTest, ShortEnums) {
+  FormatStyle Style = getMicrosoftStyle(FormatStyle::LK_Cpp);
+  Style.AllowShortEnumsOnASingleLine = true;
+  verifyFormat("enum { A, B, C } ShortEnum1, ShortEnum2;", Style);
+  Style.AllowShortEnumsOnASingleLine = false;
+  verifyFormat("enum\n"
+   "{\n"
+   "A,\n"
+   "B\n"
+   "C\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
+}
+  
 TEST_F(FormatTest, ShortCaseLabels) {
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortCaseLabelsOnASingleLine = true;
@@ -12934,6 +12948,7 @@
   CHECK_PARSE_BOOL(AllowAllConstructorInitializersOnNextLine);
   CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);
   CHECK_PARSE_BOOL(AllowShortCaseLabelsOnASingleLine);
+  CHECK_PARSE_BOOL(AllowShortEnumsOnASingleLine);
   CHECK_PARSE_BOOL(AllowShortLoopsOnASingleLine);
   CHECK_PARSE_BOOL(BinPackArguments);
   CHECK_PARSE_BOOL(BinPackParameters);
Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -98,7 +98,7 @@
   void readTokenWithJavaScriptASI();
   void parseStructuralElement();
   bool tryToParseBracedList();
-  bool parseBracedList(bool ContinueOnSemicolons = false,
+  bool parseBracedList(bool ContinueOnSemicolons = false, bool IsEnum = false,
tok::TokenKind ClosingBraceKind = tok::r_brace);
   void parseParens();
   void parseSquare(bool LambdaIntroducer = false);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1724,6 +1724,7 @@
 }
 
 bool UnwrappedLineParser::parseBracedList(bool ContinueOnSemicolons,
+  bool IsEnum,
   tok::TokenKind ClosingBraceKind) {
   bool HasError = false;
   
@@ -1764,6 +1765,8 @@
   }
 }
 if (FormatTok->Tok.getKind() == ClosingBraceKind) {
+  if (IsEnum && !Style.AllowShortEnumsOnASingleLine)
+addUnwrappedLine();
   nextToken();
   return !HasError;
 }
@@ -1822,6 +1825,8 @@
   break;
 case tok::comma:
   nextToken();
+  if (IsEnum && !Style.AllowShortEnumsOnASingleLine)
+addUnwrappedLine();
   break;
 default:
   nextToken();
@@ -2280,9 +2285,18 @@
 return true;
   }
 
+  if (!Style.AllowShortEnumsOnASingleLine)
+addUnwrappedLine();
   // Parse enum body.
   nextToken();
-  bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true);
+  if (!Style.AllowShortEnumsOnASingleLine) {
+addUnwrappedLine();
+Line->Level += 1;
+  }
+  bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true,
+   /*IsEnum=*/true);
+  if (!Style.AllowShortEnumsOnASingleLine)
+Line->Level -= 1;
   if (HasError) {
 if (FormatTok->is(tok::semi))
   nextToken();
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -397,6 +397,8 @@
Style.AllowAllConstructorInitializersOnNextLine);
 IO.mapOptional("AllowAllParametersOfDeclarationOnNextLine",
Style.AllowAllParametersOfDeclarationOnNextLine);
+IO.mapOptional("AllowShortEnumsOnASingleLine",
+   Style.AllowShortEnumsOnASingleLine);
 IO.mapOptional("AllowShortBlocksOnASingleLine",
Style.AllowShortBlocksOnASingleLine);
 IO.mapOptional("AllowShortCaseLabelsOnASingleLine",
@@ -752,6 +754,7 @@
   LLVMStyle.AllowAllArgumentsOnNextLine = true;
   LLVMStyle.AllowAllConstructorInitializersOnNextLine = true;
   LLVMStyle.AllowAllParametersOfDeclarationOnNextLine = true;
+  LLVMStyle.AllowShortEnumsOnASingleLine = true;
   LLVMStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
   LLVMStyle.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
   

[PATCH] D78982: [clang-format] Fix Microsoft style for enums

2020-04-28 Thread Aaron Smith via Phabricator via cfe-commits
asmith added a comment.

In D78982#2007172 , @MyDeveloperDay 
wrote:

> - This needs unit tests in clang/unittests/Format to demonstrate the problem 
> and test this fixing it


Is there an easy way to check the test is working?

'ninja check-clang-format' passes but would like to verify.


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

https://reviews.llvm.org/D78982



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


[PATCH] D78982: [clang-format] Fix Microsoft style for enums

2020-04-28 Thread Aaron Smith via Phabricator via cfe-commits
asmith marked 5 inline comments as done.
asmith added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1767
 if (FormatTok->Tok.getKind() == ClosingBraceKind) {
+  if (!Style.AllowEnumsOnASingleLine)
+addUnwrappedLine();

This and the line below are probably applying to more than enums. Any 
suggestions on a better fix?


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

https://reviews.llvm.org/D78982



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


[PATCH] D78982: [clang-format] Fix Microsoft style for enums

2020-04-28 Thread Aaron Smith via Phabricator via cfe-commits
asmith updated this revision to Diff 260732.
asmith added a comment.

Rename option
Add test case
Only apply to Microsoft CPP style


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

https://reviews.llvm.org/D78982

Files:
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1298,6 +1298,20 @@
"}");
 }
 
+TEST_F(FormatTest, ShortEnums) {
+  FormatStyle Style = getMicrosoftStyle(FormatStyle::LK_Cpp);
+  Style.AllowShortEnumsOnASingleLine = true;
+  verifyFormat("enum { A, B, C } ShortEnum1, ShortEnum2;", Style);
+  Style.AllowShortEnumsOnASingleLine = false;
+  verifyFormat("enum\n"
+   "{\n"
+   "A,\n"
+   "B\n"
+   "C\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
+}
+  
 TEST_F(FormatTest, ShortCaseLabels) {
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortCaseLabelsOnASingleLine = true;
@@ -12934,6 +12948,7 @@
   CHECK_PARSE_BOOL(AllowAllConstructorInitializersOnNextLine);
   CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);
   CHECK_PARSE_BOOL(AllowShortCaseLabelsOnASingleLine);
+  CHECK_PARSE_BOOL(AllowShortEnumsOnASingleLine);
   CHECK_PARSE_BOOL(AllowShortLoopsOnASingleLine);
   CHECK_PARSE_BOOL(BinPackArguments);
   CHECK_PARSE_BOOL(BinPackParameters);
Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -98,7 +98,7 @@
   void readTokenWithJavaScriptASI();
   void parseStructuralElement();
   bool tryToParseBracedList();
-  bool parseBracedList(bool ContinueOnSemicolons = false,
+  bool parseBracedList(bool ContinueOnSemicolons = false, bool IsEnum = false,
tok::TokenKind ClosingBraceKind = tok::r_brace);
   void parseParens();
   void parseSquare(bool LambdaIntroducer = false);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1724,6 +1724,7 @@
 }
 
 bool UnwrappedLineParser::parseBracedList(bool ContinueOnSemicolons,
+  bool IsEnum,
   tok::TokenKind ClosingBraceKind) {
   bool HasError = false;
   
@@ -1764,6 +1765,8 @@
   }
 }
 if (FormatTok->Tok.getKind() == ClosingBraceKind) {
+  if (IsEnum && !Style.AllowShortEnumsOnASingleLine)
+addUnwrappedLine();
   nextToken();
   return !HasError;
 }
@@ -1822,6 +1825,8 @@
   break;
 case tok::comma:
   nextToken();
+  if (IsEnum && !Style.AllowShortEnumsOnASingleLine)
+addUnwrappedLine();
   break;
 default:
   nextToken();
@@ -2280,9 +2285,18 @@
 return true;
   }
 
+  if (!Style.AllowShortEnumsOnASingleLine)
+addUnwrappedLine();
   // Parse enum body.
   nextToken();
-  bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true);
+  if (!Style.AllowShortEnumsOnASingleLine) {
+addUnwrappedLine();
+Line->Level += 1;
+  }
+  bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true,
+   /*IsEnum=*/true);
+  if (!Style.AllowShortEnumsOnASingleLine)
+Line->Level -= 1;
   if (HasError) {
 if (FormatTok->is(tok::semi))
   nextToken();
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -397,6 +397,8 @@
Style.AllowAllConstructorInitializersOnNextLine);
 IO.mapOptional("AllowAllParametersOfDeclarationOnNextLine",
Style.AllowAllParametersOfDeclarationOnNextLine);
+IO.mapOptional("AllowShortEnumsOnASingleLine",
+   Style.AllowShortEnumsOnASingleLine);
 IO.mapOptional("AllowShortBlocksOnASingleLine",
Style.AllowShortBlocksOnASingleLine);
 IO.mapOptional("AllowShortCaseLabelsOnASingleLine",
@@ -752,6 +754,7 @@
   LLVMStyle.AllowAllArgumentsOnNextLine = true;
   LLVMStyle.AllowAllConstructorInitializersOnNextLine = true;
   LLVMStyle.AllowAllParametersOfDeclarationOnNextLine = true;
+  LLVMStyle.AllowShortEnumsOnASingleLine = true;
   LLVMStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
   LLVMStyle.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
   LLVMStyle.AllowShortCaseLabelsOnASingleLine = false;
@@ -1137,6 +1140,7 @@
   Style.BraceWrapping.BeforeCatch = true;
   Style.BraceWrapping.BeforeElse = true;
   

[PATCH] D78982: [clang-format] Fix Microsoft style for enums

2020-04-28 Thread Aaron Smith via Phabricator via cfe-commits
asmith updated this revision to Diff 260551.
asmith added a comment.

Fix line breaks like this:

enum { a=1, b=2, c=3
} myEnum;

which becomes:

enum 
{

  a=1,
  b=2,
  c=3

} myEnum;


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

https://reviews.llvm.org/D78982

Files:
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineParser.cpp

Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1764,6 +1764,8 @@
   }
 }
 if (FormatTok->Tok.getKind() == ClosingBraceKind) {
+  if (!Style.AllowEnumsOnASingleLine)
+addUnwrappedLine();
   nextToken();
   return !HasError;
 }
@@ -1822,6 +1824,8 @@
   break;
 case tok::comma:
   nextToken();
+  if (!Style.AllowEnumsOnASingleLine)
+addUnwrappedLine();
   break;
 default:
   nextToken();
@@ -2280,9 +2284,17 @@
 return true;
   }
 
+  if (!Style.AllowEnumsOnASingleLine)
+addUnwrappedLine();
   // Parse enum body.
   nextToken();
+  if (!Style.AllowEnumsOnASingleLine) {
+addUnwrappedLine();
+Line->Level += 1;
+  }
   bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true);
+  if (!Style.AllowEnumsOnASingleLine)
+Line->Level -= 1;
   if (HasError) {
 if (FormatTok->is(tok::semi))
   nextToken();
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -397,6 +397,8 @@
Style.AllowAllConstructorInitializersOnNextLine);
 IO.mapOptional("AllowAllParametersOfDeclarationOnNextLine",
Style.AllowAllParametersOfDeclarationOnNextLine);
+IO.mapOptional("AllowEnumsOnASingleLine",
+   Style.AllowEnumsOnASingleLine);
 IO.mapOptional("AllowShortBlocksOnASingleLine",
Style.AllowShortBlocksOnASingleLine);
 IO.mapOptional("AllowShortCaseLabelsOnASingleLine",
@@ -752,6 +754,7 @@
   LLVMStyle.AllowAllArgumentsOnNextLine = true;
   LLVMStyle.AllowAllConstructorInitializersOnNextLine = true;
   LLVMStyle.AllowAllParametersOfDeclarationOnNextLine = true;
+  LLVMStyle.AllowEnumsOnASingleLine = true;
   LLVMStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
   LLVMStyle.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
   LLVMStyle.AllowShortCaseLabelsOnASingleLine = false;
@@ -1137,6 +1140,7 @@
   Style.BraceWrapping.BeforeCatch = true;
   Style.BraceWrapping.BeforeElse = true;
   Style.PenaltyReturnTypeOnItsOwnLine = 1000;
+  Style.AllowEnumsOnASingleLine = false;
   Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
   Style.AllowShortCaseLabelsOnASingleLine = false;
   Style.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -221,6 +221,20 @@
   /// \endcode
   bool AllowAllParametersOfDeclarationOnNextLine;
 
+  /// Allow enums on a single line.
+  /// \code
+  ///   true:
+  ///   enum { A, B } myEnum;
+  ///
+  ///   false:
+  ///   enum
+  ///   {
+  /// A,
+  /// B,
+  ///   } myEnum;
+  /// \endcode
+  bool AllowEnumsOnASingleLine;
+  
   /// Different styles for merging short blocks containing at most one
   /// statement.
   enum ShortBlockStyle {
@@ -2160,6 +2174,7 @@
R.AllowAllConstructorInitializersOnNextLine &&
AllowAllParametersOfDeclarationOnNextLine ==
R.AllowAllParametersOfDeclarationOnNextLine &&
+   AllowEnumsOnASingleLine == R.AllowEnumsOnASingleLine &&
AllowShortBlocksOnASingleLine == R.AllowShortBlocksOnASingleLine &&
AllowShortCaseLabelsOnASingleLine ==
R.AllowShortCaseLabelsOnASingleLine &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78982: [clang-format] Fix Microsoft style for enums

2020-04-27 Thread Aaron Smith via Phabricator via cfe-commits
asmith updated this revision to Diff 260542.

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

https://reviews.llvm.org/D78982

Files:
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineParser.cpp


Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2280,9 +2280,17 @@
 return true;
   }
 
+  if (!Style.AllowEnumsOnASingleLine)
+addUnwrappedLine();
   // Parse enum body.
   nextToken();
+  if (!Style.AllowEnumsOnASingleLine) {
+addUnwrappedLine();
+Line->Level += 1;
+  }
   bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true);
+  if (!Style.AllowEnumsOnASingleLine)
+Line->Level -= 1;
   if (HasError) {
 if (FormatTok->is(tok::semi))
   nextToken();
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -397,6 +397,8 @@
Style.AllowAllConstructorInitializersOnNextLine);
 IO.mapOptional("AllowAllParametersOfDeclarationOnNextLine",
Style.AllowAllParametersOfDeclarationOnNextLine);
+IO.mapOptional("AllowEnumsOnASingleLine",
+   Style.AllowEnumsOnASingleLine);
 IO.mapOptional("AllowShortBlocksOnASingleLine",
Style.AllowShortBlocksOnASingleLine);
 IO.mapOptional("AllowShortCaseLabelsOnASingleLine",
@@ -752,6 +754,7 @@
   LLVMStyle.AllowAllArgumentsOnNextLine = true;
   LLVMStyle.AllowAllConstructorInitializersOnNextLine = true;
   LLVMStyle.AllowAllParametersOfDeclarationOnNextLine = true;
+  LLVMStyle.AllowEnumsOnASingleLine = true;
   LLVMStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
   LLVMStyle.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
   LLVMStyle.AllowShortCaseLabelsOnASingleLine = false;
@@ -1137,6 +1140,7 @@
   Style.BraceWrapping.BeforeCatch = true;
   Style.BraceWrapping.BeforeElse = true;
   Style.PenaltyReturnTypeOnItsOwnLine = 1000;
+  Style.AllowEnumsOnASingleLine = false;
   Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
   Style.AllowShortCaseLabelsOnASingleLine = false;
   Style.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -221,6 +221,20 @@
   /// \endcode
   bool AllowAllParametersOfDeclarationOnNextLine;
 
+  /// Allow enums on a single line.
+  /// \code
+  ///   true:
+  ///   enum { A, B } myEnum;
+  ///
+  ///   false:
+  ///   enum
+  ///   {
+  /// A,
+  /// B,
+  ///   } myEnum;
+  /// \endcode
+  bool AllowEnumsOnASingleLine;
+  
   /// Different styles for merging short blocks containing at most one
   /// statement.
   enum ShortBlockStyle {
@@ -2160,6 +2174,7 @@
R.AllowAllConstructorInitializersOnNextLine &&
AllowAllParametersOfDeclarationOnNextLine ==
R.AllowAllParametersOfDeclarationOnNextLine &&
+   AllowEnumsOnASingleLine == R.AllowEnumsOnASingleLine &&
AllowShortBlocksOnASingleLine == R.AllowShortBlocksOnASingleLine &&
AllowShortCaseLabelsOnASingleLine ==
R.AllowShortCaseLabelsOnASingleLine &&


Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2280,9 +2280,17 @@
 return true;
   }
 
+  if (!Style.AllowEnumsOnASingleLine)
+addUnwrappedLine();
   // Parse enum body.
   nextToken();
+  if (!Style.AllowEnumsOnASingleLine) {
+addUnwrappedLine();
+Line->Level += 1;
+  }
   bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true);
+  if (!Style.AllowEnumsOnASingleLine)
+Line->Level -= 1;
   if (HasError) {
 if (FormatTok->is(tok::semi))
   nextToken();
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -397,6 +397,8 @@
Style.AllowAllConstructorInitializersOnNextLine);
 IO.mapOptional("AllowAllParametersOfDeclarationOnNextLine",
Style.AllowAllParametersOfDeclarationOnNextLine);
+IO.mapOptional("AllowEnumsOnASingleLine",
+   Style.AllowEnumsOnASingleLine);
 IO.mapOptional("AllowShortBlocksOnASingleLine",
Style.AllowShortBlocksOnASingleLine);
 IO.mapOptional("AllowShortCaseLabelsOnASingleLine",
@@ -752,6 +754,7 @@
   LLVMStyle.AllowAllArgumentsOnNextLine = true;
   LLVMStyle.AllowAllConstructorInitializersOnNextLine = true;
   

[PATCH] D78982: [clang-format] Fix Microsoft style for enums

2020-04-27 Thread Aaron Smith via Phabricator via cfe-commits
asmith added a comment.

This change tries to fix this bug.
https://bugs.llvm.org/show_bug.cgi?id=32810


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78982



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


[PATCH] D78982: [clang-format] Fix Microsoft style for enums

2020-04-27 Thread Aaron Smith via Phabricator via cfe-commits
asmith created this revision.
asmith added reviewers: jbcoe, MyDeveloperDay.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
asmith added a reviewer: thakis.

Before this change enums were formatted incorrectly for the Microsoft style.

  

[Original Source]

  
  enum {
one,
two
  } three, four;


[Incorrectly Formatted]

  
  enum blah
  {
one,
two
  } three,
  four;


[Correct Format with Patch]

  
  enum blah
  {
one,
two
  } three, four;


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78982

Files:
  clang/lib/Format/UnwrappedLineParser.cpp


Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2280,9 +2280,18 @@
 return true;
   }
 
+  if (Style.BraceWrapping.AfterEnum)
+addUnwrappedLine();
   // Parse enum body.
   nextToken();
+  if (Style.BraceWrapping.AfterEnum) {
+addUnwrappedLine();
+Line->Level += 1;
+  }
   bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true);
+  if (Style.BraceWrapping.AfterEnum)
+Line->Level -= 1;
+  
   if (HasError) {
 if (FormatTok->is(tok::semi))
   nextToken();


Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2280,9 +2280,18 @@
 return true;
   }
 
+  if (Style.BraceWrapping.AfterEnum)
+addUnwrappedLine();
   // Parse enum body.
   nextToken();
+  if (Style.BraceWrapping.AfterEnum) {
+addUnwrappedLine();
+Line->Level += 1;
+  }
   bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true);
+  if (Style.BraceWrapping.AfterEnum)
+Line->Level -= 1;
+  
   if (HasError) {
 if (FormatTok->is(tok::semi))
   nextToken();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59347: [DebugInfo] Combine Trivial and NonTrivial flags

2019-04-11 Thread Aaron Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL358219: [DebugInfo] Combine Trivial and NonTrivial flags 
(authored by asmith, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59347?vs=194249=194737#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59347

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/test/CodeGenCXX/debug-info-composite-triviality.cpp


Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -3034,10 +3034,8 @@
 else
   Flags |= llvm::DINode::FlagTypePassByValue;
 
-// Record if a C++ record is trivial type.
-if (CXXRD->isTrivial())
-  Flags |= llvm::DINode::FlagTrivial;
-else
+// Record if a C++ record is non-trivial type.
+if (!CXXRD->isTrivial())
   Flags |= llvm::DINode::FlagNonTrivial;
   }
 
Index: cfe/trunk/test/CodeGenCXX/debug-info-composite-triviality.cpp
===
--- cfe/trunk/test/CodeGenCXX/debug-info-composite-triviality.cpp
+++ cfe/trunk/test/CodeGenCXX/debug-info-composite-triviality.cpp
@@ -25,34 +25,40 @@
 
 // Cases to test composite type's triviality
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "Union",{{.*}}flags: 
{{.*}}DIFlagTrivial
+// CHECK-DAG:  {{.*}}!DIGlobalVariable(name: "Union",
+// CHECK-DAG-NEXT: {{^((?!\bDIFlagNonTrivial\b).)*$}}
 union Union {
   int a;
 } Union;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "Trivial",{{.*}}flags: 
{{.*}}DIFlagTrivial
+// CHECK-DAG:  {{.*}}!DIGlobalVariable(name: "Trivial",
+// CHECK-DAG-NEXT: {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct Trivial {
   int i;
 } Trivial;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialA",{{.*}}flags: 
{{.*}}DIFlagTrivial
+// CHECK-DAG:   {{.*}}!DIGlobalVariable(name: "TrivialA",
+// CHECK-DAG-NEXT:  {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct TrivialA {
   TrivialA() = default;
 } TrivialA;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialB",{{.*}}flags: 
{{.*}}DIFlagTrivial
+// CHECK-DAG:   {{.*}}!DIGlobalVariable(name: "TrivialB",
+// CHECK-DAG-NEXT:  {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct TrivialB {
   int m;
   TrivialB(int x) { m = x; }
   TrivialB() = default;
 } TrivialB;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialC",{{.*}}flags: 
{{.*}}DIFlagTrivial
+// CHECK-DAG:   {{.*}}!DIGlobalVariable(name: "TrivialC",
+// CHECK-DAG-NEXT:  {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct TrivialC {
   struct Trivial x;
 } TrivialC;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialD",{{.*}}flags: 
{{.*}}DIFlagTrivial
+// CHECK-DAG:   {{.*}}!DIGlobalVariable(name: "TrivialD",
+// CHECK-DAG-NEXT:  {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct NT {
   NT() {};
 };


Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -3034,10 +3034,8 @@
 else
   Flags |= llvm::DINode::FlagTypePassByValue;
 
-// Record if a C++ record is trivial type.
-if (CXXRD->isTrivial())
-  Flags |= llvm::DINode::FlagTrivial;
-else
+// Record if a C++ record is non-trivial type.
+if (!CXXRD->isTrivial())
   Flags |= llvm::DINode::FlagNonTrivial;
   }
 
Index: cfe/trunk/test/CodeGenCXX/debug-info-composite-triviality.cpp
===
--- cfe/trunk/test/CodeGenCXX/debug-info-composite-triviality.cpp
+++ cfe/trunk/test/CodeGenCXX/debug-info-composite-triviality.cpp
@@ -25,34 +25,40 @@
 
 // Cases to test composite type's triviality
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "Union",{{.*}}flags: {{.*}}DIFlagTrivial
+// CHECK-DAG:  {{.*}}!DIGlobalVariable(name: "Union",
+// CHECK-DAG-NEXT: {{^((?!\bDIFlagNonTrivial\b).)*$}}
 union Union {
   int a;
 } Union;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "Trivial",{{.*}}flags: {{.*}}DIFlagTrivial
+// CHECK-DAG:  {{.*}}!DIGlobalVariable(name: "Trivial",
+// CHECK-DAG-NEXT: {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct Trivial {
   int i;
 } Trivial;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialA",{{.*}}flags: {{.*}}DIFlagTrivial
+// CHECK-DAG:   {{.*}}!DIGlobalVariable(name: "TrivialA",
+// CHECK-DAG-NEXT:  {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct TrivialA {
   TrivialA() = default;
 } TrivialA;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialB",{{.*}}flags: {{.*}}DIFlagTrivial
+// CHECK-DAG:   {{.*}}!DIGlobalVariable(name: "TrivialB",
+// CHECK-DAG-NEXT:  {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct TrivialB {
   int m;
   TrivialB(int x) { m = x; }
   TrivialB() = default;
 } TrivialB;
 
-// CHECK-DAG: 

[PATCH] D59347: [DebugInfo] Combine Trivial and NonTrivial flags

2019-04-09 Thread Aaron Smith via Phabricator via cfe-commits
asmith marked 2 inline comments as done.
asmith added a comment.

This should be ready to commit


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

https://reviews.llvm.org/D59347



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


[PATCH] D59347: [DebugInfo] Combine Trivial and NonTrivial flags

2019-04-09 Thread Aaron Smith via Phabricator via cfe-commits
asmith updated this revision to Diff 194249.

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

https://reviews.llvm.org/D59347

Files:
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGenCXX/debug-info-composite-triviality.cpp


Index: test/CodeGenCXX/debug-info-composite-triviality.cpp
===
--- test/CodeGenCXX/debug-info-composite-triviality.cpp
+++ test/CodeGenCXX/debug-info-composite-triviality.cpp
@@ -25,34 +25,40 @@
 
 // Cases to test composite type's triviality
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "Union",{{.*}}flags: 
{{.*}}DIFlagTrivial
+// CHECK-DAG:  {{.*}}!DIGlobalVariable(name: "Union",
+// CHECK-DAG-NEXT: {{^((?!\bDIFlagNonTrivial\b).)*$}}
 union Union {
   int a;
 } Union;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "Trivial",{{.*}}flags: 
{{.*}}DIFlagTrivial
+// CHECK-DAG:  {{.*}}!DIGlobalVariable(name: "Trivial",
+// CHECK-DAG-NEXT: {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct Trivial {
   int i;
 } Trivial;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialA",{{.*}}flags: 
{{.*}}DIFlagTrivial
+// CHECK-DAG:   {{.*}}!DIGlobalVariable(name: "TrivialA",
+// CHECK-DAG-NEXT:  {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct TrivialA {
   TrivialA() = default;
 } TrivialA;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialB",{{.*}}flags: 
{{.*}}DIFlagTrivial
+// CHECK-DAG:   {{.*}}!DIGlobalVariable(name: "TrivialB",
+// CHECK-DAG-NEXT:  {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct TrivialB {
   int m;
   TrivialB(int x) { m = x; }
   TrivialB() = default;
 } TrivialB;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialC",{{.*}}flags: 
{{.*}}DIFlagTrivial
+// CHECK-DAG:   {{.*}}!DIGlobalVariable(name: "TrivialC",
+// CHECK-DAG-NEXT:  {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct TrivialC {
   struct Trivial x;
 } TrivialC;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialD",{{.*}}flags: 
{{.*}}DIFlagTrivial
+// CHECK-DAG:   {{.*}}!DIGlobalVariable(name: "TrivialD",
+// CHECK-DAG-NEXT:  {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct NT {
   NT() {};
 };
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -3034,10 +3034,8 @@
 else
   Flags |= llvm::DINode::FlagTypePassByValue;
 
-// Record if a C++ record is trivial type.
-if (CXXRD->isTrivial())
-  Flags |= llvm::DINode::FlagTrivial;
-else
+// Record if a C++ record is non-trivial type.
+if (!CXXRD->isTrivial())
   Flags |= llvm::DINode::FlagNonTrivial;
   }
 


Index: test/CodeGenCXX/debug-info-composite-triviality.cpp
===
--- test/CodeGenCXX/debug-info-composite-triviality.cpp
+++ test/CodeGenCXX/debug-info-composite-triviality.cpp
@@ -25,34 +25,40 @@
 
 // Cases to test composite type's triviality
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "Union",{{.*}}flags: {{.*}}DIFlagTrivial
+// CHECK-DAG:  {{.*}}!DIGlobalVariable(name: "Union",
+// CHECK-DAG-NEXT: {{^((?!\bDIFlagNonTrivial\b).)*$}}
 union Union {
   int a;
 } Union;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "Trivial",{{.*}}flags: {{.*}}DIFlagTrivial
+// CHECK-DAG:  {{.*}}!DIGlobalVariable(name: "Trivial",
+// CHECK-DAG-NEXT: {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct Trivial {
   int i;
 } Trivial;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialA",{{.*}}flags: {{.*}}DIFlagTrivial
+// CHECK-DAG:   {{.*}}!DIGlobalVariable(name: "TrivialA",
+// CHECK-DAG-NEXT:  {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct TrivialA {
   TrivialA() = default;
 } TrivialA;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialB",{{.*}}flags: {{.*}}DIFlagTrivial
+// CHECK-DAG:   {{.*}}!DIGlobalVariable(name: "TrivialB",
+// CHECK-DAG-NEXT:  {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct TrivialB {
   int m;
   TrivialB(int x) { m = x; }
   TrivialB() = default;
 } TrivialB;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialC",{{.*}}flags: {{.*}}DIFlagTrivial
+// CHECK-DAG:   {{.*}}!DIGlobalVariable(name: "TrivialC",
+// CHECK-DAG-NEXT:  {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct TrivialC {
   struct Trivial x;
 } TrivialC;
 
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialD",{{.*}}flags: {{.*}}DIFlagTrivial
+// CHECK-DAG:   {{.*}}!DIGlobalVariable(name: "TrivialD",
+// CHECK-DAG-NEXT:  {{^((?!\bDIFlagNonTrivial\b).)*$}}
 struct NT {
   NT() {};
 };
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -3034,10 +3034,8 @@
 else
   Flags |= llvm::DINode::FlagTypePassByValue;
 
-// Record if a C++ record is trivial type.
-if (CXXRD->isTrivial())
-  Flags |= llvm::DINode::FlagTrivial;
-else
+// Record if a C++ record is non-trivial type.
+if (!CXXRD->isTrivial())
   Flags |= 

[PATCH] D59347: [DebugInfo] Combine Trivial and NonTrivial flags

2019-03-26 Thread Aaron Smith via Phabricator via cfe-commits
asmith added a comment.

Okay if we change the flag then I believe the tests under 
llvm/tests/lib/DebugInfo/CodeView must be updated. If we use NonTrivial all the 
existing tests work as expected.

LLVM change is here (you are all reviewers).
https://reviews.llvm.org/D59348


Repository:
  rC Clang

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

https://reviews.llvm.org/D59347



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


[PATCH] D59347: [DebugInfo] Combine Trivial and NonTrivial flags

2019-03-25 Thread Aaron Smith via Phabricator via cfe-commits
asmith added a comment.

Either way. It was fewer changes to use FlagNonTrivial. Which flag do people 
want to keep?


Repository:
  rC Clang

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

https://reviews.llvm.org/D59347



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


[PATCH] D59347: [DebugInfo] Combine Trivial and NonTrivial flags

2019-03-13 Thread Aaron Smith via Phabricator via cfe-commits
asmith created this revision.
asmith added reviewers: rnk, zturner, dblaikie, probinson.
Herald added subscribers: cfe-commits, jdoerfert, aprantl.
Herald added a project: clang.

These flags are used when emitting debug info and needed to initialize 
subprogram and member function attributes (function options) for Codeview. 
These function options are used to create an accurate compiler type for UDT 
symbols (class/struct/union) from PDBs.

The Trivial flag was introduced in https://reviews.llvm.org/D45122

It's been pointed out that Trivial and NonTrivial may imply each other and that 
seems to be the case in the current tests. This change combines them into a 
single flag -- NonTrivial -- and updates the corresponding unit tests. There is 
an additional change to llvm to update the flags.


Repository:
  rC Clang

https://reviews.llvm.org/D59347

Files:
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGenCXX/debug-info-composite-triviality.cpp


Index: test/CodeGenCXX/debug-info-composite-triviality.cpp
===
--- test/CodeGenCXX/debug-info-composite-triviality.cpp
+++ test/CodeGenCXX/debug-info-composite-triviality.cpp
@@ -23,44 +23,6 @@
 // CHECK-DAG: !DIGlobalVariable(name: "GlobalVar", {{.*}}type: {{.*}}, 
isLocal: false, isDefinition: true)
 int GlobalVar = 0;
 
-// Cases to test composite type's triviality
-
-// CHECK-DAG: !DICompositeType({{.*}}, name: "Union",{{.*}}flags: 
{{.*}}DIFlagTrivial
-union Union {
-  int a;
-} Union;
-
-// CHECK-DAG: !DICompositeType({{.*}}, name: "Trivial",{{.*}}flags: 
{{.*}}DIFlagTrivial
-struct Trivial {
-  int i;
-} Trivial;
-
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialA",{{.*}}flags: 
{{.*}}DIFlagTrivial
-struct TrivialA {
-  TrivialA() = default;
-} TrivialA;
-
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialB",{{.*}}flags: 
{{.*}}DIFlagTrivial
-struct TrivialB {
-  int m;
-  TrivialB(int x) { m = x; }
-  TrivialB() = default;
-} TrivialB;
-
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialC",{{.*}}flags: 
{{.*}}DIFlagTrivial
-struct TrivialC {
-  struct Trivial x;
-} TrivialC;
-
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialD",{{.*}}flags: 
{{.*}}DIFlagTrivial
-struct NT {
-  NT() {};
-};
-struct TrivialD {
-  static struct NT x; // Member is non-trivial but is static.
-} TrivialD;
-
-
 // CHECK-DAG: !DICompositeType({{.*}}, name: "NonTrivial",{{.*}}flags: 
{{.*}}DIFlagNonTrivial
 struct NonTrivial {
   NonTrivial() {}
@@ -84,7 +46,3 @@
 // CHECK-DAG: !DICompositeType({{.*}}, name: "NonTrivialD",{{.*}}flags: 
{{.*}}DIFlagNonTrivial
 struct NonTrivialD : NonTrivial {
 } NonTrivialD;
-
-// CHECK-DAG: !DICompositeType({{.*}}, name: "NonTrivialE",{{.*}}flags: 
{{.*}}DIFlagNonTrivial
-struct NonTrivialE : Trivial, NonTrivial {
-} NonTrivialE;
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -3034,10 +3034,8 @@
 else
   Flags |= llvm::DINode::FlagTypePassByValue;
 
-// Record if a C++ record is trivial type.
-if (CXXRD->isTrivial())
-  Flags |= llvm::DINode::FlagTrivial;
-else
+// Record if a C++ record is non-trivial type.
+if (!CXXRD->isTrivial())
   Flags |= llvm::DINode::FlagNonTrivial;
   }
 


Index: test/CodeGenCXX/debug-info-composite-triviality.cpp
===
--- test/CodeGenCXX/debug-info-composite-triviality.cpp
+++ test/CodeGenCXX/debug-info-composite-triviality.cpp
@@ -23,44 +23,6 @@
 // CHECK-DAG: !DIGlobalVariable(name: "GlobalVar", {{.*}}type: {{.*}}, isLocal: false, isDefinition: true)
 int GlobalVar = 0;
 
-// Cases to test composite type's triviality
-
-// CHECK-DAG: !DICompositeType({{.*}}, name: "Union",{{.*}}flags: {{.*}}DIFlagTrivial
-union Union {
-  int a;
-} Union;
-
-// CHECK-DAG: !DICompositeType({{.*}}, name: "Trivial",{{.*}}flags: {{.*}}DIFlagTrivial
-struct Trivial {
-  int i;
-} Trivial;
-
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialA",{{.*}}flags: {{.*}}DIFlagTrivial
-struct TrivialA {
-  TrivialA() = default;
-} TrivialA;
-
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialB",{{.*}}flags: {{.*}}DIFlagTrivial
-struct TrivialB {
-  int m;
-  TrivialB(int x) { m = x; }
-  TrivialB() = default;
-} TrivialB;
-
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialC",{{.*}}flags: {{.*}}DIFlagTrivial
-struct TrivialC {
-  struct Trivial x;
-} TrivialC;
-
-// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialD",{{.*}}flags: {{.*}}DIFlagTrivial
-struct NT {
-  NT() {};
-};
-struct TrivialD {
-  static struct NT x; // Member is non-trivial but is static.
-} TrivialD;
-
-
 // CHECK-DAG: !DICompositeType({{.*}}, name: "NonTrivial",{{.*}}flags: {{.*}}DIFlagNonTrivial
 struct NonTrivial {
   NonTrivial() {}
@@ -84,7 +46,3 @@
 // CHECK-DAG: !DICompositeType({{.*}}, name: "NonTrivialD",{{.*}}flags: {{.*}}DIFlagNonTrivial
 struct NonTrivialD : 

[PATCH] D59010: [DebugInfo] Add test cases for FlagNonTrivial

2019-03-11 Thread Aaron Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC355890: [DebugInfo] Add test cases for FlagNonTrivial 
(authored by asmith, committed by ).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

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

https://reviews.llvm.org/D59010

Files:
  test/CodeGenCXX/debug-info-composite-triviality.cpp


Index: test/CodeGenCXX/debug-info-composite-triviality.cpp
===
--- test/CodeGenCXX/debug-info-composite-triviality.cpp
+++ test/CodeGenCXX/debug-info-composite-triviality.cpp
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -triple 
%itanium_abi_triple %s -o - | FileCheck %s
+
+// Cases to show some non-trivial types with flags combined with 
DIFlagNonTrivial and DIFlagTypePassByValue.
+
+// CHECK-DAG: !DICompositeType({{.*}}, name: "Explicit",{{.*}}flags: 
DIFlagTypePassByValue | DIFlagNonTrivial
+struct Explicit {
+  explicit Explicit();
+  int a;
+} Explicit;
+
+// CHECK-DAG: !DICompositeType({{.*}}, name: "Struct",{{.*}}flags: 
DIFlagTypePassByValue | DIFlagNonTrivial
+struct Struct {
+  Struct() {}
+} Struct;
+
+// CHECK-DAG: !DICompositeType({{.*}}, name: "Annotated",{{.*}}flags: 
DIFlagTypePassByValue | DIFlagNonTrivial
+struct __attribute__((trivial_abi)) Annotated {
+  Annotated() {};
+} Annotated;
+
+
+// Check a non-composite type
+// CHECK-DAG: !DIGlobalVariable(name: "GlobalVar", {{.*}}type: {{.*}}, 
isLocal: false, isDefinition: true)
+int GlobalVar = 0;
+
+// Cases to test composite type's triviality
+
+// CHECK-DAG: !DICompositeType({{.*}}, name: "Union",{{.*}}flags: 
{{.*}}DIFlagTrivial
+union Union {
+  int a;
+} Union;
+
+// CHECK-DAG: !DICompositeType({{.*}}, name: "Trivial",{{.*}}flags: 
{{.*}}DIFlagTrivial
+struct Trivial {
+  int i;
+} Trivial;
+
+// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialA",{{.*}}flags: 
{{.*}}DIFlagTrivial
+struct TrivialA {
+  TrivialA() = default;
+} TrivialA;
+
+// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialB",{{.*}}flags: 
{{.*}}DIFlagTrivial
+struct TrivialB {
+  int m;
+  TrivialB(int x) { m = x; }
+  TrivialB() = default;
+} TrivialB;
+
+// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialC",{{.*}}flags: 
{{.*}}DIFlagTrivial
+struct TrivialC {
+  struct Trivial x;
+} TrivialC;
+
+// CHECK-DAG: !DICompositeType({{.*}}, name: "TrivialD",{{.*}}flags: 
{{.*}}DIFlagTrivial
+struct NT {
+  NT() {};
+};
+struct TrivialD {
+  static struct NT x; // Member is non-trivial but is static.
+} TrivialD;
+
+
+// CHECK-DAG: !DICompositeType({{.*}}, name: "NonTrivial",{{.*}}flags: 
{{.*}}DIFlagNonTrivial
+struct NonTrivial {
+  NonTrivial() {}
+} NonTrivial;
+
+// CHECK-DAG: !DICompositeType({{.*}}, name: "NonTrivialA",{{.*}}flags: 
{{.*}}DIFlagNonTrivial
+struct NonTrivialA {
+  ~NonTrivialA();
+} NonTrivialA;
+
+// CHECK-DAG: !DICompositeType({{.*}}, name: "NonTrivialB",{{.*}}flags: 
{{.*}}DIFlagNonTrivial
+struct NonTrivialB {
+  struct NonTrivial x;
+} NonTrivialB;
+
+// CHECK-DAG: !DICompositeType({{.*}}, name: "NonTrivialC",{{.*}}flags: 
{{.*}}DIFlagNonTrivial
+struct NonTrivialC {
+  virtual void f() {}
+} NonTrivialC;
+
+// CHECK-DAG: !DICompositeType({{.*}}, name: "NonTrivialD",{{.*}}flags: 
{{.*}}DIFlagNonTrivial
+struct NonTrivialD : NonTrivial {
+} NonTrivialD;
+
+// CHECK-DAG: !DICompositeType({{.*}}, name: "NonTrivialE",{{.*}}flags: 
{{.*}}DIFlagNonTrivial
+struct NonTrivialE : Trivial, NonTrivial {
+} NonTrivialE;


Index: test/CodeGenCXX/debug-info-composite-triviality.cpp
===
--- test/CodeGenCXX/debug-info-composite-triviality.cpp
+++ test/CodeGenCXX/debug-info-composite-triviality.cpp
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -triple %itanium_abi_triple %s -o - | FileCheck %s
+
+// Cases to show some non-trivial types with flags combined with DIFlagNonTrivial and DIFlagTypePassByValue.
+
+// CHECK-DAG: !DICompositeType({{.*}}, name: "Explicit",{{.*}}flags: DIFlagTypePassByValue | DIFlagNonTrivial
+struct Explicit {
+  explicit Explicit();
+  int a;
+} Explicit;
+
+// CHECK-DAG: !DICompositeType({{.*}}, name: "Struct",{{.*}}flags: DIFlagTypePassByValue | DIFlagNonTrivial
+struct Struct {
+  Struct() {}
+} Struct;
+
+// CHECK-DAG: !DICompositeType({{.*}}, name: "Annotated",{{.*}}flags: DIFlagTypePassByValue | DIFlagNonTrivial
+struct __attribute__((trivial_abi)) Annotated {
+  Annotated() {};
+} Annotated;
+
+
+// Check a non-composite type
+// CHECK-DAG: !DIGlobalVariable(name: "GlobalVar", {{.*}}type: {{.*}}, isLocal: false, isDefinition: true)
+int GlobalVar = 0;
+
+// Cases to test composite type's triviality
+
+// CHECK-DAG: !DICompositeType({{.*}}, name: "Union",{{.*}}flags: {{.*}}DIFlagTrivial
+union Union {
+  int a;
+} Union;
+
+// CHECK-DAG: !DICompositeType({{.*}}, name: "Trivial",{{.*}}flags: 

[PATCH] D45124: [CodeGen] Record if a C++ record is a trivial type

2018-07-23 Thread Aaron Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC337736: [CodeGen] Record if a C++ record is a trivial type 
(authored by asmith, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D45124

Files:
  lib/CodeGen/CGDebugInfo.cpp


Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -2908,6 +2908,10 @@
   Flags |= llvm::DINode::FlagTypePassByReference;
 else
   Flags |= llvm::DINode::FlagTypePassByValue;
+
+// Record if a C++ record is trivial type.
+if (CXXRD->isTrivial())
+  Flags |= llvm::DINode::FlagTrivial;
   }
 
   llvm::DICompositeType *RealDecl = DBuilder.createReplaceableCompositeType(


Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -2908,6 +2908,10 @@
   Flags |= llvm::DINode::FlagTypePassByReference;
 else
   Flags |= llvm::DINode::FlagTypePassByValue;
+
+// Record if a C++ record is trivial type.
+if (CXXRD->isTrivial())
+  Flags |= llvm::DINode::FlagTrivial;
   }
 
   llvm::DICompositeType *RealDecl = DBuilder.createReplaceableCompositeType(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45124: [CodeGen] Record if a C++ record is a trivial type when emitting Codeview

2018-07-20 Thread Aaron Smith via Phabricator via cfe-commits
asmith updated this revision to Diff 156664.

https://reviews.llvm.org/D45124

Files:
  lib/CodeGen/CGDebugInfo.cpp


Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -2847,6 +2847,10 @@
   Flags |= llvm::DINode::FlagTypePassByReference;
 else
   Flags |= llvm::DINode::FlagTypePassByValue;
+
+// Record if a C++ record is trivial type.
+if (CXXRD->isTrivial())
+  Flags |= llvm::DINode::FlagTrivial;
   }
 
   llvm::DICompositeType *RealDecl = DBuilder.createReplaceableCompositeType(


Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -2847,6 +2847,10 @@
   Flags |= llvm::DINode::FlagTypePassByReference;
 else
   Flags |= llvm::DINode::FlagTypePassByValue;
+
+// Record if a C++ record is trivial type.
+if (CXXRD->isTrivial())
+  Flags |= llvm::DINode::FlagTrivial;
   }
 
   llvm::DICompositeType *RealDecl = DBuilder.createReplaceableCompositeType(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45124: [CodeGen] Record if a C++ record is a trivial type when emitting Codeview

2018-07-16 Thread Aaron Smith via Phabricator via cfe-commits
asmith added a reviewer: aleksandr.urakov.
asmith added a comment.

Adding Aleksandr


Repository:
  rC Clang

https://reviews.llvm.org/D45124



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


[PATCH] D45124: [CodeGen] Record if a C++ record is trivial type when emitting Codeview

2018-03-31 Thread Aaron Smith via Phabricator via cfe-commits
asmith created this revision.
asmith added reviewers: rnk, zturner, llvm-commits.
Herald added a subscriber: cfe-commits.

This has a dependence on https://reviews.llvm.org/D45122


Repository:
  rC Clang

https://reviews.llvm.org/D45124

Files:
  CodeGen/CGDebugInfo.cpp


Index: CodeGen/CGDebugInfo.cpp
===
--- CodeGen/CGDebugInfo.cpp
+++ CodeGen/CGDebugInfo.cpp
@@ -2838,6 +2838,12 @@
   Flags |= llvm::DINode::FlagTypePassByReference;
 else
   Flags |= llvm::DINode::FlagTypePassByValue;
+
+// When emitting codeview, record if a C++ record is trivial type.
+if (CGM.getCodeGenOpts().EmitCodeView) {
+  if (CXXRD->isTrivial())
+Flags |= llvm::DINode::FlagTrivial;
+}
   }
 
   llvm::DICompositeType *RealDecl = DBuilder.createReplaceableCompositeType(


Index: CodeGen/CGDebugInfo.cpp
===
--- CodeGen/CGDebugInfo.cpp
+++ CodeGen/CGDebugInfo.cpp
@@ -2838,6 +2838,12 @@
   Flags |= llvm::DINode::FlagTypePassByReference;
 else
   Flags |= llvm::DINode::FlagTypePassByValue;
+
+// When emitting codeview, record if a C++ record is trivial type.
+if (CGM.getCodeGenOpts().EmitCodeView) {
+  if (CXXRD->isTrivial())
+Flags |= llvm::DINode::FlagTrivial;
+}
   }
 
   llvm::DICompositeType *RealDecl = DBuilder.createReplaceableCompositeType(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44581: [Driver] Fix the descriptions for -Tdata and -Ttext options

2018-03-17 Thread Aaron Smith via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rC327775: [Driver] Fix the descriptions for -Tdata and -Ttext 
options (authored by asmith, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D44581

Files:
  include/clang/Driver/Options.td


Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -418,9 +418,9 @@
 def Tbss : JoinedOrSeparate<["-"], "Tbss">, Group,
   MetaVarName<"">, HelpText<"Set starting address of BSS to ">;
 def Tdata : JoinedOrSeparate<["-"], "Tdata">, Group,
-  MetaVarName<"">, HelpText<"Set starting address of BSS to ">;
+  MetaVarName<"">, HelpText<"Set starting address of DATA to ">;
 def Ttext : JoinedOrSeparate<["-"], "Ttext">, Group,
-  MetaVarName<"">, HelpText<"Set starting address of BSS to ">;
+  MetaVarName<"">, HelpText<"Set starting address of TEXT to ">;
 def T : JoinedOrSeparate<["-"], "T">, Group,
   

[PATCH] D44581: [Driver] Fix the descriptions for -Tdata and -Ttext options

2018-03-16 Thread Aaron Smith via Phabricator via cfe-commits
asmith created this revision.
asmith added a reviewer: llvm-commits.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D44581

Files:
  include/clang/Driver/Options.td


Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -418,9 +418,9 @@
 def Tbss : JoinedOrSeparate<["-"], "Tbss">, Group,
   MetaVarName<"">, HelpText<"Set starting address of BSS to ">;
 def Tdata : JoinedOrSeparate<["-"], "Tdata">, Group,
-  MetaVarName<"">, HelpText<"Set starting address of BSS to ">;
+  MetaVarName<"">, HelpText<"Set starting address of DATA to ">;
 def Ttext : JoinedOrSeparate<["-"], "Ttext">, Group,
-  MetaVarName<"">, HelpText<"Set starting address of BSS to ">;
+  MetaVarName<"">, HelpText<"Set starting address of TEXT to ">;
 def T : JoinedOrSeparate<["-"], "T">, Group,
   

[PATCH] D43164: Fix test clang-diff-json.cpp

2018-02-10 Thread Aaron Smith via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rC324824: Fix test clang-diff-json.cpp (authored by asmith, 
committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D43164

Files:
  test/Tooling/clang-diff-json.cpp


Index: test/Tooling/clang-diff-json.cpp
===
--- test/Tooling/clang-diff-json.cpp
+++ test/Tooling/clang-diff-json.cpp
@@ -1,10 +1,10 @@
 // RUN: clang-diff -ast-dump-json %s -- \
-// RUN: | %python -c 'import json, sys; 
json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
+// RUN: | '%python' -c 'import json, sys; 
json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
 // RUN: | FileCheck %s
 
-// CHECK: "begin": 299,
+// CHECK: "begin": 301,
 // CHECK: "type": "FieldDecl",
-// CHECK: "end": 319,
+// CHECK: "end": 321,
 // CHECK: "type": "CXXRecordDecl",
 class A {
   int x;


Index: test/Tooling/clang-diff-json.cpp
===
--- test/Tooling/clang-diff-json.cpp
+++ test/Tooling/clang-diff-json.cpp
@@ -1,10 +1,10 @@
 // RUN: clang-diff -ast-dump-json %s -- \
-// RUN: | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
+// RUN: | '%python' -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
 // RUN: | FileCheck %s
 
-// CHECK: "begin": 299,
+// CHECK: "begin": 301,
 // CHECK: "type": "FieldDecl",
-// CHECK: "end": 319,
+// CHECK: "end": 321,
 // CHECK: "type": "CXXRecordDecl",
 class A {
   int x;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43164: Fix test from failing when the python path has spaces

2018-02-10 Thread Aaron Smith via Phabricator via cfe-commits
asmith created this revision.
asmith added reviewers: zturner, llvm-commits.
Herald added subscribers: cfe-commits, klimek.

This test would fail if the python path had spaces. Add a quote around the path 
to fix this problem and update some test values changed by the addition of 
quotes around the path.

Tested on Windows and Linux with Python 3.x


Repository:
  rC Clang

https://reviews.llvm.org/D43164

Files:
  test/Tooling/clang-diff-json.cpp


Index: test/Tooling/clang-diff-json.cpp
===
--- test/Tooling/clang-diff-json.cpp
+++ test/Tooling/clang-diff-json.cpp
@@ -1,10 +1,10 @@
 // RUN: clang-diff -ast-dump-json %s -- \
-// RUN: | %python -c 'import json, sys; 
json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
+// RUN: | '%python' -c 'import json, sys; 
json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
 // RUN: | FileCheck %s
 
-// CHECK: "begin": 299,
+// CHECK: "begin": 301,
 // CHECK: "type": "FieldDecl",
-// CHECK: "end": 319,
+// CHECK: "end": 321,
 // CHECK: "type": "CXXRecordDecl",
 class A {
   int x;


Index: test/Tooling/clang-diff-json.cpp
===
--- test/Tooling/clang-diff-json.cpp
+++ test/Tooling/clang-diff-json.cpp
@@ -1,10 +1,10 @@
 // RUN: clang-diff -ast-dump-json %s -- \
-// RUN: | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
+// RUN: | '%python' -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
 // RUN: | FileCheck %s
 
-// CHECK: "begin": 299,
+// CHECK: "begin": 301,
 // CHECK: "type": "FieldDecl",
-// CHECK: "end": 319,
+// CHECK: "end": 321,
 // CHECK: "type": "CXXRecordDecl",
 class A {
   int x;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits