[PATCH] D60455: [SYCL] Add support for SYCL device attributes

2019-04-27 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

I think potentially reusing OpenCL features is desirable since the device code 
of SYCL is largely OpenCL. However I don't think we are clear enough about the 
overall device compilation flow of SYCL and I can easily suggest a number of 
different approaches including those that don't modify compiler at all. :)  I 
am afraid until we have the big picture clear it will be hard to make any 
sensible decisions.

I have created an issue about it earlier

https://github.com/intel/llvm/issues/59

and I am going to add some more comments there to explain what we should 
elaborate and agree on.

I suggest we finalize the big picture in the following weeks first and then we 
can go ahead with the detailed work in the reviews.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


[PATCH] D61222: [clang-format] Fix bug in determineTokenType() for TT_StartOfName

2019-04-27 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: klimek, MyDeveloperDay, sammccall, krasimir, djasper.
owenpan added a project: clang.
Herald added a subscriber: cfe-commits.

This patch fixes PR37175 .


Repository:
  rC Clang

https://reviews.llvm.org/D61222

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10575,6 +10575,13 @@
"  unsigned c;\n"
"}",
Alignment);
+
+  // See PR37175
+  FormatStyle Style = getMozillaStyle();
+  Style.AlignConsecutiveDeclarations = true;
+  EXPECT_EQ("DECOR1 DECOR2 uint32_t\n"
+"f1(int arg1, int arg2);",
+format("DECOR1 DECOR2 uint32_t f1 (int arg1, int arg2);", Style));
 }
 
 TEST_F(FormatTest, LinuxBraceBreaking) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1350,8 +1350,14 @@
   Current.Type = TT_BinaryOperator;
 } else if (isStartOfName(Current) &&
(!Line.MightBeFunctionDecl || Current.NestingLevel != 0)) {
-  Contexts.back().FirstStartOfName = &Current;
-  Current.Type = TT_StartOfName;
+  const FormatToken *Next = Current.Next;
+  bool NonMacroIdentifier =
+  Next && Next->Tok.getIdentifierInfo() &&
+  Next->TokenText != Next->TokenText.upper();
+  if (!NonMacroIdentifier) {
+Contexts.back().FirstStartOfName = &Current;
+Current.Type = TT_StartOfName;
+  }
 } else if (Current.is(tok::semi)) {
   // Reset FirstStartOfName after finding a semicolon so that a for loop
   // with multiple increment statements is not confused with a for loop


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10575,6 +10575,13 @@
"  unsigned c;\n"
"}",
Alignment);
+
+  // See PR37175
+  FormatStyle Style = getMozillaStyle();
+  Style.AlignConsecutiveDeclarations = true;
+  EXPECT_EQ("DECOR1 DECOR2 uint32_t\n"
+"f1(int arg1, int arg2);",
+format("DECOR1 DECOR2 uint32_t f1 (int arg1, int arg2);", Style));
 }
 
 TEST_F(FormatTest, LinuxBraceBreaking) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1350,8 +1350,14 @@
   Current.Type = TT_BinaryOperator;
 } else if (isStartOfName(Current) &&
(!Line.MightBeFunctionDecl || Current.NestingLevel != 0)) {
-  Contexts.back().FirstStartOfName = &Current;
-  Current.Type = TT_StartOfName;
+  const FormatToken *Next = Current.Next;
+  bool NonMacroIdentifier =
+  Next && Next->Tok.getIdentifierInfo() &&
+  Next->TokenText != Next->TokenText.upper();
+  if (!NonMacroIdentifier) {
+Contexts.back().FirstStartOfName = &Current;
+Current.Type = TT_StartOfName;
+  }
 } else if (Current.is(tok::semi)) {
   // Reset FirstStartOfName after finding a semicolon so that a for loop
   // with multiple increment statements is not confused with a for loop
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58573: [analyzer] Move UninitializedObjectChecker out of alpha

2019-04-27 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

I took the liberty to add that in the release notes of clang
https://reviews.llvm.org/rG5f163c7e2e62


Repository:
  rC Clang

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

https://reviews.llvm.org/D58573



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


[PATCH] D59485: [ASTImporter] Add an ImportImpl method to allow customizing Import behavior.

2019-04-27 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor updated this revision to Diff 196955.
teemperor retitled this revision from "[ASTImporter] Add an ImportInternal 
method to allow customizing Import behavior." to "[ASTImporter] Add an 
ImportImpl method to allow customizing Import behavior.".
teemperor edited the summary of this revision.
teemperor added a comment.

- Added `RegisterImportedDecl` call as suggested in D59537 

- Added an assert that checks that we register any decl that an overwritten 
ImportInternal would create.
- Fixed the tests that they no longer trigger that new assert.


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

https://reviews.llvm.org/D59485

Files:
  clang/include/clang/AST/ASTImporter.h
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -313,6 +313,14 @@
   const char *const InputFileName = "input.cc";
   const char *const OutputFileName = "output.cc";
 
+public:
+  /// Allocates an ASTImporter (or one of its subclasses).
+  typedef std::function
+  ImporterConstructor;
+
+private:
   // Buffer for the To context, must live in the test scope.
   std::string ToCode;
 
@@ -325,22 +333,33 @@
 std::unique_ptr Unit;
 TranslationUnitDecl *TUDecl = nullptr;
 std::unique_ptr Importer;
-TU(StringRef Code, StringRef FileName, ArgVector Args)
+// The lambda that constructs the ASTImporter we use in this test.
+ImporterConstructor Creator;
+TU(StringRef Code, StringRef FileName, ArgVector Args,
+   ImporterConstructor C = ImporterConstructor())
 : Code(Code), FileName(FileName),
   Unit(tooling::buildASTFromCodeWithArgs(this->Code, Args,
  this->FileName)),
-  TUDecl(Unit->getASTContext().getTranslationUnitDecl()) {
+  TUDecl(Unit->getASTContext().getTranslationUnitDecl()), Creator(C) {
   Unit->enableSourceFileDiagnostics();
+
+  // If the test doesn't need a specific ASTImporter, we just create a
+  // normal ASTImporter with it.
+  if (!Creator)
+Creator = [](ASTContext &ToContext, FileManager &ToFileManager,
+ ASTContext &FromContext, FileManager &FromFileManager,
+ bool MinimalImport, ASTImporterLookupTable *LookupTable) {
+  return new ASTImporter(ToContext, ToFileManager, FromContext,
+ FromFileManager, MinimalImport, LookupTable);
+};
 }
 
 void lazyInitImporter(ASTImporterLookupTable &LookupTable, ASTUnit *ToAST) {
   assert(ToAST);
-  if (!Importer) {
-Importer.reset(
-new ASTImporter(ToAST->getASTContext(), ToAST->getFileManager(),
-Unit->getASTContext(), Unit->getFileManager(),
-false, &LookupTable));
-  }
+  if (!Importer)
+Importer.reset(Creator(ToAST->getASTContext(), ToAST->getFileManager(),
+   Unit->getASTContext(), Unit->getFileManager(),
+   false, &LookupTable));
   assert(&ToAST->getASTContext() == &Importer->getToContext());
   createVirtualFileIfNeeded(ToAST, FileName, Code);
 }
@@ -420,11 +439,12 @@
   // Must not be called more than once within the same test.
   std::tuple
   getImportedDecl(StringRef FromSrcCode, Language FromLang, StringRef ToSrcCode,
-  Language ToLang, StringRef Identifier = DeclToImportID) {
+  Language ToLang, StringRef Identifier = DeclToImportID,
+  ImporterConstructor Creator = ImporterConstructor()) {
 ArgVector FromArgs = getArgVectorForLanguage(FromLang),
   ToArgs = getArgVectorForLanguage(ToLang);
 
-FromTUs.emplace_back(FromSrcCode, InputFileName, FromArgs);
+FromTUs.emplace_back(FromSrcCode, InputFileName, FromArgs, Creator);
 TU &FromTU = FromTUs.back();
 
 assert(!ToAST);
@@ -562,6 +582,75 @@
   EXPECT_THAT(RedeclsD1, ::testing::ContainerEq(RedeclsD2));
 }
 
+struct CustomImporter : ASTImporterOptionSpecificTestBase {};
+
+namespace {
+struct RedirectingImporter : public ASTImporter {
+  using ASTImporter::ASTImporter;
+  // ImporterConstructor that constructs this class.
+  static ASTImporterOptionSpecificTestBase::ImporterConstructor Constructor;
+
+protected:
+  llvm::Expected ImportImpl(Decl *FromD) override {
+auto *ND = dyn_cast(FromD);
+if (!ND || ND->getName() != "shouldNotBeImported")
+  return ASTImporter::ImportImpl(FromD);
+for (Decl *D : getToContext().getTranslationUnitDecl()->decls()) {
+  if (auto *ND = dyn_cast(D))
+if (ND->getName() == "realDecl") {
+  RegisterImportedDecl(FromD, ND);
+  return ND;
+}
+}
+return ASTImporter::ImportImpl(Fr

Re: r359361 - Revert Fix interactions between __builtin_constant_p and constexpr to match current trunk GCC.

2019-04-27 Thread Roman Lebedev via cfe-commits
On Sat, Apr 27, 2019 at 3:29 AM Jorge Gorbe Moya via cfe-commits
 wrote:
>
> Author: jgorbe
> Date: Fri Apr 26 17:32:04 2019
> New Revision: 359361
>
> URL: http://llvm.org/viewvc/llvm-project?rev=359361&view=rev
> Log:
> Revert Fix interactions between __builtin_constant_p and constexpr to match 
> current trunk GCC.
>
> This reverts r359059 (git commit 0b098754b73f3b96d00ecb1c7605760b11c90298)
It is common to specify the *reason* for the revert, so it is recorded
in change log.

> Removed:
> cfe/trunk/test/SemaCXX/builtin-constant-p.cpp
> Modified:
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/lib/Sema/SemaChecking.cpp
> cfe/trunk/test/SemaCXX/enable_if.cpp
>
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=359361&r1=359360&r2=359361&view=diff
> ==
> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> +++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Apr 26 17:32:04 2019
> @@ -7801,33 +7801,19 @@ EvaluateBuiltinClassifyType(const CallEx
>  }
>
>  /// EvaluateBuiltinConstantPForLValue - Determine the result of
> -/// __builtin_constant_p when applied to the given pointer.
> +/// __builtin_constant_p when applied to the given lvalue.
>  ///
> -/// A pointer is only "constant" if it is null (or a pointer cast to integer)
> -/// or it points to the first character of a string literal.
> -static bool EvaluateBuiltinConstantPForLValue(const APValue &LV) {
> -  APValue::LValueBase Base = LV.getLValueBase();
> -  if (Base.isNull()) {
> -// A null base is acceptable.
> -return true;
> -  } else if (const Expr *E = Base.dyn_cast()) {
> -if (!isa(E))
> -  return false;
> -return LV.getLValueOffset().isZero();
> -  } else {
> -// Any other base is not constant enough for GCC.
> -return false;
> -  }
> +/// An lvalue is only "constant" if it is a pointer or reference to the first
> +/// character of a string literal.
> +template
> +static bool EvaluateBuiltinConstantPForLValue(const LValue &LV) {
> +  const Expr *E = LV.getLValueBase().template dyn_cast();
> +  return E && isa(E) && LV.getLValueOffset().isZero();
>  }
>
>  /// EvaluateBuiltinConstantP - Evaluate __builtin_constant_p as similarly to
>  /// GCC as we can manage.
> -static bool EvaluateBuiltinConstantP(EvalInfo &Info, const Expr *Arg) {
> -  // Constant-folding is always enabled for the operand of 
> __builtin_constant_p
> -  // (even when the enclosing evaluation context otherwise requires a strict
> -  // language-specific constant expression).
> -  FoldConstant Fold(Info, true);
> -
> +static bool EvaluateBuiltinConstantP(ASTContext &Ctx, const Expr *Arg) {
>QualType ArgType = Arg->getType();
>
>// __builtin_constant_p always has one operand. The rules which gcc follows
> @@ -7835,27 +7821,34 @@ static bool EvaluateBuiltinConstantP(Eva
>//
>//  - If the operand is of integral, floating, complex or enumeration type,
>//and can be folded to a known value of that type, it returns 1.
> -  //  - If the operand can be folded to a pointer to the first character
> -  //of a string literal (or such a pointer cast to an integral type)
> -  //or to a null pointer or an integer cast to a pointer, it returns 1.
> +  //  - If the operand and can be folded to a pointer to the first character
> +  //of a string literal (or such a pointer cast to an integral type), it
> +  //returns 1.
>//
>// Otherwise, it returns 0.
>//
>// FIXME: GCC also intends to return 1 for literals of aggregate types, but
>// its support for this does not currently work.
> -  if (ArgType->isIntegralOrEnumerationType() || ArgType->isFloatingType() ||
> -  ArgType->isAnyComplexType() || ArgType->isPointerType() ||
> -  ArgType->isNullPtrType()) {
> -APValue V;
> -if (!::EvaluateAsRValue(Info, Arg, V))
> +  if (ArgType->isIntegralOrEnumerationType()) {
> +Expr::EvalResult Result;
> +if (!Arg->EvaluateAsRValue(Result, Ctx) || Result.HasSideEffects)
>return false;
>
> -// For a pointer (possibly cast to integer), there are special rules.
> +APValue &V = Result.Val;
> +if (V.getKind() == APValue::Int)
> +  return true;
>  if (V.getKind() == APValue::LValue)
>return EvaluateBuiltinConstantPForLValue(V);
> -
> -// Otherwise, any constant value is good enough.
> -return V.getKind() != APValue::Uninitialized;
> +  } else if (ArgType->isFloatingType() || ArgType->isAnyComplexType()) {
> +return Arg->isEvaluatable(Ctx);
> +  } else if (ArgType->isPointerType() || Arg->isGLValue()) {
> +LValue LV;
> +Expr::EvalStatus Status;
> +EvalInfo Info(Ctx, Status, EvalInfo::EM_ConstantFold);
> +if ((Arg->isGLValue() ? EvaluateLValue(Arg, LV, Info)
> +  : EvaluatePointer(Arg, LV, Info)) &&
> +!Status.HasSideEffects)
> +  return EvaluateBui

[PATCH] D61209: [clang-tidy] Fix readability-redundant-smartptr-get for MSVC STL

2019-04-27 Thread Florian Gross via Phabricator via cfe-commits
fgross updated this revision to Diff 196960.
fgross added a comment.

Fixed test file format


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

https://reviews.llvm.org/D61209

Files:
  clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
  clang-tools-extra/test/clang-tidy/readability-redundant-smartptr-get-msvc.cpp

Index: clang-tools-extra/test/clang-tidy/readability-redundant-smartptr-get-msvc.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/readability-redundant-smartptr-get-msvc.cpp
@@ -0,0 +1,94 @@
+// RUN: %check_clang_tidy %s readability-redundant-smartptr-get %t
+
+#define NULL __null
+
+namespace std {
+
+// MSVC headers define operator templates instead of plain operators.
+
+template 
+struct unique_ptr {
+  template 
+  T2& operator*() const;
+  template 
+  T2* operator->() const;
+  T* get() const;
+  explicit operator bool() const noexcept;
+};
+
+template 
+struct shared_ptr {
+  template 
+  T2& operator*() const;
+  template 
+  T2* operator->() const;
+  T* get() const;
+  explicit operator bool() const noexcept;
+};
+
+}  // namespace std
+
+struct Bar {
+  void Do();
+  void ConstDo() const;
+};
+
+void Positive() {
+  std::unique_ptr* up;
+  (*up->get()).Do();
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant get() call
+  // CHECK-MESSAGES: (*up->get()).Do();
+  // CHECK-FIXES: (**up).Do();
+
+  std::unique_ptr uu;
+  std::shared_ptr *ss;
+  bool bb = uu.get() == nullptr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: redundant get() call
+  // CHECK-MESSAGES: uu.get() == nullptr;
+  // CHECK-FIXES: bool bb = uu == nullptr;
+
+  if (up->get());
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant get() call
+  // CHECK-MESSAGES: if (up->get());
+  // CHECK-FIXES: if (*up);
+  if ((uu.get()));
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call
+  // CHECK-MESSAGES: if ((uu.get()));
+  // CHECK-FIXES: if ((uu));
+  bb = !ss->get();
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: redundant get() call
+  // CHECK-MESSAGES: bb = !ss->get();
+  // CHECK-FIXES: bb = !*ss;
+
+  bb = nullptr != ss->get();
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: redundant get() call
+  // CHECK-MESSAGES: nullptr != ss->get();
+  // CHECK-FIXES: bb = nullptr != *ss;
+
+  bb = std::unique_ptr().get() == NULL;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call
+  // CHECK-MESSAGES: bb = std::unique_ptr().get() == NULL;
+  // CHECK-FIXES: bb = std::unique_ptr() == NULL;
+  bb = ss->get() == NULL;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call
+  // CHECK-MESSAGES: bb = ss->get() == NULL;
+  // CHECK-FIXES: bb = *ss == NULL;
+
+  std::unique_ptr x, y;
+  if (x.get() == nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant get() call
+  // CHECK-MESSAGES: if (x.get() == nullptr);
+  // CHECK-FIXES: if (x == nullptr);
+  if (nullptr == y.get());
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: redundant get() call
+  // CHECK-MESSAGES: if (nullptr == y.get());
+  // CHECK-FIXES: if (nullptr == y);
+  if (x.get() == NULL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant get() call
+  // CHECK-MESSAGES: if (x.get() == NULL);
+  // CHECK-FIXES: if (x == NULL);
+  if (NULL == x.get());
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: redundant get() call
+  // CHECK-MESSAGES: if (NULL == x.get());
+  // CHECK-FIXES: if (NULL == x);
+}
Index: clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
@@ -30,6 +30,10 @@
   .bind("redundant_get");
 }
 
+internal::Matcher knownSmartptr() {
+  return recordDecl(hasAnyName("::std::unique_ptr", "::std::shared_ptr"));
+}
+
 void registerMatchersForGetArrowStart(MatchFinder *Finder,
   MatchFinder::MatchCallback *Callback) {
   const auto QuacksLikeASmartptr = recordDecl(
@@ -39,21 +43,23 @@
   has(cxxMethodDecl(hasName("operator*"), returns(qualType(references(
   type().bind("op*Type")));
 
+  // Make sure we are not missing the known standard types
+  const auto Smartptr = anyOf(knownSmartptr(), QuacksLikeASmartptr);
+
   // Catch 'ptr.get()->Foo()'
-  Finder->addMatcher(memberExpr(expr().bind("memberExpr"), isArrow(),
-hasObjectExpression(ignoringImpCasts(
-callToGet(QuacksLikeASmartptr,
- Callback);
+  Finder->addMatcher(
+  memberExpr(expr().bind("memberExpr"), isArrow(),
+ hasObjectExpression(ignoringImpCasts(callToGet(Smartptr,
+  Callback);
 
   // Catch '*ptr.get()' or '*ptr->get()'
   Finder->addMatcher(
-  unaryOperator(hasO

[PATCH] D61222: [clang-format] Fix bug in determineTokenType() for TT_StartOfName

2019-04-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D61222



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


[PATCH] D54996: [libclang] Fix clang_Cursor_isAnonymous

2019-04-27 Thread Jorn Vernee via Phabricator via cfe-commits
JornVernee added a comment.
Herald added a project: LLVM.

This seems to have changed the behaviour w.r.t inline struct or union decls in 
fields and global variables e.g.

  struct foo {
  struct {
  int x;
  } bar;
  };

For the StructDecl cursor of 'bar' isAnonymous now returns true, instead of 
false.

I guess this was intended? But we were relying on this behaviour to collect all 
nested elements that were accessible through the parent struct, e.g.

  struct foo {
  struct {
  int x;
  } bar;
  union {
  int y;
  int z;
  };
  };

'y' and 'z' are accessible directly through foo by doing `foo.y` and `foo.z.`, 
but 'x' is not, we have to do `foo.bar.x`. Since isAnonymous now returns true 
for both 'bar' and the 'inlined' anonymous union, there is no easy way to 
differentiate between whether it appears as part of a FieldDecl or not. The 
only alternative is to look up the semantic parent, create a set of all the 
FieldDecl cursors, and then filter by the field's type's declaration cursors. 
(which is kind of 'meh' for usability/performance).

Any alternative to get the old behaviour?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D54996



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


[PATCH] D60748: Fix i386 struct and union parameter alignment

2019-04-27 Thread Wei Xiao via Phabricator via cfe-commits
wxiao3 updated this revision to Diff 196967.
wxiao3 edited the summary of this revision.

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

https://reviews.llvm.org/D60748

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

Index: test/CodeGen/x86_32-arguments-linux.c
===
--- test/CodeGen/x86_32-arguments-linux.c
+++ test/CodeGen/x86_32-arguments-linux.c
@@ -3,21 +3,21 @@
 
 // CHECK-LABEL: define void @f56(
 // CHECK: i8 signext %a0, %struct.s56_0* byval align 4 %a1,
-// CHECK: i64 %a2.coerce, %struct.s56_1* byval align 4,
-// CHECK: <1 x double> %a4, %struct.s56_2* byval align 4,
-// CHECK: <4 x i32> %a6, %struct.s56_3* byval align 4,
-// CHECK: <2 x double> %a8, %struct.s56_4* byval align 4,
-// CHECK: <8 x i32> %a10, %struct.s56_5* byval align 4,
-// CHECK: <4 x double> %a12, %struct.s56_6* byval align 4)
+// CHECK: i64 %a2.coerce, %struct.s56_1* byval align 8 %a3,
+// CHECK: <1 x double> %a4, %struct.s56_2* byval align 8 %a5,
+// CHECK: <4 x i32> %a6, %struct.s56_3* byval align 16 %a7,
+// CHECK: <2 x double> %a8, %struct.s56_4* byval align 16 %a9,
+// CHECK: <8 x i32> %a10, %struct.s56_5* byval align 32 %a11,
+// CHECK: <4 x double> %a12, %struct.s56_6* byval align 32 %a13)
 
 // CHECK: call void (i32, ...) @f56_0(i32 1,
 // CHECK: i32 %{{.*}}, %struct.s56_0* byval align 4 %{{[^ ]*}},
-// CHECK: i64 %{{[^ ]*}}, %struct.s56_1* byval align 4 %{{[^ ]*}},
-// CHECK: <1 x double> %{{[^ ]*}}, %struct.s56_2* byval align 4 %{{[^ ]*}},
-// CHECK: <4 x i32> %{{[^ ]*}}, %struct.s56_3* byval align 4 %{{[^ ]*}},
-// CHECK: <2 x double> %{{[^ ]*}}, %struct.s56_4* byval align 4 %{{[^ ]*}},
-// CHECK: <8 x i32> %{{[^ ]*}}, %struct.s56_5* byval align 4 %{{[^ ]*}},
-// CHECK: <4 x double> %{{[^ ]*}}, %struct.s56_6* byval align 4 %{{[^ ]*}})
+// CHECK: i64 %{{[^ ]*}}, %struct.s56_1* byval align 8 %{{[^ ]*}},
+// CHECK: <1 x double> %{{[^ ]*}}, %struct.s56_2* byval align 8 %{{[^ ]*}},
+// CHECK: <4 x i32> %{{[^ ]*}}, %struct.s56_3* byval align 16 %{{[^ ]*}},
+// CHECK: <2 x double> %{{[^ ]*}}, %struct.s56_4* byval align 16 %{{[^ ]*}},
+// CHECK: <8 x i32> %{{[^ ]*}}, %struct.s56_5* byval align 32 %{{[^ ]*}},
+// CHECK: <4 x double> %{{[^ ]*}}, %struct.s56_6* byval align 32 %{{[^ ]*}})
 // CHECK: }
 //
 //  [i386] clang misaligns long double in structures
Index: test/CodeGen/x86_32-align-linux.c
===
--- /dev/null
+++ test/CodeGen/x86_32-align-linux.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -w -fblocks -ffreestanding -triple i386-pc-linux-gnu -emit-llvm -o %t %s
+// RUN: FileCheck < %t %s
+
+#include 
+
+typedef union {
+int d[4];
+__m128 m;
+} M128;
+
+extern void foo(int, ...);
+
+M128 a;
+
+// CHECK-LABEL: define void @test
+// CHECK: entry:
+// CHECK: call void (i32, ...) @foo(i32 1, %union.M128* byval align 16
+// CHECK: call void (i32, ...) @foo(i32 1, <4 x float>
+
+void test(void)
+{
+  foo(1, a);
+  foo(1, a.m);
+}
+
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -1010,6 +1010,7 @@
   bool IsWin32StructABI;
   bool IsSoftFloatABI;
   bool IsMCUABI;
+  bool IsPS4ABI;
   unsigned DefaultNumRegisterParameters;
 
   static bool isRegisterSize(unsigned Size) {
@@ -1076,6 +1077,7 @@
   IsWin32StructABI(Win32StructABI),
   IsSoftFloatABI(SoftFloatABI),
   IsMCUABI(CGT.getTarget().getTriple().isOSIAMCU()),
+  IsPS4ABI(CGT.getTarget().getTriple().isPS4()),
   DefaultNumRegisterParameters(NumRegisterParameters) {}
 
   bool shouldPassIndirectlyForSwift(ArrayRef scalars,
@@ -1492,18 +1494,18 @@
   if (Align <= MinABIStackAlignInBytes)
 return 0; // Use default alignment.
 
-  // On non-Darwin, the stack type alignment is always 4.
-  if (!IsDarwinVectorABI) {
-// Set explicit alignment, since we may need to realign the top.
+  if (IsDarwinVectorABI) {
+// On Darwin, if the type contains an SSE vector type, the alignment is 16.
+if (Align >= 16 && (isSSEVectorType(getContext(), Ty) ||
+  isRecordWithSSEVectorType(getContext(), Ty)))
+  return 16;
+return MinABIStackAlignInBytes;
+  } else if (IsWin32StructABI || IsPS4ABI) {
 return MinABIStackAlignInBytes;
   }
-
-  // Otherwise, if the type contains an SSE vector type, the alignment is 16.
-  if (Align >= 16 && (isSSEVectorType(getContext(), Ty) ||
-  isRecordWithSSEVectorType(getContext(), Ty)))
-return 16;
-
-  return MinABIStackAlignInBytes;
+  // i386 System V ABI 2.1: Structures and unions assume the alignment of their
+  // most strictly aligned component.
+  return Align;
 }
 
 ABIArgInfo X86_32ABIInfo::getIndirectResult(QualType Ty, bool ByVal,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D60748: Fix i386 struct and union parameter alignment

2019-04-27 Thread Wei Xiao via Phabricator via cfe-commits
wxiao3 added a comment.

Ok, I have excluded Darwin and PS4 for the changes.
The fix mainly targets at Linux so that we can compile a project with parts by 
GCC and parts by LLVM given that they follow the same ABI.


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

https://reviews.llvm.org/D60748



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


[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-04-27 Thread Wei Xiao via Phabricator via cfe-commits
wxiao3 marked 2 inline comments as done.
wxiao3 added inline comments.



Comment at: lib/CodeGen/TargetInfo.cpp:919
 /// IsX86_MMXType - Return true if this is an MMX type.
 bool IsX86_MMXType(llvm::Type *IRType) {
-  // Return true if the type is an MMX type <2 x i32>, <4 x i16>, or <8 x i8>.

rnk wrote:
> I think looking at the LLVM type to decide how something should be passed is 
> a bad pattern to follow. We should look at the clang AST to decide how things 
> will be passed, not LLVM types. Would that be complicated? Are there 
> aggregate types that end up getting passed directly in MMX registers?
For x86 32 bit target, no aggregate types end up getting passed in MMX register.
The only type passed by MMX is 

> __m64

 which is defined in header file (mmintrin.h):


```
typedef long long __m64 __attribute__((__vector_size__(8), __aligned__(8)));
```

Yes, it would be good if we define _m64 as a builtin type and handle it in AST 
level. But I'm afraid that it won't be a trivial work. Since GCC also handles 
__m64 in the same way as Clang currently does, can we just keep current 
implementation as it is?




Comment at: lib/CodeGen/TargetInfo.cpp:9489
+  // System V i386 ABI requires __m64 value passing by MMX registers.
+  bool EnableMMX = getContext().getTargetInfo().getABI() != "no-mmx";
   return SetCGInfo(new X86_32TargetCodeGenInfo(

rnk wrote:
> I think this needs to preserve existing behavior for Darwin and PS4 based on 
> comments from @rjmccall and @dexonsmith in D60748.
ok, I will follow it.


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

https://reviews.llvm.org/D59744



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


[PATCH] D61225: [COFF, ARM64] Align global symbol by size for ARM64 MSVC ABI

2019-04-27 Thread Tom Tan via Phabricator via cfe-commits
TomTan created this revision.
TomTan added a reviewer: efriedma.
Herald added subscribers: cfe-commits, kristof.beyls, javed.absar.
Herald added a project: clang.

According to alignment section in below ARM64 ABI document, MSVC could increase 
alignment of global data based on its total size. Clang doesn't do this. 
Compile the same symbol into different alignments by Clang and MSVC could cause 
link error because some instruction encodings, like 64-bit LDR/STR with 
immediate, require the target to be 8 bytes aligned, and linker could choose 
code stream with such LDR/STR instruction from MSVC and 4 bytes aligned data 
from Clang into final image, which actually cannot be linked together (see 
https://bugs.llvm.org/show_bug.cgi?id=41506 for more details).

https://docs.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=vs-2019#alignment


Repository:
  rC Clang

https://reviews.llvm.org/D61225

Files:
  lib/AST/ASTContext.cpp


Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1600,8 +1600,25 @@
   if (BaseT.getQualifiers().hasUnaligned())
 Align = Target->getCharWidth();
   if (const auto *VD = dyn_cast(D)) {
-if (VD->hasGlobalStorage() && !ForAlignof)
+if (VD->hasGlobalStorage() && !ForAlignof) {
   Align = std::max(Align, getTargetInfo().getMinGlobalAlign());
+
+  // MSVC does size based alignment for arm64 based on alignment 
section
+  // in below document, replicate that to keep alignment consistent 
with
+  // object files compiled by MSVC.
+  // 
https://docs.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions
+  if (getTargetInfo().getTriple().getArch() == llvm::Triple::aarch64 &&
+  getTargetInfo().getTriple().getEnvironment() == 
llvm::Triple::MSVC) {
+uint64_t TypeSize = getTypeSize(T.getTypePtr());
+if (TypeSize >= 512) {  // TypeSize >= 64 bytes
+  Align = std::max(Align, 128u);// align type at least 16 bytes
+} else if (TypeSize >= 64) {// TypeSize >= 8 bytes
+  Align = std::max(Align, 64u); // align type at least 8 butes
+} else if (TypeSize >= 16) {// TypeSize >= 2 bytes
+  Align = std::max(Align, 32u); // align type at least 4 bytes
+}
+  }
+}
   }
 }
 


Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1600,8 +1600,25 @@
   if (BaseT.getQualifiers().hasUnaligned())
 Align = Target->getCharWidth();
   if (const auto *VD = dyn_cast(D)) {
-if (VD->hasGlobalStorage() && !ForAlignof)
+if (VD->hasGlobalStorage() && !ForAlignof) {
   Align = std::max(Align, getTargetInfo().getMinGlobalAlign());
+
+  // MSVC does size based alignment for arm64 based on alignment section
+  // in below document, replicate that to keep alignment consistent with
+  // object files compiled by MSVC.
+  // https://docs.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions
+  if (getTargetInfo().getTriple().getArch() == llvm::Triple::aarch64 &&
+  getTargetInfo().getTriple().getEnvironment() == llvm::Triple::MSVC) {
+uint64_t TypeSize = getTypeSize(T.getTypePtr());
+if (TypeSize >= 512) {  // TypeSize >= 64 bytes
+  Align = std::max(Align, 128u);// align type at least 16 bytes
+} else if (TypeSize >= 64) {// TypeSize >= 8 bytes
+  Align = std::max(Align, 64u); // align type at least 8 butes
+} else if (TypeSize >= 16) {// TypeSize >= 2 bytes
+  Align = std::max(Align, 32u); // align type at least 4 bytes
+}
+  }
+}
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60967: Move setTargetAttributes after setGVProperties in SetFunctionAttributes

2019-04-27 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

It seems to fine just forbid `hidden`.  Again, I suspect other targets do not 
care because they are not using a standard dynamic loader to load the code 
containing kernel functions.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60967



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


[PATCH] D60283: [DebugInfo] Don't emit checksums when compiling a preprocessed CPP

2019-04-27 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

(Just for the record, I'm happy with whatever y'all end up with.)


Repository:
  rC Clang

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

https://reviews.llvm.org/D60283



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


[PATCH] D61232: [libclang] Restore old clang_Cursor_isAnonymous behaviour

2019-04-27 Thread Jorn Vernee via Phabricator via cfe-commits
JornVernee created this revision.
JornVernee added reviewers: yvvan, nik, rsmith.
JornVernee added a project: clang.
Herald added a subscriber: arphaman.

https://reviews.llvm.org/D54996 Changed the behaviour of 
clang_Cursor_isAnonymous, but there is no alternative available to get the old 
behaviour in some cases, which is essential for determining if a record is 
syntactically accessible, e.g.

  struct {
int x;
int y;
  } foo;
  
  struct {
struct {
  int x;
  int y;
};
  } bar;
  
  void fun(struct { int x; int y; } *param);

The only 'anonymous' struct here is the one nested in bar, since there is no 
way to reference the struct itself, only the fields within. Though the 
anonymity applies to the instance itself, not the type.

To avoid confusion, I have added a new function called 
clang_Cursor_isAnonymousRecordDecl which has the old behaviour of 
clang_Cursor_isAnonymous  (and updated the doc for the latter as well, which 
was seemingly forgotten).


Repository:
  rC Clang

https://reviews.llvm.org/D61232

Files:
  include/clang-c/Index.h
  tools/libclang/CXType.cpp


Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -1253,6 +1253,16 @@

   return 0;
 }
+
+unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C){
+  if (!clang_isDeclaration(C.kind))
+return 0;
+  const Decl *D = cxcursor::getCursorDecl(C);
+  if (const RecordDecl *FD = dyn_cast_or_null(D))
+return FD->isAnonymousStructOrUnion();
+  return 0;
+}
+
 CXType clang_Type_getNamedType(CXType CT){
   QualType T = GetQualType(CT);
   const Type *TP = T.getTypePtrOrNull();
Index: include/clang-c/Index.h
===
--- include/clang-c/Index.h
+++ include/clang-c/Index.h
@@ -3920,11 +3920,17 @@
  */
 CINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C);

+/**
+ * Determine whether the given cursor represents an anonymous
+ * tag or namespace
+ */
+CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
+
 /**
  * Determine whether the given cursor represents an anonymous record
  * declaration.
  */
-CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
+CINDEX_LINKAGE unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C);

 enum CXRefQualifierKind {
   /** No ref-qualifier was provided. */


Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -1253,6 +1253,16 @@

   return 0;
 }
+
+unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C){
+  if (!clang_isDeclaration(C.kind))
+return 0;
+  const Decl *D = cxcursor::getCursorDecl(C);
+  if (const RecordDecl *FD = dyn_cast_or_null(D))
+return FD->isAnonymousStructOrUnion();
+  return 0;
+}
+
 CXType clang_Type_getNamedType(CXType CT){
   QualType T = GetQualType(CT);
   const Type *TP = T.getTypePtrOrNull();
Index: include/clang-c/Index.h
===
--- include/clang-c/Index.h
+++ include/clang-c/Index.h
@@ -3920,11 +3920,17 @@
  */
 CINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C);

+/**
+ * Determine whether the given cursor represents an anonymous
+ * tag or namespace
+ */
+CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
+
 /**
  * Determine whether the given cursor represents an anonymous record
  * declaration.
  */
-CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
+CINDEX_LINKAGE unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C);

 enum CXRefQualifierKind {
   /** No ref-qualifier was provided. */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61232: [libclang] Restore old clang_Cursor_isAnonymous behaviour

2019-04-27 Thread Jorn Vernee via Phabricator via cfe-commits
JornVernee added a comment.

Also, I don't have commit access, so I would need some help with that if this 
gets accepted :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D61232



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


[PATCH] D61232: [libclang] Restore old clang_Cursor_isAnonymous behaviour

2019-04-27 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

Now we know that somebody else also uses libclang :)
I the mentioned change I only wanted to follow the same logic as in 
TypePrinter::printTag to cover more anonymity cases.

Adding the old one as an extra function seems totally fine to me.  Can you 
please add some tests for it to clarify the purpose for future users?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61232



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


[PATCH] D61232: [libclang] Restore old clang_Cursor_isAnonymous behaviour

2019-04-27 Thread Jorn Vernee via Phabricator via cfe-commits
JornVernee updated this revision to Diff 196988.

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

https://reviews.llvm.org/D61232

Files:
  include/clang-c/Index.h
  test/Index/print-type.c
  tools/c-index-test/c-index-test.c
  tools/libclang/CXType.cpp


Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -1253,6 +1253,16 @@
 
   return 0;
 }
+
+unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C){
+  if (!clang_isDeclaration(C.kind))
+return 0;
+  const Decl *D = cxcursor::getCursorDecl(C);
+  if (const RecordDecl *FD = dyn_cast_or_null(D))
+return FD->isAnonymousStructOrUnion();
+  return 0;
+}
+
 CXType clang_Type_getNamedType(CXType CT){
   QualType T = GetQualType(CT);
   const Type *TP = T.getTypePtrOrNull();
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1664,6 +1664,12 @@
 printf(" [isAnon=%d]", isAnon);
   }
 }
+   
+   /* Print if it is an anonymous record decl */
+{
+  unsigned isAnonRecDecl = clang_Cursor_isAnonymousRecordDecl(cursor);
+  printf(" [isAnonRecDecl=%d]", isAnonRecDecl);
+}
 
 printf("\n");
   }
Index: test/Index/print-type.c
===
--- test/Index/print-type.c
+++ test/Index/print-type.c
@@ -15,6 +15,20 @@
 enum Enum{i}; enum Enum elaboratedEnumType();
 struct Struct{}; struct Struct elaboratedStructType();
 
+struct {
+  int x;
+  int y;
+} foo;
+
+struct {
+  struct {
+int x;
+int y;
+  };
+} bar;
+
+void fun(struct { int x; int y; } *param);
+
 // RUN: c-index-test -test-print-type %s | FileCheck %s
 // CHECK: FunctionDecl=f:3:6 (Definition) [type=int *(int *, char *, FooType, 
int *, void (*)(int))] [typekind=FunctionProto] [canonicaltype=int *(int *, 
char *, int, int *, void (*)(int))] [canonicaltypekind=FunctionProto] 
[resulttype=int *] [resulttypekind=Pointer] [args= [int *] [Pointer] [char *] 
[Pointer] [FooType] [Typedef] [int [5]] [ConstantArray] [void (*)(int)] 
[Pointer]] [isPOD=0]
 // CHECK: ParmDecl=p:3:13 (Definition) [type=int *] [typekind=Pointer] 
[isPOD=1] [pointeetype=int] [pointeekind=Int]
@@ -53,3 +67,7 @@
 // CHECK: StructDecl=Struct:16:8 (Definition) [type=struct Struct] 
[typekind=Record] [isPOD=1]
 // CHECK: FunctionDecl=elaboratedStructType:16:32 [type=struct Struct ()] 
[typekind=FunctionNoProto] [canonicaltype=struct Struct ()] 
[canonicaltypekind=FunctionNoProto] [resulttype=struct Struct] 
[resulttypekind=Elaborated] [isPOD=0]
 // CHECK: TypeRef=struct Struct:16:8 [type=struct Struct] [typekind=Record] 
[isPOD=1]
+// CHECK: StructDecl=:18:1 (Definition) [type=struct (anonymous at 
.\test\Index\print-type.c:18:1)] [typekind=Record] [isPOD=1] [nbFields=2] 
[isAnon=1] [isAnonRecDecl=0]
+// CHECK: StructDecl=:23:1 (Definition) [type=struct (anonymous at 
.\test\Index\print-type.c:23:1)] [typekind=Record] [isPOD=1] [nbFields=1] 
[isAnon=1] [isAnonRecDecl=0]
+// CHECK: StructDecl=:24:3 (Definition) [type=struct (anonymous at 
.\test\Index\print-type.c:24:3)] [typekind=Record] [isPOD=1] [nbFields=2] 
[isAnon=1] [isAnonRecDecl=1]
+// CHECK: StructDecl=:30:10 (Definition) [type=struct (anonymous at 
.\test\Index\print-type.c:30:10)] [typekind=Record] [isPOD=1] [nbFields=2] 
[isAnon=1] [isAnonRecDecl=0]
Index: include/clang-c/Index.h
===
--- include/clang-c/Index.h
+++ include/clang-c/Index.h
@@ -3920,11 +3920,17 @@
  */
 CINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C);
 
+/**
+ * Determine whether the given cursor represents an anonymous
+ * tag or namespace
+ */
+CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
+
 /**
  * Determine whether the given cursor represents an anonymous record
  * declaration.
  */
-CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
+CINDEX_LINKAGE unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C);
 
 enum CXRefQualifierKind {
   /** No ref-qualifier was provided. */


Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -1253,6 +1253,16 @@
 
   return 0;
 }
+
+unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C){
+  if (!clang_isDeclaration(C.kind))
+return 0;
+  const Decl *D = cxcursor::getCursorDecl(C);
+  if (const RecordDecl *FD = dyn_cast_or_null(D))
+return FD->isAnonymousStructOrUnion();
+  return 0;
+}
+
 CXType clang_Type_getNamedType(CXType CT){
   QualType T = GetQualType(CT);
   const Type *TP = T.getTypePtrOrNull();
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.

[PATCH] D61232: [libclang] Restore old clang_Cursor_isAnonymous behaviour

2019-04-27 Thread Jorn Vernee via Phabricator via cfe-commits
JornVernee added a comment.

@yvvan Hows that as a test?

I'm pretty new at this, and it took a while to figure out how to run the tests. 
I used something like: `build\Release\bin\c-index-test.exe -test-print-type 
.\test\Index\print-type.c | ..\llvm\build\Release\bin\FileCheck 
.\test\Index\print-type.c`, but there's probably an easier way?


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

https://reviews.llvm.org/D61232



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


[PATCH] D61222: [clang-format] Fix bug in determineTokenType() for TT_StartOfName

2019-04-27 Thread Owen Pan via Phabricator via cfe-commits
owenpan planned changes to this revision.
owenpan added a comment.

Tested it a bit more and found another problem. The code

  DECOR1 uint32_t DECOR2 function1 (int arg1, int arg2) { return 1U; }
  DECOR1 unsigned DECOR2 function2 (int arg1, int arg2) { return 1U; }

would still be misformatted to:

  DECOR1 uint32_t DECOR2
 function1(int arg1, int arg2) { return 1U; }
  DECOR1 unsigned DECOR2
  function2(int arg1, int arg2) { return 1U; }


Repository:
  rC Clang

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

https://reviews.llvm.org/D61222



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


[PATCH] D61222: [clang-format] Fix a bug in AlignConsecutiveDeclarations

2019-04-27 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 196994.
owenpan retitled this revision from "[clang-format] Fix bug in 
determineTokenType() for TT_StartOfName" to "[clang-format] Fix a bug in 
AlignConsecutiveDeclarations".
owenpan added a comment.
This revision is now accepted and ready to land.

Fix it in `WhitespaceManager::alignConsecutiveDeclarations()` instead.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61222

Files:
  clang/lib/Format/WhitespaceManager.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10575,6 +10575,16 @@
"  unsigned c;\n"
"}",
Alignment);
+
+  // See PR37175
+  FormatStyle Style = getMozillaStyle();
+  Style.AlignConsecutiveDeclarations = true;
+  EXPECT_EQ("DECOR1 /**/ DECOR2 /**/ int8_t /**/\n"
+"foo(int a);",
+format("DECOR1 /**/ DECOR2 /**/ int8_t /**/ foo (int a);", Style));
+  EXPECT_EQ("DECOR1 /**/ int8_t /**/ DECOR2 /**/\n"
+"bar(int a);",
+format("DECOR1 /**/ int8_t /**/ DECOR2 /**/ bar (int a);", Style));
 }
 
 TEST_F(FormatTest, LinuxBraceBreaking) {
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -463,9 +463,21 @@
   [](Change const &C) {
 // tok::kw_operator is necessary for aligning operator overload
 // definitions.
-return C.Tok->is(TT_StartOfName) ||
-   C.Tok->is(TT_FunctionDeclarationName) ||
-   C.Tok->is(tok::kw_operator);
+if (C.Tok->isOneOf(TT_FunctionDeclarationName, tok::kw_operator))
+  return true;
+if (C.Tok->isNot(TT_StartOfName))
+  return false;
+// Check if there is a subsequent name that starts the same 
declaration.
+for (FormatToken *Next = C.Tok->Next; Next; Next = Next->Next) {
+  if (Next->is(tok::comment))
+continue;
+  if (!Next->Tok.getIdentifierInfo())
+break;
+  if (Next->isOneOf(TT_StartOfName, TT_FunctionDeclarationName,
+tok::kw_operator))
+return false;
+}
+return true;
   },
   Changes, /*StartAt=*/0);
 }


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10575,6 +10575,16 @@
"  unsigned c;\n"
"}",
Alignment);
+
+  // See PR37175
+  FormatStyle Style = getMozillaStyle();
+  Style.AlignConsecutiveDeclarations = true;
+  EXPECT_EQ("DECOR1 /**/ DECOR2 /**/ int8_t /**/\n"
+"foo(int a);",
+format("DECOR1 /**/ DECOR2 /**/ int8_t /**/ foo (int a);", Style));
+  EXPECT_EQ("DECOR1 /**/ int8_t /**/ DECOR2 /**/\n"
+"bar(int a);",
+format("DECOR1 /**/ int8_t /**/ DECOR2 /**/ bar (int a);", Style));
 }
 
 TEST_F(FormatTest, LinuxBraceBreaking) {
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -463,9 +463,21 @@
   [](Change const &C) {
 // tok::kw_operator is necessary for aligning operator overload
 // definitions.
-return C.Tok->is(TT_StartOfName) ||
-   C.Tok->is(TT_FunctionDeclarationName) ||
-   C.Tok->is(tok::kw_operator);
+if (C.Tok->isOneOf(TT_FunctionDeclarationName, tok::kw_operator))
+  return true;
+if (C.Tok->isNot(TT_StartOfName))
+  return false;
+// Check if there is a subsequent name that starts the same declaration.
+for (FormatToken *Next = C.Tok->Next; Next; Next = Next->Next) {
+  if (Next->is(tok::comment))
+continue;
+  if (!Next->Tok.getIdentifierInfo())
+break;
+  if (Next->isOneOf(TT_StartOfName, TT_FunctionDeclarationName,
+tok::kw_operator))
+return false;
+}
+return true;
   },
   Changes, /*StartAt=*/0);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61220: lib/Header: Fix Visual Studio builds try #2

2019-04-27 Thread Vyacheslav Zakharin via Phabricator via cfe-commits
vzakhari added inline comments.



Comment at: clang/lib/Headers/CMakeLists.txt:173
 
 set(header_install_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION})
 

Please add "/include" at the end.



Comment at: clang/lib/Headers/CMakeLists.txt:176
 install(
-  DIRECTORY ${output_dir}
+  FILES ${install_files}
   DESTINATION ${header_install_dir}

This is going to flatten the headers' install directory structure.  install() 
will put the files just by their name.

I had a local fix that use install() with RENAME, and it worked.  I can try to 
find it.  Basically, we need to keep two lists:
1. The same as this ${install_files}
2. New list install_as, which holds all ${src} values passed to 
copy_header_to_output_dir()

Walking the two lists together we may use install(FILES 
${elt_from_install_files} RENAME ${elt_from_install_as} ...)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61220



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


[PATCH] D50860: [libc++][test] Remove non-portable assumption that thread's constructor allocates with ::new

2019-04-27 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

LGTM minus inline comments.




Comment at: 
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp:171
 #ifndef TEST_HAS_NO_EXCEPTIONS
-{
+if (numAllocs > 0) {
 try

CaseyCarter wrote:
> EricWF wrote:
> > I'm not sure I understand this change either.
> > 
> If thread creation in `test_throwing_new_during_thread_creation` resulted in 
> `0` calls to `::operator new`, the expectation is that the same will occur 
> here when we create a thread. If `::operator new` isn't called, it can't 
> throw the exception this test is expecting to catch.
Since libc++ seems to allocate, could we sanity test that?

```
// The test below is non-portable because it expects `std::thread` to call 
`new`, which may not be the case for all implementations.
LIBCPP_ASSERT(numAllocs > 0); // libc++ should call new. Sanity check 
`numAllocs`.
if (numAllocs > 0) { ... }
```


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

https://reviews.llvm.org/D50860



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


r359393 - [PowerPC][Clang] Add tests for PowerPC MMX intrinsics

2019-04-27 Thread Qiu Chaofan via cfe-commits
Author: chaofan
Date: Sat Apr 27 23:27:33 2019
New Revision: 359393

URL: http://llvm.org/viewvc/llvm-project?rev=359393&view=rev
Log:
[PowerPC][Clang] Add tests for PowerPC MMX intrinsics

Add the rest of test cases covering functions defined in mmintrin.h on PowerPC.

Reviewed By: Jinsong Ji

Modified:
cfe/trunk/test/CodeGen/ppc-mmintrin.c

Modified: cfe/trunk/test/CodeGen/ppc-mmintrin.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ppc-mmintrin.c?rev=359393&r1=359392&r2=359393&view=diff
==
--- cfe/trunk/test/CodeGen/ppc-mmintrin.c (original)
+++ cfe/trunk/test/CodeGen/ppc-mmintrin.c Sat Apr 27 23:27:33 2019
@@ -1,16 +1,508 @@
 // REQUIRES: powerpc-registered-target
 
 // RUN: %clang -S -emit-llvm -target powerpc64-gnu-linux -mcpu=pwr8 
-DNO_WARN_X86_INTRINSICS %s \
-// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt | FileCheck %s --check-prefixes=CHECK-P8,CHECK,CHECK-BE
 // RUN: %clang -S -emit-llvm -target powerpc64le-gnu-linux -mcpu=pwr8 
-DNO_WARN_X86_INTRINSICS %s \
-// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt | FileCheck %s --check-prefixes=CHECK-P8,CHECK,CHECK-LE
+// RUN: %clang -S -emit-llvm -target powerpc64-gnu-linux -mcpu=pwr9 
-DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt | FileCheck %s --check-prefixes=CHECK-P9,CHECK,CHECK-BE
+// RUN: %clang -S -emit-llvm -target powerpc64le-gnu-linux -mcpu=pwr9 
-DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt | FileCheck %s --check-prefixes=CHECK-P9,CHECK,CHECK-LE
 
 #include 
 
 unsigned long long int ull1, ull2;
+int i1, i2;
+short s[4];
+signed char c[8];
+long long int ll1;
 __m64 m1, m2, res;
 
 void __attribute__((noinline))
+test_add() {
+  res = _mm_add_pi32(m1, m2);
+  res = _mm_add_pi16(m1, m2);
+  res = _mm_add_pi8(m1, m2);
+  res = _mm_adds_pu16(m1, m2);
+  res = _mm_adds_pu8(m1, m2);
+  res = _mm_adds_pi16(m1, m2);
+  res = _mm_adds_pi8(m1, m2);
+}
+
+// CHECK-LABEL: @test_add
+
+// CHECK: define available_externally i64 @_mm_add_pi32
+
+// CHECK-P9: [[REG1:[0-9a-zA-Z_%.]+]] = call <2 x i64> @vec_splats(unsigned 
long long)
+// CHECK-P9-NEXT: [[REG2:[0-9a-zA-Z_%.]+]] = bitcast <2 x i64> [[REG1]] to <4 
x i32>
+// CHECK-P9-NEXT: store <4 x i32> [[REG2]], <4 x i32>* 
[[REG3:[0-9a-zA-Z_%.]+]], align 16
+// CHECK-P9-NEXT: [[REG4:[0-9a-zA-Z_%.]+]] = load i64, i64* 
{{[0-9a-zA-Z_%.]+}}, align 8
+// CHECK-P9-NEXT: [[REG5:[0-9a-zA-Z_%.]+]] = call <2 x i64> 
@vec_splats(unsigned long long)
+// CHECK-P9-NEXT: [[REG6:[0-9a-zA-Z_%.]+]] = bitcast <2 x i64> [[REG5]] to <4 
x i32>
+// CHECK-P9-NEXT: store <4 x i32> [[REG6]], <4 x i32>* 
[[REG7:[0-9a-zA-Z_%.]+]], align 16
+// CHECK-P9-NEXT: [[REG8:[0-9a-zA-Z_%.]+]] = load <4 x i32>, <4 x i32>* 
[[REG3]], align 16
+// CHECK-P9-NEXT: [[REG9:[0-9a-zA-Z_%.]+]] = load <4 x i32>, <4 x i32>* 
[[REG7]], align 16
+// CHECK-P9-NEXT: [[REG10:[0-9a-zA-Z_%.]+]] = call <4 x i32> @vec_add(int 
vector[4], int vector[4])(<4 x i32> [[REG8]], <4 x i32> [[REG9]])
+// CHECK-P9-NEXT: store <4 x i32> [[REG10]], <4 x i32>* 
[[REG11:[0-9a-zA-Z_%.]+]], align 16
+// CHECK-P9-NEXT: [[REG12:[0-9a-zA-Z_%.]+]] = load <4 x i32>, <4 x i32>* 
[[REG11]], align 16
+// CHECK-P9-NEXT: [[REG13:[0-9a-zA-Z_%.]+]] = bitcast <4 x i32> %6 to <2 x i64>
+// CHECK-P9-NEXT: [[REG14:[0-9a-zA-Z_%.]+]] = extractelement <2 x i64> 
[[REG13]], i32 0
+// CHECK-P9-NEXT: ret i64 [[REG14]]
+
+// CHECK-P8: [[REG15:[0-9a-zA-Z_%.]+]] = getelementptr inbounds [2 x i32], [2 
x i32]* {{[0-9a-zA-Z_%.]+}}, i64 0, i64 0
+// CHECK-P8-NEXT: [[REG16:[0-9a-zA-Z_%.]+]] = load i32, i32* [[REG15]]
+// CHECK-P8: [[REG17:[0-9a-zA-Z_%.]+]] = getelementptr inbounds [2 x i32], [2 
x i32]* {{[0-9a-zA-Z_%.]+}}, i64 0, i64 0
+// CHECK-P8-NEXT: [[REG18:[0-9a-zA-Z_%.]+]] = load i32, i32* [[REG17]]
+// CHECK-P8-NEXT: add nsw i32 [[REG16]], [[REG18]]
+// CHECK-P8: [[REG19:[0-9a-zA-Z_%.]+]] = getelementptr inbounds [2 x i32], [2 
x i32]* {{[0-9a-zA-Z_%.]+}}, i64 0, i64 1
+// CHECK-P8-NEXT: [[REG20:[0-9a-zA-Z_%.]+]] = load i32, i32* [[REG19]]
+// CHECK-P8: [[REG21:[0-9a-zA-Z_%.]+]] = getelementptr inbounds [2 x i32], [2 
x i32]* {{[0-9a-zA-Z_%.]+}}, i64 0, i64 1
+// CHECK-P8-NEXT: [[REG22:[0-9a-zA-Z_%.]+]] = load i32, i32* [[REG21]]
+// CHECK-P8-NEXT: add nsw i32 [[REG20]], [[REG22]]
+
+// CHECK: define available_externally i64 @_mm_add_pi16
+// CHECK: [[REG23:[0-9a-zA-Z_%.]+]] = call <2 x i64> @vec_splats
+// CHECK-NEXT: [[REG24:[0-9a-zA-Z_%.]+]] = bitcast <2 x i64> [[REG23]] to <8 x 
i16>
+// CHECK-NEXT: store <8 x i16> [[REG24]], <