[PATCH] D65064: [CrossTU] Add a function to retrieve original source location.

2019-07-22 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: cfe-commits, gamesh411, Szelethus, dkrupp.
Herald added a reviewer: martong.
Herald added a reviewer: shafik.
Herald added a project: clang.

A new function will be added to get the original SourceLocation
for a SourceLocation that was imported as result of getCrossTUDefinition.
The returned SourceLocation is in the context of the (original)
SourceManager for the original source file. Additionally the
ASTUnit object for that source file is returned. This is needed
to get a SourceManager to operate on with the returned source location.

The new function works if multiple different source files are loaded
with the same CrossTU context.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65064

Files:
  clang/include/clang/AST/ASTImporter.h
  clang/include/clang/CrossTU/CrossTranslationUnit.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/CrossTU/CrossTranslationUnit.cpp
  clang/unittests/CrossTU/CrossTranslationUnitTest.cpp

Index: clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
===
--- clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
+++ clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
@@ -28,13 +28,18 @@
   : CTU(CI), Success(Success) {}
 
   void HandleTranslationUnit(ASTContext &Ctx) {
+auto FindFInTU = [](const TranslationUnitDecl *TU) {
+  const FunctionDecl *FD = nullptr;
+  for (const Decl *D : TU->decls()) {
+FD = dyn_cast(D);
+if (FD && FD->getName() == "f")
+  break;
+  }
+  return FD;
+};
+
 const TranslationUnitDecl *TU = Ctx.getTranslationUnitDecl();
-const FunctionDecl *FD = nullptr;
-for (const Decl *D : TU->decls()) {
-  FD = dyn_cast(D);
-  if (FD && FD->getName() == "f")
-break;
-}
+const FunctionDecl *FD = FindFInTU(TU);
 assert(FD && FD->getName() == "f");
 bool OrigFDHasBody = FD->hasBody();
 
@@ -78,6 +83,28 @@
 if (NewFDorError) {
   const FunctionDecl *NewFD = *NewFDorError;
   *Success = NewFD && NewFD->hasBody() && !OrigFDHasBody;
+
+  if (NewFD) {
+// Check GetImportedFromSourceLocation.
+llvm::Optional> SLocResult =
+CTU.getImportedFromSourceLocation(NewFD->getLocation());
+EXPECT_TRUE(SLocResult);
+if (SLocResult) {
+  SourceLocation OrigSLoc = (*SLocResult).first;
+  ASTUnit *OrigUnit = (*SLocResult).second;
+  // OrigUnit is created internally by CTU (is not the
+  // ASTWithDefinition).
+  TranslationUnitDecl *OrigTU =
+  OrigUnit->getASTContext().getTranslationUnitDecl();
+  const FunctionDecl *FDWithDefinition = FindFInTU(OrigTU);
+  EXPECT_TRUE(FDWithDefinition);
+  if (FDWithDefinition) {
+EXPECT_EQ(FDWithDefinition->getName(), "f");
+EXPECT_TRUE(FDWithDefinition->isThisDeclarationADefinition());
+EXPECT_EQ(OrigSLoc, FDWithDefinition->getLocation());
+  }
+}
+  }
 }
   }
 
Index: clang/lib/CrossTU/CrossTranslationUnit.cpp
===
--- clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -295,7 +295,7 @@
 
   TranslationUnitDecl *TU = Unit->getASTContext().getTranslationUnitDecl();
   if (const T *ResultDecl = findDefInDeclContext(TU, LookupName))
-return importDefinition(ResultDecl);
+return importDefinition(ResultDecl, Unit);
   return llvm::make_error(index_error_code::failed_import);
 }
 
@@ -411,10 +411,13 @@
 
 template 
 llvm::Expected
-CrossTranslationUnitContext::importDefinitionImpl(const T *D) {
+CrossTranslationUnitContext::importDefinitionImpl(const T *D, ASTUnit *Unit) {
   assert(hasBodyOrInit(D) && "Decls to be imported should have body or init.");
 
-  ASTImporter &Importer = getOrCreateASTImporter(D->getASTContext());
+  assert(&D->getASTContext() == &Unit->getASTContext() &&
+ "ASTContext of Decl and the unit should match.");
+  ASTImporter &Importer = getOrCreateASTImporter(Unit);
+
   auto ToDeclOrError = Importer.Import(D);
   if (!ToDeclOrError) {
 handleAllErrors(ToDeclOrError.takeError(),
@@ -441,13 +444,15 @@
 }
 
 llvm::Expected
-CrossTranslationUnitContext::importDefinition(const FunctionDecl *FD) {
-  return importDefinitionImpl(FD);
+CrossTranslationUnitContext::importDefinition(const FunctionDecl *FD,
+  ASTUnit *Unit) {
+  return importDefinitionImpl(FD, Unit);
 }
 
 llvm::Expected
-CrossTranslationUnitContext::importDefinition(const VarDecl *VD) {
-  return importDefinitionImpl(VD);
+CrossTranslationUnitContext::importDefinition(const VarDecl *VD,
+  ASTUnit *Unit) {
+  return importDefinitionImpl(VD, Unit);
 }
 
 void CrossTranslationUnitContext::lazyInitImporterSharedSt(
@@ -457,7 +462,9 @@
 }
 
 ASTImpor

[PATCH] D64554: [CrossTU] Add a function to retrieve original source location.

2019-07-22 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

New patch:
https://reviews.llvm.org/D65064


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64554



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


[PATCH] D64739: [SVE][Inline-Asm] Add support to specify SVE registers in the clobber list

2019-07-22 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added inline comments.



Comment at: clang/test/CodeGen/aarch64-sve-inline-asm.c:1
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -emit-llvm -target-feature 
+sve -o - %s | FileCheck %s
+

rovka wrote:
> Can you also add a test without +sve, to make sure we get a diagnostic?
Without the `-emit-llvm` part this test invokes (and tests the diagnostic of) 
the compiler. I don't think this is what we want. At the same time, this code 
should probably still continue match the z and p registers even if the target 
feature is not given, and thus leave it to LLVM to determine whether the use of 
these registers makes sense or not. So removing `-target-feature +sve` from the 
RUN line should be sufficient here. @rovka do you agree?



Comment at: clang/test/CodeGen/aarch64-sve-inline-asm.c:12
+  "add z31.d, p0/m, z31.d, z31.d\n"
+  : "=w"(t)
+  :

There is no variable linked to `t` in this inline asm, so you can remove this 
clause.


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

https://reviews.llvm.org/D64739



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


[PATCH] D65065: [clang-tidy] Possibility of displaying duplicate warnings

2019-07-22 Thread Tibor Brunner via Phabricator via cfe-commits
bruntib created this revision.
bruntib added reviewers: alexfh, xazax.hun, Szelethus.
Herald added subscribers: cfe-commits, mgrang, rnkovacs, whisperity.
Herald added a project: clang.

In case a checker is registered multiple times as an alias, the emitted 
warnings are uniqued by the report message. However, it is random which checker 
name is included in the warning. When processing the output of clang-tidy this 
behavior caused some problems. So in this commit clang-tidy has been extended 
with a --duplicate-reports flag which prevents uniquing the warnings and both 
checker's messages are printed under their name.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D65065

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/test/clang-tidy/duplicate-reports-with.cpp
  clang-tools-extra/test/clang-tidy/duplicate-reports-without.cpp

Index: clang-tools-extra/test/clang-tidy/duplicate-reports-without.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/duplicate-reports-without.cpp
@@ -0,0 +1,17 @@
+// RUN: %check_clang_tidy %s cert-err09-cpp,cert-err61-cpp %t
+
+void alwaysThrows() {
+  int ex = 42;
+  // It is unknown which checker alias is reporting the warning, that is why
+  // the checker name is not included in the message.
+
+  // CHECK-MESSAGES: warning: throw expression should throw anonymous temporary values instead
+  throw ex;
+}
+
+void doTheJob() {
+  try {
+alwaysThrows();
+  } catch (int&) {
+  }
+}
Index: clang-tools-extra/test/clang-tidy/duplicate-reports-with.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/duplicate-reports-with.cpp
@@ -0,0 +1,19 @@
+// RUN: %check_clang_tidy %s cert-err09-cpp,cert-err61-cpp %t -duplicate-reports --
+
+void alwaysThrows() {
+  int ex = 42;
+  // At this location both cert-err09-cpp and cert-err61-cpp report the
+  // message. The order of the reports is unknown, that's why the checker name
+  // is not included in the expected warning.
+
+  // CHECK-MESSAGES: warning: throw expression should throw anonymous temporary values instead
+  // CHECK-MESSAGES: warning: throw expression should throw anonymous temporary values instead
+  throw ex;
+}
+
+void doTheJob() {
+  try {
+alwaysThrows();
+  } catch (int&) {
+  }
+}
Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -78,6 +78,15 @@
  cl::init(""),
  cl::cat(ClangTidyCategory));
 
+static cl::opt DuplicateReports("duplicate-reports", cl::desc(R"(
+Some checkers are aliases of others, so the same
+issue may be reported by different checkers at
+the same location. These duplicates are uniqued
+unless this flag is provided.
+)"),
+ cl::init(false),
+ cl::cat(ClangTidyCategory));
+
 static cl::opt HeaderFilter("header-filter", cl::desc(R"(
 Regular expression matching the names of the
 headers to output diagnostics from. Diagnostics
@@ -266,6 +275,7 @@
   ClangTidyOptions DefaultOptions;
   DefaultOptions.Checks = DefaultChecks;
   DefaultOptions.WarningsAsErrors = "";
+  DefaultOptions.DuplicateReports = DuplicateReports;
   DefaultOptions.HeaderFilterRegex = HeaderFilter;
   DefaultOptions.SystemHeaders = SystemHeaders;
   DefaultOptions.FormatStyle = FormatStyle;
@@ -279,6 +289,8 @@
 OverrideOptions.Checks = Checks;
   if (WarningsAsErrors.getNumOccurrences() > 0)
 OverrideOptions.WarningsAsErrors = WarningsAsErrors;
+  if (DuplicateReports.getNumOccurrences() > 0)
+OverrideOptions.DuplicateReports = DuplicateReports;
   if (HeaderFilter.getNumOccurrences() > 0)
 OverrideOptions.HeaderFilterRegex = HeaderFilter;
   if (SystemHeaders.getNumOccurrences() > 0)
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.h
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -66,6 +66,10 @@
   /// \brief WarningsAsErrors filter.
   llvm::Optional WarningsAsErrors;
 
+  /// \brief Indicates whether warnings emitted by alias checkers should be
+  /// reported multiple times.
+  llvm::Optional DuplicateReports;
+
   /// \brief Output warnings from headers matching this filter. Warnings from
   /// main files will always be displayed.
   llvm::Optional HeaderFilterRegex;
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
==

[PATCH] D63932: [GlobalDCE] Dead Virtual Function Elimination

2019-07-22 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63932



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


[PATCH] D65000: [ARM] Set default alignment to 64bits

2019-07-22 Thread Peter Smith via Phabricator via cfe-commits
peter.smith added reviewers: srhines, danalbert.
peter.smith added a comment.

I think that this may not apply for Android as AFAIK their ABI still requires 
128-bit alignment in some cases. Adding some more reviewers from Android.




Comment at: lib/Basic/Targets/ARM.cpp:311
 
   // Maximum alignment for ARM NEON data types should be 64-bits (AAPCS)
   if (IsAAPCS && (Triple.getEnvironment() != llvm::Triple::Android))

I think that Android can require a higher alignment in some cases (See below). 
I think that this was explained in D33205


Repository:
  rC Clang

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

https://reviews.llvm.org/D65000



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


[PATCH] D65042: [Concept] Placeholder constraints and abbreviated templates

2019-07-22 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

`ASTImporter.cpp` and `ASTStructuralEquivalence.cpp` looks good to me!




Comment at: lib/AST/ASTImporter.cpp:1286
 
-  return Importer.getToContext().getAutoType(*ToDeducedTypeOrErr,
- T->getKeyword(),
- /*IsDependent*/false);
+  ExpectedDecl ToTypeConstraintConcept = import(T->getTypeConstraintConcept());
+  if (!ToTypeConstraintConcept)

LGTM!



Comment at: lib/AST/ASTStructuralEquivalence.cpp:732
 
-  case Type::Auto:
-if (!IsStructurallyEquivalent(Context, 
cast(T1)->getDeducedType(),
-  cast(T2)->getDeducedType()))
+  case Type::Auto: {
+auto *Auto1 = cast(T1);

This looks good to me!


Repository:
  rC Clang

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

https://reviews.llvm.org/D65042



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


[PATCH] D65067: [clangd] Fix auto expand not work on "const au^to s = 123;"

2019-07-22 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65067

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -663,6 +663,35 @@
 const char * x = "test";
   )cpp";
   checkTransform(ID, Input, Output);
+
+  // qualified auto type
+  Input = R"cpp(
+class Foo {};
+const au^to x = Foo();
+  )cpp";
+  Output = R"cpp(
+class Foo {};
+const Foo x = Foo();
+  )cpp";
+  checkTransform(ID, Input, Output);
+
+  Input = R"cpp(
+volatile au^to x = 1;
+  )cpp";
+  Output = R"cpp(
+volatile int x = 1;
+  )cpp";
+  checkTransform(ID, Input, Output);
+
+  Input = R"cpp(
+class Foo {};
+const au^to *x = new Foo();
+  )cpp";
+  Output = R"cpp(
+class Foo {};
+const Foo *x = new Foo();
+  )cpp";
+  checkTransform(ID, Input, Output);
 }
 
 } // namespace
Index: clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
@@ -60,9 +60,12 @@
   CachedLocation = llvm::None;
   if (auto *Node = Inputs.ASTSelection.commonAncestor()) {
 if (auto *TypeNode = Node->ASTNode.get()) {
-  if (const AutoTypeLoc Result = TypeNode->getAs()) {
+  auto Node = *TypeNode;
+  // Skip any qualifiers (e.g. const) around auto.
+  if (const auto QTL = Node.getAs())
+Node = QTL.getUnqualifiedLoc();
+  if (const AutoTypeLoc Result = Node.getAs())
 CachedLocation = Result;
-  }
 }
   }
   return (bool) CachedLocation;


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -663,6 +663,35 @@
 const char * x = "test";
   )cpp";
   checkTransform(ID, Input, Output);
+
+  // qualified auto type
+  Input = R"cpp(
+class Foo {};
+const au^to x = Foo();
+  )cpp";
+  Output = R"cpp(
+class Foo {};
+const Foo x = Foo();
+  )cpp";
+  checkTransform(ID, Input, Output);
+
+  Input = R"cpp(
+volatile au^to x = 1;
+  )cpp";
+  Output = R"cpp(
+volatile int x = 1;
+  )cpp";
+  checkTransform(ID, Input, Output);
+
+  Input = R"cpp(
+class Foo {};
+const au^to *x = new Foo();
+  )cpp";
+  Output = R"cpp(
+class Foo {};
+const Foo *x = new Foo();
+  )cpp";
+  checkTransform(ID, Input, Output);
 }
 
 } // namespace
Index: clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
@@ -60,9 +60,12 @@
   CachedLocation = llvm::None;
   if (auto *Node = Inputs.ASTSelection.commonAncestor()) {
 if (auto *TypeNode = Node->ASTNode.get()) {
-  if (const AutoTypeLoc Result = TypeNode->getAs()) {
+  auto Node = *TypeNode;
+  // Skip any qualifiers (e.g. const) around auto.
+  if (const auto QTL = Node.getAs())
+Node = QTL.getUnqualifiedLoc();
+  if (const AutoTypeLoc Result = Node.getAs())
 CachedLocation = Result;
-  }
 }
   }
   return (bool) CachedLocation;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r366670 - [OpenCL] Improve destructor support in C++ for OpenCL

2019-07-22 Thread Marco Antognini via cfe-commits
Author: mantognini
Date: Mon Jul 22 02:39:13 2019
New Revision: 366670

URL: http://llvm.org/viewvc/llvm-project?rev=366670&view=rev
Log:
[OpenCL] Improve destructor support in C++ for OpenCL

This re-applies r366422 with a fix for Bug PR42665 and a new regression
test.

Added:
cfe/trunk/test/CodeGenCXX/PR42665.cpp
cfe/trunk/test/CodeGenOpenCLCXX/addrspace-with-class.cl
Removed:
cfe/trunk/test/CodeGenOpenCLCXX/addrspace-ctor.cl
Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/CodeGen/CGCXXABI.h
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=366670&r1=39&r2=366670&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Mon Jul 22 02:39:13 2019
@@ -2232,20 +2232,20 @@ public:
 
   overridden_method_range overridden_methods() const;
 
-  /// Returns the parent of this method declaration, which
+  /// Return the parent of this method declaration, which
   /// is the class in which this method is defined.
   const CXXRecordDecl *getParent() const {
 return cast(FunctionDecl::getParent());
   }
 
-  /// Returns the parent of this method declaration, which
+  /// Return the parent of this method declaration, which
   /// is the class in which this method is defined.
   CXXRecordDecl *getParent() {
 return const_cast(
  cast(FunctionDecl::getParent()));
   }
 
-  /// Returns the type of the \c this pointer.
+  /// Return the type of the \c this pointer.
   ///
   /// Should only be called for instance (i.e., non-static) methods. Note
   /// that for the call operator of a lambda closure type, this returns the
@@ -2253,9 +2253,17 @@ public:
   /// 'this' type.
   QualType getThisType() const;
 
+  /// Return the type of the object pointed by \c this.
+  ///
+  /// See getThisType() for usage restriction.
+  QualType getThisObjectType() const;
+
   static QualType getThisType(const FunctionProtoType *FPT,
   const CXXRecordDecl *Decl);
 
+  static QualType getThisObjectType(const FunctionProtoType *FPT,
+const CXXRecordDecl *Decl);
+
   Qualifiers getMethodQualifiers() const {
 return getType()->getAs()->getMethodQuals();
   }

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=366670&r1=39&r2=366670&view=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Mon Jul 22 02:39:13 2019
@@ -185,15 +185,20 @@ public:
   static CXXMemberCallExpr *CreateEmpty(const ASTContext &Ctx, unsigned 
NumArgs,
 EmptyShell Empty);
 
-  /// Retrieves the implicit object argument for the member call.
+  /// Retrieve the implicit object argument for the member call.
   ///
   /// For example, in "x.f(5)", this returns the sub-expression "x".
   Expr *getImplicitObjectArgument() const;
 
-  /// Retrieves the declaration of the called method.
+  /// Retrieve the type of the object argument.
+  ///
+  /// Note that this always returns a non-pointer type.
+  QualType getObjectType() const;
+
+  /// Retrieve the declaration of the called method.
   CXXMethodDecl *getMethodDecl() const;
 
-  /// Retrieves the CXXRecordDecl for the underlying type of
+  /// Retrieve the CXXRecordDecl for the underlying type of
   /// the implicit object argument.
   ///
   /// Note that this is may not be the same declaration as that of the class

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=366670&r1=39&r2=366670&view=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Mon Jul 22 02:39:13 2019
@@ -2253,12 +2253,23 @@ CXXMethodDecl::overridden_methods() cons
   return getASTContext().overridden_methods(this);
 }
 
+static QualType getThisObjectType(ASTContext &C, const FunctionProtoType *FPT,
+  const CXXRecordDecl *Decl) {
+  QualType ClassTy = C.getTypeDeclType(Decl);
+  return C.getQualifiedType(ClassTy, FPT->getMethodQuals());
+}
+
 QualType CXXMethodDecl::getThisType(const FunctionProtoType *FPT,
 

[PATCH] D65064: [CrossTU] Add a function to retrieve original source location.

2019-07-22 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65064



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


[PATCH] D64762: [AST] Treat semantic form of InitListExpr as implicit code in traversals

2019-07-22 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang/include/clang/AST/RecursiveASTVisitor.h:2332
   S->isSemanticForm() ? S->getSyntacticForm() : S, Queue));
   TRY_TO(TraverseSynOrSemInitListExpr(
   S->isSemanticForm() ? S : S->getSemanticForm(), Queue));

gribozavr wrote:
> ilya-biryukov wrote:
> > ilya-biryukov wrote:
> > > gribozavr wrote:
> > > > Instead of adding a whole new if statement, could you wrap the second 
> > > > existing TRY_TO in `if(shouldVisitImplicitCode())` ?
> > > Despite looking very similar, that would **not** be equivalent to the 
> > > current version.
> > > 
> > > For most init lists (that do not have alternative "form"), the following 
> > > invariants hold:
> > > ```
> > > InitList* E = ...;
> > > assert(E->isSemanticForm());
> > > assert(E->isSyntacticForm()); 
> > > assert(E->getSynacticForm() == nullptr);
> > > ```
> > > 
> > > This subtle fact means the current code does not traversed the list twice 
> > > if they do not have an alternative form (either semantic or syntactic).
> > > 
> > > Now, if we only run the first statement, we will call 
> > > `TraverseSynOrSemInitListExpr(S->getSyntacticForm())` and 
> > > `S->getSyntacticForm()` returns `null`. So we don't traverse anything.
> > > 
> > > I tried various ways to keep both calls, but they all ended up being too 
> > > complicated, hence the final version. Let me know if you see a better way 
> > > to address this.
> > To make the last sentence less confusing:
> > I tried various ways to keep **only two** calls, but they were too 
> > complicated and I ended up introducing an extra call to `TraverseSyn...` 
> > instead.
> > 
> > assert(E->getSynacticForm() == nullptr);
> 
> That's... a really nice API.
> 
> What do you think about the following:
> 
> ```
> if (S->isSyntacticForm() && S->isSemanticForm()) {
>   // `S` does not have alternative forms, traverse the only form that's 
> available.
>   TRY_TO(TraverseSynOrSemInitListExpr(S, Queue));
>   return true;
> }
> 
> TRY_TO(TraverseSynOrSemInitListExpr(
>   S->isSemanticForm() ? S->getSyntacticForm() : S, Queue));
> if (getDerived().shouldVisitImplicitCode()) {
>   TRY_TO(TraverseSynOrSemInitListExpr(
> S->isSyntacticForm() ? S->getSemanticForm() : S, Queue));
> }
> ```
Definitely reads better, updated the revision accordingly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64762



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


[PATCH] D65000: [ARM] Set default alignment to 64bits

2019-07-22 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio updated this revision to Diff 211034.
dnsampaio added a comment.

- Set androideabi alignment to 128 bits


Repository:
  rC Clang

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

https://reviews.llvm.org/D65000

Files:
  lib/Basic/Targets/ARM.cpp
  test/CodeGen/ARM/exception-alignment.cpp
  test/SemaCXX/warn-overaligned-type-thrown.cpp


Index: test/SemaCXX/warn-overaligned-type-thrown.cpp
===
--- test/SemaCXX/warn-overaligned-type-thrown.cpp
+++ test/SemaCXX/warn-overaligned-type-thrown.cpp
@@ -2,11 +2,12 @@
 // RUN: %clang_cc1 -triple arm64-apple-ios10 -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions -DUNDERALIGNED %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos10 -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions -DUNDERALIGNED %s
 // RUN: %clang_cc1 -triple arm64-apple-watchos4 -verify -fsyntax-only 
-std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
+// RUN: %clang_cc1 -triple arm-linux-gnueabi -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions  -DUNDERALIGNED %s
+// RUN: %clang_cc1 -triple arm-linux-androideabi -verify -fsyntax-only 
-std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.14 -verify -fsyntax-only 
-std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple arm64-apple-ios12 -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos12 -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple arm64-apple-watchos5 -verify -fsyntax-only 
-std=c++11 -fcxx-exceptions -fexceptions %s
-// RUN: %clang_cc1 -triple arm-linux-gnueabi -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple aarch64-linux-gnueabi -verify -fsyntax-only 
-std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple mipsel-linux-gnu -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple mips64el-linux-gnu -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions %s
Index: test/CodeGen/ARM/exception-alignment.cpp
===
--- /dev/null
+++ test/CodeGen/ARM/exception-alignment.cpp
@@ -0,0 +1,18 @@
+// Bug: https://bugs.llvm.org/show_bug.cgi?id=42668
+// REQUIRES: arm-registered-target
+// RUN: %clang --target=arm-arm-none-eabi -march=armv8-a -S -emit-llvm -Os -o 
- %s | FileCheck --check-prefixes=CHECK,A8 %s
+// RUN: %clang --target=arm-linux-androideabi -march=armv8-a -S -emit-llvm -Os 
-o - %s | FileCheck --check-prefixes=CHECK,A16 %s
+// CHECK: [[E:%[A-z0-9]+]] = tail call i8* @__cxa_allocate_exception
+// CHECK-NEXT: [[BC:%[A-z0-9]+]] = bitcast i8* [[E]] to <2 x i64>*
+// A16-NEXT: store <2 x i64> , <2 x i64>* [[BC]], align 16
+#include 
+
+int main(void) {
+  try {
+throw vld1q_u64(((const uint64_t[2]){1, 2}));
+  } catch (uint64x2_t exc) {
+return 0;
+  }
+  return 1;
+}
+
Index: lib/Basic/Targets/ARM.cpp
===
--- lib/Basic/Targets/ARM.cpp
+++ lib/Basic/Targets/ARM.cpp
@@ -325,6 +325,11 @@
: "\01mcount";
 
   SoftFloatABI = llvm::is_contained(Opts.FeaturesAsWritten, "+soft-float-abi");
+
+  // For AArch32, the largest alignment required by the ABI is 64-bit
+   // but Android ABI uses 128-bit alignment as default
+  DefaultAlignForAttributeAligned =
+   (Triple.getEnvironment() == llvm::Triple::Android)?128:64;
 }
 
 StringRef ARMTargetInfo::getABI() const { return ABI; }


Index: test/SemaCXX/warn-overaligned-type-thrown.cpp
===
--- test/SemaCXX/warn-overaligned-type-thrown.cpp
+++ test/SemaCXX/warn-overaligned-type-thrown.cpp
@@ -2,11 +2,12 @@
 // RUN: %clang_cc1 -triple arm64-apple-ios10 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos10 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
 // RUN: %clang_cc1 -triple arm64-apple-watchos4 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
+// RUN: %clang_cc1 -triple arm-linux-gnueabi -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions  -DUNDERALIGNED %s
+// RUN: %clang_cc1 -triple arm-linux-androideabi -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.14 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple arm64-apple-ios12 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos12 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple arm64-apple-watchos5 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %

[PATCH] D64762: [AST] Treat semantic form of InitListExpr as implicit code in traversals

2019-07-22 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 211035.
ilya-biryukov marked an inline comment as done.
ilya-biryukov added a comment.

- Rewrite code as suggested in the review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64762

Files:
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPreOrder.cpp


Index: clang/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPreOrder.cpp
===
--- clang/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPreOrder.cpp
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPreOrder.cpp
@@ -17,14 +17,22 @@
 class InitListExprPreOrderVisitor
 : public ExpectedLocationVisitor {
 public:
+  InitListExprPreOrderVisitor(bool VisitImplicitCode)
+  : VisitImplicitCode(VisitImplicitCode) {}
+
+  bool shouldVisitImplicitCode() const { return VisitImplicitCode; }
+
   bool VisitInitListExpr(InitListExpr *ILE) {
 Match(ILE->isSemanticForm() ? "semantic" : "syntactic", 
ILE->getBeginLoc());
 return true;
   }
+
+private:
+  bool VisitImplicitCode;
 };
 
 TEST(RecursiveASTVisitor, InitListExprIsPreOrderVisitedTwice) {
-  InitListExprPreOrderVisitor Visitor;
+  InitListExprPreOrderVisitor Visitor(/*VisitImplicitCode=*/true);
   Visitor.ExpectMatch("syntactic", 2, 21);
   Visitor.ExpectMatch("semantic", 2, 21);
   EXPECT_TRUE(Visitor.runOver("struct S { int x; };\n"
@@ -32,4 +40,13 @@
   InitListExprPreOrderVisitor::Lang_C));
 }
 
+TEST(RecursiveASTVisitor, InitListExprVisitedOnceWhenNoImplicit) {
+  InitListExprPreOrderVisitor Visitor(/*VisitImplicitCode=*/false);
+  Visitor.ExpectMatch("syntactic", 2, 21);
+  Visitor.DisallowMatch("semantic", 2, 21);
+  EXPECT_TRUE(Visitor.runOver("struct S { int x; };\n"
+  "static struct S s = {.x = 0};\n",
+  InitListExprPreOrderVisitor::Lang_C));
+}
+
 } // end anonymous namespace
Index: clang/include/clang/AST/RecursiveASTVisitor.h
===
--- clang/include/clang/AST/RecursiveASTVisitor.h
+++ clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2308,19 +2308,30 @@
   return true;
 }
 
-// This method is called once for each pair of syntactic and semantic
-// InitListExpr, and it traverses the subtrees defined by the two forms. This
-// may cause some of the children to be visited twice, if they appear both in
-// the syntactic and the semantic form.
+// If shouldVisitImplicitCode() returns false, this method traverses only the
+// syntactic form of InitListExpr.
+// If shouldVisitImplicitCode() return true, this method is called once for
+// each pair of syntactic and semantic InitListExpr, and it traverses the
+// subtrees defined by the two forms. This may cause some of the children to be
+// visited twice, if they appear both in the syntactic and the semantic form.
 //
 // There is no guarantee about which form \p S takes when this method is 
called.
 template 
 bool RecursiveASTVisitor::TraverseInitListExpr(
 InitListExpr *S, DataRecursionQueue *Queue) {
+  if (S->isSemanticForm() && S->isSyntacticForm()) {
+// `S` does not have alternative forms, traverse only once.
+TRY_TO(TraverseSynOrSemInitListExpr(S, Queue));
+return true;
+  }
   TRY_TO(TraverseSynOrSemInitListExpr(
   S->isSemanticForm() ? S->getSyntacticForm() : S, Queue));
-  TRY_TO(TraverseSynOrSemInitListExpr(
-  S->isSemanticForm() ? S : S->getSemanticForm(), Queue));
+  if (getDerived().shouldVisitImplicitCode()) {
+// Only visit the semantic form if the clients are interested in implicit
+// compiler-generated.
+TRY_TO(TraverseSynOrSemInitListExpr(
+S->isSemanticForm() ? S : S->getSemanticForm(), Queue));
+  }
   return true;
 }
 


Index: clang/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPreOrder.cpp
===
--- clang/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPreOrder.cpp
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPreOrder.cpp
@@ -17,14 +17,22 @@
 class InitListExprPreOrderVisitor
 : public ExpectedLocationVisitor {
 public:
+  InitListExprPreOrderVisitor(bool VisitImplicitCode)
+  : VisitImplicitCode(VisitImplicitCode) {}
+
+  bool shouldVisitImplicitCode() const { return VisitImplicitCode; }
+
   bool VisitInitListExpr(InitListExpr *ILE) {
 Match(ILE->isSemanticForm() ? "semantic" : "syntactic", ILE->getBeginLoc());
 return true;
   }
+
+private:
+  bool VisitImplicitCode;
 };
 
 TEST(RecursiveASTVisitor, InitListExprIsPreOrderVisitedTwice) {
-  InitListExprPreOrderVisitor Visitor;
+  InitListExprPreOrderVisitor Visitor(/*VisitImplicitCode=*/true);
   Visitor.ExpectMatch("syntactic", 2, 21);
   Visitor.ExpectMatch("semantic", 2, 21);
   

[PATCH] D65064: [CrossTU] Add a function to retrieve original source location.

2019-07-22 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:476
+  NewImporter->setFileIDImportHandler(
+  [this, Unit](FileID ToID, FileID FromID, ASTImporter &Importer) {
+assert(ImportedFileIDs.find(ToID) == ImportedFileIDs.end() &&

The `Importer` is not used, perhaps it is not needed in the lambda?

Or we might have the mapping of ToID->FromID in the ASTImporter, and the 
FromID->FromUnit mapping in the CTUContext?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65064



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


r366672 - [AST] Treat semantic form of InitListExpr as implicit code in traversals

2019-07-22 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon Jul 22 02:58:53 2019
New Revision: 366672

URL: http://llvm.org/viewvc/llvm-project?rev=366672&view=rev
Log:
[AST] Treat semantic form of InitListExpr as implicit code in traversals

Summary:
In particular, do not traverse the semantic form if shouldVisitImplicitCode()
returns false.

This simplifies the common case of traversals, avoiding the need to
worry about some expressions being traversed twice.

No tests break after the change, the change would allow to simplify at
least one of the usages, i.e. r366070 which had to handle this in
clangd.

Reviewers: gribozavr

Reviewed By: gribozavr

Subscribers: kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D64762

Modified:
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h

cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPreOrder.cpp

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=366672&r1=366671&r2=366672&view=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Mon Jul 22 02:58:53 2019
@@ -2308,19 +2308,30 @@ bool RecursiveASTVisitor::Trave
   return true;
 }
 
-// This method is called once for each pair of syntactic and semantic
-// InitListExpr, and it traverses the subtrees defined by the two forms. This
-// may cause some of the children to be visited twice, if they appear both in
-// the syntactic and the semantic form.
+// If shouldVisitImplicitCode() returns false, this method traverses only the
+// syntactic form of InitListExpr.
+// If shouldVisitImplicitCode() return true, this method is called once for
+// each pair of syntactic and semantic InitListExpr, and it traverses the
+// subtrees defined by the two forms. This may cause some of the children to be
+// visited twice, if they appear both in the syntactic and the semantic form.
 //
 // There is no guarantee about which form \p S takes when this method is 
called.
 template 
 bool RecursiveASTVisitor::TraverseInitListExpr(
 InitListExpr *S, DataRecursionQueue *Queue) {
+  if (S->isSemanticForm() && S->isSyntacticForm()) {
+// `S` does not have alternative forms, traverse only once.
+TRY_TO(TraverseSynOrSemInitListExpr(S, Queue));
+return true;
+  }
   TRY_TO(TraverseSynOrSemInitListExpr(
   S->isSemanticForm() ? S->getSyntacticForm() : S, Queue));
-  TRY_TO(TraverseSynOrSemInitListExpr(
-  S->isSemanticForm() ? S : S->getSemanticForm(), Queue));
+  if (getDerived().shouldVisitImplicitCode()) {
+// Only visit the semantic form if the clients are interested in implicit
+// compiler-generated.
+TRY_TO(TraverseSynOrSemInitListExpr(
+S->isSemanticForm() ? S : S->getSemanticForm(), Queue));
+  }
   return true;
 }
 

Modified: 
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPreOrder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPreOrder.cpp?rev=366672&r1=366671&r2=366672&view=diff
==
--- 
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPreOrder.cpp 
(original)
+++ 
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPreOrder.cpp 
Mon Jul 22 02:58:53 2019
@@ -17,19 +17,36 @@ namespace {
 class InitListExprPreOrderVisitor
 : public ExpectedLocationVisitor {
 public:
+  InitListExprPreOrderVisitor(bool VisitImplicitCode)
+  : VisitImplicitCode(VisitImplicitCode) {}
+
+  bool shouldVisitImplicitCode() const { return VisitImplicitCode; }
+
   bool VisitInitListExpr(InitListExpr *ILE) {
 Match(ILE->isSemanticForm() ? "semantic" : "syntactic", 
ILE->getBeginLoc());
 return true;
   }
+
+private:
+  bool VisitImplicitCode;
 };
 
 TEST(RecursiveASTVisitor, InitListExprIsPreOrderVisitedTwice) {
-  InitListExprPreOrderVisitor Visitor;
+  InitListExprPreOrderVisitor Visitor(/*VisitImplicitCode=*/true);
   Visitor.ExpectMatch("syntactic", 2, 21);
   Visitor.ExpectMatch("semantic", 2, 21);
   EXPECT_TRUE(Visitor.runOver("struct S { int x; };\n"
   "static struct S s = {.x = 0};\n",
   InitListExprPreOrderVisitor::Lang_C));
+}
+
+TEST(RecursiveASTVisitor, InitListExprVisitedOnceWhenNoImplicit) {
+  InitListExprPreOrderVisitor Visitor(/*VisitImplicitCode=*/false);
+  Visitor.ExpectMatch("syntactic", 2, 21);
+  Visitor.DisallowMatch("semantic", 2, 21);
+  EXPECT_TRUE(Visitor.runOver("struct S { int x; };\n"
+  "static struct S s = {.x = 0};\n",
+  InitListExprPreOrderVisitor::Lang_C));
 }
 
 } // end anonymous namespace


___
cfe-commits mailing list
cfe-commits@lists.llvm.or

[PATCH] D64762: [AST] Treat semantic form of InitListExpr as implicit code in traversals

2019-07-22 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366672: [AST] Treat semantic form of InitListExpr as 
implicit code in traversals (authored by ibiryukov, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64762?vs=211035&id=211040#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64762

Files:
  cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
  cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPreOrder.cpp


Index: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
===
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
@@ -2308,19 +2308,30 @@
   return true;
 }
 
-// This method is called once for each pair of syntactic and semantic
-// InitListExpr, and it traverses the subtrees defined by the two forms. This
-// may cause some of the children to be visited twice, if they appear both in
-// the syntactic and the semantic form.
+// If shouldVisitImplicitCode() returns false, this method traverses only the
+// syntactic form of InitListExpr.
+// If shouldVisitImplicitCode() return true, this method is called once for
+// each pair of syntactic and semantic InitListExpr, and it traverses the
+// subtrees defined by the two forms. This may cause some of the children to be
+// visited twice, if they appear both in the syntactic and the semantic form.
 //
 // There is no guarantee about which form \p S takes when this method is 
called.
 template 
 bool RecursiveASTVisitor::TraverseInitListExpr(
 InitListExpr *S, DataRecursionQueue *Queue) {
+  if (S->isSemanticForm() && S->isSyntacticForm()) {
+// `S` does not have alternative forms, traverse only once.
+TRY_TO(TraverseSynOrSemInitListExpr(S, Queue));
+return true;
+  }
   TRY_TO(TraverseSynOrSemInitListExpr(
   S->isSemanticForm() ? S->getSyntacticForm() : S, Queue));
-  TRY_TO(TraverseSynOrSemInitListExpr(
-  S->isSemanticForm() ? S : S->getSemanticForm(), Queue));
+  if (getDerived().shouldVisitImplicitCode()) {
+// Only visit the semantic form if the clients are interested in implicit
+// compiler-generated.
+TRY_TO(TraverseSynOrSemInitListExpr(
+S->isSemanticForm() ? S : S->getSemanticForm(), Queue));
+  }
   return true;
 }
 
Index: 
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPreOrder.cpp
===
--- 
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPreOrder.cpp
+++ 
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPreOrder.cpp
@@ -17,14 +17,22 @@
 class InitListExprPreOrderVisitor
 : public ExpectedLocationVisitor {
 public:
+  InitListExprPreOrderVisitor(bool VisitImplicitCode)
+  : VisitImplicitCode(VisitImplicitCode) {}
+
+  bool shouldVisitImplicitCode() const { return VisitImplicitCode; }
+
   bool VisitInitListExpr(InitListExpr *ILE) {
 Match(ILE->isSemanticForm() ? "semantic" : "syntactic", 
ILE->getBeginLoc());
 return true;
   }
+
+private:
+  bool VisitImplicitCode;
 };
 
 TEST(RecursiveASTVisitor, InitListExprIsPreOrderVisitedTwice) {
-  InitListExprPreOrderVisitor Visitor;
+  InitListExprPreOrderVisitor Visitor(/*VisitImplicitCode=*/true);
   Visitor.ExpectMatch("syntactic", 2, 21);
   Visitor.ExpectMatch("semantic", 2, 21);
   EXPECT_TRUE(Visitor.runOver("struct S { int x; };\n"
@@ -32,4 +40,13 @@
   InitListExprPreOrderVisitor::Lang_C));
 }
 
+TEST(RecursiveASTVisitor, InitListExprVisitedOnceWhenNoImplicit) {
+  InitListExprPreOrderVisitor Visitor(/*VisitImplicitCode=*/false);
+  Visitor.ExpectMatch("syntactic", 2, 21);
+  Visitor.DisallowMatch("semantic", 2, 21);
+  EXPECT_TRUE(Visitor.runOver("struct S { int x; };\n"
+  "static struct S s = {.x = 0};\n",
+  InitListExprPreOrderVisitor::Lang_C));
+}
+
 } // end anonymous namespace


Index: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
===
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
@@ -2308,19 +2308,30 @@
   return true;
 }
 
-// This method is called once for each pair of syntactic and semantic
-// InitListExpr, and it traverses the subtrees defined by the two forms. This
-// may cause some of the children to be visited twice, if they appear both in
-// the syntactic and the semantic form.
+// If shouldVisitImplicitCode() returns false, this method traverses only the
+// syntactic form of InitListExpr.
+// If shouldVisitImplicitCode() return true, this method is called once for
+// each pair of syntactic and semantic InitListExpr, and it traverses the
+// subtrees defin

[clang-tools-extra] r366674 - [clangd] Log input code of failed highlighting tests. NFC

2019-07-22 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon Jul 22 03:05:11 2019
New Revision: 366674

URL: http://llvm.org/viewvc/llvm-project?rev=366674&view=rev
Log:
[clangd] Log input code of failed highlighting tests. NFC

Modified:
clang-tools-extra/trunk/clangd/unittests/SemanticHighlightingTests.cpp

Modified: clang-tools-extra/trunk/clangd/unittests/SemanticHighlightingTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/SemanticHighlightingTests.cpp?rev=366674&r1=366673&r2=366674&view=diff
==
--- clang-tools-extra/trunk/clangd/unittests/SemanticHighlightingTests.cpp 
(original)
+++ clang-tools-extra/trunk/clangd/unittests/SemanticHighlightingTests.cpp Mon 
Jul 22 03:05:11 2019
@@ -50,7 +50,8 @@ void checkHighlightings(llvm::StringRef
   }
 
   auto ActualTokens = getSemanticHighlightings(AST);
-  EXPECT_THAT(ActualTokens, 
testing::UnorderedElementsAreArray(ExpectedTokens));
+  EXPECT_THAT(ActualTokens, testing::UnorderedElementsAreArray(ExpectedTokens))
+   << "Inputs is:\n" << Code;
 }
 
 TEST(SemanticHighlighting, GetsCorrectTokens) {


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


[PATCH] D65000: [ARM] Set default alignment to 64bits

2019-07-22 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio marked 2 inline comments as done.
dnsampaio added a comment.

Set android-abi default to 128. Added tests for android and not-android.




Comment at: lib/Basic/Targets/ARM.cpp:311
 
   // Maximum alignment for ARM NEON data types should be 64-bits (AAPCS)
   if (IsAAPCS && (Triple.getEnvironment() != llvm::Triple::Android))

peter.smith wrote:
> I think that Android can require a higher alignment in some cases (See 
> below). I think that this was explained in D33205
Hi @peter.smith ,
thanks for the review, I did not know about the androidabi being 128 bits 
default. Updated accordingly.


Repository:
  rC Clang

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

https://reviews.llvm.org/D65000



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


[PATCH] D64744: #pragma clang loop vectorize_predicate(enable|disable)

2019-07-22 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer updated this revision to Diff 211042.
SjoerdMeijer added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

- Moved the codegen test to a separate file
- Added a langref description for this new metadata node.


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

https://reviews.llvm.org/D64744

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/CodeGen/CGLoopInfo.cpp
  clang/lib/CodeGen/CGLoopInfo.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/AST/ast-print-pragmas.cpp
  clang/test/CodeGenCXX/pragma-loop-predicate.cpp
  clang/test/Parser/pragma-loop.cpp
  clang/test/Parser/pragma-unroll-and-jam.cpp
  llvm/docs/LangRef.rst

Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -5389,6 +5389,21 @@
!0 = !{!"llvm.loop.vectorize.enable", i1 0}
!1 = !{!"llvm.loop.vectorize.enable", i1 1}
 
+'``llvm.loop.vectorize.predicate.enable``' Metadata
+^^^
+
+This metadata selectively enables or disables creating predicated instructions
+for the loop, which can enable folding of the scalar epilogue loop into the
+main loop. The first operand is the string
+``llvm.loop.vectorize.predicate.enable`` and the second operand is a bit. If
+the bit operand value is 1 vectorization is enabled. A value of 0 disables
+vectorization:
+
+.. code-block:: llvm
+
+   !0 = !{!"llvm.loop.vectorize.predicate.enable", i1 0}
+   !1 = !{!"llvm.loop.vectorize.predicate.enable", i1 1}
+
 '``llvm.loop.vectorize.width``' Metadata
 
 
Index: clang/test/Parser/pragma-unroll-and-jam.cpp
===
--- clang/test/Parser/pragma-unroll-and-jam.cpp
+++ clang/test/Parser/pragma-unroll-and-jam.cpp
@@ -67,7 +67,7 @@
   }
 
 // pragma clang unroll_and_jam is disabled for the moment
-/* expected-error {{invalid option 'unroll_and_jam'; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, or distribute}} */ #pragma clang loop unroll_and_jam(4)
+/* expected-error {{invalid option 'unroll_and_jam'; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, vectorize_predicate, or distribute}} */ #pragma clang loop unroll_and_jam(4)
   for (int i = 0; i < Length; i++) {
 for (int j = 0; j < Length; j++) {
   List[i * Length + j] = Value;
Index: clang/test/Parser/pragma-loop.cpp
===
--- clang/test/Parser/pragma-loop.cpp
+++ clang/test/Parser/pragma-loop.cpp
@@ -81,6 +81,7 @@
 
 #pragma clang loop vectorize(enable)
 #pragma clang loop interleave(enable)
+#pragma clang loop vectorize_predicate(enable)
 #pragma clang loop unroll(full)
   while (i + 1 < Length) {
 List[i] = i;
@@ -95,6 +96,7 @@
 
 #pragma clang loop vectorize(disable)
 #pragma clang loop interleave(disable)
+#pragma clang loop vectorize_predicate(disable)
 #pragma clang loop unroll(disable)
   while (i - 1 < Length) {
 List[i] = i;
@@ -111,7 +113,7 @@
   }
 
   int VList[Length];
-#pragma clang loop vectorize(disable) interleave(disable) unroll(disable)
+#pragma clang loop vectorize(disable) interleave(disable) unroll(disable) vectorize_predicate(disable)
   for (int j : VList) {
 VList[j] = List[j];
   }
@@ -130,11 +132,13 @@
 
 /* expected-error {{expected '('}} */ #pragma clang loop vectorize
 /* expected-error {{expected '('}} */ #pragma clang loop interleave
+/* expected-error {{expected '('}} */ #pragma clang loop vectorize_predicate
 /* expected-error {{expected '('}} */ #pragma clang loop unroll
 /* expected-error {{expected '('}} */ #pragma clang loop distribute
 
 /* expected-error {{expected ')'}} */ #pragma clang loop vectorize(enable
 /* expected-error {{expected ')'}} */ #pragma clang loop interleave(enable
+/* expected-error {{expected ')'}} */ #pragma clang loop vectorize_predicate(enable
 /* expected-error {{expected ')'}} */ #pragma clang loop unroll(full
 /* expected-error {{expected ')'}} */ #pragma clang loop distribute(enable
 
@@ -147,7 +151,7 @@
 /* expected-error {{missing argument; expected 'enable', 'full' or 'disable'}} */ #pragma clang loop unroll()
 /* expected-error {{missing argument; expected 'enable' or 'disable'}} */ #pragma clang loop distribute()
 
-/* expected-error {{missing option; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, or distribute}} */ #pragma clang loop
+/* expected-error {{missing option; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, vectorize_predicate, or distribut

[PATCH] D65000: [ARM] Set default alignment to 64bits

2019-07-22 Thread Peter Smith via Phabricator via cfe-commits
peter.smith added a comment.

Thanks for the update. Will be worth adding some reviewers from Apple to see if 
this change should be IsAAPCS only. I've no more further comments myself 
besides a small nit on style.




Comment at: lib/Basic/Targets/ARM.cpp:331
+   // but Android ABI uses 128-bit alignment as default
+  DefaultAlignForAttributeAligned =
+   (Triple.getEnvironment() == llvm::Triple::Android)?128:64;

Nit: suggest running clang-format over the conditional expression I think that 
spaces are needed around ? and :

The previous bit of code used
```
if (IsAAPCS && (Triple.getEnvironment() != llvm::Triple::Android))
MaxVectorAlign = 64;
```
The IsAAPCS could be important here as on Macho targets IsAAPCS may not be 
true, see calls to setABI in ARMTargetInfo::ARMTargetInfo.


Repository:
  rC Clang

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

https://reviews.llvm.org/D65000



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


[PATCH] D64739: [SVE][Inline-Asm] Add support to specify SVE registers in the clobber list

2019-07-22 Thread Diana Picus via Phabricator via cfe-commits
rovka added inline comments.



Comment at: clang/test/CodeGen/aarch64-sve-inline-asm.c:1
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -emit-llvm -target-feature 
+sve -o - %s | FileCheck %s
+

sdesmalen wrote:
> rovka wrote:
> > Can you also add a test without +sve, to make sure we get a diagnostic?
> Without the `-emit-llvm` part this test invokes (and tests the diagnostic of) 
> the compiler. I don't think this is what we want. At the same time, this code 
> should probably still continue match the z and p registers even if the target 
> feature is not given, and thus leave it to LLVM to determine whether the use 
> of these registers makes sense or not. So removing `-target-feature +sve` 
> from the RUN line should be sufficient here. @rovka do you agree?
Good point, we probably don't want this to be an integration test of the whole 
compiler. Removing the target feature altogether sounds good to me.


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

https://reviews.llvm.org/D64739



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


[clang-tools-extra] r366675 - [clangd] Set buffer name for main file. NFCI

2019-07-22 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Mon Jul 22 04:12:16 2019
New Revision: 366675

URL: http://llvm.org/viewvc/llvm-project?rev=366675&view=rev
Log:
[clangd] Set buffer name for main file. NFCI

Modified:
clang-tools-extra/trunk/clangd/ClangdUnit.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=366675&r1=366674&r2=366675&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Mon Jul 22 04:12:16 2019
@@ -570,7 +570,8 @@ buildPreamble(PathRef FileName, Compiler
   PreambleParsedCallback PreambleCallback) {
   // Note that we don't need to copy the input contents, preamble can live
   // without those.
-  auto ContentsBuffer = llvm::MemoryBuffer::getMemBuffer(Inputs.Contents);
+  auto ContentsBuffer =
+  llvm::MemoryBuffer::getMemBuffer(Inputs.Contents, FileName);
   auto Bounds =
   ComputePreambleBounds(*CI.getLangOpts(), ContentsBuffer.get(), 0);
 
@@ -650,10 +651,10 @@ buildAST(PathRef FileName, std::unique_p
 // dirs.
   }
 
-  return ParsedAST::build(llvm::make_unique(*Invocation),
-  Preamble,
-  
llvm::MemoryBuffer::getMemBufferCopy(Inputs.Contents),
-  std::move(VFS), Inputs.Index, Inputs.Opts);
+  return ParsedAST::build(
+  llvm::make_unique(*Invocation), Preamble,
+  llvm::MemoryBuffer::getMemBufferCopy(Inputs.Contents, FileName),
+  std::move(VFS), Inputs.Index, Inputs.Opts);
 }
 
 SourceLocation getBeginningOfIdentifier(const ParsedAST &Unit,


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


[PATCH] D64863: [clangd] Ignore diags from builtin files

2019-07-22 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/Diagnostics.cpp:563
 FillDiagBase(*LastDiag);
-adjustDiagFromHeader(*LastDiag, Info, *LangOpts);
+if (!InsideMainFile)
+  LastDiagWasAdjusted = adjustDiagFromHeader(*LastDiag, Info, *LangOpts);

kadircet wrote:
> ilya-biryukov wrote:
> > We probably want to **always** set the value of this field to avoid 
> > accidentally reading the flag for the previous `LastDiag`
> I don't follow, this is always set in line `475` at the beginning of 
> `HandleDiagnostic` method.
I might be missing something, but the only assignment to `LastDiagWasAdjusted` 
seems to be here (apart from initialization at the declaration site)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64863



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


[PATCH] D65064: [CrossTU] Add a function to retrieve original source location.

2019-07-22 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 211059.
balazske marked an inline comment as done.
balazske added a comment.

Removed ASTImporter from "callback" function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65064

Files:
  clang/include/clang/AST/ASTImporter.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/CrossTU/CrossTranslationUnit.cpp


Index: clang/lib/CrossTU/CrossTranslationUnit.cpp
===
--- clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -472,12 +472,11 @@
   ASTImporter *NewImporter = new ASTImporter(
   Context, Context.getSourceManager().getFileManager(), From,
   From.getSourceManager().getFileManager(), false, ImporterSharedSt);
-  NewImporter->setFileIDImportHandler(
-  [this, Unit](FileID ToID, FileID FromID, ASTImporter &Importer) {
-assert(ImportedFileIDs.find(ToID) == ImportedFileIDs.end() &&
-   "FileID already imported, should not happen.");
-ImportedFileIDs[ToID] = std::make_pair(FromID, Unit);
-  });
+  NewImporter->setFileIDImportHandler([this, Unit](FileID ToID, FileID FromID) 
{
+assert(ImportedFileIDs.find(ToID) == ImportedFileIDs.end() &&
+   "FileID already imported, should not happen.");
+ImportedFileIDs[ToID] = std::make_pair(FromID, Unit);
+  });
   ASTUnitImporterMap[From.getTranslationUnitDecl()].reset(NewImporter);
   return *NewImporter;
 }
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -8423,7 +8423,7 @@
   ImportedFileIDs[FromID] = ToID;
 
   if (FileIDImportHandler)
-FileIDImportHandler(ToID, FromID, *this);
+FileIDImportHandler(ToID, FromID);
 
   return ToID;
 }
Index: clang/include/clang/AST/ASTImporter.h
===
--- clang/include/clang/AST/ASTImporter.h
+++ clang/include/clang/AST/ASTImporter.h
@@ -87,8 +87,8 @@
 using NonEquivalentDeclSet = llvm::DenseSet>;
 using ImportedCXXBaseSpecifierMap =
 llvm::DenseMap;
-using FileIDImportHandlerType = std::function;
+using FileIDImportHandlerType =
+std::function;
 
 // An ImportPath is the list of the AST nodes which we visit during an
 // Import call.
@@ -317,7 +317,7 @@
 /// Set a callback function for FileID import handling.
 /// The function is invoked when a FileID is imported from the From 
context.
 /// The imported FileID in the To context and the original FileID in the
-/// From context, and the ASTImporter itself are passed to it.
+/// From context is passed to it.
 void setFileIDImportHandler(FileIDImportHandlerType H) {
   FileIDImportHandler = H;
 }


Index: clang/lib/CrossTU/CrossTranslationUnit.cpp
===
--- clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -472,12 +472,11 @@
   ASTImporter *NewImporter = new ASTImporter(
   Context, Context.getSourceManager().getFileManager(), From,
   From.getSourceManager().getFileManager(), false, ImporterSharedSt);
-  NewImporter->setFileIDImportHandler(
-  [this, Unit](FileID ToID, FileID FromID, ASTImporter &Importer) {
-assert(ImportedFileIDs.find(ToID) == ImportedFileIDs.end() &&
-   "FileID already imported, should not happen.");
-ImportedFileIDs[ToID] = std::make_pair(FromID, Unit);
-  });
+  NewImporter->setFileIDImportHandler([this, Unit](FileID ToID, FileID FromID) {
+assert(ImportedFileIDs.find(ToID) == ImportedFileIDs.end() &&
+   "FileID already imported, should not happen.");
+ImportedFileIDs[ToID] = std::make_pair(FromID, Unit);
+  });
   ASTUnitImporterMap[From.getTranslationUnitDecl()].reset(NewImporter);
   return *NewImporter;
 }
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -8423,7 +8423,7 @@
   ImportedFileIDs[FromID] = ToID;
 
   if (FileIDImportHandler)
-FileIDImportHandler(ToID, FromID, *this);
+FileIDImportHandler(ToID, FromID);
 
   return ToID;
 }
Index: clang/include/clang/AST/ASTImporter.h
===
--- clang/include/clang/AST/ASTImporter.h
+++ clang/include/clang/AST/ASTImporter.h
@@ -87,8 +87,8 @@
 using NonEquivalentDeclSet = llvm::DenseSet>;
 using ImportedCXXBaseSpecifierMap =
 llvm::DenseMap;
-using FileIDImportHandlerType = std::function;
+using FileIDImportHandlerType =
+std::function;
 
 // An ImportPath is the list of the AST nodes which we visit during an
 // Import call.
@@ -317,7 +317,7 @@
 /// Set a callback function 

[PATCH] D65064: [CrossTU] Add a function to retrieve original source location.

2019-07-22 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:476
+  NewImporter->setFileIDImportHandler(
+  [this, Unit](FileID ToID, FileID FromID, ASTImporter &Importer) {
+assert(ImportedFileIDs.find(ToID) == ImportedFileIDs.end() &&

martong wrote:
> The `Importer` is not used, perhaps it is not needed in the lambda?
> 
> Or we might have the mapping of ToID->FromID in the ASTImporter, and the 
> FromID->FromUnit mapping in the CTUContext?
Yes the `Importer` is not needed (if needed later it can be added to the lambda 
as a variable).
Additional mappings of `FileID` seems not needed now, the current solution is 
sufficient for this use case. If there is a ToID->FromID in the ASTImporter a 
"callback" lambda would be still needed to make the FromID->FromUnit mapping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65064



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


r366682 - Revert the change to the [[nodiscard]] feature test macro value.

2019-07-22 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Jul 22 05:49:28 2019
New Revision: 366682

URL: http://llvm.org/viewvc/llvm-project?rev=366682&view=rev
Log:
Revert the change to the [[nodiscard]] feature test macro value.

This value only gets bumped once both P1301 and P1771 are implemented.

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/test/Preprocessor/has_attribute.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=366682&r1=366681&r2=366682&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Mon Jul 22 05:49:28 2019
@@ -2335,7 +2335,7 @@ def WarnUnused : InheritableAttr {
 }
 
 def WarnUnusedResult : InheritableAttr {
-  let Spellings = [CXX11<"", "nodiscard", 201907>, C2x<"", "nodiscard">,
+  let Spellings = [CXX11<"", "nodiscard", 201603>, C2x<"", "nodiscard">,
CXX11<"clang", "warn_unused_result">,
GCC<"warn_unused_result">];
   let Subjects = SubjectList<[ObjCMethod, Enum, Record, FunctionLike]>;

Modified: cfe/trunk/test/Preprocessor/has_attribute.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/has_attribute.cpp?rev=366682&r1=366681&r2=366682&view=diff
==
--- cfe/trunk/test/Preprocessor/has_attribute.cpp (original)
+++ cfe/trunk/test/Preprocessor/has_attribute.cpp Mon Jul 22 05:49:28 2019
@@ -63,7 +63,7 @@ CXX11(unlikely)
 // CHECK: maybe_unused: 201603L
 // ITANIUM: no_unique_address: 201803L
 // WINDOWS: no_unique_address: 0
-// CHECK: nodiscard: 201907L
+// CHECK: nodiscard: 201603L
 // CHECK: noreturn: 200809L
 // FIXME(201803L) CHECK: unlikely: 0
 


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


Re: r366626 - Implement P1301R4, which allows specifying an optional message on the [[nodiscard]] attribute.

2019-07-22 Thread Aaron Ballman via cfe-commits
On Sun, Jul 21, 2019 at 7:40 AM Richard Smith  wrote:
>
> On Sat, 20 Jul 2019 at 09:55, Aaron Ballman via cfe-commits 
>  wrote:
>>
>> Author: aaronballman
>> Date: Sat Jul 20 00:56:34 2019
>> New Revision: 366626
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=366626&view=rev
>> Log:
>> Implement P1301R4, which allows specifying an optional message on the 
>> [[nodiscard]] attribute.
>>
>> This also bumps the attribute feature test value and introduces the notion 
>> of a C++2a extension warning.
>>
>> Modified:
>> cfe/trunk/include/clang/Basic/Attr.td
>> cfe/trunk/include/clang/Basic/AttrDocs.td
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>> cfe/trunk/lib/Sema/SemaStmt.cpp
>> cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p1.cpp
>> cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp
>> cfe/trunk/test/Preprocessor/has_attribute.cpp
>> cfe/trunk/test/Sema/c2x-nodiscard.c
>> cfe/trunk/test/SemaCXX/cxx11-attr-print.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/Attr.td
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=366626&r1=366625&r2=366626&view=diff
>> ==
>> --- cfe/trunk/include/clang/Basic/Attr.td (original)
>> +++ cfe/trunk/include/clang/Basic/Attr.td Sat Jul 20 00:56:34 2019
>> @@ -2335,10 +2335,11 @@ def WarnUnused : InheritableAttr {
>>  }
>>
>>  def WarnUnusedResult : InheritableAttr {
>> -  let Spellings = [CXX11<"", "nodiscard", 201603>, C2x<"", "nodiscard">,
>> +  let Spellings = [CXX11<"", "nodiscard", 201907>, C2x<"", "nodiscard">,
>
>
> We shouldn't bump the version until we also implement P1771R1, as this number 
> indicates that both papers are implemented.

Good call. I've switched back to the previous value in r366682. Thanks
for catching this!

~Aaron

>
>>
>> CXX11<"clang", "warn_unused_result">,
>> GCC<"warn_unused_result">];
>>let Subjects = SubjectList<[ObjCMethod, Enum, Record, FunctionLike]>;
>> +  let Args = [StringArgument<"Message", 1>];
>>let Documentation = [WarnUnusedResultsDocs];
>>  }
>>
>>
>> Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=366626&r1=366625&r2=366626&view=diff
>> ==
>> --- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
>> +++ cfe/trunk/include/clang/Basic/AttrDocs.td Sat Jul 20 00:56:34 2019
>> @@ -1482,6 +1482,13 @@ generated when a function or its return
>>  potentially-evaluated discarded-value expression that is not explicitly 
>> cast to
>>  `void`.
>>
>> +A string literal may optionally be provided to the attribute, which will be
>> +reproduced in any resulting diagnostics. Redeclarations using different 
>> forms
>> +of the attribute (with or without the string literal or with different 
>> string
>> +literal contents) are allowed. If there are redeclarations of the entity 
>> with
>> +differing string literals, it is unspecified which one will be used by Clang
>> +in any resulting diagnostics.
>> +
>>  .. code-block: c++
>>struct [[nodiscard]] error_info { /*...*/ };
>>error_info enable_missile_safety_mode();
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=366626&r1=366625&r2=366626&view=diff
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat Jul 20 00:56:34 
>> 2019
>> @@ -7436,6 +7436,9 @@ def warn_side_effects_typeid : Warning<
>>  def warn_unused_result : Warning<
>>"ignoring return value of function declared with %0 attribute">,
>>InGroup;
>> +def warn_unused_result_msg : Warning<
>> +  "ignoring return value of function declared with %0 attribute: %1">,
>> +  InGroup;
>>  def warn_unused_volatile : Warning<
>>"expression result unused; assign into a variable to force a volatile 
>> load">,
>>InGroup>;
>> @@ -7444,6 +7447,8 @@ def ext_cxx14_attr : Extension<
>>"use of the %0 attribute is a C++14 extension">, InGroup;
>>  def ext_cxx17_attr : Extension<
>>"use of the %0 attribute is a C++17 extension">, InGroup;
>> +def ext_cxx2a_attr : Extension<
>> +  "use of the %0 attribute is a C++2a extension">, InGroup;
>>
>>  def warn_unused_comparison : Warning<
>>"%select{equality|inequality|relational|three-way}0 comparison result 
>> unused">,
>>
>> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=366626&r1=366625&r2=366626&view=diff
>> =

r366683 - Updated the signature for some stack related intrinsics (CLANG)

2019-07-22 Thread Christudasan Devadasan via cfe-commits
Author: cdevadas
Date: Mon Jul 22 05:50:30 2019
New Revision: 366683

URL: http://llvm.org/viewvc/llvm-project?rev=366683&view=rev
Log:
Updated the signature for some stack related intrinsics (CLANG)

Modified the intrinsics
int_addressofreturnaddress,
int_frameaddress & int_sponentry.
This commit depends on the changes in rL366679

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D64563

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/test/CodeGen/builtin-sponentry.c
cfe/trunk/test/CodeGen/exceptions-seh.c
cfe/trunk/test/CodeGen/integer-overflow.c
cfe/trunk/test/CodeGen/ms-intrinsics.c
cfe/trunk/test/CodeGen/ms-setjmp.c
cfe/trunk/test/CodeGenOpenCL/builtins-generic-amdgcn.cl

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=366683&r1=366682&r2=366683&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Jul 22 05:50:30 2019
@@ -843,10 +843,12 @@ static RValue EmitMSVCRTSetJmp(CodeGenFu
 Name = SJKind == MSVCSetJmpKind::_setjmp ? "_setjmp" : "_setjmpex";
 Arg1Ty = CGF.Int8PtrTy;
 if (CGF.getTarget().getTriple().getArch() == llvm::Triple::aarch64) {
-  Arg1 = 
CGF.Builder.CreateCall(CGF.CGM.getIntrinsic(Intrinsic::sponentry));
+  Arg1 = CGF.Builder.CreateCall(
+  CGF.CGM.getIntrinsic(Intrinsic::sponentry, CGF.AllocaInt8PtrTy));
 } else
-  Arg1 = 
CGF.Builder.CreateCall(CGF.CGM.getIntrinsic(Intrinsic::frameaddress),
-llvm::ConstantInt::get(CGF.Int32Ty, 0));
+  Arg1 = CGF.Builder.CreateCall(
+  CGF.CGM.getIntrinsic(Intrinsic::frameaddress, CGF.AllocaInt8PtrTy),
+  llvm::ConstantInt::get(CGF.Int32Ty, 0));
   }
 
   // Mark the call site and declaration with ReturnsTwice.
@@ -2556,7 +2558,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(
   case Builtin::BI__builtin_frame_address: {
 Value *Depth = ConstantEmitter(*this).emitAbstract(E->getArg(0),
getContext().UnsignedIntTy);
-Function *F = CGM.getIntrinsic(Intrinsic::frameaddress);
+Function *F = CGM.getIntrinsic(Intrinsic::frameaddress, AllocaInt8PtrTy);
 return RValue::get(Builder.CreateCall(F, Depth));
   }
   case Builtin::BI__builtin_extract_return_addr: {
@@ -2637,9 +2639,9 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 Address Buf = EmitPointerWithAlignment(E->getArg(0));
 
 // Store the frame pointer to the setjmp buffer.
-Value *FrameAddr =
-  Builder.CreateCall(CGM.getIntrinsic(Intrinsic::frameaddress),
- ConstantInt::get(Int32Ty, 0));
+Value *FrameAddr = Builder.CreateCall(
+CGM.getIntrinsic(Intrinsic::frameaddress, AllocaInt8PtrTy),
+ConstantInt::get(Int32Ty, 0));
 Builder.CreateStore(FrameAddr, Buf);
 
 // Store the stack pointer to the setjmp buffer.
@@ -7293,12 +7295,13 @@ Value *CodeGenFunction::EmitAArch64Built
   }
 
   if (BuiltinID == AArch64::BI_AddressOfReturnAddress) {
-llvm::Function *F = CGM.getIntrinsic(Intrinsic::addressofreturnaddress);
+llvm::Function *F =
+CGM.getIntrinsic(Intrinsic::addressofreturnaddress, AllocaInt8PtrTy);
 return Builder.CreateCall(F);
   }
 
   if (BuiltinID == AArch64::BI__builtin_sponentry) {
-llvm::Function *F = CGM.getIntrinsic(Intrinsic::sponentry);
+llvm::Function *F = CGM.getIntrinsic(Intrinsic::sponentry, 
AllocaInt8PtrTy);
 return Builder.CreateCall(F);
   }
 
@@ -12113,7 +12116,8 @@ Value *CodeGenFunction::EmitX86BuiltinEx
   }
 
   case X86::BI_AddressOfReturnAddress: {
-Function *F = CGM.getIntrinsic(Intrinsic::addressofreturnaddress);
+Function *F =
+CGM.getIntrinsic(Intrinsic::addressofreturnaddress, AllocaInt8PtrTy);
 return Builder.CreateCall(F);
   }
   case X86::BI__stosb: {

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=366683&r1=366682&r2=366683&view=diff
==
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Mon Jul 22 05:50:30 2019
@@ -1774,7 +1774,8 @@ void CodeGenFunction::EmitCapturedLocals
 // EH registration is passed in as the EBP physical register.  We can
 // recover that with llvm.frameaddress(1).
 EntryFP = Builder.CreateCall(
-CGM.getIntrinsic(llvm::Intrinsic::frameaddress), 
{Builder.getInt32(1)});
+CGM.getIntrinsic(llvm::Intrinsic::frameaddress, AllocaInt8PtrTy),
+{Builder.getInt32(1)});
   } else {
 // Otherwise, for x64 and 32-bit finally functions, the parent FP is the
 // second parameter.

Modified: cfe/trunk/test/CodeGen/builtin-sponentry.c
URL: 
http://ll

[PATCH] D64563: Updated the signature for some stack related intrinsics (CLANG)

2019-07-22 Thread Christudasan Devadasan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366683: Updated the signature for some stack related 
intrinsics (CLANG) (authored by cdevadas, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64563?vs=210648&id=211064#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64563

Files:
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/lib/CodeGen/CGException.cpp
  cfe/trunk/test/CodeGen/builtin-sponentry.c
  cfe/trunk/test/CodeGen/exceptions-seh.c
  cfe/trunk/test/CodeGen/integer-overflow.c
  cfe/trunk/test/CodeGen/ms-intrinsics.c
  cfe/trunk/test/CodeGen/ms-setjmp.c
  cfe/trunk/test/CodeGenOpenCL/builtins-generic-amdgcn.cl

Index: cfe/trunk/test/CodeGenOpenCL/builtins-generic-amdgcn.cl
===
--- cfe/trunk/test/CodeGenOpenCL/builtins-generic-amdgcn.cl
+++ cfe/trunk/test/CodeGenOpenCL/builtins-generic-amdgcn.cl
@@ -14,3 +14,8 @@
 {
   *out = __builtin_clzl(a);
 }
+
+// CHECK: tail call i8 addrspace(5)* @llvm.frameaddress.p5i8(i32 0)
+void test_builtin_frame_address(int *out) {
+*out = __builtin_frame_address(0);
+}
Index: cfe/trunk/test/CodeGen/exceptions-seh.c
===
--- cfe/trunk/test/CodeGen/exceptions-seh.c
+++ cfe/trunk/test/CodeGen/exceptions-seh.c
@@ -51,7 +51,7 @@
 // 32-bit SEH needs this filter to save the exception code.
 //
 // X86-LABEL: define internal i32 @"?filt$0@0@safe_div@@"()
-// X86: %[[ebp:[^ ]*]] = call i8* @llvm.frameaddress(i32 1)
+// X86: %[[ebp:[^ ]*]] = call i8* @llvm.frameaddress.p0i8(i32 1)
 // X86: %[[fp:[^ ]*]] = call i8* @llvm.eh.recoverfp(i8* bitcast (i32 (i32, i32, i32*)* @safe_div to i8*), i8* %[[ebp]])
 // X86: call i8* @llvm.localrecover(i8* bitcast (i32 (i32, i32, i32*)* @safe_div to i8*), i8* %[[fp]], i32 0)
 // X86: load i8*, i8**
@@ -103,7 +103,7 @@
 // ARM64: call i8* @llvm.localrecover(i8* bitcast (i32 ()* @filter_expr_capture to i8*), i8* %[[fp]], i32 0)
 //
 // X86-LABEL: define internal i32 @"?filt$0@0@filter_expr_capture@@"()
-// X86: %[[ebp:[^ ]*]] = call i8* @llvm.frameaddress(i32 1)
+// X86: %[[ebp:[^ ]*]] = call i8* @llvm.frameaddress.p0i8(i32 1)
 // X86: %[[fp:[^ ]*]] = call i8* @llvm.eh.recoverfp(i8* bitcast (i32 ()* @filter_expr_capture to i8*), i8* %[[ebp]])
 // X86: call i8* @llvm.localrecover(i8* bitcast (i32 ()* @filter_expr_capture to i8*), i8* %[[fp]], i32 0)
 //
Index: cfe/trunk/test/CodeGen/ms-intrinsics.c
===
--- cfe/trunk/test/CodeGen/ms-intrinsics.c
+++ cfe/trunk/test/CodeGen/ms-intrinsics.c
@@ -142,7 +142,7 @@
   return _AddressOfReturnAddress();
 }
 // CHECK-INTEL-LABEL: define dso_local i8* @test_AddressOfReturnAddress()
-// CHECK-INTEL: = tail call i8* @llvm.addressofreturnaddress()
+// CHECK-INTEL: = tail call i8* @llvm.addressofreturnaddress.p0i8()
 // CHECK-INTEL: ret i8*
 #endif
 
Index: cfe/trunk/test/CodeGen/integer-overflow.c
===
--- cfe/trunk/test/CodeGen/integer-overflow.c
+++ cfe/trunk/test/CodeGen/integer-overflow.c
@@ -99,8 +99,8 @@
 
   // PR24256: don't instrument __builtin_frame_address.
   __builtin_frame_address(0 + 0);
-  // DEFAULT:  call i8* @llvm.frameaddress(i32 0)
-  // WRAPV:call i8* @llvm.frameaddress(i32 0)
-  // TRAPV:call i8* @llvm.frameaddress(i32 0)
-  // CATCH_UB: call i8* @llvm.frameaddress(i32 0)
+  // DEFAULT:  call i8* @llvm.frameaddress.p0i8(i32 0)
+  // WRAPV:call i8* @llvm.frameaddress.p0i8(i32 0)
+  // TRAPV:call i8* @llvm.frameaddress.p0i8(i32 0)
+  // CATCH_UB: call i8* @llvm.frameaddress.p0i8(i32 0)
 }
Index: cfe/trunk/test/CodeGen/ms-setjmp.c
===
--- cfe/trunk/test/CodeGen/ms-setjmp.c
+++ cfe/trunk/test/CodeGen/ms-setjmp.c
@@ -20,12 +20,12 @@
   // I386-NEXT:  ret i32 %[[call]]
 
   // X64-LABEL: define dso_local i32 @test_setjmp
-  // X64:   %[[addr:.*]] = call i8* @llvm.frameaddress(i32 0)
+  // X64:   %[[addr:.*]] = call i8* @llvm.frameaddress.p0i8(i32 0)
   // X64:   %[[call:.*]] = call i32 @_setjmp(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @jb, i64 0, i64 0), i8* %[[addr]])
   // X64-NEXT:  ret i32 %[[call]]
 
   // AARCH64-LABEL: define dso_local i32 @test_setjmp
-  // AARCH64:   %[[addr:.*]] = call i8* @llvm.sponentry()
+  // AARCH64:   %[[addr:.*]] = call i8* @llvm.sponentry.p0i8()
   // AARCH64:   %[[call:.*]] = call i32 @_setjmpex(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @jb, i64 0, i64 0), i8* %[[addr]])
   // AARCH64-NEXT:  ret i32 %[[call]]
 }
@@ -33,12 +33,12 @@
 int test_setjmpex() {
   return _setjmpex(jb);
   // X64-LABEL: define dso_local i32 @test_setjmpex
-  // X64:   %[[addr:.*]] = call i8* @llvm.frameaddres

[PATCH] D64744: #pragma clang loop vectorize_predicate(enable|disable)

2019-07-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Is it intentional that this review has no reviewers listed (like, is this a 
work in progress you don't expect review on yet)?




Comment at: clang/include/clang/Basic/Attr.td:2985
+   "pipeline", "pipeline_initiation_interval", 
"distribute",
+   "vectorize_predicate"],
   ["Vectorize", "VectorizeWidth", "Interleave", 
"InterleaveCount",

You need to update AttrDocs.td for this as well.


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

https://reviews.llvm.org/D64744



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


[PATCH] D65012: Adds support for formatting NS_CLOSED_ENUM alongside NS_ENUM.

2019-07-22 Thread Hank Heijink via Phabricator via cfe-commits
heijink updated this revision to Diff 211065.
heijink edited the summary of this revision.
heijink added a comment.

Also added support for formatting CF_CLOSED_ENUM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65012

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


Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -118,6 +118,11 @@
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
+  Style = getStyle("{}", "a.h", "none",
+   "typedef NS_CLOSED_ENUM(NSInteger, Foo) {};\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
   Style = getStyle("{}", "a.h", "none", "enum Foo {};");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1716,6 +1716,8 @@
 
 TEST_F(FormatTest, FormatsNSEnums) {
   verifyGoogleFormat("typedef NS_ENUM(NSInteger, SomeName) { AAA, BBB }");
+  verifyGoogleFormat(
+  "typedef NS_CLOSED_ENUM(NSInteger, SomeName) { AAA, BBB }");
   verifyGoogleFormat("typedef NS_ENUM(NSInteger, MyType) {\n"
  "  // Information about someDecentlyLongValue.\n"
  "  someDecentlyLongValue,\n"
@@ -1724,6 +1726,14 @@
  "  // Information about aThirdDecentlyLongValue.\n"
  "  aThirdDecentlyLongValue\n"
  "};");
+  verifyGoogleFormat("typedef NS_CLOSED_ENUM(NSInteger, MyType) {\n"
+ "  // Information about someDecentlyLongValue.\n"
+ "  someDecentlyLongValue,\n"
+ "  // Information about anotherDecentlyLongValue.\n"
+ "  anotherDecentlyLongValue,\n"
+ "  // Information about aThirdDecentlyLongValue.\n"
+ "  aThirdDecentlyLongValue\n"
+ "};");
   verifyGoogleFormat("typedef NS_OPTIONS(NSInteger, MyType) {\n"
  "  a = 1,\n"
  "  b = 2,\n"
@@ -1734,6 +1744,11 @@
  "  b = 2,\n"
  "  c = 3,\n"
  "};");
+  verifyGoogleFormat("typedef CF_CLOSED_ENUM(NSInteger, MyType) {\n"
+ "  a = 1,\n"
+ "  b = 2,\n"
+ "  c = 3,\n"
+ "};");
   verifyGoogleFormat("typedef CF_OPTIONS(NSInteger, MyType) {\n"
  "  a = 1,\n"
  "  b = 2,\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1215,7 +1215,8 @@
 case tok::kw_typedef:
   nextToken();
   if (FormatTok->isOneOf(Keywords.kw_NS_ENUM, Keywords.kw_NS_OPTIONS,
- Keywords.kw_CF_ENUM, Keywords.kw_CF_OPTIONS))
+ Keywords.kw_CF_ENUM, Keywords.kw_CF_OPTIONS,
+ Keywords.kw_CF_CLOSED_ENUM, 
Keywords.kw_NS_CLOSED_ENUM))
 parseEnum();
   break;
 case tok::kw_struct:
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -677,8 +677,10 @@
 kw_override = &IdentTable.get("override");
 kw_in = &IdentTable.get("in");
 kw_of = &IdentTable.get("of");
+kw_CF_CLOSED_ENUM = &IdentTable.get("CF_CLOSED_ENUM");
 kw_CF_ENUM = &IdentTable.get("CF_ENUM");
 kw_CF_OPTIONS = &IdentTable.get("CF_OPTIONS");
+kw_NS_CLOSED_ENUM = &IdentTable.get("NS_CLOSED_ENUM");
 kw_NS_ENUM = &IdentTable.get("NS_ENUM");
 kw_NS_OPTIONS = &IdentTable.get("NS_OPTIONS");
 
@@ -787,8 +789,10 @@
   IdentifierInfo *kw_override;
   IdentifierInfo *kw_in;
   IdentifierInfo *kw_of;
+  IdentifierInfo *kw_CF_CLOSED_ENUM;
   IdentifierInfo *kw_CF_ENUM;
   IdentifierInfo *kw_CF_OPTIONS;
+  IdentifierInfo *kw_NS_CLOSED_ENUM;
   IdentifierInfo *kw_NS_ENUM;
   IdentifierInfo *kw_NS_OPTIONS;
   IdentifierInfo *kw___except;


Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -118,6 +118,11 @@
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
+  Style = getStyle("{}", "a.h", "none",
+   "type

[PATCH] D64744: #pragma clang loop vectorize_predicate(enable|disable)

2019-07-22 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

> Is it intentional that this review has no reviewers listed (like, is this a 
> work in progress you don't expect review on yet)?

No, sorry about this, that's not intentional. It started indeed as a 
work-in-progress patch when I wrote to the clang/llvm with an idea about this. 
I wanted to show some code too, but didn't add reviewers at that point. In the 
mean time, this patch has evolved quite a bit, but I never bothered to add 
reviewers, but will do.

> You need to update AttrDocs.td for this as well.

Thanks for the suggestion! Will do.


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

https://reviews.llvm.org/D64744



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


[clang-tools-extra] r366687 - Update documentation for all CERT checks that correspond to a recommendation.

2019-07-22 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Jul 22 06:22:08 2019
New Revision: 366687

URL: http://llvm.org/viewvc/llvm-project?rev=366687&view=rev
Log:
Update documentation for all CERT checks that correspond to a recommendation.

CERT removed their C++ secure coding recommendations from public view and so 
the links within that documentation are stale. This updates various pieces of 
documentation to make this more clear, and to help add substance where our docs 
deferred to CERT's wiki.

Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl21-cpp.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err09-cpp.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-oop11-cpp.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl21-cpp.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl21-cpp.rst?rev=366687&r1=366686&r2=366687&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl21-cpp.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl21-cpp.rst Mon Jul 
22 06:22:08 2019
@@ -7,6 +7,18 @@ This check flags postfix ``operator++``
 if the return type is not a const object. This also warns if the return type
 is a reference type.
 
+The object returned by a postfix increment or decrement operator is supposed
+to be a snapshot of the object's value prior to modification. With such an
+implementation, any modifications made to the resulting object from calling
+operator++(int) would be modifying a temporary object. Thus, such an
+implementation of a postfix increment or decrement operator should instead
+return a const object, prohibiting accidental mutation of a temporary object.
+Similarly, it is unexpected for the postfix operator to return a reference to
+its previous state, and any subsequent modifications would be operating on a
+stale object.
+
 This check corresponds to the CERT C++ Coding Standard recommendation
-`DCL21-CPP. Overloaded postfix increment and decrement operators should return 
a const object
-`_.
+DCL21-CPP. Overloaded postfix increment and decrement operators should return a
+const object. However, all of the CERT recommendations have been removed from
+public view, and so their justification for the behavior of this check requires
+an account on their wiki to view.
\ No newline at end of file

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err09-cpp.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err09-cpp.rst?rev=366687&r1=366686&r2=366687&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err09-cpp.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err09-cpp.rst Mon Jul 
22 06:22:08 2019
@@ -8,3 +8,8 @@ cert-err09-cpp
 The cert-err09-cpp check is an alias, please see
 `misc-throw-by-value-catch-by-reference 
`_
 for more information.
+
+This check corresponds to the CERT C++ Coding Standard recommendation
+ERR09-CPP. Throw anonymous temporaries. However, all of the CERT 
recommendations
+have been removed from public view, and so their justification for the behavior
+of this check requires an account on their wiki to view.
\ No newline at end of file

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/cert-oop11-cpp.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cert-oop11-cpp.rst?rev=366687&r1=366686&r2=366687&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-oop11-cpp.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/cert-oop11-cpp.rst Mon Jul 
22 06:22:08 2019
@@ -8,3 +8,9 @@ cert-oop11-cpp
 The cert-oop11-cpp check is an alias, please see
 `performance-move-constructor-init `_
 for more information.
+
+This check corresponds to the CERT C++ Coding Standard recommendation
+OOP11-CPP. Do not copy-initialize members or base classes from a move
+constructor. However, all of the CERT recommendations have been removed from
+public view, and so their justification for the behavior of this check requires
+an account on their wiki to view.
\ No newline at end of file

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst?rev=366687&r1=366686&r2=366687&view=diff
=

[PATCH] D65067: [clangd] Fix auto expand not work on "const au^to s = 123;"

2019-07-22 Thread Haojian Wu via Phabricator via cfe-commits
hokein abandoned this revision.
hokein added a comment.

as discussed, this is an issue of selection tree (selection tree should give 
the `AutoTypeLoc` on `const aut^o`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65067



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


[PATCH] D63126: [clangd] Implement "prepareRename"

2019-07-22 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 211080.
hokein added a comment.

Update the patch, and add tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63126

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/clients/clangd-vscode/package.json
  clang-tools-extra/clangd/test/prepare-rename.test

Index: clang-tools-extra/clangd/test/prepare-rename.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/prepare-rename.test
@@ -0,0 +1,30 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{"textDocument": {"rename": {"dynamicRegistration": true, "prepareSupport": true}}},"trace":"off"}}
+# CHECK:  "renameProvider": {
+# CHECK-NEXT:"prepareProvider": true
+# CHECK-NEXT:  },
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.cpp","languageId":"cpp","version":1,"text":"int foo;"}}}
+---
+{"jsonrpc":"2.0","id":1,"method":"textDocument/prepareRename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":5}}}
+#  CHECK:  "id": 1,
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": {
+# CHECK-NEXT:  "end": {
+# CHECK-NEXT:"character": 7,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "start": {
+# CHECK-NEXT:"character": 4,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  }
+# CHECK-NEXT:  }
+---
+{"jsonrpc":"2.0","id":2,"method":"textDocument/prepareRename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":2}}}
+#  CHECK:  "id": 2,
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": null
+---
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}
Index: clang-tools-extra/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -6,7 +6,7 @@
 "publisher": "llvm-vs-code-extensions",
 "homepage": "https://clang.llvm.org/extra/clangd.html";,
 "engines": {
-"vscode": "^1.30.0"
+"vscode": "^1.36.0"
 },
 "categories": [
 "Programming Languages",
@@ -35,8 +35,8 @@
 "test": "node ./node_modules/vscode/bin/test"
 },
 "dependencies": {
-"vscode-languageclient": "^5.2.0",
-"vscode-languageserver": "^5.2.0"
+"vscode-languageclient": "^5.3.0-next.6",
+"vscode-languageserver": "^5.3.0-next.6"
 },
 "devDependencies": {
 "@types/mocha": "^2.2.32",
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -422,6 +422,10 @@
   /// The content format that should be used for Hover requests.
   /// textDocument.hover.contentEncoding
   MarkupKind HoverContentFormat = MarkupKind::PlainText;
+
+  /// The client supports testing for validity of rename operations
+  /// before execution.
+  bool RenamePrepareSupport = false;
 };
 bool fromJSON(const llvm::json::Value &, ClientCapabilities &);
 
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -331,6 +331,10 @@
 }
   }
 }
+if (auto *Rename = TextDocument->getObject("rename")) {
+  if (auto RenameSupport = Rename->getBoolean("prepareSupport"))
+R.RenamePrepareSupport = *RenameSupport;
+}
   }
   if (auto *Workspace = O->getObject("workspace")) {
 if (auto *Symbol = Workspace->getObject("symbol")) {
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -241,6 +241,10 @@
  PathRef File, Position Pos,
  StringRef TriggerText);
 
+  /// Test the validity of a rename operation.
+  void prepareRename(PathRef File, Position Pos,
+ Callback> CB);
+
   /// Rename all occurrences of the symbol at the \p Pos in \p File to
   /// \p NewName.
   /// If WantFormat is false, the final TextEdit will be not formatted,
Index: clang-tools-extra/clangd/ClangdServer.cpp
==

r366689 - [OPENMP]Add support for analysis of firstprivate variables.

2019-07-22 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Jul 22 06:51:07 2019
New Revision: 366689

URL: http://llvm.org/viewvc/llvm-project?rev=366689&view=rev
Log:
[OPENMP]Add support for analysis of firstprivate variables.

Summary:
Firstprivate variables are the variables, for which the private copies
must be created in the OpenMP regions and must be initialized with the
original values. Thus, we must report if the uninitialized variable is
used as firstprivate.

Reviewers: NoQ

Subscribers: guansong, jdoerfert, caomhin, kkwli0, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D64765

Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/test/Analysis/cfg-openmp.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/parallel_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/parallel_sections_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_teams_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/task_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/taskloop_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/taskloop_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_firstprivate_messages.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_firstprivate_messages.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/teams_firstprivate_messages.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=366689&r1=366688&r2=366689&view=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Mon Jul 22 06:51:07 2019
@@ -2099,10 +2099,12 @@ public:
   }
 
   child_range used_children() {
-return child_range(child_iterator(), child_iterator());
+return child_range(reinterpret_cast(varlist_begin()),
+   reinterpret_cast(varlist_end()));
   }
   const_child_range used_children() const {
-return const_child_range(const_child_iterator(), const_child_iterator());
+auto Children = const_cast(this)->used_children();
+return const_child_range(Children.begin(), Children.end());
   }
 
   static bool classof(const OMPClause *T) {

Modified: cfe/trunk/test/Analysis/cfg-openmp.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cfg-openmp.cpp?rev=366689&r1=366688&r2=366689&view=diff
==
--- cfe/trunk/test/Analysis/cfg-openmp.cpp (original)
+++ cfe/trunk/test/Analysis/cfg-openmp.cpp Mon Jul 22 06:51:07 2019
@@ -5,7 +5,8 @@ void xxx(int argc) {
 // CHECK:[B1]
 // CHECK-NEXT:   1: int x;
 // CHECK-NEXT:   2: int cond;
-  int x, cond;
+// CHECK-NEXT:   3: int fp;
+  int x, cond, fp;
 // CHECK-NEXT:   [[#ATOM:]]: x
 // CHECK-NEXT:   [[#ATOM+1]]: [B1.[[#ATOM]]] (ImplicitCastExpr, 
LValueToRValue, int)
 // CHECK-NEXT:   [[#ATOM+2]]: argc
@@ -29,10 +30,11 @@ void xxx(int argc) {
 // CHECK-NEXT:  [[#DPF+4]]: cond
 // CHECK-NEXT:  [[#DPF+5]]: [B1.[[#DPF+4]]] (ImplicitCastExpr, LValueToRValue, 
int)
 // CHECK-NEXT:  [[#DPF+6]]: [B1.[[#DPF+5]]] (ImplicitCastExpr, 
IntegralToBoolean, _Bool)
-// CHECK-NEXT:  [[#DPF+7]]: #pragma omp distribute parallel for if(parallel: 
cond)
+// CHECK-NEXT:  [[#DPF+7]]: fp
+// CHECK-NEXT:  [[#DPF+8]]: #pragma omp distribute parallel for if(parallel: 
cond) firstprivate(fp)
 // CHECK-NEXT:for (int i = 0; i < 10; ++i)
 // CHECK-NEXT:[B1.[[#DPF+3]]];
-#pragma omp distribute parallel for if(parallel:cond)
+#pragma omp distribute parallel for if(parallel:cond) firstprivate(fp)
   for (int i = 0; i < 10; ++i)
 argc = x;
 // CHECK-NEXT:  [[#DPFS:]]: x
@@ -42,10 +44,11 @@ void xxx(int argc) {
 // CHECK-NEXT:  [[#DPFS+4]]: cond
 // CHECK-NEXT:  [[#DPFS+5]]: [B1.[[#DPFS+4]]] (ImplicitCastExpr, 
LValueToRValue, int)
 

[PATCH] D64765: [OPENMP]Add support for analysis of firstprivate variables.

2019-07-22 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366689: [OPENMP]Add support for analysis of firstprivate 
variables. (authored by ABataev, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64765

Files:
  cfe/trunk/include/clang/AST/OpenMPClause.h
  cfe/trunk/test/Analysis/cfg-openmp.cpp
  cfe/trunk/test/OpenMP/distribute_parallel_for_firstprivate_messages.cpp
  cfe/trunk/test/OpenMP/distribute_parallel_for_simd_firstprivate_messages.cpp
  cfe/trunk/test/OpenMP/parallel_firstprivate_messages.cpp
  cfe/trunk/test/OpenMP/parallel_for_firstprivate_messages.cpp
  cfe/trunk/test/OpenMP/parallel_for_simd_firstprivate_messages.cpp
  cfe/trunk/test/OpenMP/parallel_sections_firstprivate_messages.cpp
  cfe/trunk/test/OpenMP/target_firstprivate_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_firstprivate_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_for_firstprivate_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_for_simd_firstprivate_messages.cpp
  cfe/trunk/test/OpenMP/target_simd_firstprivate_messages.cpp
  cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_messages.cpp
  
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_messages.cpp
  
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_messages.cpp
  cfe/trunk/test/OpenMP/target_teams_distribute_simd_firstprivate_messages.cpp
  cfe/trunk/test/OpenMP/target_teams_firstprivate_messages.cpp
  cfe/trunk/test/OpenMP/task_firstprivate_messages.cpp
  cfe/trunk/test/OpenMP/taskloop_firstprivate_messages.cpp
  cfe/trunk/test/OpenMP/taskloop_simd_firstprivate_messages.cpp
  cfe/trunk/test/OpenMP/teams_distribute_firstprivate_messages.cpp
  cfe/trunk/test/OpenMP/teams_distribute_parallel_for_firstprivate_messages.cpp
  
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_messages.cpp
  cfe/trunk/test/OpenMP/teams_distribute_simd_firstprivate_messages.cpp
  cfe/trunk/test/OpenMP/teams_firstprivate_messages.cpp

Index: cfe/trunk/include/clang/AST/OpenMPClause.h
===
--- cfe/trunk/include/clang/AST/OpenMPClause.h
+++ cfe/trunk/include/clang/AST/OpenMPClause.h
@@ -2099,10 +2099,12 @@
   }
 
   child_range used_children() {
-return child_range(child_iterator(), child_iterator());
+return child_range(reinterpret_cast(varlist_begin()),
+   reinterpret_cast(varlist_end()));
   }
   const_child_range used_children() const {
-return const_child_range(const_child_iterator(), const_child_iterator());
+auto Children = const_cast(this)->used_children();
+return const_child_range(Children.begin(), Children.end());
   }
 
   static bool classof(const OMPClause *T) {
Index: cfe/trunk/test/OpenMP/target_teams_distribute_simd_firstprivate_messages.cpp
===
--- cfe/trunk/test/OpenMP/target_teams_distribute_simd_firstprivate_messages.cpp
+++ cfe/trunk/test/OpenMP/target_teams_distribute_simd_firstprivate_messages.cpp
@@ -19,6 +19,13 @@
   return argc;
 }
 
+void xxx(int argc) {
+  int fp; // expected-note {{initialize the variable 'fp' to silence this warning}}
+#pragma omp target teams distribute simd firstprivate(fp) // expected-warning {{variable 'fp' is uninitialized when used here}}
+  for (int i = 0; i < 10; ++i)
+;
+}
+
 struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
 extern S1 a;
 class S2 {
Index: cfe/trunk/test/OpenMP/distribute_parallel_for_firstprivate_messages.cpp
===
--- cfe/trunk/test/OpenMP/distribute_parallel_for_firstprivate_messages.cpp
+++ cfe/trunk/test/OpenMP/distribute_parallel_for_firstprivate_messages.cpp
@@ -8,6 +8,14 @@
 bool foobool(int argc) {
   return argc;
 }
+
+void xxx(int argc) {
+  int fp; // expected-note {{initialize the variable 'fp' to silence this warning}}
+#pragma omp distribute parallel for firstprivate(fp) // expected-warning {{variable 'fp' is uninitialized when used here}}
+  for (int i = 0; i < 10; ++i)
+;
+}
+
 extern int omp_default_mem_alloc;
 
 struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
Index: cfe/trunk/test/OpenMP/target_firstprivate_messages.cpp
===
--- cfe/trunk/test/OpenMP/target_firstprivate_messages.cpp
+++ cfe/trunk/test/OpenMP/target_firstprivate_messages.cpp
@@ -2,6 +2,13 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
 
+void xxx(int argc) {
+  int fp, fp1; // expected-note {{initialize the variable 'fp' to silence this warning}} expected-note {{initialize the variable 'fp1' to silence this warning}}
+#pragma omp target firstprivate(fp) // 

[PATCH] D65092: [clang] Add isDirectlyDerivedFrom AST Matcher.

2019-07-22 Thread Anton Bikineev via Phabricator via cfe-commits
AntonBikineev created this revision.
AntonBikineev added a reviewer: rsmith.
AntonBikineev added a project: clang.

This patch adds isDirectlyDerivedFrom AST-matcher which is similar to 
isDerivedFrom but only matches against direct base classes.


Repository:
  rC Clang

https://reviews.llvm.org/D65092

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -331,6 +331,16 @@
   EXPECT_TRUE(notMatches("class Y;", IsDerivedFromX));
   EXPECT_TRUE(notMatches("", IsDerivedFromX));
 
+  DeclarationMatcher IsDirectlyDerivedFromX =
+  cxxRecordDecl(isDirectlyDerivedFrom("X"));
+
+  EXPECT_TRUE(
+  matches("class X {}; class Y : public X {};", IsDirectlyDerivedFromX));
+  EXPECT_TRUE(notMatches("class X {};", IsDirectlyDerivedFromX));
+  EXPECT_TRUE(notMatches("class X;", IsDirectlyDerivedFromX));
+  EXPECT_TRUE(notMatches("class Y;", IsDirectlyDerivedFromX));
+  EXPECT_TRUE(notMatches("", IsDirectlyDerivedFromX));
+
   DeclarationMatcher IsAX = cxxRecordDecl(isSameOrDerivedFrom("X"));
 
   EXPECT_TRUE(matches("class X {}; class Y : public X {};", IsAX));
@@ -341,125 +351,240 @@
 
   DeclarationMatcher ZIsDerivedFromX =
 cxxRecordDecl(hasName("Z"), isDerivedFrom("X"));
+  DeclarationMatcher ZIsDirectlyDerivedFromX =
+  cxxRecordDecl(hasName("Z"), isDirectlyDerivedFrom("X"));
   EXPECT_TRUE(
 matches("class X {}; class Y : public X {}; class Z : public Y {};",
 ZIsDerivedFromX));
+  EXPECT_TRUE(
+  notMatches("class X {}; class Y : public X {}; class Z : public Y {};",
+ ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(
 matches("class X {};"
   "template class Y : public X {};"
   "class Z : public Y {};", ZIsDerivedFromX));
+  EXPECT_TRUE(notMatches("class X {};"
+ "template class Y : public X {};"
+ "class Z : public Y {};",
+ ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(matches("class X {}; template class Z : public X {};",
   ZIsDerivedFromX));
+  EXPECT_TRUE(matches("class X {}; template class Z : public X {};",
+  ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(
 matches("template class X {}; "
   "template class Z : public X {};",
 ZIsDerivedFromX));
+  EXPECT_TRUE(matches("template class X {}; "
+  "template class Z : public X {};",
+  ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(
 matches("template class X {}; "
   "template class Z : public X {};",
 ZIsDerivedFromX));
+  EXPECT_TRUE(matches("template class X {}; "
+  "template class Z : public X {};",
+  ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(
 notMatches("template class A { class Z : public X {}; };",
ZIsDerivedFromX));
+  EXPECT_TRUE(
+  notMatches("template class A { class Z : public X {}; };",
+ ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(
 matches("template class A { public: class Z : public X {}; }; "
   "class X{}; void y() { A::Z z; }", ZIsDerivedFromX));
+  EXPECT_TRUE(
+  matches("template class A { public: class Z : public X {}; }; "
+  "class X{}; void y() { A::Z z; }",
+  ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(
 matches("template  class X {}; "
   "template class A { class Z : public X {}; };",
 ZIsDerivedFromX));
+  EXPECT_TRUE(
+  matches("template  class X {}; "
+  "template class A { class Z : public X {}; };",
+  ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(
 notMatches("template class X> class A { "
  "  class Z : public X {}; };", ZIsDerivedFromX));
+  EXPECT_TRUE(notMatches("template class X> class A { "
+ "  class Z : public X {}; };",
+ ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(
 matches("template class X> class A { "
   "  public: class Z : public X {}; }; "
   "template class X {}; void y() { A::Z z; }",
 ZIsDerivedFromX));
+  EXPECT_TRUE(matches("template class X> class A { "
+  "  public: class Z : public X {}; }; "
+  "template class X {}; void y() { A::Z z; }",
+  ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(
 notMatches("template class A { class Z : public X::D {}; };",
ZIsDerivedFromX));
+  EXPECT_TRUE(
+  notMatches("template class A { class Z : 

[PATCH] D64914: Implement P1771

2019-07-22 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 211094.
erichkeane marked an inline comment as done.
erichkeane added a comment.

Rebased and did all the comments (including the www_status).  @aaron.ballman : 
Wasn't positive what you meant about the conversion functions, but I think I 
got one?  I would also love some bikeshedding on the documentation.


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

https://reviews.llvm.org/D64914

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/Expr.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp
  clang/test/Preprocessor/has_attribute.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -664,7 +664,7 @@
 

 http://wg21.link/p1771r1";>P1771R1 (DR)
-No
+SVN
   
 
   [[maybe_unused]] attribute
Index: clang/test/Preprocessor/has_attribute.cpp
===
--- clang/test/Preprocessor/has_attribute.cpp
+++ clang/test/Preprocessor/has_attribute.cpp
@@ -63,7 +63,7 @@
 // CHECK: maybe_unused: 201603L
 // ITANIUM: no_unique_address: 201803L
 // WINDOWS: no_unique_address: 0
-// CHECK: nodiscard: 201603L
+// CHECK: nodiscard: 201907L
 // CHECK: noreturn: 200809L
 // FIXME(201803L) CHECK: unlikely: 0
 
Index: clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp
===
--- clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp
+++ clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp
@@ -80,6 +80,27 @@
   conflicting_reason(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute: special reason}}
 }
 
+namespace p1771 {
+  struct [[nodiscard]] ConvertTo{};
+  struct S {
+[[nodiscard]] S();
+S(int);
+[[gnu::warn_unused_result]] S(double);
+operator ConvertTo();
+  };
+
+  struct[[nodiscard]] Y{};
+
+  void usage() {
+S(); // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard' attribute}}
+S(1);
+S(2.2);
+Y(); // expected-warning {{expression result unused}}
+S s;
+(ConvertTo)s; // expected-warning {{expression result unused}}
+  }
+}; // namespace p1771
+
 #ifdef EXT
 // expected-warning@5 {{use of the 'nodiscard' attribute is a C++17 extension}}
 // expected-warning@9 {{use of the 'nodiscard' attribute is a C++17 extension}}
@@ -91,4 +112,7 @@
 // expected-warning@71 {{use of the 'nodiscard' attribute is a C++2a extension}}
 // expected-warning@73 {{use of the 'nodiscard' attribute is a C++2a extension}}
 // expected-warning@74 {{use of the 'nodiscard' attribute is a C++2a extension}}
+// expected-warning@84 {{use of the 'nodiscard' attribute is a C++17 extension}}
+// expected-warning@86 {{use of the 'nodiscard' attribute is a C++17 extension}}
+// expected-warning@92 {{use of the 'nodiscard' attribute is a C++17 extension}}
 #endif
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -284,6 +284,13 @@
 return;
   }
 }
+  } else if (const auto *CE = dyn_cast(E)) {
+if (const CXXConstructorDecl *Ctor = CE->getConstructor()) {
+  if (const auto *A = Ctor->getAttr()) {
+Diag(Loc, diag::warn_unused_constructor) << A << R1 << R2;
+return;
+  }
+}
   } else if (ShouldSuppress)
 return;
 
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -2831,7 +2831,8 @@
 
 static void handleWarnUnusedResult(Sema &S, Decl *D, const ParsedAttr &AL) {
   if (D->getFunctionType() &&
-  D->getFunctionType()->getReturnType()->isVoidType()) {
+  D->getFunctionType()->getReturnType()->isVoidType() &&
+  !isa(D)) {
 S.Diag(AL.getLoc(), diag::warn_attribute_void_function_method) << AL << 0;
 return;
   }
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -2563,13 +2563,31 @@
   case CXXTemporaryObjectExprClass:
   case CXXConstructExprClass: {
 if (const CXXRecordDecl *Type = getType()->getAsCXXRecordDecl()) {
-  if (Type->hasAttr()) {
+  const auto *WarnURAttr = Type->getAttr();
+  if (Type->hasAttr() ||
+  (WarnURAttr && WarnURAttr->IsCXX11NoDiscard())) {
 WarnE = this;
 Loc = getBeginLoc();
 R1 = getSourceRange();
 return true;
   }
 }
+
+const auto *CE = cast(this);
+if (const CXXConstructorDecl *Ctor 

[PATCH] D64744: #pragma clang loop vectorize_predicate(enable|disable)

2019-07-22 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer updated this revision to Diff 211096.
SjoerdMeijer added a comment.

More doc changes added to `AttrDocs.td` and `LangRef.rst`


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

https://reviews.llvm.org/D64744

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/CodeGen/CGLoopInfo.cpp
  clang/lib/CodeGen/CGLoopInfo.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/AST/ast-print-pragmas.cpp
  clang/test/CodeGenCXX/pragma-loop-predicate.cpp
  clang/test/Parser/pragma-loop.cpp
  clang/test/Parser/pragma-unroll-and-jam.cpp
  llvm/docs/LangRef.rst

Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -5389,6 +5389,21 @@
!0 = !{!"llvm.loop.vectorize.enable", i1 0}
!1 = !{!"llvm.loop.vectorize.enable", i1 1}
 
+'``llvm.loop.vectorize.predicate.enable``' Metadata
+^^^
+
+This metadata selectively enables or disables creating predicated instructions
+for the loop, which can enable folding of the scalar epilogue loop into the
+main loop. The first operand is the string
+``llvm.loop.vectorize.predicate.enable`` and the second operand is a bit. If
+the bit operand value is 1 vectorization is enabled. A value of 0 disables
+vectorization:
+
+.. code-block:: llvm
+
+   !0 = !{!"llvm.loop.vectorize.predicate.enable", i1 0}
+   !1 = !{!"llvm.loop.vectorize.predicate.enable", i1 1}
+
 '``llvm.loop.vectorize.width``' Metadata
 
 
Index: clang/test/Parser/pragma-unroll-and-jam.cpp
===
--- clang/test/Parser/pragma-unroll-and-jam.cpp
+++ clang/test/Parser/pragma-unroll-and-jam.cpp
@@ -67,7 +67,7 @@
   }
 
 // pragma clang unroll_and_jam is disabled for the moment
-/* expected-error {{invalid option 'unroll_and_jam'; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, or distribute}} */ #pragma clang loop unroll_and_jam(4)
+/* expected-error {{invalid option 'unroll_and_jam'; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, vectorize_predicate, or distribute}} */ #pragma clang loop unroll_and_jam(4)
   for (int i = 0; i < Length; i++) {
 for (int j = 0; j < Length; j++) {
   List[i * Length + j] = Value;
Index: clang/test/Parser/pragma-loop.cpp
===
--- clang/test/Parser/pragma-loop.cpp
+++ clang/test/Parser/pragma-loop.cpp
@@ -81,6 +81,7 @@
 
 #pragma clang loop vectorize(enable)
 #pragma clang loop interleave(enable)
+#pragma clang loop vectorize_predicate(enable)
 #pragma clang loop unroll(full)
   while (i + 1 < Length) {
 List[i] = i;
@@ -95,6 +96,7 @@
 
 #pragma clang loop vectorize(disable)
 #pragma clang loop interleave(disable)
+#pragma clang loop vectorize_predicate(disable)
 #pragma clang loop unroll(disable)
   while (i - 1 < Length) {
 List[i] = i;
@@ -111,7 +113,7 @@
   }
 
   int VList[Length];
-#pragma clang loop vectorize(disable) interleave(disable) unroll(disable)
+#pragma clang loop vectorize(disable) interleave(disable) unroll(disable) vectorize_predicate(disable)
   for (int j : VList) {
 VList[j] = List[j];
   }
@@ -130,11 +132,13 @@
 
 /* expected-error {{expected '('}} */ #pragma clang loop vectorize
 /* expected-error {{expected '('}} */ #pragma clang loop interleave
+/* expected-error {{expected '('}} */ #pragma clang loop vectorize_predicate
 /* expected-error {{expected '('}} */ #pragma clang loop unroll
 /* expected-error {{expected '('}} */ #pragma clang loop distribute
 
 /* expected-error {{expected ')'}} */ #pragma clang loop vectorize(enable
 /* expected-error {{expected ')'}} */ #pragma clang loop interleave(enable
+/* expected-error {{expected ')'}} */ #pragma clang loop vectorize_predicate(enable
 /* expected-error {{expected ')'}} */ #pragma clang loop unroll(full
 /* expected-error {{expected ')'}} */ #pragma clang loop distribute(enable
 
@@ -147,7 +151,7 @@
 /* expected-error {{missing argument; expected 'enable', 'full' or 'disable'}} */ #pragma clang loop unroll()
 /* expected-error {{missing argument; expected 'enable' or 'disable'}} */ #pragma clang loop distribute()
 
-/* expected-error {{missing option; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, or distribute}} */ #pragma clang loop
+/* expected-error {{missing option; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, vectorize_predicate, or distribute}} */ #pragma clang loop
 /* expected-

[PATCH] D44100: [ASTImporter] Reorder fields after structure import is finished

2019-07-22 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

@a_sidorin, @shafik This is a polite Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D44100



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


r366694 - [NFC] Relaxed regression tests for PR42665

2019-07-22 Thread Marco Antognini via cfe-commits
Author: mantognini
Date: Mon Jul 22 07:47:36 2019
New Revision: 366694

URL: http://llvm.org/viewvc/llvm-project?rev=366694&view=rev
Log:
[NFC] Relaxed regression tests for PR42665

Following up on the buildbot failures, this commits relaxes some tests:
instead of checking for specific IR output, it now ensures that the
underlying issue (the crash), and only that, doesn't happen.

Modified:
cfe/trunk/test/CodeGenCXX/PR42665.cpp

Modified: cfe/trunk/test/CodeGenCXX/PR42665.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/PR42665.cpp?rev=366694&r1=366693&r2=366694&view=diff
==
--- cfe/trunk/test/CodeGenCXX/PR42665.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/PR42665.cpp Mon Jul 22 07:47:36 2019
@@ -1,7 +1,8 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -std=c++17 -O0 %s -o 
- | FileCheck %s
-// RUN: %clang_cc1 -triple %ms_abi_triple -emit-llvm -std=c++17 -O0 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -std=c++17 -O0 %s -emit-llvm -o /dev/null -verify -triple 
%itanium_abi_triple
+// RUN: %clang_cc1 -std=c++17 -O0 %s -emit-llvm -o /dev/null -verify -triple 
%ms_abi_triple
 
 // Minimal reproducer for PR42665.
+// expected-no-diagnostics
 
 struct Foo {
   Foo() = default;
@@ -31,31 +32,3 @@ void foobar() {
   d(f); // Invoke virtual destructor of Foo through d.
 } // p's destructor is invoked.
 
-// Regexes are used to handle both kind of mangling.
-//
-// CHECK-LABEL: define linkonce_odr{{( dso_local)?}} void 
@{{.*deleter.*Foo.*}}(%struct.Foo* dereferenceable({{[0-9]+}})
-// CHECK-SAME: [[T:%.*]])
-// CHECK: [[T_ADDR:%.*]] = alloca %struct.Foo*
-// CHECK: store %struct.Foo* [[T]], %struct.Foo** [[T_ADDR]]
-// CHECK: [[R0:%.*]] = load %struct.Foo*, %struct.Foo** [[T_ADDR]]
-// CHECK: [[R1:%.*]] = bitcast %struct.Foo* [[R0]] to 
[[TYPE:.*struct\.Foo.*]]***
-// CHECK: [[VTABLE:%.*]] = load [[TYPE]]**, [[TYPE]]*** [[R1]]
-// CHECK: [[VFUN:%.*]] = getelementptr inbounds [[TYPE]]*, [[TYPE]]** 
[[VTABLE]], i64 0
-// CHECK: [[DTOR:%.*]] = load [[TYPE]]*, [[TYPE]]** [[VFUN]]
-// CHECK: call {{(void|i8\*)}} [[DTOR]](%struct.Foo* [[R0]]
-//
-// CHECK-LABEL: define{{( dso_local)?}} void @{{.*foobar.*}}()
-// CHECK: [[P:%.*]] = alloca %struct.Pair
-// CHECK: [[F:%.*]] = alloca %struct.Foo*
-// CHECK: [[D:%.*]] = alloca [[TYPE:void \(%struct.Foo\*\)]]**
-// CHECK: call void @{{.*make_pair.*}}(%struct.Pair* sret [[P]])
-// CHECK: [[FIRST:%.*]] = getelementptr inbounds %struct.Pair, %struct.Pair* 
[[P]], i32 0, i32 0
-// CHECK: store %struct.Foo* [[FIRST]], %struct.Foo** [[F]]
-// CHECK: [[SECOND:%.*]] = getelementptr inbounds %struct.Pair, %struct.Pair* 
[[P]], i32 0, i32 1
-// CHECK: store void (%struct.Foo*)** [[SECOND]], [[TYPE]]*** [[D]]
-// CHECK: [[R0:%.*]] = load [[TYPE]]**, [[TYPE]]*** [[D]]
-// CHECK: [[R1:%.*]] = load [[TYPE]]*, [[TYPE]]** [[R0]]
-// CHECK: [[R2:%.*]] = load %struct.Foo*, %struct.Foo** [[F]]
-// CHECK: call void [[R1]](%struct.Foo* dereferenceable({{[0-9]+}}) [[R2]])
-// CHECK: call void @{{.*Pair.*Foo.*}}(%struct.Pair* [[P]])
-


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


[PATCH] D64569: [OpenCL] Improve destructor support in C++ for OpenCL

2019-07-22 Thread Marco Antognini via Phabricator via cfe-commits
mantognini added a comment.

FYI In order to fix buildbot test failures, I've pushed 
https://reviews.llvm.org/rG1b2da771f561affe36eb5eb0c7a3d2862c5a5c1c. I'll keep 
an eye on buildbots for additional fallout.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64569



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


[PATCH] D65000: [ARM] Set default alignment to 64bits

2019-07-22 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio updated this revision to Diff 211103.
dnsampaio added a comment.

- Joined assignments for default alignments and neon_vector alignment


Repository:
  rC Clang

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

https://reviews.llvm.org/D65000

Files:
  lib/Basic/Targets/ARM.cpp
  test/CodeGen/ARM/exception-alignment.cpp
  test/SemaCXX/warn-overaligned-type-thrown.cpp


Index: test/SemaCXX/warn-overaligned-type-thrown.cpp
===
--- test/SemaCXX/warn-overaligned-type-thrown.cpp
+++ test/SemaCXX/warn-overaligned-type-thrown.cpp
@@ -2,11 +2,12 @@
 // RUN: %clang_cc1 -triple arm64-apple-ios10 -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions -DUNDERALIGNED %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos10 -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions -DUNDERALIGNED %s
 // RUN: %clang_cc1 -triple arm64-apple-watchos4 -verify -fsyntax-only 
-std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
+// RUN: %clang_cc1 -triple arm-linux-gnueabi -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions  -DUNDERALIGNED %s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.14 -verify -fsyntax-only 
-std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple arm64-apple-ios12 -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos12 -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple arm64-apple-watchos5 -verify -fsyntax-only 
-std=c++11 -fcxx-exceptions -fexceptions %s
-// RUN: %clang_cc1 -triple arm-linux-gnueabi -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -triple arm-linux-androideabi -verify -fsyntax-only 
-std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple aarch64-linux-gnueabi -verify -fsyntax-only 
-std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple mipsel-linux-gnu -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple mips64el-linux-gnu -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions %s
Index: test/CodeGen/ARM/exception-alignment.cpp
===
--- /dev/null
+++ test/CodeGen/ARM/exception-alignment.cpp
@@ -0,0 +1,18 @@
+// Bug: https://bugs.llvm.org/show_bug.cgi?id=42668
+// REQUIRES: arm-registered-target
+// RUN: %clang --target=arm-arm-none-eabi -march=armv8-a -S -emit-llvm -Os -o 
- %s | FileCheck --check-prefixes=CHECK,A8 %s
+// RUN: %clang --target=arm-linux-androideabi -march=armv8-a -S -emit-llvm -Os 
-o - %s | FileCheck --check-prefixes=CHECK,A16 %s
+// CHECK: [[E:%[A-z0-9]+]] = tail call i8* @__cxa_allocate_exception
+// CHECK-NEXT: [[BC:%[A-z0-9]+]] = bitcast i8* [[E]] to <2 x i64>*
+// A16-NEXT: store <2 x i64> , <2 x i64>* [[BC]], align 16
+#include 
+
+int main(void) {
+  try {
+throw vld1q_u64(((const uint64_t[2]){1, 2}));
+  } catch (uint64x2_t exc) {
+return 0;
+  }
+  return 1;
+}
+
Index: lib/Basic/Targets/ARM.cpp
===
--- lib/Basic/Targets/ARM.cpp
+++ lib/Basic/Targets/ARM.cpp
@@ -309,8 +309,9 @@
   setAtomic();
 
   // Maximum alignment for ARM NEON data types should be 64-bits (AAPCS)
+  // as well the default alignment
   if (IsAAPCS && (Triple.getEnvironment() != llvm::Triple::Android))
-MaxVectorAlign = 64;
+DefaultAlignForAttributeAligned = MaxVectorAlign = 64;
 
   // Do force alignment of members that follow zero length bitfields.  If
   // the alignment of the zero-length bitfield is greater than the member


Index: test/SemaCXX/warn-overaligned-type-thrown.cpp
===
--- test/SemaCXX/warn-overaligned-type-thrown.cpp
+++ test/SemaCXX/warn-overaligned-type-thrown.cpp
@@ -2,11 +2,12 @@
 // RUN: %clang_cc1 -triple arm64-apple-ios10 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos10 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
 // RUN: %clang_cc1 -triple arm64-apple-watchos4 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
+// RUN: %clang_cc1 -triple arm-linux-gnueabi -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions  -DUNDERALIGNED %s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.14 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple arm64-apple-ios12 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos12 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple arm64-apple-watchos5 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
-// RUN: %clang_cc1 -triple arm-linux-gnueabi -verify -fsyntax-only -std=c++11 -fcx

[PATCH] D64241: [ASTImporter] Fix inequivalence of ClassTemplateInstantiations

2019-07-22 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

@a_sidorin This is a polite Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64241



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


[PATCH] D64739: [SVE][Inline-Asm] Add support to specify SVE registers in the clobber list

2019-07-22 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 24.
kmclaughlin added a comment.

- Updated test to remove unused variable 't'


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

https://reviews.llvm.org/D64739

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/test/CodeGen/aarch64-sve-inline-asm.c


Index: clang/test/CodeGen/aarch64-sve-inline-asm.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-inline-asm.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -emit-llvm -target-feature 
+sve -o - %s | FileCheck %s -check-prefix=CHECK-SVE
+// RUN: not %clang_cc1 -triple aarch64-none-linux-gnu -S %s -o - 2>&1 | 
FileCheck %s -check-prefix=CHECK-ERROR
+
+void test_sve_asm() {
+  asm volatile(
+  "ptrue p0.d\n"
+  "ptrue p15.d\n"
+  "add z0.d, p0/m, z0.d, z0.d\n"
+  "add z31.d, p0/m, z31.d, z31.d\n"
+  :
+  :
+  : "z0", "z31", "p0", "p15");
+  // CHECK-SVE: "~{z0},~{z31},~{p0},~{p15}"
+  // CHECK-ERROR: error: instruction requires: sve
+}
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -351,10 +351,19 @@
 "d12", "d13", "d14", "d15", "d16", "d17", "d18", "d19", "d20", "d21", 
"d22",
 "d23", "d24", "d25", "d26", "d27", "d28", "d29", "d30", "d31",
 
-// Vector registers
+// Neon vector registers
 "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "v11",
 "v12", "v13", "v14", "v15", "v16", "v17", "v18", "v19", "v20", "v21", 
"v22",
-"v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31"
+"v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",
+
+// SVE vector registers
+"z0",  "z1",  "z2",  "z3",  "z4",  "z5",  "z6",  "z7",  "z8",  "z9",  
"z10",
+"z11", "z12", "z13", "z14", "z15", "z16", "z17", "z18", "z19", "z20", 
"z21",
+"z22", "z23", "z24", "z25", "z26", "z27", "z28", "z29", "z30", "z31",
+
+// SVE predicate registers
+"p0",  "p1",  "p2",  "p3",  "p4",  "p5",  "p6",  "p7",  "p8",  "p9",  
"p10",
+"p11", "p12", "p13", "p14", "p15"
 };
 
 ArrayRef AArch64TargetInfo::getGCCRegNames() const {


Index: clang/test/CodeGen/aarch64-sve-inline-asm.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-inline-asm.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -emit-llvm -target-feature +sve -o - %s | FileCheck %s -check-prefix=CHECK-SVE
+// RUN: not %clang_cc1 -triple aarch64-none-linux-gnu -S %s -o - 2>&1 | FileCheck %s -check-prefix=CHECK-ERROR
+
+void test_sve_asm() {
+  asm volatile(
+  "ptrue p0.d\n"
+  "ptrue p15.d\n"
+  "add z0.d, p0/m, z0.d, z0.d\n"
+  "add z31.d, p0/m, z31.d, z31.d\n"
+  :
+  :
+  : "z0", "z31", "p0", "p15");
+  // CHECK-SVE: "~{z0},~{z31},~{p0},~{p15}"
+  // CHECK-ERROR: error: instruction requires: sve
+}
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -351,10 +351,19 @@
 "d12", "d13", "d14", "d15", "d16", "d17", "d18", "d19", "d20", "d21", "d22",
 "d23", "d24", "d25", "d26", "d27", "d28", "d29", "d30", "d31",
 
-// Vector registers
+// Neon vector registers
 "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "v11",
 "v12", "v13", "v14", "v15", "v16", "v17", "v18", "v19", "v20", "v21", "v22",
-"v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31"
+"v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",
+
+// SVE vector registers
+"z0",  "z1",  "z2",  "z3",  "z4",  "z5",  "z6",  "z7",  "z8",  "z9",  "z10",
+"z11", "z12", "z13", "z14", "z15", "z16", "z17", "z18", "z19", "z20", "z21",
+"z22", "z23", "z24", "z25", "z26", "z27", "z28", "z29", "z30", "z31",
+
+// SVE predicate registers
+"p0",  "p1",  "p2",  "p3",  "p4",  "p5",  "p6",  "p7",  "p8",  "p9",  "p10",
+"p11", "p12", "p13", "p14", "p15"
 };
 
 ArrayRef AArch64TargetInfo::getGCCRegNames() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r366698 - [clangd] Add dlog()s for SelectionTree, enabling -debug-only=SelectionTree.cpp

2019-07-22 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Mon Jul 22 08:55:53 2019
New Revision: 366698

URL: http://llvm.org/viewvc/llvm-project?rev=366698&view=rev
Log:
[clangd] Add dlog()s for SelectionTree, enabling -debug-only=SelectionTree.cpp

Summary:
SelectionTree is a RecursiveASTVisitor which processes getSourceRange() for
every node. This is a lot of surface area with the AST, as getSourceRange()
is specialized for *many* node types.
And the resulting SelectionTree depends on the source ranges of many
visited nodes, and the order of traversal.

Put together, this means we really need a traversal log to debug when we
get an unexpected SelectionTree. I've built this ad-hoc a few times, now
it's time to check it in.

Example output:
```
D[14:07:44.184] Computing selection for 

D[14:07:44.184]  push: VarDecl const auto x = 42
D[14:07:44.184]   claimRange: 
D[14:07:44.184]   push: NestedNameSpecifierLoc (empty NestedNameSpecifierLoc)
D[14:07:44.184]   pop: NestedNameSpecifierLoc (empty NestedNameSpecifierLoc)
D[14:07:44.184]   push: QualifiedTypeLoc const auto
D[14:07:44.184]   pop: QualifiedTypeLoc const auto
D[14:07:44.184]claimRange: 
D[14:07:44.184]hit selection: 

D[14:07:44.184]   skip: IntegerLiteral 42
D[14:07:44.184]skipped range = 

D[14:07:44.184]  pop: VarDecl const auto x = 42
D[14:07:44.184]   claimRange: 
D[14:07:44.184]  skip: VarDecl int y = 43
D[14:07:44.184]   skipped range = 

D[14:07:44.184] Built selection tree
TranslationUnitDecl
  VarDecl const auto x = 42
 .QualifiedTypeLoc const auto

```

Reviewers: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D65073

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

Modified: cfe/trunk/lib/AST/ASTTypeTraits.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTTypeTraits.cpp?rev=366698&r1=366697&r2=366698&view=diff
==
--- cfe/trunk/lib/AST/ASTTypeTraits.cpp (original)
+++ cfe/trunk/lib/AST/ASTTypeTraits.cpp Mon Jul 22 08:55:53 2019
@@ -15,6 +15,7 @@
 #include "clang/AST/ASTTypeTraits.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/NestedNameSpecifier.h"
 
 namespace clang {
 namespace ast_type_traits {
@@ -129,9 +130,12 @@ void DynTypedNode::print(llvm::raw_ostre
 TN->print(OS, PP);
   else if (const NestedNameSpecifier *NNS = get())
 NNS->print(OS, PP);
-  else if (const NestedNameSpecifierLoc *NNSL = get())
-NNSL->getNestedNameSpecifier()->print(OS, PP);
-  else if (const QualType *QT = get())
+  else if (const NestedNameSpecifierLoc *NNSL = get()) 
{
+if (const NestedNameSpecifier *NNS = NNSL->getNestedNameSpecifier())
+  NNS->print(OS, PP);
+else
+  OS << "(empty NestedNameSpecifierLoc)";
+  } else if (const QualType *QT = get())
 QT->print(OS, PP);
   else if (const TypeLoc *TL = get())
 TL->getType().print(OS, PP);


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


[clang-tools-extra] r366698 - [clangd] Add dlog()s for SelectionTree, enabling -debug-only=SelectionTree.cpp

2019-07-22 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Mon Jul 22 08:55:53 2019
New Revision: 366698

URL: http://llvm.org/viewvc/llvm-project?rev=366698&view=rev
Log:
[clangd] Add dlog()s for SelectionTree, enabling -debug-only=SelectionTree.cpp

Summary:
SelectionTree is a RecursiveASTVisitor which processes getSourceRange() for
every node. This is a lot of surface area with the AST, as getSourceRange()
is specialized for *many* node types.
And the resulting SelectionTree depends on the source ranges of many
visited nodes, and the order of traversal.

Put together, this means we really need a traversal log to debug when we
get an unexpected SelectionTree. I've built this ad-hoc a few times, now
it's time to check it in.

Example output:
```
D[14:07:44.184] Computing selection for 

D[14:07:44.184]  push: VarDecl const auto x = 42
D[14:07:44.184]   claimRange: 
D[14:07:44.184]   push: NestedNameSpecifierLoc (empty NestedNameSpecifierLoc)
D[14:07:44.184]   pop: NestedNameSpecifierLoc (empty NestedNameSpecifierLoc)
D[14:07:44.184]   push: QualifiedTypeLoc const auto
D[14:07:44.184]   pop: QualifiedTypeLoc const auto
D[14:07:44.184]claimRange: 
D[14:07:44.184]hit selection: 

D[14:07:44.184]   skip: IntegerLiteral 42
D[14:07:44.184]skipped range = 

D[14:07:44.184]  pop: VarDecl const auto x = 42
D[14:07:44.184]   claimRange: 
D[14:07:44.184]  skip: VarDecl int y = 43
D[14:07:44.184]   skipped range = 

D[14:07:44.184] Built selection tree
TranslationUnitDecl
  VarDecl const auto x = 42
 .QualifiedTypeLoc const auto

```

Reviewers: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D65073

Modified:
clang-tools-extra/trunk/clangd/Selection.cpp
clang-tools-extra/trunk/clangd/Selection.h

Modified: clang-tools-extra/trunk/clangd/Selection.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Selection.cpp?rev=366698&r1=366697&r2=366698&view=diff
==
--- clang-tools-extra/trunk/clangd/Selection.cpp (original)
+++ clang-tools-extra/trunk/clangd/Selection.cpp Mon Jul 22 08:55:53 2019
@@ -8,15 +8,19 @@
 
 #include "Selection.h"
 #include "ClangdUnit.h"
+#include "Logger.h"
 #include "SourceCode.h"
 #include "clang/AST/ASTTypeTraits.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/TypeLoc.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -59,6 +63,31 @@ private:
   std::vector> Ranges; // Always sorted.
 };
 
+// Dump a node for debugging.
+// DynTypedNode::print() doesn't include the kind of node, which is useful.
+void printNode(llvm::raw_ostream &OS, const DynTypedNode &N,
+   const PrintingPolicy &PP) {
+  if (const TypeLoc *TL = N.get()) {
+// TypeLoc is a hierarchy, but has only a single ASTNodeKind.
+// Synthesize the name from the Type subclass (except for 
QualifiedTypeLoc).
+if (TL->getTypeLocClass() == TypeLoc::Qualified)
+  OS << "QualifiedTypeLoc";
+else
+  OS << TL->getType()->getTypeClassName() << "TypeLoc";
+  } else {
+OS << N.getNodeKind().asStringRef();
+  }
+  OS << " ";
+  N.print(OS, PP);
+}
+
+std::string printNodeToString(const DynTypedNode &N, const PrintingPolicy &PP) 
{
+  std::string S;
+  llvm::raw_string_ostream OS(S);
+  printNode(OS, N, PP);
+  return std::move(OS.str());
+}
+
 // We find the selection by visiting written nodes in the AST, looking for 
nodes
 // that intersect with the selected character range.
 //
@@ -71,9 +100,9 @@ class SelectionVisitor : public Recursiv
 public:
   // Runs the visitor to gather selected nodes and their ancestors.
   // If there is any selection, the root (TUDecl) is the first node.
-  static std::deque collect(ASTContext &AST, unsigned Begin,
-  unsigned End, FileID File) {
-SelectionVisitor V(AST, Begin, End, File);
+  static std::deque collect(ASTContext &AST, const PrintingPolicy &PP,
+  unsigned Begin, unsigned End, FileID File) {
+SelectionVisitor V(AST, PP, Begin, End, File);
 V.TraverseAST(AST);
 assert(V.Stack.size() == 1 && "Unpaired push/pop?");
 assert(V.Stack.top() == &V.Nodes.front());
@@ -114,9 +143,12 @@ public:
   }
   // Stmt is the same, but this form allows the data recursion optimization.
   bool dataTraverseStmtPre(Stmt *X) {
-if (!X || canSafelySkipNode(X->getSourceRange()))
+if (!X)
+  return false;
+auto N = DynTypedNode::create(*X);
+if (canSafelySkipNode(N))
   return false;
-push(DynTypedNode::create(*X));
+push(std::move(N));
 return true;
   }
   bool dataTraverseStmtPost(Stmt *X) {
@@ -130,10 +162,10 @@ public:
 

[PATCH] D64991: [analyzer][WIP] Implement a primitive reaching definitions analysis

2019-07-22 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus updated this revision to Diff 29.
Szelethus added a comment.

I plan to split this patch up eventually, but here's where I'm standing right 
now:

- Correct the algorithm that by accident did this: `GEN[B] = GEN[B] union 
(IN[B] - KILL[B])` instead of this: `OUT[B] = GEN[B] union (IN[B] - KILL[B])`
- Realize that `llvm::SmallSet` uses both `operator==` and `operator<`, and 
since for a reaching definition set I'd like to sort by `VarDecl`, but for the 
kill set that AND the `CFGElementRef`, give up on it and use `std::set` instead 
with two different comparators
- Collect all non-local variables and regard all function calls as definitions 
to them
- Collect parameter declarations as well, add them to `GEN[entry block]`
- Plenty more test cases


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

https://reviews.llvm.org/D64991

Files:
  clang/include/clang/Analysis/Analyses/ReachingDefinitions.h
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/Analysis/CMakeLists.txt
  clang/lib/Analysis/ReachingDefinitions.cpp
  clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
  clang/test/Analysis/dump-definitions.cpp

Index: clang/test/Analysis/dump-definitions.cpp
===
--- /dev/null
+++ clang/test/Analysis/dump-definitions.cpp
@@ -0,0 +1,385 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=debug.DumpCFG \
+// RUN:   -analyzer-checker=debug.DumpGenSets \
+// RUN:   -analyzer-checker=debug.DumpKillSets \
+// RUN:   -analyzer-checker=debug.DumpReachingDefinitions \
+// RUN:   2>&1 | FileCheck %s
+
+int global_var;
+
+int getInt();
+int *getIntPtr();
+bool coin();
+
+
+void single_vardecl_in_declstmt() {
+  int *ptr = getIntPtr();
+}
+// [B2 (ENTRY)] -> [B1] -> [B0 (EXIT)]
+
+// CHECK:  GEN sets: blockid (varname [blockid, elementid])
+// CHECK-NEXT: 1 (global_var, [1, 2])
+// CHECK-NEXT: 1 (ptr, [1, 3])
+// CHECK-NEXT: KILL sets: blockid (varname [blockid, elementid])
+// CHECK-NEXT: Reaching definition sets: blockid IN/OUT (varname [blockid, elementid])
+// CHECK-NEXT: 0 IN (global_var, [1, 2])
+// CHECK-NEXT: 0 IN (ptr, [1, 3])
+// CHECK-NEXT: 0 OUT (global_var, [1, 2])
+// CHECK-NEXT: 0 OUT (ptr, [1, 3])
+// CHECK-NEXT: 1 OUT (global_var, [1, 2])
+// CHECK-NEXT: 1 OUT (ptr, [1, 3])
+
+void multiple_vardecl_in_declstmt() {
+  int *ptr = getIntPtr(), i;
+}
+// [B2 (ENTRY)] -> [B1] -> [B0 (EXIT)]
+
+// CHECK:  GEN sets: blockid (varname [blockid, elementid])
+// CHECK-NEXT: 1 (global_var, [1, 2])
+// CHECK-NEXT: 1 (ptr, [1, 3])
+// CHECK-NEXT: 1 (i, [1, 4])
+// CHECK-NEXT: KILL sets: blockid (varname [blockid, elementid])
+// CHECK-NEXT: Reaching definition sets: blockid IN/OUT (varname [blockid, elementid])
+// CHECK-NEXT: 0 IN (global_var, [1, 2])
+// CHECK-NEXT: 0 IN (ptr, [1, 3])
+// CHECK-NEXT: 0 IN (i, [1, 4])
+// CHECK-NEXT: 0 OUT (global_var, [1, 2])
+// CHECK-NEXT: 0 OUT (ptr, [1, 3])
+// CHECK-NEXT: 0 OUT (i, [1, 4])
+// CHECK-NEXT: 1 OUT (global_var, [1, 2])
+// CHECK-NEXT: 1 OUT (ptr, [1, 3])
+// CHECK-NEXT: 1 OUT (i, [1, 4])
+
+void function_and_vardecl_in_declstmt() {
+  int *ptr = getIntPtr(), a();
+}
+// [B2 (ENTRY)] -> [B1] -> [B0 (EXIT)]
+
+// CHECK:  GEN sets: blockid (varname [blockid, elementid])
+// CHECK-NEXT: 1 (global_var, [1, 2])
+// CHECK-NEXT: 1 (ptr, [1, 3])
+// CHECK-NEXT: KILL sets: blockid (varname [blockid, elementid])
+// CHECK-NEXT: Reaching definition sets: blockid IN/OUT (varname [blockid, elementid])
+// CHECK-NEXT: 0 IN (global_var, [1, 2])
+// CHECK-NEXT: 0 IN (ptr, [1, 3])
+// CHECK-NEXT: 0 OUT (global_var, [1, 2])
+// CHECK-NEXT: 0 OUT (ptr, [1, 3])
+// CHECK-NEXT: 1 OUT (global_var, [1, 2])
+// CHECK-NEXT: 1 OUT (ptr, [1, 3])
+
+void single_def_in_same_block() {
+  int *ptr = getIntPtr();
+
+  if (coin())
+ptr = 0;
+
+  if (!ptr)
+*ptr = 5;
+}
+//-> [B3] ->-> [B1] ->
+//   /  \  /  \
+// [B5 (ENTRY)] -> [B4] --> [B2] ---> [B0 (EXIT)]
+
+// CHECK:  GEN sets: blockid (varname [blockid, elementid])
+// CHECK-NEXT: 3 (ptr, [3, 3])
+// CHECK-NEXT: 4 (global_var, [4, 6])
+// CHECK-NEXT: 4 (ptr, [4, 3])
+// CHECK-NEXT: KILL sets: blockid (varname [blockid, elementid])
+// CHECK-NEXT: 3 (ptr, [4, 3])
+// CHECK-NEXT: 4 (ptr, [3, 3])
+// CHECK-NEXT: Reaching definition sets: blockid IN/OUT (varname [blockid, elementid])
+// CHECK-NEXT: 0 IN (global_var, [4, 6])
+// CHECK-NEXT: 0 IN (ptr, [3, 3])
+// CHECK-NEXT: 0 OUT (global_var, [4, 6])
+// CHECK-NEXT: 0 OUT (ptr, [3, 3])
+// CHECK-NEXT: 1 IN (global_var, [4, 6])
+// CHECK-NEXT: 1 IN (ptr, [3, 3])
+// CHECK-NEXT: 1 OUT (global_var, [4, 6])
+// CHECK-NEXT: 1 OUT (ptr, [3, 3])
+// CHECK-NEXT: 2 IN (global_var, [4, 6])
+// CHECK-NEXT: 2 IN (ptr, [3, 3])
+// CHECK-NEXT: 2 OUT (global_var, [4, 6])
+// CHECK-NEXT: 2 OUT (ptr, [3, 3])
+// CHECK-NEXT: 3 IN (global_var, [4, 6])
+// CHECK-NEXT: 3 IN (ptr, [4, 3])
+// CHECK-NEXT: 3 OUT 

r366699 - [X86] Remove const from some intrinsics that shouldn't have them

2019-07-22 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Mon Jul 22 09:14:09 2019
New Revision: 366699

URL: http://llvm.org/viewvc/llvm-project?rev=366699&view=rev
Log:
[X86] Remove const from some intrinsics that shouldn't have them

Modified:
cfe/trunk/lib/Headers/emmintrin.h

Modified: cfe/trunk/lib/Headers/emmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/emmintrin.h?rev=366699&r1=366698&r2=366699&view=diff
==
--- cfe/trunk/lib/Headers/emmintrin.h (original)
+++ cfe/trunk/lib/Headers/emmintrin.h Mon Jul 22 09:14:09 2019
@@ -4029,7 +4029,7 @@ _mm_storeu_si128(__m128i_u *__p, __m128i
 /// \param __b
 ///A 128-bit integer vector containing the value to be stored.
 static __inline__ void __DEFAULT_FN_ATTRS
-_mm_storeu_si64(void const *__p, __m128i __b)
+_mm_storeu_si64(void *__p, __m128i __b)
 {
   struct __storeu_si64 {
 long long __v;
@@ -4050,7 +4050,7 @@ _mm_storeu_si64(void const *__p, __m128i
 /// \param __b
 ///A 128-bit integer vector containing the value to be stored.
 static __inline__ void __DEFAULT_FN_ATTRS
-_mm_storeu_si32(void const *__p, __m128i __b)
+_mm_storeu_si32(void *__p, __m128i __b)
 {
   struct __storeu_si32 {
 int __v;
@@ -4071,7 +4071,7 @@ _mm_storeu_si32(void const *__p, __m128i
 /// \param __b
 ///A 128-bit integer vector containing the value to be stored.
 static __inline__ void __DEFAULT_FN_ATTRS
-_mm_storeu_si16(void const *__p, __m128i __b)
+_mm_storeu_si16(void *__p, __m128i __b)
 {
   struct __storeu_si16 {
 short __v;


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


[PATCH] D64256: Teach some warnings to respect gsl::Pointer and gsl::Owner attributes

2019-07-22 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 211127.
xazax.hun marked 5 inline comments as done.
xazax.hun added a comment.

- Address the rest of the review comments.


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

https://reviews.llvm.org/D64256

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaInit.cpp
  clang/test/Sema/warn-lifetime-analysis-nocfg.cpp

Index: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
===
--- /dev/null
+++ clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
@@ -0,0 +1,116 @@
+// RUN: %clang_cc1 -fsyntax-only -Wdangling -Wdangling-field -Wreturn-stack-address -verify %s
+struct [[gsl::Owner(int)]] MyIntOwner {
+  MyIntOwner();
+  int &operator*();
+  int *c_str() const;
+};
+
+struct [[gsl::Pointer(int)]] MyIntPointer {
+  MyIntPointer(int *p = nullptr);
+  // Conversion operator and constructor conversion will result in two
+  // different ASTs. The former is tested with another owner and 
+  // pointer type.
+  MyIntPointer(const MyIntOwner &);
+  int &operator*();
+  MyIntOwner toOwner();
+};
+
+struct [[gsl::Pointer(long)]] MyLongPointerFromConversion {
+  MyLongPointerFromConversion(long *p = nullptr);
+  long &operator*();
+};
+
+struct [[gsl::Owner(long)]] MyLongOwnerWithConversion {
+  MyLongOwnerWithConversion();
+  operator MyLongPointerFromConversion();
+  long &operator*();
+  MyIntPointer releaseAsMyPointer();
+  long *releaseAsRawPointer();
+};
+
+void danglingHeapObject() {
+  new MyLongPointerFromConversion(MyLongOwnerWithConversion{}); // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}}
+  new MyIntPointer(MyIntOwner{}); // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}}
+}
+
+void intentionalFalseNegative() {
+  int i;
+  MyIntPointer p{&i};
+  // In this case we do not have enough information in a statement local
+  // analysis to detect the problem.
+  new MyIntPointer(p);
+  new MyIntPointer(MyIntPointer{p});
+}
+
+MyIntPointer ownershipTransferToMyPointer() {
+  MyLongOwnerWithConversion t;
+  return t.releaseAsMyPointer(); // ok
+}
+
+long *ownershipTransferToRawPointer() {
+  MyLongOwnerWithConversion t;
+  return t.releaseAsRawPointer(); // ok
+}
+
+int *danglingRawPtrFromLocal() {
+  MyIntOwner t;
+  return t.c_str(); // TODO
+}
+
+int *danglingRawPtrFromTemp() {
+  MyIntPointer p;
+  return p.toOwner().c_str(); // TODO
+}
+
+struct Y {
+  int a[4];
+};
+
+void dangligGslPtrFromTemporary() {
+  MyIntPointer p = Y{}.a; // expected-warning {{temporary whose address is used as value of local variable 'p' will be destroyed at the end of the full-expression}}
+  (void)p;
+}
+
+struct DanglingGslPtrField {
+  MyIntPointer p; // expected-note 2{{pointer member declared here}}
+  MyLongPointerFromConversion p2; // expected-note {{pointer member declared here}}
+  DanglingGslPtrField(int i) : p(&i) {} // expected-warning {{initializing pointer member 'p' with the stack address of parameter 'i'}}
+  DanglingGslPtrField() : p2(MyLongOwnerWithConversion{}) {} // expected-warning {{initializing pointer member 'p2' to point to a temporary object whose lifetime is shorter than the lifetime of the constructed object}}
+  DanglingGslPtrField(double) : p(MyIntOwner{}) {} // expected-warning {{initializing pointer member 'p' to point to a temporary object whose lifetime is shorter than the lifetime of the constructed object}}
+};
+
+MyIntPointer danglingGslPtrFromLocal() {
+  int j;
+  return &j; // expected-warning {{address of stack memory associated with local variable 'j' returned}}
+}
+
+MyLongPointerFromConversion daglingGslPtrFromLocalOwner() {
+  MyLongOwnerWithConversion t;
+  return t; // TODO
+}
+
+MyLongPointerFromConversion danglingGslPtrFromTemporary() {
+  return MyLongOwnerWithConversion{}; // expected-warning {{returning address of local temporary object}}
+}
+
+MyIntPointer global;
+MyLongPointerFromConversion global2;
+
+void initLocalGslPtrWithTempOwner() {
+  MyIntPointer p = MyIntOwner{}; // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}}
+  p = MyIntOwner{}; // TODO ?
+  global = MyIntOwner{}; // TODO ?
+  MyLongPointerFromConversion p2 = MyLongOwnerWithConversion{}; // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}}
+  p2 = MyLongOwnerWithConversion{}; // TODO ?
+  global2 = MyLongOwnerWithConversion{}; // TODO ?
+}
+
+struct IntVector {
+  int *begin();
+  int *end();
+};
+
+void modelIterators() {
+  int *it = IntVector{}.begin(); // TODO ?
+  (void)it;
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -6507,6 +6507,8 @@
 VarInit,
 LValToRVal,
 LifetimeBoundCall,
+GslPointerInit,
+GslOwnerTemporaryIni

[PATCH] D65100: [clangd] Fix SelectionTree traversal of qualified types

2019-07-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

QualifiedTypeLoc isn't treated like a regular citizen by RecursiveASTVisitor.
This meant we weren't intercepting the traversal of its inner TypeLoc.

Most of the changes here are about exposing kind() so we can improve the
precision of our tests.

This should fix the issue raised in D65067 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65100

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/Selection.h
  clang-tools-extra/clangd/unittests/SelectionTests.cpp

Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -49,9 +49,7 @@
 }
 
 std::string nodeKind(const SelectionTree::Node *N) {
-  if (!N)
-return "";
-  return N->ASTNode.getNodeKind().asStringRef().str();
+  return N ? N->kind() : "";
 }
 
 std::vector allNodes(const SelectionTree &T) {
@@ -102,14 +100,14 @@
 struct AAA { struct BBB { static int ccc(); };};
 int x = AAA::[[B^B^B]]::ccc();
   )cpp",
-  "TypeLoc",
+  "RecordTypeLoc",
   },
   {
   R"cpp(
 struct AAA { struct BBB { static int ccc(); };};
 int x = AAA::[[B^BB^]]::ccc();
   )cpp",
-  "TypeLoc",
+  "RecordTypeLoc",
   },
   {
   R"cpp(
@@ -182,19 +180,19 @@
   R"cpp(
 [[^void]] (*S)(int) = nullptr;
   )cpp",
-  "TypeLoc",
+  "BuiltinTypeLoc",
   },
   {
   R"cpp(
 [[void (*S)^(int)]] = nullptr;
   )cpp",
-  "TypeLoc",
+  "FunctionProtoTypeLoc",
   },
   {
   R"cpp(
 [[void (^*S)(int)]] = nullptr;
   )cpp",
-  "TypeLoc",
+  "FunctionProtoTypeLoc",
   },
   {
   R"cpp(
@@ -206,7 +204,7 @@
   R"cpp(
 [[void ^(*S)(int)]] = nullptr;
   )cpp",
-  "TypeLoc",
+  "FunctionProtoTypeLoc",
   },
 
   // Point selections.
@@ -218,8 +216,8 @@
   {"int bar; void foo() [[{ foo (); }]]^", "CompoundStmt"},
 
   // Tricky case: FunctionTypeLoc in FunctionDecl has a hole in it.
-  {"[[^void]] foo();", "TypeLoc"},
-  {"[[void foo^()]];", "TypeLoc"},
+  {"[[^void]] foo();", "BuiltinTypeLoc"},
+  {"[[void foo^()]];", "FunctionProtoTypeLoc"},
   {"[[^void foo^()]];", "FunctionDecl"},
   {"[[void ^foo()]];", "FunctionDecl"},
   // Tricky case: two VarDecls share a specifier.
@@ -229,6 +227,9 @@
   {"[[st^ruct {int x;}]] y;", "CXXRecordDecl"},
   {"[[struct {int x;} ^y]];", "VarDecl"},
   {"struct {[[int ^x]];} y;", "FieldDecl"},
+  // FIXME: the AST has no location info for qualifiers.
+  {"const [[a^uto]] x = 42;", "AutoTypeLoc"},
+  {"[[co^nst auto x = 42]];", "VarDecl"},
 
   {"^", nullptr},
   {"void foo() { [[foo^^]] (); }", "DeclRefExpr"},
@@ -239,7 +240,8 @@
   {"int x = 42^;", nullptr},
 
   // Node types that have caused problems in the past.
-  {"template  void foo() { [[^T]] t; }", "TypeLoc"},
+  {"template  void foo() { [[^T]] t; }",
+   "TemplateTypeParmTypeLoc"},
 
   // No crash
   {
Index: clang-tools-extra/clangd/Selection.h
===
--- clang-tools-extra/clangd/Selection.h
+++ clang-tools-extra/clangd/Selection.h
@@ -96,6 +96,8 @@
 // Walk up the AST to get the DeclContext of this Node,
 // which is not the node itself.
 const DeclContext& getDeclContext() const;
+// Printable node kind, like "CXXRecordDecl" or "AutoTypeLoc".
+std::string kind() const;
   };
   // The most specific common ancestor of all the selected nodes.
   // If there is no selection, this is nullptr.
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -63,10 +63,8 @@
   std::vector> Ranges; // Always sorted.
 };
 
-// Dump a node for debugging.
-// DynTypedNode::print() doesn't include the kind of node, which is useful.
-void printNode(llvm::raw_ostream &OS, const DynTypedNode &N,
-   const PrintingPolicy &PP) {
+// Show the type of a node for debugging.
+void printNodeKind(llvm::raw_ostream &OS, const DynTypedNode &N) {
   if (const TypeLoc *TL = N.get()) {
 // TypeLoc is a hierarchy, but has only a single ASTNodeKind.
 // Synthesize the name from the Type subclass (except for QualifiedTypeLoc).
@@ -77,14 +75,13 @@
   } else {
 OS << N.getNodeKind().asStringRef();
   }
-  OS << "

[PATCH] D65000: [ARM] Set default alignment to 64bits

2019-07-22 Thread Peter Smith via Phabricator via cfe-commits
peter.smith added a comment.

test case missing A8 aside this looks ok to me. Would like to see if there are 
any comments from the Pacific time zone.




Comment at: test/CodeGen/ARM/exception-alignment.cpp:8
+// A16-NEXT: store <2 x i64> , <2 x i64>* [[BC]], align 16
+#include 
+

Are you missing the A8 case? presumably:
```
store <2 x i64> , <2 x i64>* [[BC]], align 8
```



Repository:
  rC Clang

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

https://reviews.llvm.org/D65000



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


[PATCH] D65012: Adds support for formatting NS_CLOSED_ENUM and CF_CLOSED_ENUM alongside NS_ENUM and CF_ENUM.

2019-07-22 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton accepted this revision.
benhamilton added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65012



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


[PATCH] D65012: Adds support for formatting NS_CLOSED_ENUM and CF_CLOSED_ENUM alongside NS_ENUM and CF_ENUM.

2019-07-22 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added a comment.

Oh, I forgot there's one more place you should touch — the Objective-C style 
guesser for headers will need to be updated to understand that `NS_CLOSED_ENUM` 
indicates Objective-C:

https://reviews.llvm.org/source/llvm-github/browse/master/clang/lib/Format/Format.cpp$1688

Can you update this as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65012



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


[PATCH] D65000: [ARM] Set default alignment to 64bits

2019-07-22 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio updated this revision to Diff 211132.
dnsampaio added a comment.

- Joined assignments for default alignments and neon_vector alignment
- Added missing align 8 test


Repository:
  rC Clang

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

https://reviews.llvm.org/D65000

Files:
  lib/Basic/Targets/ARM.cpp
  test/CodeGen/ARM/exception-alignment.cpp
  test/SemaCXX/warn-overaligned-type-thrown.cpp


Index: test/SemaCXX/warn-overaligned-type-thrown.cpp
===
--- test/SemaCXX/warn-overaligned-type-thrown.cpp
+++ test/SemaCXX/warn-overaligned-type-thrown.cpp
@@ -2,11 +2,12 @@
 // RUN: %clang_cc1 -triple arm64-apple-ios10 -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions -DUNDERALIGNED %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos10 -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions -DUNDERALIGNED %s
 // RUN: %clang_cc1 -triple arm64-apple-watchos4 -verify -fsyntax-only 
-std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
+// RUN: %clang_cc1 -triple arm-linux-gnueabi -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions  -DUNDERALIGNED %s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.14 -verify -fsyntax-only 
-std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple arm64-apple-ios12 -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos12 -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple arm64-apple-watchos5 -verify -fsyntax-only 
-std=c++11 -fcxx-exceptions -fexceptions %s
-// RUN: %clang_cc1 -triple arm-linux-gnueabi -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -triple arm-linux-androideabi -verify -fsyntax-only 
-std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple aarch64-linux-gnueabi -verify -fsyntax-only 
-std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple mipsel-linux-gnu -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple mips64el-linux-gnu -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions %s
Index: test/CodeGen/ARM/exception-alignment.cpp
===
--- /dev/null
+++ test/CodeGen/ARM/exception-alignment.cpp
@@ -0,0 +1,19 @@
+// Bug: https://bugs.llvm.org/show_bug.cgi?id=42668
+// REQUIRES: arm-registered-target
+// RUN: %clang --target=arm-arm-none-eabi -march=armv8-a -S -emit-llvm -Os -o 
- %s | FileCheck --check-prefixes=CHECK,A8 %s
+// RUN: %clang --target=arm-linux-androideabi -march=armv8-a -S -emit-llvm -Os 
-o - %s | FileCheck --check-prefixes=CHECK,A16 %s
+// CHECK: [[E:%[A-z0-9]+]] = tail call i8* @__cxa_allocate_exception
+// CHECK-NEXT: [[BC:%[A-z0-9]+]] = bitcast i8* [[E]] to <2 x i64>*
+// A8-NEXT: store <2 x i64> , <2 x i64>* [[BC]], align 8
+// A16-NEXT: store <2 x i64> , <2 x i64>* [[BC]], align 16
+#include 
+
+int main(void) {
+  try {
+throw vld1q_u64(((const uint64_t[2]){1, 2}));
+  } catch (uint64x2_t exc) {
+return 0;
+  }
+  return 1;
+}
+
Index: lib/Basic/Targets/ARM.cpp
===
--- lib/Basic/Targets/ARM.cpp
+++ lib/Basic/Targets/ARM.cpp
@@ -309,8 +309,9 @@
   setAtomic();
 
   // Maximum alignment for ARM NEON data types should be 64-bits (AAPCS)
+  // as well the default alignment
   if (IsAAPCS && (Triple.getEnvironment() != llvm::Triple::Android))
-MaxVectorAlign = 64;
+DefaultAlignForAttributeAligned = MaxVectorAlign = 64;
 
   // Do force alignment of members that follow zero length bitfields.  If
   // the alignment of the zero-length bitfield is greater than the member


Index: test/SemaCXX/warn-overaligned-type-thrown.cpp
===
--- test/SemaCXX/warn-overaligned-type-thrown.cpp
+++ test/SemaCXX/warn-overaligned-type-thrown.cpp
@@ -2,11 +2,12 @@
 // RUN: %clang_cc1 -triple arm64-apple-ios10 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos10 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
 // RUN: %clang_cc1 -triple arm64-apple-watchos4 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
+// RUN: %clang_cc1 -triple arm-linux-gnueabi -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions  -DUNDERALIGNED %s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.14 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple arm64-apple-ios12 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos12 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple arm64-apple-watchos5 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions

[PATCH] D65000: [ARM] Set default alignment to 64bits

2019-07-22 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio marked an inline comment as done.
dnsampaio added a comment.

True. Thx again.


Repository:
  rC Clang

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

https://reviews.llvm.org/D65000



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


[libunwind] r366701 - [libunwind][ARM] Fix types in _Unwind_VRS_Get.

2019-07-22 Thread Mikhail Maltsev via cfe-commits
Author: miyuki
Date: Mon Jul 22 09:43:03 2019
New Revision: 366701

URL: http://llvm.org/viewvc/llvm-project?rev=366701&view=rev
Log:
[libunwind][ARM] Fix types in _Unwind_VRS_Get.

This is a small fix for https://reviews.llvm.org/D64996. The types of
w0 and w1 in _Unwind_VRS_Get must be uint64_t, not uint32_t.

Committing as obvious.

Modified:
libunwind/trunk/src/Unwind-EHABI.cpp

Modified: libunwind/trunk/src/Unwind-EHABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Unwind-EHABI.cpp?rev=366701&r1=366700&r2=366701&view=diff
==
--- libunwind/trunk/src/Unwind-EHABI.cpp (original)
+++ libunwind/trunk/src/Unwind-EHABI.cpp Mon Jul 22 09:43:03 2019
@@ -941,8 +941,8 @@ _Unwind_VRS_Pop(_Unwind_Context *context
   // format 1", which is equivalent to FSTMD + a padding word.
   for (uint32_t i = first; i < end; ++i) {
 // SP is only 32-bit aligned so don't copy 64-bit at a time.
-uint32_t w0 = *sp++;
-uint32_t w1 = *sp++;
+uint64_t w0 = *sp++;
+uint64_t w1 = *sp++;
 #ifdef __LITTLE_ENDIAN__
 uint64_t value = (w1 << 32) | w0;
 #else


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


[PATCH] D65012: Adds support for formatting NS_CLOSED_ENUM and CF_CLOSED_ENUM alongside NS_ENUM and CF_ENUM.

2019-07-22 Thread Hank Heijink via Phabricator via cfe-commits
heijink updated this revision to Diff 211135.
heijink added a comment.

Adds NS_CLOSED_ENUM to the keywords that cause LLVM to detect Objective-C. 
Changed NSInteger to int in the unit tests, because NSInteger also signals 
Objective-C.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65012

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

Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -114,7 +114,12 @@
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
 
   Style =
-  getStyle("{}", "a.h", "none", "typedef NS_ENUM(NSInteger, Foo) {};\n");
+  getStyle("{}", "a.h", "none", "typedef NS_ENUM(int, Foo) {};\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none",
+   "typedef NS_CLOSED_ENUM(int, Foo) {};\n");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1716,6 +1716,8 @@
 
 TEST_F(FormatTest, FormatsNSEnums) {
   verifyGoogleFormat("typedef NS_ENUM(NSInteger, SomeName) { AAA, BBB }");
+  verifyGoogleFormat(
+  "typedef NS_CLOSED_ENUM(NSInteger, SomeName) { AAA, BBB }");
   verifyGoogleFormat("typedef NS_ENUM(NSInteger, MyType) {\n"
  "  // Information about someDecentlyLongValue.\n"
  "  someDecentlyLongValue,\n"
@@ -1724,6 +1726,14 @@
  "  // Information about aThirdDecentlyLongValue.\n"
  "  aThirdDecentlyLongValue\n"
  "};");
+  verifyGoogleFormat("typedef NS_CLOSED_ENUM(NSInteger, MyType) {\n"
+ "  // Information about someDecentlyLongValue.\n"
+ "  someDecentlyLongValue,\n"
+ "  // Information about anotherDecentlyLongValue.\n"
+ "  anotherDecentlyLongValue,\n"
+ "  // Information about aThirdDecentlyLongValue.\n"
+ "  aThirdDecentlyLongValue\n"
+ "};");
   verifyGoogleFormat("typedef NS_OPTIONS(NSInteger, MyType) {\n"
  "  a = 1,\n"
  "  b = 2,\n"
@@ -1734,6 +1744,11 @@
  "  b = 2,\n"
  "  c = 3,\n"
  "};");
+  verifyGoogleFormat("typedef CF_CLOSED_ENUM(NSInteger, MyType) {\n"
+ "  a = 1,\n"
+ "  b = 2,\n"
+ "  c = 3,\n"
+ "};");
   verifyGoogleFormat("typedef CF_OPTIONS(NSInteger, MyType) {\n"
  "  a = 1,\n"
  "  b = 2,\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1215,7 +1215,8 @@
 case tok::kw_typedef:
   nextToken();
   if (FormatTok->isOneOf(Keywords.kw_NS_ENUM, Keywords.kw_NS_OPTIONS,
- Keywords.kw_CF_ENUM, Keywords.kw_CF_OPTIONS))
+ Keywords.kw_CF_ENUM, Keywords.kw_CF_OPTIONS,
+ Keywords.kw_CF_CLOSED_ENUM, Keywords.kw_NS_CLOSED_ENUM))
 parseEnum();
   break;
 case tok::kw_struct:
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -677,8 +677,10 @@
 kw_override = &IdentTable.get("override");
 kw_in = &IdentTable.get("in");
 kw_of = &IdentTable.get("of");
+kw_CF_CLOSED_ENUM = &IdentTable.get("CF_CLOSED_ENUM");
 kw_CF_ENUM = &IdentTable.get("CF_ENUM");
 kw_CF_OPTIONS = &IdentTable.get("CF_OPTIONS");
+kw_NS_CLOSED_ENUM = &IdentTable.get("NS_CLOSED_ENUM");
 kw_NS_ENUM = &IdentTable.get("NS_ENUM");
 kw_NS_OPTIONS = &IdentTable.get("NS_OPTIONS");
 
@@ -787,8 +789,10 @@
   IdentifierInfo *kw_override;
   IdentifierInfo *kw_in;
   IdentifierInfo *kw_of;
+  IdentifierInfo *kw_CF_CLOSED_ENUM;
   IdentifierInfo *kw_CF_ENUM;
   IdentifierInfo *kw_CF_OPTIONS;
+  IdentifierInfo *kw_NS_CLOSED_ENUM;
   IdentifierInfo *kw_NS_ENUM;
   IdentifierInfo *kw_NS_OPTIONS;
   IdentifierInfo *kw___except;
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1685,7 +1685,7 @@
   

r366702 - [OPENMP][MSVC]Enable /openmp[:experimental] to compile OpenMP.

2019-07-22 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Jul 22 09:49:59 2019
New Revision: 366702

URL: http://llvm.org/viewvc/llvm-project?rev=366702&view=rev
Log:
[OPENMP][MSVC]Enable /openmp[:experimental] to compile OpenMP.

Mapped /openmp[:experimental] to -fopenmp option and /openmp- option to
-fno-openmp

Modified:
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/test/Driver/fopenmp.c

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=366702&r1=366701&r2=366702&view=diff
==
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Mon Jul 22 09:49:59 2019
@@ -254,7 +254,13 @@ def _SLASH_Zp_flag : CLFlag<"Zp">,
   Alias, AliasArgs<["1"]>;
 def _SLASH_Zs : CLFlag<"Zs">, HelpText<"Syntax-check only">,
   Alias;
-
+def _SLASH_openmp_ : CLFlag<"openmp-">,
+  HelpText<"Disable OpenMP support">, Alias;
+def _SLASH_openmp : CLFlag<"openmp">, HelpText<"Enable OpenMP support">,
+  Alias;
+def _SLASH_openmp_experimental : CLFlag<"openmp:experimental">,
+  HelpText<"Enable OpenMP support with experimental SIMD support">,
+  Alias;
 
 // Non-aliases:
 
@@ -381,7 +387,6 @@ def _SLASH_FS : CLIgnoredFlag<"FS">;
 def _SLASH_JMC : CLIgnoredFlag<"JMC">;
 def _SLASH_kernel_ : CLIgnoredFlag<"kernel-">;
 def _SLASH_nologo : CLIgnoredFlag<"nologo">;
-def _SLASH_openmp_ : CLIgnoredFlag<"openmp-">;
 def _SLASH_permissive_ : CLIgnoredFlag<"permissive-">;
 def _SLASH_RTC : CLIgnoredJoined<"RTC">;
 def _SLASH_sdl : CLIgnoredFlag<"sdl">;
@@ -436,8 +441,6 @@ def _SLASH_hotpatch : CLFlag<"hotpatch">
 def _SLASH_kernel : CLFlag<"kernel">;
 def _SLASH_LN : CLFlag<"LN">;
 def _SLASH_MP : CLJoined<"MP">;
-def _SLASH_openmp : CLFlag<"openmp">;
-def _SLASH_openmp_experimental : CLFlag<"openmp:experimental">;
 def _SLASH_Qfast_transcendentals : CLFlag<"Qfast_transcendentals">;
 def _SLASH_QIfist : CLFlag<"QIfist">;
 def _SLASH_Qimprecise_fwaits : CLFlag<"Qimprecise_fwaits">;

Modified: cfe/trunk/test/Driver/fopenmp.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fopenmp.c?rev=366702&r1=366701&r2=366702&view=diff
==
--- cfe/trunk/test/Driver/fopenmp.c (original)
+++ cfe/trunk/test/Driver/fopenmp.c Mon Jul 22 09:49:59 2019
@@ -13,6 +13,10 @@
 // RUN: %clang -target x86_64-windows-gnu -fopenmp=libomp -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-CC1-OPENMP
 // RUN: %clang -target x86_64-windows-gnu -fopenmp=libgomp -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-CC1-NO-OPENMP
 // RUN: %clang -target x86_64-windows-gnu -fopenmp=libiomp5 -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-CC1-OPENMP
+// RUN: %clang -target x86_64-windows-gnu -fopenmp=libiomp5 -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-CC1-OPENMP
+// RUN: %clang_cl --target=x86_64-windows-msvc /openmp -### -- %s 2>&1 | 
FileCheck --check-prefix=CHECK-CC1-OPENMP %s
+// RUN: %clang_cl --target=i686-windows-msvc /openmp:experimental -### -- %s 
2>&1 | FileCheck --check-prefix=CHECK-CC1-OPENMP %s
+// RUN: %clang_cl --target=x86_64-windows-msvc /openmp- -### -- %s 2>&1 | 
FileCheck --check-prefix=CHECK-CC1-NO-OPENMP %s
 //
 // CHECK-CC1-OPENMP: "-cc1"
 // CHECK-CC1-OPENMP: "-fopenmp"


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


[PATCH] D64799: [Sema] Emit diagnostics for uncorrected delayed typos at the end of TU

2019-07-22 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D64799#1592263 , @rnk wrote:

> In D64799#1591732 , @ilya-biryukov 
> wrote:
>
> > @rsmith, I'll look into emitting the typos when we pop expression 
> > evaluation context, but do we expect this to cover **all** cases where 
> > `TypoExpr`s are produced?
> >  (conservatively assuming that the answer is "no") should we land this 
> > patch and also emit at the end of TU in addition to expression evaluation 
> > context?
>
>
> I was going to pose the question this way: suppose clang already diagnosed 
> typos when leaving an expr evaluation context, when appropriate. Would it 
> still make sense to relax this assertion to diagnose any remaining ones at 
> end of TU? Are we confident that we can catch all the typos, always? I'm not 
> confident that everything will be handled, so I think we should take this 
> change as is.


There may still be uncorrected typos left behind in the outermost 
`ExprEvalContext` (created by the `Sema` constructor). In principle we should 
be able to get rid of that and parse all expressions in an evaluation context 
created for that expression (and anywhere we can't do that is a bug because 
we'll be parsing an expression without specifying whether it's 
potentially-evaluated, etc), but in practice it looks like there are still at 
least a few places where we parse expressions with no expression evaluation 
context, so cleaning up the typos in `ExprEvalContext[0]` from 
`ActOnEndOfTranslationUnitFragment` seems reasonable to me too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64799



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


[PATCH] D65012: Adds support for formatting NS_CLOSED_ENUM and CF_CLOSED_ENUM alongside NS_ENUM and CF_ENUM.

2019-07-22 Thread Hank Heijink via Phabricator via cfe-commits
heijink updated this revision to Diff 211137.
heijink added a comment.

Fixed formatting of Format.cpp.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65012

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

Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -114,7 +114,12 @@
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
 
   Style =
-  getStyle("{}", "a.h", "none", "typedef NS_ENUM(NSInteger, Foo) {};\n");
+  getStyle("{}", "a.h", "none", "typedef NS_ENUM(int, Foo) {};\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none",
+   "typedef NS_CLOSED_ENUM(int, Foo) {};\n");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1716,6 +1716,8 @@
 
 TEST_F(FormatTest, FormatsNSEnums) {
   verifyGoogleFormat("typedef NS_ENUM(NSInteger, SomeName) { AAA, BBB }");
+  verifyGoogleFormat(
+  "typedef NS_CLOSED_ENUM(NSInteger, SomeName) { AAA, BBB }");
   verifyGoogleFormat("typedef NS_ENUM(NSInteger, MyType) {\n"
  "  // Information about someDecentlyLongValue.\n"
  "  someDecentlyLongValue,\n"
@@ -1724,6 +1726,14 @@
  "  // Information about aThirdDecentlyLongValue.\n"
  "  aThirdDecentlyLongValue\n"
  "};");
+  verifyGoogleFormat("typedef NS_CLOSED_ENUM(NSInteger, MyType) {\n"
+ "  // Information about someDecentlyLongValue.\n"
+ "  someDecentlyLongValue,\n"
+ "  // Information about anotherDecentlyLongValue.\n"
+ "  anotherDecentlyLongValue,\n"
+ "  // Information about aThirdDecentlyLongValue.\n"
+ "  aThirdDecentlyLongValue\n"
+ "};");
   verifyGoogleFormat("typedef NS_OPTIONS(NSInteger, MyType) {\n"
  "  a = 1,\n"
  "  b = 2,\n"
@@ -1734,6 +1744,11 @@
  "  b = 2,\n"
  "  c = 3,\n"
  "};");
+  verifyGoogleFormat("typedef CF_CLOSED_ENUM(NSInteger, MyType) {\n"
+ "  a = 1,\n"
+ "  b = 2,\n"
+ "  c = 3,\n"
+ "};");
   verifyGoogleFormat("typedef CF_OPTIONS(NSInteger, MyType) {\n"
  "  a = 1,\n"
  "  b = 2,\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1215,7 +1215,8 @@
 case tok::kw_typedef:
   nextToken();
   if (FormatTok->isOneOf(Keywords.kw_NS_ENUM, Keywords.kw_NS_OPTIONS,
- Keywords.kw_CF_ENUM, Keywords.kw_CF_OPTIONS))
+ Keywords.kw_CF_ENUM, Keywords.kw_CF_OPTIONS,
+ Keywords.kw_CF_CLOSED_ENUM, Keywords.kw_NS_CLOSED_ENUM))
 parseEnum();
   break;
 case tok::kw_struct:
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -677,8 +677,10 @@
 kw_override = &IdentTable.get("override");
 kw_in = &IdentTable.get("in");
 kw_of = &IdentTable.get("of");
+kw_CF_CLOSED_ENUM = &IdentTable.get("CF_CLOSED_ENUM");
 kw_CF_ENUM = &IdentTable.get("CF_ENUM");
 kw_CF_OPTIONS = &IdentTable.get("CF_OPTIONS");
+kw_NS_CLOSED_ENUM = &IdentTable.get("NS_CLOSED_ENUM");
 kw_NS_ENUM = &IdentTable.get("NS_ENUM");
 kw_NS_OPTIONS = &IdentTable.get("NS_OPTIONS");
 
@@ -787,8 +789,10 @@
   IdentifierInfo *kw_override;
   IdentifierInfo *kw_in;
   IdentifierInfo *kw_of;
+  IdentifierInfo *kw_CF_CLOSED_ENUM;
   IdentifierInfo *kw_CF_ENUM;
   IdentifierInfo *kw_CF_OPTIONS;
+  IdentifierInfo *kw_NS_CLOSED_ENUM;
   IdentifierInfo *kw_NS_ENUM;
   IdentifierInfo *kw_NS_OPTIONS;
   IdentifierInfo *kw___except;
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1685,10 +1685,11 @@
 std::end(FoundationIdentifiers),
 FormatTok->TokenText)) ||
 FormatTok->is(TT

[PATCH] D65102: [OpenCL] Rename lang mode flag for C++ mode

2019-07-22 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added reviewers: svenvh, neil.hickey, kpet.
Herald added subscribers: ebevhan, yaxunl.

This suggestion was made in 
https://reviews.llvm.org/D64418?id=210101#inline-579453 but I am changing this 
standalone here.

I see two benefits for this rename:

- Aligning better with OpenCL C conversion
- Removing ambiguity with OpenCL C++

Since this is the first official release that contains C++ for OpenCL support 
it seems logical to change at this stage.


https://reviews.llvm.org/D65102

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/LangStandards.def
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/mangle-address-space.cpp
  test/CodeGenOpenCL/builtins.cl
  test/CodeGenOpenCL/images.cl
  test/CodeGenOpenCL/logical-ops.cl
  test/CodeGenOpenCL/pipe_builtin.cl
  test/CodeGenOpenCL/sampler.cl
  test/CodeGenOpenCL/spir_version.cl
  test/CodeGenOpenCL/to_addr_builtin.cl
  test/CodeGenOpenCLCXX/address-space-castoperators.cpp
  test/CodeGenOpenCLCXX/address-space-deduction.cl
  test/CodeGenOpenCLCXX/address-space-deduction2.cl
  test/CodeGenOpenCLCXX/addrspace-conversion.cl
  test/CodeGenOpenCLCXX/addrspace-derived-base.cl
  test/CodeGenOpenCLCXX/addrspace-of-this.cl
  test/CodeGenOpenCLCXX/addrspace-operators.cl
  test/CodeGenOpenCLCXX/addrspace-references.cl
  test/CodeGenOpenCLCXX/addrspace-with-class.cl
  test/CodeGenOpenCLCXX/atexit.cl
  test/CodeGenOpenCLCXX/global_init.cl
  test/CodeGenOpenCLCXX/local_addrspace_init.cl
  test/CodeGenOpenCLCXX/method-overload-address-space.cl
  test/CodeGenOpenCLCXX/template-address-spaces.cl
  test/Driver/autocomplete.c
  test/Driver/opencl.cl
  test/Frontend/opencl.cl
  test/Frontend/stdlang.c
  test/Headers/opencl-c-header.cl
  test/Parser/opencl-cxx-keywords.cl
  test/Parser/opencl-cxx-virtual.cl
  test/Preprocessor/predefined-macros.c
  test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  test/SemaOpenCL/address-spaces.cl
  test/SemaOpenCL/builtin.cl
  test/SemaOpenCL/clk_event_t.cl
  test/SemaOpenCL/extension-version.cl
  test/SemaOpenCL/extensions.cl
  test/SemaOpenCL/invalid-image.cl
  test/SemaOpenCL/invalid-pipes-cl2.0.cl
  test/SemaOpenCLCXX/address-space-deduction.cl
  test/SemaOpenCLCXX/address-space-of-this-class-scope.cl
  test/SemaOpenCLCXX/address-space-of-this.cl
  test/SemaOpenCLCXX/address-space-references.cl
  test/SemaOpenCLCXX/address-space-templates.cl
  test/SemaOpenCLCXX/address_space_overloading.cl
  test/SemaOpenCLCXX/kernel_invalid.cl
  test/SemaOpenCLCXX/method-overload-address-space.cl
  test/SemaOpenCLCXX/newdelete.cl
  test/SemaOpenCLCXX/restricted.cl

Index: test/SemaOpenCLCXX/restricted.cl
===
--- test/SemaOpenCLCXX/restricted.cl
+++ test/SemaOpenCLCXX/restricted.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -pedantic -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=clc++ -pedantic -verify -fsyntax-only
 
 // This test checks that various C/C++/OpenCL C constructs are not available in
 // C++ for OpenCL.
Index: test/SemaOpenCLCXX/newdelete.cl
===
--- test/SemaOpenCLCXX/newdelete.cl
+++ test/SemaOpenCLCXX/newdelete.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -pedantic -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=clc++ -pedantic -verify -fsyntax-only
 
 class A {
   public:
Index: test/SemaOpenCLCXX/method-overload-address-space.cl
===
--- test/SemaOpenCLCXX/method-overload-address-space.cl
+++ test/SemaOpenCLCXX/method-overload-address-space.cl
@@ -1,4 +1,4 @@
-//RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -pedantic -verify
+//RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=clc++ -pedantic -verify
 
 struct C {
   void m1() __local __local; //expected-warning{{multiple identical address spaces specified for type}}
Index: test/SemaOpenCLCXX/kernel_invalid.cl
===
--- test/SemaOpenCLCXX/kernel_invalid.cl
+++ test/SemaOpenCLCXX/kernel_invalid.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -cl-std=c++ -pedantic -verify -fsyntax-only
+// RUN: %clang_cc1 %s -cl-std=clc++ -pedantic -verify -fsyntax-only
 
 struct C {
   kernel void m(); //expected-error{{kernel functions cannot be class members}}
Index: test/SemaOpenCLCXX/address_space_overloading.cl
===
--- test/SemaOpenCLCXX/address_space_overloading.cl
+++ test/SemaOpenCLCXX/address_space_overloading.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=c++
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++
 // expected-no-diagnostics
 
 struct RetGlob {
Index: test/SemaOpenCLCXX/address-space-templates.cl
==

[PATCH] D65101: [clangd] SelectionTree treats TranslationUnitDecl consistently with other containers.

2019-07-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Previously TranslationUnitDecl would never be selected.
This means root() and commonAncestor() are now never null, and therefore changed
them to references.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65101

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/Selection.h
  clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
  clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
  clang-tools-extra/clangd/refactor/tweaks/RawStringLiteral.cpp
  clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
  clang-tools-extra/clangd/unittests/SelectionTests.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -269,13 +269,13 @@
   checkNotAvailable(ID, "/*c^omment*/ int foo() return 2 ^ + 2; }");
 
   const char *Input = "int fcall(int); int x = fca[[ll(2 +]]2);";
-  const char *Output = R"(TranslationUnitDecl 
-  VarDecl int x = fcall(2 + 2)
-   .CallExpr fcall(2 + 2)
-  ImplicitCastExpr fcall
-   .DeclRefExpr fcall
- .BinaryOperator 2 + 2
-   *IntegerLiteral 2
+  const char *Output = R"( TranslationUnitDecl 
+   VarDecl int x = fcall(2 + 2)
+.CallExpr fcall(2 + 2)
+   ImplicitCastExpr fcall
+.DeclRefExpr fcall
+  .BinaryOperator 2 + 2
+*IntegerLiteral 2
 )";
   EXPECT_EQ(Output, getMessage(ID, Input));
 }
Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -9,6 +9,8 @@
 #include "Selection.h"
 #include "SourceCode.h"
 #include "TestTU.h"
+#include "clang/AST/Decl.h"
+#include "llvm/Support/Casting.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
@@ -34,28 +36,26 @@
   }
 }
 
-Range nodeRange(const SelectionTree::Node *N, ParsedAST &AST) {
-  if (!N)
-return Range{};
+Range nodeRange(const SelectionTree::Node &N, ParsedAST &AST) {
   const SourceManager &SM = AST.getSourceManager();
   const LangOptions &LangOpts = AST.getASTContext().getLangOpts();
   StringRef Buffer = SM.getBufferData(SM.getMainFileID());
+  if (llvm::isa_and_nonnull(N.ASTNode.get()))
+return Range{Position{}, offsetToPosition(Buffer, Buffer.size())};
   auto FileRange =
-  toHalfOpenFileRange(SM, LangOpts, N->ASTNode.getSourceRange());
+  toHalfOpenFileRange(SM, LangOpts, N.ASTNode.getSourceRange());
   assert(FileRange && "We should be able to get the File Range");
   return Range{
   offsetToPosition(Buffer, SM.getFileOffset(FileRange->getBegin())),
   offsetToPosition(Buffer, SM.getFileOffset(FileRange->getEnd()))};
 }
 
-std::string nodeKind(const SelectionTree::Node *N) {
-  if (!N)
-return "";
-  return N->ASTNode.getNodeKind().asStringRef().str();
+std::string nodeKind(const SelectionTree::Node &N) {
+  return N.ASTNode.getNodeKind().asStringRef().str();
 }
 
 std::vector allNodes(const SelectionTree &T) {
-  std::vector Result = {T.root()};
+  std::vector Result = {&T.root()};
   for (unsigned I = 0; I < Result.size(); ++I) {
 const SelectionTree::Node *N = Result[I];
 Result.insert(Result.end(), N->Children.begin(), N->Children.end());
@@ -65,16 +65,16 @@
 
 // Returns true if Common is a descendent of Root.
 // Verifies nothing is selected above Common.
-bool verifyCommonAncestor(const SelectionTree::Node *Root,
-  const SelectionTree::Node *Common,
+bool verifyCommonAncestor(const SelectionTree::Node &Root,
+  const SelectionTree::Node &Common,
   StringRef MarkedCode) {
-  if (Root == Common)
+  if (&Root == &Common)
 return true;
-  if (Root->Selected)
+  if (Root.Selected)
 ADD_FAILURE() << "Selected nodes outside common ancestor\n" << MarkedCode;
   bool Seen = false;
-  for (const SelectionTree::Node *Child : Root->Children)
-if (verifyCommonAncestor(Child, Common, MarkedCode)) {
+  for (const SelectionTree::Node *Child : Root.Children)
+if (verifyCommonAncestor(*Child, Common, MarkedCode)) {
   if (Seen)
 ADD_FAILURE() << "Saw common ancestor twice\n" << MarkedCode;
   Seen = true;
@@ -162,7 +162,7 @@
 #define CALL_FUNCTION(X) X^()^
 void bar() { CALL_FUNCTION(foo); }
   )cpp",
-  nullptr,
+  "TranslationUnitDecl",
   },
   {
   R"cpp(
@@ -230,13 +230,13 @@
   {"[[str

[PATCH] D64416: [AArch64] Add support for Transactional Memory Extension (TME)

2019-07-22 Thread Momchil Velikov via Phabricator via cfe-commits
chill updated this revision to Diff 211140.
This revision is now accepted and ready to land.

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

https://reviews.llvm.org/D64416

Files:
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Headers/arm_acle.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/aarch64-tme.cpp
  clang/test/Sema/aarch64-tme-errors.c
  clang/test/Sema/aarch64-tme-tcancel-errors.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/AArch64TargetParser.h
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/test/CodeGen/AArch64/tme.ll
  llvm/test/MC/AArch64/tme-error.s
  llvm/test/MC/AArch64/tme.s
  llvm/test/MC/Disassembler/AArch64/tme.txt
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -1119,6 +1119,7 @@
   {"rcpc", "norcpc", "+rcpc", "-rcpc" },
   {"rng", "norng", "+rand", "-rand"},
   {"memtag", "nomemtag", "+mte", "-mte"},
+  {"tme", "notme", "+tme", "-tme"},
   {"ssbs", "nossbs", "+ssbs", "-ssbs"},
   {"sb", "nosb", "+sb", "-sb"},
   {"predres", "nopredres", "+predres", "-predres"}
Index: llvm/test/MC/Disassembler/AArch64/tme.txt
===
--- /dev/null
+++ llvm/test/MC/Disassembler/AArch64/tme.txt
@@ -0,0 +1,19 @@
+# Tests for transaction memory extension instructions
+# RUN: llvm-mc -triple=aarch64 -mattr=+tme   -disassemble < %s  | FileCheck %s
+# RUN: not llvm-mc -triple=aarch64 -mattr=-tme   -disassemble < %s 2>&1 | FileCheck %s --check-prefix=NOTME
+
+[0x63,0x30,0x23,0xd5]
+[0x64,0x31,0x23,0xd5]
+[0x7f,0x30,0x03,0xd5]
+[0x80,0x46,0x62,0xd4]
+
+# CHECK: tstart x3
+# CHECK: ttest  x4
+# CHECK: tcommit
+# CHECK: tcancel #0x1234
+
+# NOTEME: mrs
+# NOTEME-NEXT: mrs
+# NOTEME-NEXT: msr
+# NOTME:  warning: invalid instruction encoding
+# NOTME-NEXT: [0x80,0x46,0x62,0xd4]
Index: llvm/test/MC/AArch64/tme.s
===
--- /dev/null
+++ llvm/test/MC/AArch64/tme.s
@@ -0,0 +1,24 @@
+// Tests for transaction memory extension instructions
+//
+// RUN: llvm-mc -triple aarch64 -show-encoding -mattr=+tme   < %s  | FileCheck %s
+// RUN: not llvm-mc -triple aarch64 -show-encoding -mattr=-tme   < %s 2>&1 | FileCheck %s --check-prefix=NOTME
+
+tstart x3
+ttest  x4
+tcommit
+tcancel #0x1234
+
+// CHECK: tstart x3 // encoding: [0x63,0x30,0x23,0xd5]
+// CHECK: ttest x4  // encoding: [0x64,0x31,0x23,0xd5]
+// CHECK: tcommit   // encoding: [0x7f,0x30,0x03,0xd5]
+// CHECK: tcancel #0x1234   // encoding: [0x80,0x46,0x62,0xd4]
+
+
+// NOTME: instruction requires: tme
+// NOTME-NEXT: tstart x3
+// NOTME: instruction requires: tme
+// NOTME-NEXT: ttest  x4
+// NOTME: instruction requires: tme
+// NOTME-NEXT: tcommit
+// NOTME: instruction requires: tme
+// NOTME-NEXT: tcancel #0x1234
Index: llvm/test/MC/AArch64/tme-error.s
===
--- /dev/null
+++ llvm/test/MC/AArch64/tme-error.s
@@ -0,0 +1,47 @@
+// Tests for transactional memory extension instructions
+// RUN: not llvm-mc -triple aarch64 -show-encoding -mattr=+tme < %s 2>&1   | FileCheck %s
+
+tstart
+// CHECK: error: too few operands for instruction
+// CHECK-NEXT: tstart
+tstart  x4, x5
+// CHECK: error: invalid operand for instruction
+// CHECK-NEXT: tstart x4, x5
+tstart  x4, #1
+// CHECK: error: invalid operand for instruction
+// CHECK-NEXT: tstart x4, #1
+tstart  sp
+// CHECK: error: invalid operand for instruction
+// CHECK-NEXT: tstart sp
+
+ttest
+// CHECK: error: too few operands for instruction
+// CHECK-NEXT: ttest
+ttest  x4, x5
+// CHECK: error: invalid operand for instruction
+// CHECK-NEXT: ttest x4, x5
+ttest  x4, #1
+// CHECK: error: invalid operand for instruction
+// CHECK-NEXT: ttest x4, #1
+ttest  sp
+// CHECK: error: invalid operand for instruction
+// CHECK-NEXT: ttest sp
+
+tcommit  x4
+// CHECK: error: invalid operand for instruction
+// CHECK-NEXT: tcommit x4
+tcommit  sp
+// CHECK: error: invalid operand for instruction
+// CHECK-NEXT: tcommit sp
+
+
+tcancel
+// CHECK: error: too few operands for instruction
+// CHECK-NEXT tcancel
+tcancel x0
+// CHECK: error: immediate must be an integer in range [0, 65535]
+// CHECK-NEXT tcancel
+tcancel #65536
+// CHECK: error: immediate must be an integer in range 

[PATCH] D64256: Teach some warnings to respect gsl::Pointer and gsl::Owner attributes

2019-07-22 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 211142.
xazax.hun added a comment.

- Fix a TODO and add some more tests.


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

https://reviews.llvm.org/D64256

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaInit.cpp
  clang/test/Sema/warn-lifetime-analysis-nocfg.cpp

Index: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
===
--- /dev/null
+++ clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
@@ -0,0 +1,125 @@
+// RUN: %clang_cc1 -fsyntax-only -Wdangling -Wdangling-field -Wreturn-stack-address -verify %s
+struct [[gsl::Owner(int)]] MyIntOwner {
+  MyIntOwner();
+  int &operator*();
+  int *c_str() const;
+};
+
+struct [[gsl::Pointer(int)]] MyIntPointer {
+  MyIntPointer(int *p = nullptr);
+  // Conversion operator and constructor conversion will result in two
+  // different ASTs. The former is tested with another owner and 
+  // pointer type.
+  MyIntPointer(const MyIntOwner &);
+  int &operator*();
+  MyIntOwner toOwner();
+};
+
+struct [[gsl::Pointer(long)]] MyLongPointerFromConversion {
+  MyLongPointerFromConversion(long *p = nullptr);
+  long &operator*();
+};
+
+struct [[gsl::Owner(long)]] MyLongOwnerWithConversion {
+  MyLongOwnerWithConversion();
+  operator MyLongPointerFromConversion();
+  long &operator*();
+  MyIntPointer releaseAsMyPointer();
+  long *releaseAsRawPointer();
+};
+
+void danglingHeapObject() {
+  new MyLongPointerFromConversion(MyLongOwnerWithConversion{}); // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}}
+  new MyIntPointer(MyIntOwner{}); // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}}
+}
+
+void intentionalFalseNegative() {
+  int i;
+  MyIntPointer p{&i};
+  // In this case we do not have enough information in a statement local
+  // analysis to detect the problem.
+  new MyIntPointer(p);
+  new MyIntPointer(MyIntPointer{p});
+}
+
+MyIntPointer ownershipTransferToMyPointer() {
+  MyLongOwnerWithConversion t;
+  return t.releaseAsMyPointer(); // ok
+}
+
+long *ownershipTransferToRawPointer() {
+  MyLongOwnerWithConversion t;
+  return t.releaseAsRawPointer(); // ok
+}
+
+int *danglingRawPtrFromLocal() {
+  MyIntOwner t;
+  return t.c_str(); // TODO
+}
+
+int *danglingRawPtrFromTemp() {
+  MyIntPointer p;
+  return p.toOwner().c_str(); // TODO
+}
+
+struct Y {
+  int a[4];
+};
+
+void dangligGslPtrFromTemporary() {
+  MyIntPointer p = Y{}.a; // expected-warning {{temporary whose address is used as value of local variable 'p' will be destroyed at the end of the full-expression}}
+  (void)p;
+}
+
+struct DanglingGslPtrField {
+  MyIntPointer p; // expected-note 2{{pointer member declared here}}
+  MyLongPointerFromConversion p2; // expected-note {{pointer member declared here}}
+  DanglingGslPtrField(int i) : p(&i) {} // expected-warning {{initializing pointer member 'p' with the stack address of parameter 'i'}}
+  DanglingGslPtrField() : p2(MyLongOwnerWithConversion{}) {} // expected-warning {{initializing pointer member 'p2' to point to a temporary object whose lifetime is shorter than the lifetime of the constructed object}}
+  DanglingGslPtrField(double) : p(MyIntOwner{}) {} // expected-warning {{initializing pointer member 'p' to point to a temporary object whose lifetime is shorter than the lifetime of the constructed object}}
+};
+
+MyIntPointer danglingGslPtrFromLocal() {
+  int j;
+  return &j; // expected-warning {{address of stack memory associated with local variable 'j' returned}}
+}
+
+MyIntPointer daglingGslPtrFromLocalOwner() {
+  MyIntOwner localOwner;
+  return localOwner; // expected-warning {{address of stack memory associated with local variable 'localOwner' returned}}
+}
+
+MyLongPointerFromConversion daglingGslPtrFromLocalOwnerConv() {
+  MyLongOwnerWithConversion localOwner;
+  return localOwner; // expected-warning {{address of stack memory associated with local variable 'localOwner' returned}}
+}
+
+MyIntPointer danglingGslPtrFromTemporary() {
+  return MyIntOwner{}; // expected-warning {{returning address of local temporary object}}
+}
+
+MyLongPointerFromConversion danglingGslPtrFromTemporaryConv() {
+  return MyLongOwnerWithConversion{}; // expected-warning {{returning address of local temporary object}}
+}
+
+MyIntPointer global;
+MyLongPointerFromConversion global2;
+
+void initLocalGslPtrWithTempOwner() {
+  MyIntPointer p = MyIntOwner{}; // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}}
+  p = MyIntOwner{}; // TODO ?
+  global = MyIntOwner{}; // TODO ?
+  MyLongPointerFromConversion p2 = MyLongOwnerWithConversion{}; // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}}
+  p2 = MyLongOwnerWithConversion{}; // TODO ?
+  global2 = MyLongOwnerWithConversion{}; // TODO ?
+}
+
+struct IntVector {

[PATCH] D65092: [clang] Add isDirectlyDerivedFrom AST Matcher.

2019-07-22 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:2637
   internal::Matcher, Base) {
-  return Finder->classIsDerivedFrom(&Node, Base, Builder);
+  return Finder->classIsDerivedFrom(&Node, Base, Builder, false);
 }

/*Directly=*/false
(and similarly below for true)



Comment at: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp:342
+  EXPECT_TRUE(notMatches("class Y;", IsDirectlyDerivedFromX));
+  EXPECT_TRUE(notMatches("", IsDirectlyDerivedFromX));
+

I think these tests are ~enough, given the implementation.
Specifically, I think duplicating all the negative tests is not covering more 
ground.
If you disagree, feel free to argue back :)



Repository:
  rC Clang

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

https://reviews.llvm.org/D65092



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


Re: r366474 - [OPENMP]Provide correct data sharing attributes for loop control

2019-07-22 Thread Hans Wennborg via cfe-commits
Merged to Clang 9 in r366705.

On Thu, Jul 18, 2019 at 10:48 AM Alexey Bataev via cfe-commits
 wrote:
>
> Author: abataev
> Date: Thu Jul 18 10:49:13 2019
> New Revision: 366474
>
> URL: http://llvm.org/viewvc/llvm-project?rev=366474&view=rev
> Log:
> [OPENMP]Provide correct data sharing attributes for loop control
> variables.
>
> Loop control variables are private in loop-based constructs and we shall
> take this into account when generate the code for inner constructs.
> Currently, those variables are reported as shared in many cases. Moved
> the analysis of the data-sharing attributes of the loop control variable
> to an early semantic stage to correctly handle their attributes.
>
> Modified:
> cfe/trunk/lib/Sema/SemaOpenMP.cpp
> cfe/trunk/test/OpenMP/distribute_parallel_for_firstprivate_messages.cpp
> 
> cfe/trunk/test/OpenMP/distribute_parallel_for_simd_firstprivate_messages.cpp
> cfe/trunk/test/OpenMP/distribute_simd_firstprivate_messages.cpp
> cfe/trunk/test/OpenMP/distribute_simd_misc_messages.c
> cfe/trunk/test/OpenMP/for_misc_messages.c
> cfe/trunk/test/OpenMP/for_simd_misc_messages.c
> cfe/trunk/test/OpenMP/parallel_for_firstprivate_messages.cpp
> cfe/trunk/test/OpenMP/parallel_for_misc_messages.c
> cfe/trunk/test/OpenMP/parallel_for_simd_firstprivate_messages.cpp
> cfe/trunk/test/OpenMP/simd_misc_messages.c
> cfe/trunk/test/OpenMP/target_parallel_for_firstprivate_messages.cpp
> cfe/trunk/test/OpenMP/target_parallel_for_misc_messages.c
> cfe/trunk/test/OpenMP/target_parallel_for_simd_firstprivate_messages.cpp
> cfe/trunk/test/OpenMP/target_parallel_for_simd_misc_messages.c
> cfe/trunk/test/OpenMP/target_simd_firstprivate_messages.cpp
> 
> cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_misc_messages.c
> cfe/trunk/test/OpenMP/target_teams_distribute_simd_misc_messages.c
> cfe/trunk/test/OpenMP/task_codegen.c
> cfe/trunk/test/OpenMP/taskloop_firstprivate_messages.cpp
> cfe/trunk/test/OpenMP/taskloop_simd_firstprivate_messages.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=366474&r1=366473&r2=366474&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Jul 18 10:49:13 2019
> @@ -139,6 +139,7 @@ private:
>  /// clause, false otherwise.
>  llvm::Optional> 
> OrderedRegion;
>  unsigned AssociatedLoops = 1;
> +bool HasMutipleLoops = false;
>  const Decl *PossiblyLoopCounter = nullptr;
>  bool NowaitRegion = false;
>  bool CancelRegion = false;
> @@ -678,12 +679,19 @@ public:
>/// Set collapse value for the region.
>void setAssociatedLoops(unsigned Val) {
>  getTopOfStack().AssociatedLoops = Val;
> +if (Val > 1)
> +  getTopOfStack().HasMutipleLoops = true;
>}
>/// Return collapse value for region.
>unsigned getAssociatedLoops() const {
>  const SharingMapTy *Top = getTopOfStackOrNull();
>  return Top ? Top->AssociatedLoops : 0;
>}
> +  /// Returns true if the construct is associated with multiple loops.
> +  bool hasMutipleLoops() const {
> +const SharingMapTy *Top = getTopOfStackOrNull();
> +return Top ? Top->HasMutipleLoops : false;
> +  }
>
>/// Marks current target region as one with closely nested teams
>/// region.
> @@ -5604,13 +5612,14 @@ void Sema::ActOnOpenMPLoopInitialization
>  if (!ISC.checkAndSetInit(Init, /*EmitDiags=*/false)) {
>if (ValueDecl *D = ISC.getLoopDecl()) {
>  auto *VD = dyn_cast(D);
> +DeclRefExpr *PrivateRef = nullptr;
>  if (!VD) {
>if (VarDecl *Private = isOpenMPCapturedDecl(D)) {
>  VD = Private;
>} else {
> -DeclRefExpr *Ref = buildCapture(*this, D, 
> ISC.getLoopDeclRefExpr(),
> -/*WithInit=*/false);
> -VD = cast(Ref->getDecl());
> +PrivateRef = buildCapture(*this, D, ISC.getLoopDeclRefExpr(),
> +  /*WithInit=*/false);
> +VD = cast(PrivateRef->getDecl());
>}
>  }
>  DSAStack->addLoopControlVariable(D, VD);
> @@ -5623,6 +5632,49 @@ void Sema::ActOnOpenMPLoopInitialization
>   
> Var->getType().getNonLValueExprType(Context),
>   ForLoc, /*RefersToCapture=*/true));
>  }
> +OpenMPDirectiveKind DKind = DSAStack->getCurrentDirective();
> +// OpenMP [2.14.1.1, Data-sharing Attribute Rules for Variables
> +// Referenced in a Construct, C/C++]. The loop iteration variable in 
> the
> +// associated for-loop of a simd construct with just one associated
> +// for-loop may be listed in a linear clause with a 
> constant-linear-step
> +// 

Re: r366483 - [OPENMP]Fix sharing of threadprivate variables with TLS support.

2019-07-22 Thread Hans Wennborg via cfe-commits
Merged to Clang 9 in r366706.

On Thu, Jul 18, 2019 at 12:39 PM Alexey Bataev via cfe-commits
 wrote:
>
> Author: abataev
> Date: Thu Jul 18 12:40:24 2019
> New Revision: 366483
>
> URL: http://llvm.org/viewvc/llvm-project?rev=366483&view=rev
> Log:
> [OPENMP]Fix sharing of threadprivate variables with TLS support.
>
> If the threadprivate variable is used in the copyin clause on inner
> parallel directive with TLS support, we capture this variable in all
> outer OpenMP scopes. It leads to the fact that in all scopes we're
> working with the original variable, not the threadprivate copies.
>
> Modified:
> cfe/trunk/lib/Sema/SemaOpenMP.cpp
> cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=366483&r1=366482&r2=366483&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Jul 18 12:40:24 2019
> @@ -1882,6 +1882,13 @@ bool Sema::isOpenMPPrivateDecl(const Val
>  !isOpenMPSimdDirective(DSAStack->getCurrentDirective()))
>return true;
>}
> +  if (const auto *VD = dyn_cast(D)) {
> +if (DSAStack->isThreadPrivate(const_cast(VD)) &&
> +DSAStack->isForceVarCapturing() &&
> +!DSAStack->hasExplicitDSA(
> +D, [](OpenMPClauseKind K) { return K == OMPC_copyin; }, Level))
> +  return true;
> +  }
>return DSAStack->hasExplicitDSA(
>   D, [](OpenMPClauseKind K) { return K == OMPC_private; }, Level) 
> ||
>   (DSAStack->isClauseParsingMode() &&
>
> Modified: cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp?rev=366483&r1=366482&r2=366483&view=diff
> ==
> --- cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp (original)
> +++ cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp Thu Jul 18 12:40:24 2019
> @@ -19,6 +19,7 @@
>  // RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -DLAMBDA -triple 
> x86_64-linux -emit-llvm %s -o - | FileCheck -check-prefix=TLS-LAMBDA %s
>  // RUN: %clang_cc1 -verify -fopenmp -x c++ -fblocks -DBLOCKS -triple 
> x86_64-linux -emit-llvm %s -o - | FileCheck -check-prefix=TLS-BLOCKS %s
>  // RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -DARRAY -triple 
> x86_64-linux-gnu -emit-llvm %s -o - | FileCheck -check-prefix=TLS-ARRAY %s
> +// RUN: %clang_cc1 -verify -fopenmp -x c++ -DNESTED -triple x86_64-linux 
> -emit-llvm %s -o - | FileCheck %s -check-prefix=NESTED
>
>  // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple x86_64-linux 
> -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
>  // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-linux 
> -emit-pch -o %t %s
> @@ -28,7 +29,7 @@
>  // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -std=c++11 -DARRAY -triple 
> x86_64-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
>  // SIMD-ONLY1-NOT: {{__kmpc|__tgt}}
>  // expected-no-diagnostics
> -#ifndef ARRAY
> +#if !defined(ARRAY) && !defined(NESTED)
>  #ifndef HEADER
>  #define HEADER
>
> @@ -493,7 +494,7 @@ int main() {
>  // TLS-CHECK: ret void
>
>  #endif
> -#else
> +#elif defined(ARRAY)
>  // ARRAY-LABEL: array_func
>  // TLS-ARRAY-LABEL: array_func
>
> @@ -522,6 +523,24 @@ void array_func() {
>  #pragma omp parallel copyin(a, s)
>;
>  }
> -#endif
> -
> +#elif defined(NESTED)
> +int t;
> +#pragma omp threadprivate(t)
> +// NESTED: foo
> +void foo() {
> +  // NESTED: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) 
> @__kmpc_fork_call(%struct.ident_t* @{{.+}}, i32 0, void (i32*, i32*, ...)* 
> bitcast (void (i32*, i32*)* [[OUTLINED:@.+]] to void (i32*, i32*, ...)*))
> +#pragma omp parallel
> +#pragma omp parallel copyin(t)
> +  ++t;
> +}
> +// NESTED: define {{.*}}void [[OUTLINED]](
> +// NESTED: [[T:%.+]] = call i32* [[THRP_T:@.+]]()
> +// NESTED:  call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) 
> @__kmpc_fork_call(%struct.ident_t* @{{.+}}, i32 1, void (i32*, i32*, ...)* 
> bitcast (void (i32*, i32*, i32*)* [[OUTLINED1:@.+]] to void (i32*, i32*, 
> ...)*), i32* [[T]])
> +
> +// NESTED: define {{.*}}void [[OUTLINED1]](
> +// NESTED: [[T_MASTER:%.+]] = load i32*, i32** %
> +// NESTED: [[T:%.+]] = call i32* [[THRP_T]]()
> +// NESTED: [[T_MASTER_VAL:%.+]] = load i32, i32* [[T_MASTER]],
> +// NESTED: store i32 [[T_MASTER_VAL]], i32* [[T]],
> +#endif // NESTED
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D65104: [clang-tidy] Add FixItHint for performance-noexcept-move-constructor

2019-07-22 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis created this revision.
zinovy.nis added reviewers: alexfh, rsmith, aaron.ballman.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D65104

Files:
  clang-tidy/performance/NoexceptMoveConstructorCheck.cpp
  test/clang-tidy/performance-noexcept-move-constructor-fix.cpp

Index: test/clang-tidy/performance-noexcept-move-constructor-fix.cpp
===
--- test/clang-tidy/performance-noexcept-move-constructor-fix.cpp
+++ test/clang-tidy/performance-noexcept-move-constructor-fix.cpp
@@ -0,0 +1,67 @@
+// RUN: %check_clang_tidy %s performance-noexcept-move-constructor %t
+
+struct C_1 {
+ ~C_1() {}
+ C_1(int a) {}
+ C_1(C_1&& a) :C_1(5) {}
+ // CHECK-FIXES:{{.*}}noexcept{{.*}}
+ C_1& operator=(C_1&&) { return *this; }
+ // CHECK-FIXES:{{.*}}noexcept{{.*}}
+};
+
+struct C_2 {
+ ~C_2() {}
+ C_2(C_2&& a);
+ // CHECK-FIXES:{{.*}}noexcept{{.*}}
+ C_2& operator=(C_2&&);
+ // CHECK-FIXES:{{.*}}noexcept{{.*}}
+};
+
+C_2::C_2(C_2&& a) {}
+// CHECK-FIXES:{{.*}}noexcept{{.*}}
+C_2& C_2::operator=(C_2&&) { return *this; }
+// CHECK-FIXES:{{.*}}noexcept{{.*}}
+
+struct C_4 {
+ ~C_4() {}
+ C_4(C_4&& a);
+ // CHECK-FIXES:{{.*}}noexcept{{.*}}
+ C_4& operator=(C_4&& a);
+ // CHECK-FIXES:{{.*}}noexcept{{.*}}
+};
+
+C_4::C_4(C_4&& a) = default;
+// CHECK-FIXES:{{.*}}noexcept{{.*}}
+C_4& C_4::operator=(C_4&& a) = default;
+// CHECK-FIXES:{{.*}}noexcept{{.*}}
+
+template 
+struct C_5 {
+ C_5(C_5&&) {}
+ // CHECK-FIXES:{{.*}}noexcept{{.*}}
+ ~C_5() {}
+ C_5& operator=(C_5&& a) = default;
+ // CHECK-FIXES:{{.*}}noexcept{{.*}}
+};
+
+template 
+struct C_6 {
+ C_6(C_6&&) {}
+ // CHECK-FIXES:{{.*}}noexcept{{.*}}
+ ~C_6() {}
+ auto operator=(C_6&& a)->C_6 = default;
+ // CHECK-FIXES:{{.*}}noexcept{{.*}}
+};
+
+template 
+struct C_7 {
+ C_7(C_7&&) {}
+ // CHECK-FIXES:{{.*}}noexcept{{.*}}
+ ~C_7() {}
+ auto operator=(C_7&& a)->C_7;
+ // CHECK-FIXES:{{.*}}noexcept{{.*}}
+};
+
+template 
+auto C_7::operator=(C_7&& a) -> C_7 {}
+// CHECK-FIXES:{{.*}}noexcept{{.*}}
Index: clang-tidy/performance/NoexceptMoveConstructorCheck.cpp
===
--- clang-tidy/performance/NoexceptMoveConstructorCheck.cpp
+++ clang-tidy/performance/NoexceptMoveConstructorCheck.cpp
@@ -9,6 +9,7 @@
 #include "NoexceptMoveConstructorCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/FixIt.h"
 
 using namespace clang::ast_matchers;
 
@@ -33,7 +34,7 @@
 const MatchFinder::MatchResult &Result) {
   if (const auto *Decl = Result.Nodes.getNodeAs("decl")) {
 StringRef MethodType = "assignment operator";
-if (const auto *Ctor = dyn_cast(Decl)) {
+if (const CXXConstructorDecl *Ctor = dyn_cast(Decl)) {
   if (!Ctor->isMoveConstructor())
 return;
   MethodType = "constructor";
@@ -47,9 +48,20 @@
   return;
 
 if (!isNoexceptExceptionSpec(ProtoType->getExceptionSpecType())) {
-  diag(Decl->getLocation(), "move %0s should be marked noexcept")
+  auto Diag =
+  diag(Decl->getLocation(), "move %0s should be marked noexcept")
   << MethodType;
-  // FIXME: Add a fixit.
+  // Add FixIt hints.
+  SourceManager &SM = *Result.SourceManager;
+  assert(Decl->getNumParams() > 0);
+  SourceLocation NoexceptLoc = Decl->getParamDecl(Decl->getNumParams() - 1)
+   ->getSourceRange()
+   .getEnd();
+  if (NoexceptLoc.isValid())
+NoexceptLoc = Lexer::findLocationAfterToken(
+NoexceptLoc, tok::r_paren, SM, Result.Context->getLangOpts(), true);
+  if (NoexceptLoc.isValid())
+Diag << FixItHint::CreateInsertion(NoexceptLoc, " noexcept ");
   return;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D65104: [clang-tidy] Add FixItHint for performance-noexcept-move-constructor

2019-07-22 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis updated this revision to Diff 211147.

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

https://reviews.llvm.org/D65104

Files:
  clang-tidy/performance/NoexceptMoveConstructorCheck.cpp
  test/clang-tidy/performance-noexcept-move-constructor-fix.cpp

Index: test/clang-tidy/performance-noexcept-move-constructor-fix.cpp
===
--- test/clang-tidy/performance-noexcept-move-constructor-fix.cpp
+++ test/clang-tidy/performance-noexcept-move-constructor-fix.cpp
@@ -0,0 +1,67 @@
+// RUN: %check_clang_tidy %s performance-noexcept-move-constructor %t
+
+struct C_1 {
+ ~C_1() {}
+ C_1(int a) {}
+ C_1(C_1&& a) :C_1(5) {}
+ // CHECK-FIXES:{{.*}}noexcept{{.*}}
+ C_1& operator=(C_1&&) { return *this; }
+ // CHECK-FIXES:{{.*}}noexcept{{.*}}
+};
+
+struct C_2 {
+ ~C_2() {}
+ C_2(C_2&& a);
+ // CHECK-FIXES:{{.*}}noexcept{{.*}}
+ C_2& operator=(C_2&&);
+ // CHECK-FIXES:{{.*}}noexcept{{.*}}
+};
+
+C_2::C_2(C_2&& a) {}
+// CHECK-FIXES:{{.*}}noexcept{{.*}}
+C_2& C_2::operator=(C_2&&) { return *this; }
+// CHECK-FIXES:{{.*}}noexcept{{.*}}
+
+struct C_4 {
+ ~C_4() {}
+ C_4(C_4&& a);
+ // CHECK-FIXES:{{.*}}noexcept{{.*}}
+ C_4& operator=(C_4&& a);
+ // CHECK-FIXES:{{.*}}noexcept{{.*}}
+};
+
+C_4::C_4(C_4&& a) = default;
+// CHECK-FIXES:{{.*}}noexcept{{.*}}
+C_4& C_4::operator=(C_4&& a) = default;
+// CHECK-FIXES:{{.*}}noexcept{{.*}}
+
+template 
+struct C_5 {
+ C_5(C_5&&) {}
+ // CHECK-FIXES:{{.*}}noexcept{{.*}}
+ ~C_5() {}
+ C_5& operator=(C_5&& a) = default;
+ // CHECK-FIXES:{{.*}}noexcept{{.*}}
+};
+
+template 
+struct C_6 {
+ C_6(C_6&&) {}
+ // CHECK-FIXES:{{.*}}noexcept{{.*}}
+ ~C_6() {}
+ auto operator=(C_6&& a)->C_6 = default;
+ // CHECK-FIXES:{{.*}}noexcept{{.*}}
+};
+
+template 
+struct C_7 {
+ C_7(C_7&&) {}
+ // CHECK-FIXES:{{.*}}noexcept{{.*}}
+ ~C_7() {}
+ auto operator=(C_7&& a)->C_7;
+ // CHECK-FIXES:{{.*}}noexcept{{.*}}
+};
+
+template 
+auto C_7::operator=(C_7&& a) -> C_7 {}
+// CHECK-FIXES:{{.*}}noexcept{{.*}}
Index: clang-tidy/performance/NoexceptMoveConstructorCheck.cpp
===
--- clang-tidy/performance/NoexceptMoveConstructorCheck.cpp
+++ clang-tidy/performance/NoexceptMoveConstructorCheck.cpp
@@ -9,6 +9,7 @@
 #include "NoexceptMoveConstructorCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/FixIt.h"
 
 using namespace clang::ast_matchers;
 
@@ -47,9 +48,20 @@
   return;
 
 if (!isNoexceptExceptionSpec(ProtoType->getExceptionSpecType())) {
-  diag(Decl->getLocation(), "move %0s should be marked noexcept")
+  auto Diag =
+  diag(Decl->getLocation(), "move %0s should be marked noexcept")
   << MethodType;
-  // FIXME: Add a fixit.
+  // Add FixIt hints.
+  SourceManager &SM = *Result.SourceManager;
+  assert(Decl->getNumParams() > 0);
+  SourceLocation NoexceptLoc = Decl->getParamDecl(Decl->getNumParams() - 1)
+   ->getSourceRange()
+   .getEnd();
+  if (NoexceptLoc.isValid())
+NoexceptLoc = Lexer::findLocationAfterToken(
+NoexceptLoc, tok::r_paren, SM, Result.Context->getLangOpts(), true);
+  if (NoexceptLoc.isValid())
+Diag << FixItHint::CreateInsertion(NoexceptLoc, " noexcept ");
   return;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r366699 - [X86] Remove const from some intrinsics that shouldn't have them

2019-07-22 Thread Hans Wennborg via cfe-commits
Merged to clang 9 in r366711.

On Mon, Jul 22, 2019 at 9:13 AM Paul Robinson via cfe-commits
 wrote:
>
> Author: probinson
> Date: Mon Jul 22 09:14:09 2019
> New Revision: 366699
>
> URL: http://llvm.org/viewvc/llvm-project?rev=366699&view=rev
> Log:
> [X86] Remove const from some intrinsics that shouldn't have them
>
> Modified:
> cfe/trunk/lib/Headers/emmintrin.h
>
> Modified: cfe/trunk/lib/Headers/emmintrin.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/emmintrin.h?rev=366699&r1=366698&r2=366699&view=diff
> ==
> --- cfe/trunk/lib/Headers/emmintrin.h (original)
> +++ cfe/trunk/lib/Headers/emmintrin.h Mon Jul 22 09:14:09 2019
> @@ -4029,7 +4029,7 @@ _mm_storeu_si128(__m128i_u *__p, __m128i
>  /// \param __b
>  ///A 128-bit integer vector containing the value to be stored.
>  static __inline__ void __DEFAULT_FN_ATTRS
> -_mm_storeu_si64(void const *__p, __m128i __b)
> +_mm_storeu_si64(void *__p, __m128i __b)
>  {
>struct __storeu_si64 {
>  long long __v;
> @@ -4050,7 +4050,7 @@ _mm_storeu_si64(void const *__p, __m128i
>  /// \param __b
>  ///A 128-bit integer vector containing the value to be stored.
>  static __inline__ void __DEFAULT_FN_ATTRS
> -_mm_storeu_si32(void const *__p, __m128i __b)
> +_mm_storeu_si32(void *__p, __m128i __b)
>  {
>struct __storeu_si32 {
>  int __v;
> @@ -4071,7 +4071,7 @@ _mm_storeu_si32(void const *__p, __m128i
>  /// \param __b
>  ///A 128-bit integer vector containing the value to be stored.
>  static __inline__ void __DEFAULT_FN_ATTRS
> -_mm_storeu_si16(void const *__p, __m128i __b)
> +_mm_storeu_si16(void *__p, __m128i __b)
>  {
>struct __storeu_si16 {
>  short __v;
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D65092: [clang] Add isDirectlyDerivedFrom AST Matcher.

2019-07-22 Thread Anton Bikineev via Phabricator via cfe-commits
AntonBikineev updated this revision to Diff 211148.
AntonBikineev added a comment.

Manuel, I left some cases which deviated from the isDerivedFrom matcher.


Repository:
  rC Clang

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

https://reviews.llvm.org/D65092

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -331,6 +331,16 @@
   EXPECT_TRUE(notMatches("class Y;", IsDerivedFromX));
   EXPECT_TRUE(notMatches("", IsDerivedFromX));
 
+  DeclarationMatcher IsDirectlyDerivedFromX =
+  cxxRecordDecl(isDirectlyDerivedFrom("X"));
+
+  EXPECT_TRUE(
+  matches("class X {}; class Y : public X {};", IsDirectlyDerivedFromX));
+  EXPECT_TRUE(notMatches("class X {};", IsDirectlyDerivedFromX));
+  EXPECT_TRUE(notMatches("class X;", IsDirectlyDerivedFromX));
+  EXPECT_TRUE(notMatches("class Y;", IsDirectlyDerivedFromX));
+  EXPECT_TRUE(notMatches("", IsDirectlyDerivedFromX));
+
   DeclarationMatcher IsAX = cxxRecordDecl(isSameOrDerivedFrom("X"));
 
   EXPECT_TRUE(matches("class X {}; class Y : public X {};", IsAX));
@@ -341,13 +351,22 @@
 
   DeclarationMatcher ZIsDerivedFromX =
 cxxRecordDecl(hasName("Z"), isDerivedFrom("X"));
+  DeclarationMatcher ZIsDirectlyDerivedFromX =
+  cxxRecordDecl(hasName("Z"), isDirectlyDerivedFrom("X"));
   EXPECT_TRUE(
 matches("class X {}; class Y : public X {}; class Z : public Y {};",
 ZIsDerivedFromX));
+  EXPECT_TRUE(
+  notMatches("class X {}; class Y : public X {}; class Z : public Y {};",
+ ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(
 matches("class X {};"
   "template class Y : public X {};"
   "class Z : public Y {};", ZIsDerivedFromX));
+  EXPECT_TRUE(notMatches("class X {};"
+ "template class Y : public X {};"
+ "class Z : public Y {};",
+ ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(matches("class X {}; template class Z : public X {};",
   ZIsDerivedFromX));
   EXPECT_TRUE(
@@ -411,6 +430,9 @@
 matches("class X {}; class Y : public X {}; "
   "typedef Y V; typedef V W; class Z : public W {};",
 ZIsDerivedFromX));
+  EXPECT_TRUE(notMatches("class X {}; class Y : public X {}; "
+ "typedef Y V; typedef V W; class Z : public W {};",
+ ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(
 matches("template class X {}; "
   "template class A { class Z : public X {}; };",
@@ -467,6 +489,14 @@
   "template<> struct X<0> : public A {};"
   "struct B : public X<42> {};",
 cxxRecordDecl(hasName("B"), isDerivedFrom(recordDecl(hasName("A"));
+  EXPECT_TRUE(notMatches(
+  "struct A {};"
+  "template struct X;"
+  "template struct X : public X {};"
+  "template<> struct X<0> : public A {};"
+  "struct B : public X<42> {};",
+  cxxRecordDecl(hasName("B"),
+isDirectlyDerivedFrom(recordDecl(hasName("A"));
 
   // FIXME: Once we have better matchers for template type matching,
   // get rid of the Variable(...) matching and match the right template
Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp
===
--- clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -430,7 +430,8 @@
 
   bool classIsDerivedFrom(const CXXRecordDecl *Declaration,
   const Matcher &Base,
-  BoundNodesTreeBuilder *Builder) override;
+  BoundNodesTreeBuilder *Builder,
+  bool Directly) override;
 
   // Implements ASTMatchFinder::matchesChildOf.
   bool matchesChildOf(const ast_type_traits::DynTypedNode &Node,
@@ -817,7 +818,8 @@
 // derived from itself.
 bool MatchASTVisitor::classIsDerivedFrom(const CXXRecordDecl *Declaration,
  const Matcher &Base,
- BoundNodesTreeBuilder *Builder) {
+ BoundNodesTreeBuilder *Builder,
+ bool Directly) {
   if (!Declaration->hasDefinition())
 return false;
   for (const auto &It : Declaration->bases()) {
@@ -842,7 +844,7 @@
   *Builder = std::move(Result);
   return true;
 }
-if (classIsDerivedFrom(ClassDecl, Base, Builder))
+if (!Directly && classIsDerivedFrom(ClassDecl, Base, Builder, Directly))
   return true;
   }
   return false;
In

Re: [clang-tools-extra] r366443 - [clangd] Disable DumpRecordLayout by default per https://bugs.llvm.org/show_bug.cgi?id=42670

2019-07-22 Thread Hans Wennborg via cfe-commits
Merged to the 9 branch in r366713.

On Thu, Jul 18, 2019 at 8:00 AM Sam McCall via cfe-commits
 wrote:
>
> Author: sammccall
> Date: Thu Jul 18 08:00:38 2019
> New Revision: 366443
>
> URL: http://llvm.org/viewvc/llvm-project?rev=366443&view=rev
> Log:
> [clangd] Disable DumpRecordLayout by default per 
> https://bugs.llvm.org/show_bug.cgi?id=42670
>
> Modified:
> clang-tools-extra/trunk/clangd/refactor/tweaks/DumpAST.cpp
>
> Modified: clang-tools-extra/trunk/clangd/refactor/tweaks/DumpAST.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/refactor/tweaks/DumpAST.cpp?rev=366443&r1=366442&r2=366443&view=diff
> ==
> --- clang-tools-extra/trunk/clangd/refactor/tweaks/DumpAST.cpp (original)
> +++ clang-tools-extra/trunk/clangd/refactor/tweaks/DumpAST.cpp Thu Jul 18 
> 08:00:38 2019
> @@ -128,6 +128,11 @@ public:
>  TypeWithKeyword::getTagTypeKindName(Record->getTagKind()));
>}
>Intent intent() const override { return Info; }
> +  // FIXME: this is interesting to most users. However:
> +  //  - triggering is too broad (e.g. triggers on comments within a class)
> +  //  - showMessage has inconsistent UX (e.g. newlines are stripped in 
> VSCode)
> +  //  - the output itself is a bit hard to decipher.
> +  bool hidden() const override { return true; }
>
>  private:
>const RecordDecl *Record = nullptr;
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang-tools-extra] r366451 - [Clangd] Changed ExtractVariable to only work on non empty selections

2019-07-22 Thread Hans Wennborg via cfe-commits
Merged to the 9 branch in r366714

On Thu, Jul 18, 2019 at 8:37 AM Shaurya Gupta via cfe-commits
 wrote:
>
> Author: sureyeaah
> Date: Thu Jul 18 08:38:03 2019
> New Revision: 366451
>
> URL: http://llvm.org/viewvc/llvm-project?rev=366451&view=rev
> Log:
> [Clangd] Changed ExtractVariable to only work on non empty selections
>
> Summary:
> - For now, we don't trigger in any case if it's an empty selection
> - Fixed unittests
>
> Reviewers: kadircet, sammccall
>
> Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits
>
> Tags: #clang
>
> Differential Revision: https://reviews.llvm.org/D64912
>
> Modified:
> clang-tools-extra/trunk/clangd/refactor/Tweak.cpp
> clang-tools-extra/trunk/clangd/refactor/Tweak.h
> clang-tools-extra/trunk/clangd/refactor/tweaks/ExtractVariable.cpp
> clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp
>
> Modified: clang-tools-extra/trunk/clangd/refactor/Tweak.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/refactor/Tweak.cpp?rev=366451&r1=366450&r2=366451&view=diff
> ==
> --- clang-tools-extra/trunk/clangd/refactor/Tweak.cpp (original)
> +++ clang-tools-extra/trunk/clangd/refactor/Tweak.cpp Thu Jul 18 08:38:03 2019
> @@ -40,7 +40,8 @@ void validateRegistry() {
>
>  Tweak::Selection::Selection(ParsedAST &AST, unsigned RangeBegin,
>  unsigned RangeEnd)
> -: AST(AST), ASTSelection(AST.getASTContext(), RangeBegin, RangeEnd) {
> +: AST(AST), SelectionBegin(RangeBegin), SelectionEnd(RangeEnd),
> +  ASTSelection(AST.getASTContext(), RangeBegin, RangeEnd) {
>auto &SM = AST.getSourceManager();
>Code = SM.getBufferData(SM.getMainFileID());
>Cursor = SM.getComposedLoc(SM.getMainFileID(), RangeBegin);
>
> Modified: clang-tools-extra/trunk/clangd/refactor/Tweak.h
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/refactor/Tweak.h?rev=366451&r1=366450&r2=366451&view=diff
> ==
> --- clang-tools-extra/trunk/clangd/refactor/Tweak.h (original)
> +++ clang-tools-extra/trunk/clangd/refactor/Tweak.h Thu Jul 18 08:38:03 2019
> @@ -46,7 +46,12 @@ public:
>  /// Parsed AST of the active file.
>  ParsedAST &AST;
>  /// A location of the cursor in the editor.
> +// FIXME: Cursor is redundant and should be removed
>  SourceLocation Cursor;
> +/// The begin offset of the selection
> +unsigned SelectionBegin;
> +/// The end offset of the selection
> +unsigned SelectionEnd;
>  /// The AST nodes that were selected.
>  SelectionTree ASTSelection;
>  // FIXME: provide a way to get sources and ASTs for other files.
>
> Modified: clang-tools-extra/trunk/clangd/refactor/tweaks/ExtractVariable.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/refactor/tweaks/ExtractVariable.cpp?rev=366451&r1=366450&r2=366451&view=diff
> ==
> --- clang-tools-extra/trunk/clangd/refactor/tweaks/ExtractVariable.cpp 
> (original)
> +++ clang-tools-extra/trunk/clangd/refactor/tweaks/ExtractVariable.cpp Thu 
> Jul 18 08:38:03 2019
> @@ -219,7 +219,8 @@ bool ExtractVariable::prepare(const Sele
>const ASTContext &Ctx = Inputs.AST.getASTContext();
>const SourceManager &SM = Inputs.AST.getSourceManager();
>const SelectionTree::Node *N = Inputs.ASTSelection.commonAncestor();
> -  if (!N)
> +  // we don't trigger on empty selections for now
> +  if (!N || Inputs.SelectionBegin == Inputs.SelectionEnd)
>  return false;
>Target = llvm::make_unique(N, SM, Ctx);
>return Target->isExtractable();
>
> Modified: clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp?rev=366451&r1=366450&r2=366451&view=diff
> ==
> --- clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp (original)
> +++ clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp Thu Jul 18 
> 08:38:03 2019
> @@ -296,35 +296,36 @@ TEST(TweakTest, ExtractVariable) {
>checkAvailable(ID, R"cpp(
>  int xyz() {
>// return statement
> -  return ^1;
> +  return [[1]];
>  }
>  void f() {
> -  int a = 5 + [[4 ^* ^xyz^()]];
> +  int a = [[5 +]] [[4 * xyz]]();
>// multivariable initialization
>if(1)
> -int x = ^1, y = ^a + 1, a = ^1, z = a + 1;
> +int x = [[1]], y = [[a]] + 1, a = [[1]], z = a + 1;
>// if without else
> -  if(^1) {}
> +  if([[1]])
> +a = [[1]];
>// if with else
> -  if(a < ^3)
> -if(a == ^4)
> -  a = ^5;
> +  if(a < [[3]])
> +if(a == [[4]])
> +  a = [[5]];
>  else
> -  a = ^6;
> 

[PATCH] D64256: Teach some warnings to respect gsl::Pointer and gsl::Owner attributes

2019-07-22 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 211150.
xazax.hun added a comment.

- Fix a false positive from previous change.


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

https://reviews.llvm.org/D64256

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaInit.cpp
  clang/test/Sema/warn-lifetime-analysis-nocfg.cpp

Index: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
===
--- /dev/null
+++ clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
@@ -0,0 +1,130 @@
+// RUN: %clang_cc1 -fsyntax-only -Wdangling -Wdangling-field -Wreturn-stack-address -verify %s
+struct [[gsl::Owner(int)]] MyIntOwner {
+  MyIntOwner();
+  int &operator*();
+  int *c_str() const;
+};
+
+struct [[gsl::Pointer(int)]] MyIntPointer {
+  MyIntPointer(int *p = nullptr);
+  // Conversion operator and constructor conversion will result in two
+  // different ASTs. The former is tested with another owner and 
+  // pointer type.
+  MyIntPointer(const MyIntOwner &);
+  int &operator*();
+  MyIntOwner toOwner();
+};
+
+struct [[gsl::Pointer(long)]] MyLongPointerFromConversion {
+  MyLongPointerFromConversion(long *p = nullptr);
+  long &operator*();
+};
+
+struct [[gsl::Owner(long)]] MyLongOwnerWithConversion {
+  MyLongOwnerWithConversion();
+  operator MyLongPointerFromConversion();
+  long &operator*();
+  MyIntPointer releaseAsMyPointer();
+  long *releaseAsRawPointer();
+};
+
+void danglingHeapObject() {
+  new MyLongPointerFromConversion(MyLongOwnerWithConversion{}); // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}}
+  new MyIntPointer(MyIntOwner{}); // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}}
+}
+
+void intentionalFalseNegative() {
+  int i;
+  MyIntPointer p{&i};
+  // In this case we do not have enough information in a statement local
+  // analysis to detect the problem.
+  new MyIntPointer(p);
+  new MyIntPointer(MyIntPointer{p});
+}
+
+MyIntPointer ownershipTransferToMyPointer() {
+  MyLongOwnerWithConversion t;
+  return t.releaseAsMyPointer(); // ok
+}
+
+long *ownershipTransferToRawPointer() {
+  MyLongOwnerWithConversion t;
+  return t.releaseAsRawPointer(); // ok
+}
+
+int *danglingRawPtrFromLocal() {
+  MyIntOwner t;
+  return t.c_str(); // TODO
+}
+
+int *danglingRawPtrFromTemp() {
+  MyIntPointer p;
+  return p.toOwner().c_str(); // TODO
+}
+
+struct Y {
+  int a[4];
+};
+
+void dangligGslPtrFromTemporary() {
+  MyIntPointer p = Y{}.a; // expected-warning {{temporary whose address is used as value of local variable 'p' will be destroyed at the end of the full-expression}}
+  (void)p;
+}
+
+struct DanglingGslPtrField {
+  MyIntPointer p; // expected-note 2{{pointer member declared here}}
+  MyLongPointerFromConversion p2; // expected-note {{pointer member declared here}}
+  DanglingGslPtrField(int i) : p(&i) {} // expected-warning {{initializing pointer member 'p' with the stack address of parameter 'i'}}
+  DanglingGslPtrField() : p2(MyLongOwnerWithConversion{}) {} // expected-warning {{initializing pointer member 'p2' to point to a temporary object whose lifetime is shorter than the lifetime of the constructed object}}
+  DanglingGslPtrField(double) : p(MyIntOwner{}) {} // expected-warning {{initializing pointer member 'p' to point to a temporary object whose lifetime is shorter than the lifetime of the constructed object}}
+};
+
+MyIntPointer danglingGslPtrFromLocal() {
+  int j;
+  return &j; // expected-warning {{address of stack memory associated with local variable 'j' returned}}
+}
+
+MyIntPointer returningLocalPointer() {
+  MyIntPointer localPointer;
+  return localPointer; // ok
+}
+
+MyIntPointer daglingGslPtrFromLocalOwner() {
+  MyIntOwner localOwner;
+  return localOwner; // expected-warning {{address of stack memory associated with local variable 'localOwner' returned}}
+}
+
+MyLongPointerFromConversion daglingGslPtrFromLocalOwnerConv() {
+  MyLongOwnerWithConversion localOwner;
+  return localOwner; // expected-warning {{address of stack memory associated with local variable 'localOwner' returned}}
+}
+
+MyIntPointer danglingGslPtrFromTemporary() {
+  return MyIntOwner{}; // expected-warning {{returning address of local temporary object}}
+}
+
+MyLongPointerFromConversion danglingGslPtrFromTemporaryConv() {
+  return MyLongOwnerWithConversion{}; // expected-warning {{returning address of local temporary object}}
+}
+
+MyIntPointer global;
+MyLongPointerFromConversion global2;
+
+void initLocalGslPtrWithTempOwner() {
+  MyIntPointer p = MyIntOwner{}; // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}}
+  p = MyIntOwner{}; // TODO ?
+  global = MyIntOwner{}; // TODO ?
+  MyLongPointerFromConversion p2 = MyLongOwnerWithConversion{}; // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}}
+  p2 = MyLo

Re: r366448 - [ASTUnit] Fix a regression in cached completions

2019-07-22 Thread Hans Wennborg via cfe-commits
Merged together with r366457 to Clang 9 in r366717.

On Thu, Jul 18, 2019 at 8:21 AM Ilya Biryukov via cfe-commits
 wrote:
>
> Author: ibiryukov
> Date: Thu Jul 18 08:21:34 2019
> New Revision: 366448
>
> URL: http://llvm.org/viewvc/llvm-project?rev=366448&view=rev
> Log:
> [ASTUnit] Fix a regression in cached completions
>
> Summary:
> After r345152 cached completions started adding namespaces after
> nested name specifiers, e.g. in `some_name::^`
>
> The CCC_Symbol indicates the completed item cannot be a namespace (it is
> described as being "a type, a function or a variable" in the comments).
>
> Therefore, 'nested specifier' completions should only be added from cache
> when the context is CCC_SymbolOrNewName (which roughly seems to indicate
> that a nested name specifier is allowed).
>
> Fixes https://bugs.llvm.org/show_bug.cgi?id=42646
>
> Reviewers: kadircet, sammccall
>
> Reviewed By: kadircet, sammccall
>
> Subscribers: arphaman, nik, sammccall, cfe-commits
>
> Tags: #clang
>
> Differential Revision: https://reviews.llvm.org/D64918
>
> Added:
> cfe/trunk/test/Index/complete-qualified-cached.cpp
> Modified:
> cfe/trunk/lib/Frontend/ASTUnit.cpp
>
> Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=366448&r1=366447&r2=366448&view=diff
> ==
> --- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
> +++ cfe/trunk/lib/Frontend/ASTUnit.cpp Thu Jul 18 08:21:34 2019
> @@ -435,7 +435,6 @@ void ASTUnit::CacheCodeCompletionResults
>| (1LL << CodeCompletionContext::CCC_UnionTag)
>| (1LL << CodeCompletionContext::CCC_ClassOrStructTag)
>| (1LL << CodeCompletionContext::CCC_Type)
> -  | (1LL << CodeCompletionContext::CCC_Symbol)
>| (1LL << CodeCompletionContext::CCC_SymbolOrNewName)
>| (1LL << CodeCompletionContext::CCC_ParenthesizedExpression);
>
>
> Added: cfe/trunk/test/Index/complete-qualified-cached.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-qualified-cached.cpp?rev=366448&view=auto
> ==
> --- cfe/trunk/test/Index/complete-qualified-cached.cpp (added)
> +++ cfe/trunk/test/Index/complete-qualified-cached.cpp Thu Jul 18 08:21:34 
> 2019
> @@ -0,0 +1,22 @@
> +namespace a_namespace {};
> +class Class { static void foo(); };
> +Class::
> +// Completion for a_namespace should be available at the start of the line.
> +// START-OF-LINE: a_namespace
> +// START-OF-LINE: Class
> +// -- Using cached completions.
> +// RUN: CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:3:1 %s \
> +// RUN: | FileCheck --check-prefix=START-OF-LINE %s
> +// -- Without cached completions.
> +// RUN: c-index-test -code-completion-at=%s:3:1 %s \
> +// RUN: | FileCheck --check-prefix=START-OF-LINE %s
> +//
> +//
> +// ... and should not be available after 'Class::^'
> +// AFTER-QUALIFIER: Class
> +// -- Using cached completions.
> +// RUN: CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:3:8 %s \
> +// RUN: | FileCheck --implicit-check-not=a_namespace 
> --check-prefix=AFTER-QUALIFIER %s
> +// -- Without cached completions.
> +// RUN: c-index-test -code-completion-at=%s:3:8 %s \
> +// RUN: | FileCheck --implicit-check-not=a_namespace 
> --check-prefix=AFTER-QUALIFIER %s
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang-tools-extra] r366455 - [clangd] Get rid of dots and dotsdots within GlobalCompilationDatabase

2019-07-22 Thread Hans Wennborg via cfe-commits
Merged this and r366559 to the 9 branch in r366718.

On Thu, Jul 18, 2019 at 9:13 AM Kadir Cetinkaya via cfe-commits
 wrote:
>
> Author: kadircet
> Date: Thu Jul 18 09:13:23 2019
> New Revision: 366455
>
> URL: http://llvm.org/viewvc/llvm-project?rev=366455&view=rev
> Log:
> [clangd] Get rid of dots and dotsdots within GlobalCompilationDatabase
>
> Reviewers: sammccall
>
> Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits
>
> Tags: #clang
>
> Differential Revision: https://reviews.llvm.org/D64860
>
> Modified:
> clang-tools-extra/trunk/clangd/FS.cpp
> clang-tools-extra/trunk/clangd/FS.h
> clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
> 
> clang-tools-extra/trunk/clangd/unittests/GlobalCompilationDatabaseTests.cpp
>
> Modified: clang-tools-extra/trunk/clangd/FS.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FS.cpp?rev=366455&r1=366454&r2=366455&view=diff
> ==
> --- clang-tools-extra/trunk/clangd/FS.cpp (original)
> +++ clang-tools-extra/trunk/clangd/FS.cpp Thu Jul 18 09:13:23 2019
> @@ -111,5 +111,11 @@ PreambleFileStatusCache::getConsumingFS(
>return llvm::IntrusiveRefCntPtr(new CacheVFS(std::move(FS), 
> *this));
>  }
>
> +Path removeDots(PathRef File) {
> +  llvm::SmallString<128> CanonPath(File);
> +  llvm::sys::path::remove_dots(CanonPath, /*remove_dot_dot=*/true);
> +  return CanonPath.str().str();
> +}
> +
>  } // namespace clangd
>  } // namespace clang
>
> Modified: clang-tools-extra/trunk/clangd/FS.h
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FS.h?rev=366455&r1=366454&r2=366455&view=diff
> ==
> --- clang-tools-extra/trunk/clangd/FS.h (original)
> +++ clang-tools-extra/trunk/clangd/FS.h Thu Jul 18 09:13:23 2019
> @@ -9,6 +9,7 @@
>  #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FS_H
>  #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FS_H
>
> +#include "Path.h"
>  #include "clang/Basic/LLVM.h"
>  #include "llvm/ADT/Optional.h"
>  #include "llvm/Support/VirtualFileSystem.h"
> @@ -65,6 +66,13 @@ private:
>llvm::StringMap StatCache;
>  };
>
> +/// Returns a version of \p File that doesn't contain dots and dot dots.
> +/// e.g /a/b/../c -> /a/c
> +/// /a/b/./c -> /a/b/c
> +/// FIXME: We should avoid encountering such paths in clangd internals by
> +/// filtering everything we get over LSP, CDB, etc.
> +Path removeDots(PathRef File);
> +
>  } // namespace clangd
>  } // namespace clang
>
>
> Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp?rev=366455&r1=366454&r2=366455&view=diff
> ==
> --- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp (original)
> +++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Thu Jul 18 
> 09:13:23 2019
> @@ -7,6 +7,7 @@
>  
> //===--===//
>
>  #include "GlobalCompilationDatabase.h"
> +#include "FS.h"
>  #include "Logger.h"
>  #include "Path.h"
>  #include "clang/Frontend/CompilerInvocation.h"
> @@ -15,6 +16,7 @@
>  #include "llvm/ADT/None.h"
>  #include "llvm/ADT/Optional.h"
>  #include "llvm/ADT/STLExtras.h"
> +#include "llvm/ADT/SmallString.h"
>  #include "llvm/Support/FileSystem.h"
>  #include "llvm/Support/Path.h"
>  #include 
> @@ -147,12 +149,15 @@ DirectoryBasedGlobalCompilationDatabase:
>getCDBInDirLocked(*CompileCommandsDir);
>Result.PI.SourceRoot = *CompileCommandsDir;
>  } else {
> -  actOnAllParentDirectories(
> -  Request.FileName, [this, &SentBroadcast, &Result](PathRef Path) {
> -std::tie(Result.CDB, SentBroadcast) = getCDBInDirLocked(Path);
> -Result.PI.SourceRoot = Path;
> -return Result.CDB != nullptr;
> -  });
> +  // Traverse the canonical version to prevent false positives. i.e.:
> +  // src/build/../a.cc can detect a CDB in /src/build if not 
> canonicalized.
> +  actOnAllParentDirectories(removeDots(Request.FileName),
> +[this, &SentBroadcast, &Result](PathRef 
> Path) {
> +  std::tie(Result.CDB, SentBroadcast) =
> +  getCDBInDirLocked(Path);
> +  Result.PI.SourceRoot = Path;
> +  return Result.CDB != nullptr;
> +});
>  }
>
>  if (!Result.CDB)
> @@ -209,7 +214,8 @@ void DirectoryBasedGlobalCompilationData
>  actOnAllParentDirectories(File, [&](PathRef Path) {
>if (DirectoryHasCDB.lookup(Path)) {
>  if (Path == Result.PI.SourceRoot)
> -  GovernedFiles.push_back(File);
> +  // Make

r366719 - Adds support for formatting NS_CLOSED_ENUM and CF_CLOSED_ENUM alongside NS_ENUM and CF_ENUM.

2019-07-22 Thread Ben Hamilton via cfe-commits
Author: benhamilton
Date: Mon Jul 22 11:20:01 2019
New Revision: 366719

URL: http://llvm.org/viewvc/llvm-project?rev=366719&view=rev
Log:
Adds support for formatting NS_CLOSED_ENUM and CF_CLOSED_ENUM alongside NS_ENUM 
and CF_ENUM.

Summary:
Addresses the formatting of NS_CLOSED_ENUM and CF_CLOSED_ENUM, introduced in 
Swift 5.

Before:

```
typedef NS_CLOSED_ENUM(NSInteger, Foo){FooValueOne = 1, FooValueTwo,
   FooValueThree};
```

After:

```
typedef NS_CLOSED_ENUM(NSInteger, Foo) {
  FooValueOne = 1,
  FooValueTwo,
  FooValueThree
};
```

Contributed by heijink.

Reviewers: benhamilton, krasimir

Reviewed By: benhamilton

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D65012

Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/FormatToken.h
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
cfe/trunk/unittests/Format/FormatTestObjC.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=366719&r1=366718&r2=366719&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon Jul 22 11:20:01 2019
@@ -1685,10 +1685,11 @@ private:
 std::end(FoundationIdentifiers),
 FormatTok->TokenText)) ||
 FormatTok->is(TT_ObjCStringLiteral) ||
-FormatTok->isOneOf(Keywords.kw_NS_ENUM, Keywords.kw_NS_OPTIONS,
-   TT_ObjCBlockLBrace, TT_ObjCBlockLParen,
-   TT_ObjCDecl, TT_ObjCForIn, TT_ObjCMethodExpr,
-   TT_ObjCMethodSpecifier, TT_ObjCProperty)) {
+FormatTok->isOneOf(Keywords.kw_NS_CLOSED_ENUM, Keywords.kw_NS_ENUM,
+   Keywords.kw_NS_OPTIONS, TT_ObjCBlockLBrace,
+   TT_ObjCBlockLParen, TT_ObjCDecl, TT_ObjCForIn,
+   TT_ObjCMethodExpr, TT_ObjCMethodSpecifier,
+   TT_ObjCProperty)) {
   LLVM_DEBUG(llvm::dbgs()
  << "Detected ObjC at location "
  << FormatTok->Tok.getLocation().printToString(

Modified: cfe/trunk/lib/Format/FormatToken.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=366719&r1=366718&r2=366719&view=diff
==
--- cfe/trunk/lib/Format/FormatToken.h (original)
+++ cfe/trunk/lib/Format/FormatToken.h Mon Jul 22 11:20:01 2019
@@ -677,8 +677,10 @@ struct AdditionalKeywords {
 kw_override = &IdentTable.get("override");
 kw_in = &IdentTable.get("in");
 kw_of = &IdentTable.get("of");
+kw_CF_CLOSED_ENUM = &IdentTable.get("CF_CLOSED_ENUM");
 kw_CF_ENUM = &IdentTable.get("CF_ENUM");
 kw_CF_OPTIONS = &IdentTable.get("CF_OPTIONS");
+kw_NS_CLOSED_ENUM = &IdentTable.get("NS_CLOSED_ENUM");
 kw_NS_ENUM = &IdentTable.get("NS_ENUM");
 kw_NS_OPTIONS = &IdentTable.get("NS_OPTIONS");
 
@@ -787,8 +789,10 @@ struct AdditionalKeywords {
   IdentifierInfo *kw_override;
   IdentifierInfo *kw_in;
   IdentifierInfo *kw_of;
+  IdentifierInfo *kw_CF_CLOSED_ENUM;
   IdentifierInfo *kw_CF_ENUM;
   IdentifierInfo *kw_CF_OPTIONS;
+  IdentifierInfo *kw_NS_CLOSED_ENUM;
   IdentifierInfo *kw_NS_ENUM;
   IdentifierInfo *kw_NS_OPTIONS;
   IdentifierInfo *kw___except;

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=366719&r1=366718&r2=366719&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Mon Jul 22 11:20:01 2019
@@ -1215,7 +1215,8 @@ void UnwrappedLineParser::parseStructura
 case tok::kw_typedef:
   nextToken();
   if (FormatTok->isOneOf(Keywords.kw_NS_ENUM, Keywords.kw_NS_OPTIONS,
- Keywords.kw_CF_ENUM, Keywords.kw_CF_OPTIONS))
+ Keywords.kw_CF_ENUM, Keywords.kw_CF_OPTIONS,
+ Keywords.kw_CF_CLOSED_ENUM, 
Keywords.kw_NS_CLOSED_ENUM))
 parseEnum();
   break;
 case tok::kw_struct:

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=366719&r1=366718&r2=366719&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jul 22 11:20:01 2019
@@ -1716,6 +1716,8 @@ TEST_F(FormatTest, FormatsTypedefEnum) {
 
 TEST_F(FormatTest, FormatsNSEnums) {
   verifyGoogleFormat("typedef NS_ENUM(

[PATCH] D65012: Adds support for formatting NS_CLOSED_ENUM and CF_CLOSED_ENUM alongside NS_ENUM and CF_ENUM.

2019-07-22 Thread Ben Hamilton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366719: Adds support for formatting NS_CLOSED_ENUM and 
CF_CLOSED_ENUM alongside NS_ENUM… (authored by benhamilton, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D65012?vs=211137&id=211153#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D65012

Files:
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/lib/Format/FormatToken.h
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/unittests/Format/FormatTest.cpp
  cfe/trunk/unittests/Format/FormatTestObjC.cpp

Index: cfe/trunk/unittests/Format/FormatTest.cpp
===
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -1716,6 +1716,8 @@
 
 TEST_F(FormatTest, FormatsNSEnums) {
   verifyGoogleFormat("typedef NS_ENUM(NSInteger, SomeName) { AAA, BBB }");
+  verifyGoogleFormat(
+  "typedef NS_CLOSED_ENUM(NSInteger, SomeName) { AAA, BBB }");
   verifyGoogleFormat("typedef NS_ENUM(NSInteger, MyType) {\n"
  "  // Information about someDecentlyLongValue.\n"
  "  someDecentlyLongValue,\n"
@@ -1724,6 +1726,14 @@
  "  // Information about aThirdDecentlyLongValue.\n"
  "  aThirdDecentlyLongValue\n"
  "};");
+  verifyGoogleFormat("typedef NS_CLOSED_ENUM(NSInteger, MyType) {\n"
+ "  // Information about someDecentlyLongValue.\n"
+ "  someDecentlyLongValue,\n"
+ "  // Information about anotherDecentlyLongValue.\n"
+ "  anotherDecentlyLongValue,\n"
+ "  // Information about aThirdDecentlyLongValue.\n"
+ "  aThirdDecentlyLongValue\n"
+ "};");
   verifyGoogleFormat("typedef NS_OPTIONS(NSInteger, MyType) {\n"
  "  a = 1,\n"
  "  b = 2,\n"
@@ -1734,6 +1744,11 @@
  "  b = 2,\n"
  "  c = 3,\n"
  "};");
+  verifyGoogleFormat("typedef CF_CLOSED_ENUM(NSInteger, MyType) {\n"
+ "  a = 1,\n"
+ "  b = 2,\n"
+ "  c = 3,\n"
+ "};");
   verifyGoogleFormat("typedef CF_OPTIONS(NSInteger, MyType) {\n"
  "  a = 1,\n"
  "  b = 2,\n"
Index: cfe/trunk/unittests/Format/FormatTestObjC.cpp
===
--- cfe/trunk/unittests/Format/FormatTestObjC.cpp
+++ cfe/trunk/unittests/Format/FormatTestObjC.cpp
@@ -114,7 +114,12 @@
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
 
   Style =
-  getStyle("{}", "a.h", "none", "typedef NS_ENUM(NSInteger, Foo) {};\n");
+  getStyle("{}", "a.h", "none", "typedef NS_ENUM(int, Foo) {};\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+  Style = getStyle("{}", "a.h", "none",
+   "typedef NS_CLOSED_ENUM(int, Foo) {};\n");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
Index: cfe/trunk/lib/Format/FormatToken.h
===
--- cfe/trunk/lib/Format/FormatToken.h
+++ cfe/trunk/lib/Format/FormatToken.h
@@ -677,8 +677,10 @@
 kw_override = &IdentTable.get("override");
 kw_in = &IdentTable.get("in");
 kw_of = &IdentTable.get("of");
+kw_CF_CLOSED_ENUM = &IdentTable.get("CF_CLOSED_ENUM");
 kw_CF_ENUM = &IdentTable.get("CF_ENUM");
 kw_CF_OPTIONS = &IdentTable.get("CF_OPTIONS");
+kw_NS_CLOSED_ENUM = &IdentTable.get("NS_CLOSED_ENUM");
 kw_NS_ENUM = &IdentTable.get("NS_ENUM");
 kw_NS_OPTIONS = &IdentTable.get("NS_OPTIONS");
 
@@ -787,8 +789,10 @@
   IdentifierInfo *kw_override;
   IdentifierInfo *kw_in;
   IdentifierInfo *kw_of;
+  IdentifierInfo *kw_CF_CLOSED_ENUM;
   IdentifierInfo *kw_CF_ENUM;
   IdentifierInfo *kw_CF_OPTIONS;
+  IdentifierInfo *kw_NS_CLOSED_ENUM;
   IdentifierInfo *kw_NS_ENUM;
   IdentifierInfo *kw_NS_OPTIONS;
   IdentifierInfo *kw___except;
Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -1215,7 +1215,8 @@
 case tok::kw_typedef:
   nextToken();
   if (FormatTok->isOneOf(Keywords.kw_NS_ENUM, Keywords.kw_NS_OPTIONS,
- Keywords.kw_CF_ENUM, Keywords.kw_CF_OPTIONS))
+ Keywords.kw_CF_ENUM, Keywords.kw_CF_OPTIONS,
+ Keywords.kw_CF_CLOSED_ENUM, Keywords.kw_NS_CLOSED_ENUM))
 parseEnum();
   break;
 case tok::kw_struct:
Index: cfe/trunk/l

[PATCH] D65106: [OPENMP]Add support for analysis of reduction variables.

2019-07-22 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: NoQ.
Herald added subscribers: jdoerfert, guansong.
Herald added a project: clang.

Reduction variables are the variables, for which the private copies
must be created in the OpenMP regions. Then they are initialized with
the predefined values depending on the reduction operation. After exit
from the OpenMP region the original variable is updated using the
reduction value and the value of the original reduction variable.


Repository:
  rC Clang

https://reviews.llvm.org/D65106

Files:
  include/clang/AST/OpenMPClause.h
  test/Analysis/cfg-openmp.cpp
  test/OpenMP/distribute_parallel_for_reduction_messages.cpp
  test/OpenMP/distribute_parallel_for_simd_reduction_messages.cpp
  test/OpenMP/distribute_simd_reduction_messages.cpp
  test/OpenMP/for_reduction_messages.cpp
  test/OpenMP/for_simd_reduction_messages.cpp
  test/OpenMP/parallel_for_reduction_messages.cpp
  test/OpenMP/parallel_for_simd_reduction_messages.cpp
  test/OpenMP/parallel_reduction_messages.cpp
  test/OpenMP/parallel_sections_reduction_messages.cpp
  test/OpenMP/sections_reduction_messages.cpp
  test/OpenMP/simd_reduction_messages.cpp
  test/OpenMP/target_parallel_for_reduction_messages.cpp
  test/OpenMP/target_parallel_for_simd_reduction_messages.cpp
  test/OpenMP/target_parallel_reduction_messages.cpp
  test/OpenMP/target_reduction_messages.cpp
  test/OpenMP/target_simd_reduction_messages.cpp
  test/OpenMP/target_teams_distribute_parallel_for_reduction_messages.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_reduction_messages.cpp
  test/OpenMP/target_teams_distribute_reduction_messages.cpp
  test/OpenMP/target_teams_distribute_simd_reduction_messages.cpp
  test/OpenMP/target_teams_reduction_messages.cpp
  test/OpenMP/taskloop_reduction_messages.cpp
  test/OpenMP/taskloop_simd_reduction_messages.cpp
  test/OpenMP/teams_distribute_parallel_for_reduction_messages.cpp
  test/OpenMP/teams_distribute_parallel_for_simd_reduction_messages.cpp
  test/OpenMP/teams_distribute_reduction_messages.cpp
  test/OpenMP/teams_distribute_simd_reduction_messages.cpp
  test/OpenMP/teams_reduction_messages.cpp

Index: test/OpenMP/teams_reduction_messages.cpp
===
--- test/OpenMP/teams_reduction_messages.cpp
+++ test/OpenMP/teams_reduction_messages.cpp
@@ -7,6 +7,14 @@
 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 -o - %s -Wno-openmp-target -Wuninitialized
 
 extern int omp_default_mem_alloc;
+void xxx(int argc) {
+  int fp; // expected-note {{initialize the variable 'fp' to silence this warning}}
+#pragma omp target
+#pragma omp teams reduction(+:fp) // expected-warning {{variable 'fp' is uninitialized when used here}}
+  for (int i = 0; i < 10; ++i)
+;
+}
+
 void foo() {
 }
 
Index: test/OpenMP/teams_distribute_simd_reduction_messages.cpp
===
--- test/OpenMP/teams_distribute_simd_reduction_messages.cpp
+++ test/OpenMP/teams_distribute_simd_reduction_messages.cpp
@@ -7,6 +7,14 @@
 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wno-openmp-target -Wuninitialized
 
 extern int omp_default_mem_alloc;
+void xxx(int argc) {
+  int fp; // expected-note {{initialize the variable 'fp' to silence this warning}}
+#pragma omp target
+#pragma omp teams distribute simd reduction(+:fp) // expected-warning {{variable 'fp' is uninitialized when used here}}
+  for (int i = 0; i < 10; ++i)
+;
+}
+
 void foo() {
 }
 
Index: test/OpenMP/teams_distribute_reduction_messages.cpp
===
--- test/OpenMP/teams_distribute_reduction_messages.cpp
+++ test/OpenMP/teams_distribute_reduction_messages.cpp
@@ -7,6 +7,14 @@
 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wno-openmp-target -Wuninitialized
 
 extern int omp_default_mem_alloc;
+void xxx(int argc) {
+  int fp; // expected-note {{initialize the variable 'fp' to silence this warning}}
+#pragma omp target
+#pragma omp teams distribute reduction(+:fp) // expected-warning {{variable 'fp' is uninitialized when used here}}
+  for (int i = 0; i < 10; ++i)
+;
+}
+
 void foo() {
 }
 
Index: test/OpenMP/teams_distribute_parallel_for_simd_reduction_messages.cpp
===
--- test/OpenMP/teams_distribute_parallel_for_simd_reduction_messages.cpp
+++ test/OpenMP/teams_distribute_parallel_for_simd_reduction_messages.cpp
@@ -7,6 +7,14 @@
 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wno-openmp-target -Wuninitialized
 
 extern int omp_default_mem_alloc;
+void xxx(int argc) {
+  int fp; // expected-note {{initialize the variable 'fp' to silence this warning}}
+#pragma omp target
+#pragma omp teams distribute parallel for simd reduction(+:fp) // expected-warning {{variable 'fp' is uninitialized when used here}}
+  for (int i = 0; i < 10; ++i)
+;
+}
+
 void foo() {
 }
 
Index: test/OpenMP/team

[PATCH] D65092: [clang] Add isDirectlyDerivedFrom AST Matcher.

2019-07-22 Thread Manuel Klimek via Phabricator via cfe-commits
klimek requested changes to this revision.
klimek added inline comments.
This revision now requires changes to proceed.



Comment at: clang/docs/LibASTMatchersReference.html:5277
 
+MatcherCXXRecordDecl>isDirectlyDerivedFromMatcherNamedDecl>
 Base
+Matches C++ 
classes that are directly derived from

Did you manually change this? This should be generated from the code, but I 
don't see this text anywhere in the code comments?


Repository:
  rC Clang

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

https://reviews.llvm.org/D65092



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


[PATCH] D65107: [clang-doc] Fix html entities in rendered text

2019-07-22 Thread Diego Astiazarán via Phabricator via cfe-commits
DiegoAstiazaran created this revision.
DiegoAstiazaran added reviewers: jakehehrlich, juliehockett.
DiegoAstiazaran added a project: clang-tools-extra.

Replace <, > and " with its corresponding html entities before rendering text 
nodes.


https://reviews.llvm.org/D65107

Files:
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp


Index: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -258,6 +258,14 @@
   Extended->Children.back()->Kind = "TextComment";
   Extended->Children.back()->Text = " continues onto the next line.";
 
+  Top.Children.emplace_back(llvm::make_unique());
+  CommentInfo *Entities = Top.Children.back().get();
+  Entities->Kind = "ParagraphComment";
+  Entities->Children.emplace_back(llvm::make_unique());
+  Entities->Children.back()->Kind = "TextComment";
+  Entities->Children.back()->Name = "ParagraphComment";
+  Entities->Children.back()->Text = " Comment with html entities: <, > and 
\".";
+
   I.Description.emplace_back(std::move(Top));
 
   auto G = getHTMLGenerator();
@@ -285,6 +293,9 @@
   
  Extended description that continues onto the next line.
   
+  
+ Comment with html entities: <, > and ".
+  
 
   
 
Index: clang-tools-extra/clang-doc/HTMLGenerator.cpp
===
--- clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -71,7 +71,12 @@
 
   std::string Text; // Content of node
   bool Indented; // Indicates if an indentation must be rendered before the 
text
+
+  void FixText();
   void Render(llvm::raw_ostream &OS, int IndentationLevel) override;
+
+private:
+  std::string getHTMLEntity(const char &C);
 };
 
 struct TagNode : public HTMLNode {
@@ -173,7 +178,30 @@
   llvm_unreachable("Unhandled HTMLTag::TagType");
 }
 
+std::string TextNode::getHTMLEntity(const char &C) {
+  switch (C) {
+  case '<':
+return "<";
+  case '>':
+return ">";
+  case '"':
+return """;
+  default:
+return std::string(&C, 1);
+  }
+}
+
+void TextNode::FixText() {
+  static const std::string CharactersToReplace = "<>\"";
+  std::size_t found = Text.find_first_of(CharactersToReplace);
+  while (found != std::string::npos) {
+Text.replace(found, 1, getHTMLEntity(Text[found]));
+found = Text.find_first_of(CharactersToReplace, found + 1);
+  }
+}
+
 void TextNode::Render(llvm::raw_ostream &OS, int IndentationLevel) {
+  FixText();
   if (Indented)
 OS.indent(IndentationLevel * 2);
   OS << Text;


Index: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -258,6 +258,14 @@
   Extended->Children.back()->Kind = "TextComment";
   Extended->Children.back()->Text = " continues onto the next line.";
 
+  Top.Children.emplace_back(llvm::make_unique());
+  CommentInfo *Entities = Top.Children.back().get();
+  Entities->Kind = "ParagraphComment";
+  Entities->Children.emplace_back(llvm::make_unique());
+  Entities->Children.back()->Kind = "TextComment";
+  Entities->Children.back()->Name = "ParagraphComment";
+  Entities->Children.back()->Text = " Comment with html entities: <, > and \".";
+
   I.Description.emplace_back(std::move(Top));
 
   auto G = getHTMLGenerator();
@@ -285,6 +293,9 @@
   
  Extended description that continues onto the next line.
   
+  
+ Comment with html entities: <, > and ".
+  
 
   
 
Index: clang-tools-extra/clang-doc/HTMLGenerator.cpp
===
--- clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -71,7 +71,12 @@
 
   std::string Text; // Content of node
   bool Indented; // Indicates if an indentation must be rendered before the text
+
+  void FixText();
   void Render(llvm::raw_ostream &OS, int IndentationLevel) override;
+
+private:
+  std::string getHTMLEntity(const char &C);
 };
 
 struct TagNode : public HTMLNode {
@@ -173,7 +178,30 @@
   llvm_unreachable("Unhandled HTMLTag::TagType");
 }
 
+std::string TextNode::getHTMLEntity(const char &C) {
+  switch (C) {
+  case '<':
+return "<";
+  case '>':
+return ">";
+  case '"':
+return """;
+  default:
+return std::string(&C, 1);
+  }
+}
+
+void TextNode::FixText() {
+  static const std::string CharactersToReplace = "<>\"";
+  std::size_t found = Text.find_first_of(CharactersToReplace);
+  while (found != std::string::npos) {
+Text.replace(found, 1, getHTMLEntity(Text[found]));
+found = Text.find_first_of(CharactersToReplace, found 

[PATCH] D65108: Reland "driver: Don't warn about assembler flags being unused when not assembling"

2019-07-22 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: rnk.

This relands r365703 (and r365714), originally reviewed at
https://reviews.llvm.org/D64527.

The problem with the old approach was that clang would now warn about
-Wa flags that the integrated assembler didn't understand even when
-fno-integrated-as was used.

Just checking for that before calling CollectArgsForIntegratedAssembler
still makes clang warn about unused flags with -fno-integrated-as, which
isn't desired either.

Instead, omit just the "unknown flag" diag if the integrated assembler
isn't in use.

One of the new test cases is by nickdesaulniers from
https://reviews.llvm.org/D64655.


https://reviews.llvm.org/D65108

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/as-options.s

Index: clang/test/Driver/as-options.s
===
--- clang/test/Driver/as-options.s
+++ clang/test/Driver/as-options.s
@@ -35,3 +35,45 @@
 // RUN:   | FileCheck %s
 
 // CHECK: "-I" "foo_dir"
+
+// Test that assembler options don't cause warnings when there's no assembler
+// stage.
+
+// RUN: %clang -mincremental-linker-compatible -E \
+// RUN:   -o /dev/null -x c++ %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=NOWARN --allow-empty %s
+// RUN: %clang -mincremental-linker-compatible -E \
+// RUN:   -o /dev/null -x assembler-with-cpp %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=NOWARN --allow-empty %s
+// RUN: %clang -mimplicit-it=always -target armv7-linux-gnueabi -E \
+// RUN:   -o /dev/null -x c++ %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=NOWARN --allow-empty %s
+// RUN: %clang -mimplicit-it=always -target armv7-linux-gnueabi -E \
+// RUN:   -o /dev/null -x assembler-with-cpp %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=NOWARN --allow-empty %s
+// RUN: %clang -Wa,-mbig-obj -target i386-pc-windows -E \
+// RUN:   -o /dev/null -x c++ %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=NOWARN --allow-empty %s
+// RUN: %clang -Wa,-mbig-obj -target i386-pc-windows -E \
+// RUN:   -o /dev/null -x assembler-with-cpp %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=NOWARN --allow-empty %s
+// NOWARN-NOT: unused
+
+// Test that unsupported arguments do not cause errors when -fno-integrated-as
+// is set.
+// RUN: %clang -Wa,-mno-warn-deprecated -fno-integrated-as %s -S 2>&1 \
+// RUN:   | FileCheck --check-prefix=NOERROR --allow-empty %s
+// NOERROR-NOT: error: unsupported argument '-mno-warn-deprecated' to option 'Wa,'
+
+// -Wa flags shouldn't cause warnings without an assembler stage with
+// -fno-integrated-as either.
+// RUN: %clang -Wa,-mno-warn-deprecated -fno-integrated-as %s -S 2>&1 \
+// RUN:   | FileCheck --check-prefix=NOWARN --allow-empty %s
+
+// But -m flags for the integrated assembler _should_ warn if the integrated
+// assembler is not in use.
+// RUN: %clang -mrelax-all -fintegrated-as %s -S 2>&1 \
+// RUN:   | FileCheck --check-prefix=NOWARN --allow-empty %s
+// RUN: %clang -mrelax-all -fno-integrated-as %s -S 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN --allow-empty %s
+// WARN: unused
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2045,38 +2045,42 @@
 static void CollectArgsForIntegratedAssembler(Compilation &C,
   const ArgList &Args,
   ArgStringList &CmdArgs,
-  const Driver &D) {
-  if (UseRelaxAll(C, Args))
-CmdArgs.push_back("-mrelax-all");
-
-  // Only default to -mincremental-linker-compatible if we think we are
-  // targeting the MSVC linker.
-  bool DefaultIncrementalLinkerCompatible =
-  C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment();
-  if (Args.hasFlag(options::OPT_mincremental_linker_compatible,
-   options::OPT_mno_incremental_linker_compatible,
-   DefaultIncrementalLinkerCompatible))
-CmdArgs.push_back("-mincremental-linker-compatible");
-
-  switch (C.getDefaultToolChain().getArch()) {
-  case llvm::Triple::arm:
-  case llvm::Triple::armeb:
-  case llvm::Triple::thumb:
-  case llvm::Triple::thumbeb:
-if (Arg *A = Args.getLastArg(options::OPT_mimplicit_it_EQ)) {
-  StringRef Value = A->getValue();
-  if (Value == "always" || Value == "never" || Value == "arm" ||
-  Value == "thumb") {
-CmdArgs.push_back("-mllvm");
-CmdArgs.push_back(Args.MakeArgString("-arm-implicit-it=" + Value));
-  } else {
-D.Diag(diag::err_drv_unsupported_option_argument)
-<< A->getOption().getName() << Value;
+  const Driver &D,
+  bool IsIntegratedAs) {
+  // Claim flags for the integrated assembler only if it's being used.
+  if (IsIntegratedAs) {
+if (UseRelaxAll(C, Args))
+  

[PATCH] D65108: Reland "driver: Don't warn about assembler flags being unused when not assembling"

2019-07-22 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Note to self: Check https://github.com/ClangBuiltLinux/linux/issues/598 before 
landing this.


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

https://reviews.llvm.org/D65108



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


[PATCH] D65108: Reland "driver: Don't warn about assembler flags being unused when not assembling"

2019-07-22 Thread Nico Weber via Phabricator via cfe-commits
thakis marked an inline comment as done.
thakis added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2051
+  // Claim flags for the integrated assembler only if it's being used.
+  if (IsIntegratedAs) {
+if (UseRelaxAll(C, Args))

(This just wraps all the red lines on the lhs in an `if (IsIntegratedAs)` and 
leaves them all otherwise unchanged.)


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

https://reviews.llvm.org/D65108



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


[PATCH] D64655: [Clang][Driver] don't error for unsupported as options for -no-integrated-as

2019-07-22 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

I think https://reviews.llvm.org/D65108 is a better fix, for the reason rnk 
gave above. I think this one can be abandoned.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64655



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


[PATCH] D65108: Reland "driver: Don't warn about assembler flags being unused when not assembling"

2019-07-22 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2051
+  // Claim flags for the integrated assembler only if it's being used.
+  if (IsIntegratedAs) {
+if (UseRelaxAll(C, Args))

thakis wrote:
> (This just wraps all the red lines on the lhs in an `if (IsIntegratedAs)` and 
> leaves them all otherwise unchanged.)
Return early on negated condition instead of adding additional indentation and 
messing with `git blame`.


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

https://reviews.llvm.org/D65108



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


[PATCH] D65108: Reland "driver: Don't warn about assembler flags being unused when not assembling"

2019-07-22 Thread Nico Weber via Phabricator via cfe-commits
thakis marked an inline comment as done.
thakis added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2051
+  // Claim flags for the integrated assembler only if it's being used.
+  if (IsIntegratedAs) {
+if (UseRelaxAll(C, Args))

nickdesaulniers wrote:
> thakis wrote:
> > (This just wraps all the red lines on the lhs in an `if (IsIntegratedAs)` 
> > and leaves them all otherwise unchanged.)
> Return early on negated condition instead of adding additional indentation 
> and messing with `git blame`.
It doesn't skip the whole function, just the first few flags.


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

https://reviews.llvm.org/D65108



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


[PATCH] D64883: Add new warning -Walloca for use of builtin alloca function

2019-07-22 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:2776
+def warn_alloca : Warning<
+  "use of builtin function %0">,
+  InGroup>, DefaultIgnore;

aaron.ballman wrote:
> george.burgess.iv wrote:
> > nit: I'd just say "use of function '%0'" here; "builtin" doesn't really add 
> > much.
> > 
> > I also wonder if we should be saying anything more than "we found a use of 
> > this function." Looks like GCC doesn't (https://godbolt.org/z/sYs_8G), but 
> > since this warning is sort of opinionated in itself, might it be better to 
> > expand this to "use of '%0' is discouraged"?
> > 
> > WDYT, Aaron?
> What is the purpose to this diagnostic, aside from GCC compatibility? What 
> does it protect against?
> 
> If there's a reason users should not use alloc(), it would be better for the 
> diagnostic to spell it out.
> 
> Btw, I'm okay with this being default-off because the GCC warning is as well. 
> I'm mostly hoping we can do better with our diagnostic wording.
> I'm mostly hoping we can do better with our diagnostic wording

+1

> What is the purpose to this diagnostic?

I think the intent boils down to that `alloca` is easily misused, and leads to 
e.g., https://www.qualys.com/2017/06/19/stack-clash/stack-clash.txt . Since its 
use often boils down to nothing but a tiny micro-optimization, some parties 
would like to discourage its use.

Both glibc and bionic recommend against the use of `alloca` in their 
documentation, though glibc's docs are less assertive than bionic's, and 
explicitly call out "[alloca's] use can improve efficiency compared to the use 
of malloc plus free."

Greping a codebase and investigating the first 15 results:
- all of them look like microoptimizations; many of them also sit close to 
other `malloc`/`new` ops, so allocating on these paths presumably isn't 
prohibitively expensive
- all but two of the uses of `alloca` have no logic to fall back to the heap 
`malloc` if the array they want to allocate passes a certain threshold. Some of 
the uses make it look *really* easy for the array to grow very large.
- one of the uses compares the result of `alloca` to `NULL`. Since `alloca`'s 
behavior is undefined if it fails, ...

I'm having trouble putting this into a concise and actionable diagnostic 
message, though. The best I can come up with at the moment is something along 
the lines of "use of function %0 is subtle; consider using heap allocation 
instead."


Repository:
  rC Clang

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

https://reviews.llvm.org/D64883



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


[PATCH] D65108: Reland "driver: Don't warn about assembler flags being unused when not assembling"

2019-07-22 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2051
+  // Claim flags for the integrated assembler only if it's being used.
+  if (IsIntegratedAs) {
+if (UseRelaxAll(C, Args))

thakis wrote:
> nickdesaulniers wrote:
> > thakis wrote:
> > > (This just wraps all the red lines on the lhs in an `if (IsIntegratedAs)` 
> > > and leaves them all otherwise unchanged.)
> > Return early on negated condition instead of adding additional indentation 
> > and messing with `git blame`.
> It doesn't skip the whole function, just the first few flags.
oic


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

https://reviews.llvm.org/D65108



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


[PATCH] D65108: Reland "driver: Don't warn about assembler flags being unused when not assembling"

2019-07-22 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3564
+ArgStringList DummyArgs;
+CollectArgsForIntegratedAssembler(C, Args, DummyArgs, D,
+  TC.useIntegratedAs());

I think it would be better to use ClaimAllArgs here. If you look around in this 
code, there's a fair amount of stuff like this:
```
  if (KernelOrKext) {
// -mkernel and -fapple-kext imply no exceptions, so claim exception related
// arguments now to avoid warnings about unused arguments.
Args.ClaimAllArgs(options::OPT_fexceptions);
Args.ClaimAllArgs(options::OPT_fno_exceptions);
Args.ClaimAllArgs(options::OPT_fobjc_exceptions);
Args.ClaimAllArgs(options::OPT_fno_objc_exceptions);
Args.ClaimAllArgs(options::OPT_fcxx_exceptions);
Args.ClaimAllArgs(options::OPT_fno_cxx_exceptions);
return;
  }
```
It repeats the knowledge of which flags are passed to the assembler (looks like 
5), but it is consistent with what's already done.


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

https://reviews.llvm.org/D65108



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


[PATCH] D64991: [analyzer][WIP] Implement a primitive reaching definitions analysis

2019-07-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D64991#1595853 , @Szelethus wrote:

> `CFGElementRef`


Wait, is it a thing already?? Did i miss anything???

> This analysis isn't conservative enough yet, I really should include function 
> calls with non-const references into the gen set, but hey, at this point I'm 
> optimistic that it can be done.

"Conservative" is not a property of the algorithm; it depends on how is the 
algorithm used. For some purposes you'll want to add an extra definition when 
you're not sure if it'll be a definition, for other purposes you'll want to 
only have definitions in which you are 100% certain in the set.




Comment at: clang/lib/Analysis/ReachingDefinitions.cpp:68
+auto Assignments =
+match(stmt(forEachDescendant(AssignmentM)), *S, *Context);
+if (!Assignments.empty()) {

I don't think you really need this. Every assignment would anyway appear in the 
CFG as a separate element. And also `forEachDescendant()` may accidentally scan 
items in different CFG blocks (i.e., if the whole statement is a `?:` or a 
logical op).


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

https://reviews.llvm.org/D64991



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


[PATCH] D64991: [analyzer][WIP] Implement a primitive reaching definitions analysis

2019-07-22 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D64991#1596292 , @NoQ wrote:

> In D64991#1595853 , @Szelethus wrote:
>
> > `CFGElementRef`
>
>
> Wait, is it a thing already?? Did i miss anything???


Oh, yea, I have it locally, still need to iron out a couple things on that 
before daring to upload it :) I figured it wouldn't cause much confusion so I 
shared this one kinda hanging in the air.

>> This analysis isn't conservative enough yet, I really should include 
>> function calls with non-const references into the gen set, but hey, at this 
>> point I'm optimistic that it can be done.
> 
> "Conservative" is not a property of the algorithm; it depends on how is the 
> algorithm used. For some purposes you'll want to add an extra definition when 
> you're not sure if it'll be a definition, for other purposes you'll want to 
> only have definitions in which you are 100% certain in the set.

Aye I'll try to specify on that. Thanks!


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

https://reviews.llvm.org/D64991



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


[PATCH] D65110: [NewPM] Run avx*-builtins.c tests under the new pass manager only

2019-07-22 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: chandlerc, craig.topper, spatel, RKSimon.
leonardchan added a project: clang.

This patch changes the following tests to run under the new pass manager only:

  Clang :: CodeGen/avx512-reduceMinMaxIntrin.c (1 of 4)
  Clang :: CodeGen/avx512vl-builtins.c (2 of 4)
  Clang :: CodeGen/avx512vlbw-builtins.c (3 of 4)
  Clang :: CodeGen/avx512f-builtins.c (4 of 4)

The new PM added extra bitcasts that weren't checked before. For 
reduceMinMaxIntrin.c, the issue was mostly the alloca's being in a different 
order. Other changes involved extra bitcasts, and differently ordered loads and 
stores, but the logic should still be the same.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65110

Files:
  clang/test/CodeGen/avx512-reduceMinMaxIntrin.c
  clang/test/CodeGen/avx512f-builtins.c
  clang/test/CodeGen/avx512vl-builtins.c
  clang/test/CodeGen/avx512vlbw-builtins.c

Index: clang/test/CodeGen/avx512vlbw-builtins.c
===
--- clang/test/CodeGen/avx512vlbw-builtins.c
+++ clang/test/CodeGen/avx512vlbw-builtins.c
@@ -1,6 +1,5 @@
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bw -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bw -target-feature +avx512vl -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s
-
+// RUN: %clang_cc1 -ffreestanding %s -fexperimental-new-pass-manager -triple=x86_64-apple-darwin -target-feature +avx512bw -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -fexperimental-new-pass-manager -triple=x86_64-apple-darwin -target-feature +avx512bw -target-feature +avx512vl -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s
 
 #include 
 
@@ -901,6 +900,8 @@
   // CHECK: [[SUB:%.*]] = sub <16 x i8> zeroinitializer, [[A:%.*]]
   // CHECK: [[CMP:%.*]] = icmp sgt <16 x i8> [[A]], zeroinitializer
   // CHECK: [[SEL:%.*]] = select <16 x i1> [[CMP]], <16 x i8> [[A]], <16 x i8> [[SUB]]
+  // CHECK: [[TMP:%.*]] = bitcast [[SRCTY:<.*>]] [[SEL]] to [[DSTTY:<.*>]]
+  // CHECK: [[SEL:%.*]] = bitcast [[DSTTY]] [[TMP]] to [[SRCTY]]
   // CHECK: select <16 x i1> %{{.*}}, <16 x i8> [[SEL]], <16 x i8> %{{.*}}
   return _mm_mask_abs_epi8(__W,__U,__A); 
 }
@@ -910,6 +911,8 @@
   // CHECK: [[SUB:%.*]] = sub <16 x i8> zeroinitializer, [[A:%.*]]
   // CHECK: [[CMP:%.*]] = icmp sgt <16 x i8> [[A]], zeroinitializer
   // CHECK: [[SEL:%.*]] = select <16 x i1> [[CMP]], <16 x i8> [[A]], <16 x i8> [[SUB]]
+  // CHECK: [[TMP:%.*]] = bitcast [[SRCTY:<.*>]] [[SEL]] to [[DSTTY:<.*>]]
+  // CHECK: [[SEL:%.*]] = bitcast [[DSTTY]] [[TMP]] to [[SRCTY]]
   // CHECK: select <16 x i1> %{{.*}}, <16 x i8> [[SEL]], <16 x i8> %{{.*}}
   return _mm_maskz_abs_epi8(__U,__A); 
 }
@@ -919,6 +922,8 @@
   // CHECK: [[SUB:%.*]] = sub <32 x i8> zeroinitializer, [[A:%.*]]
   // CHECK: [[CMP:%.*]] = icmp sgt <32 x i8> [[A]], zeroinitializer
   // CHECK: [[SEL:%.*]] = select <32 x i1> [[CMP]], <32 x i8> [[A]], <32 x i8> [[SUB]]
+  // CHECK: [[TMP:%.*]] = bitcast [[SRCTY:<.*>]] [[SEL]] to [[DSTTY:<.*>]]
+  // CHECK: [[SEL:%.*]] = bitcast [[DSTTY]] [[TMP]] to [[SRCTY]]
   // CHECK: select <32 x i1> %{{.*}}, <32 x i8> [[SEL]], <32 x i8> %{{.*}}
   return _mm256_mask_abs_epi8(__W,__U,__A); 
 }
@@ -928,6 +933,8 @@
   // CHECK: [[SUB:%.*]] = sub <32 x i8> zeroinitializer, [[A:%.*]]
   // CHECK: [[CMP:%.*]] = icmp sgt <32 x i8> [[A]], zeroinitializer
   // CHECK: [[SEL:%.*]] = select <32 x i1> [[CMP]], <32 x i8> [[A]], <32 x i8> [[SUB]]
+  // CHECK: [[TMP:%.*]] = bitcast [[SRCTY:<.*>]] [[SEL]] to [[DSTTY:<.*>]]
+  // CHECK: [[SEL:%.*]] = bitcast [[DSTTY]] [[TMP]] to [[SRCTY]]
   // CHECK: select <32 x i1> %{{.*}}, <32 x i8> [[SEL]], <32 x i8> %{{.*}}
   return _mm256_maskz_abs_epi8(__U,__A); 
 }
@@ -937,6 +944,8 @@
   // CHECK: [[SUB:%.*]] = sub <8 x i16> zeroinitializer, [[A:%.*]]
   // CHECK: [[CMP:%.*]] = icmp sgt <8 x i16> [[A]], zeroinitializer
   // CHECK: [[SEL:%.*]] = select <8 x i1> [[CMP]], <8 x i16> [[A]], <8 x i16> [[SUB]]
+  // CHECK: [[TMP:%.*]] = bitcast [[SRCTY:<.*>]] [[SEL]] to [[DSTTY:<.*>]]
+  // CHECK: [[SEL:%.*]] = bitcast [[DSTTY]] [[TMP]] to [[SRCTY]]
   // CHECK: select <8 x i1> %{{.*}}, <8 x i16> [[SEL]], <8 x i16> %{{.*}}
   return _mm_mask_abs_epi16(__W,__U,__A); 
 }
@@ -946,6 +955,8 @@
   // CHECK: [[SUB:%.*]] = sub <8 x i16> zeroinitializer, [[A:%.*]]
   // CHECK: [[CMP:%.*]] = icmp sgt <8 x i16> [[A]], zeroinitializer
   // CHECK: [[SEL:%.*]] = select <8 x i1> [[CMP]], <8 x i16> [[A]], <8 x i16> [[SUB]]
+  // CHECK: [[TMP:%.*]] = bitcast [[SRCTY:<.*>]] [[SEL]] to [[DSTTY:<.*>]]
+  // CHECK: [[SEL:%.*]] = bitcast [[DSTTY]] [[TMP]] to [[SRCTY]]
   // CHECK: select <8 x i1> %{{.*}}, <8 x i16> [[SEL]], <8 x i16> %{{.*}}
   return _mm_maskz_abs_epi16(__U,__A); 
 }
@@ -955,

[PATCH] D63638: [clang][NewPM] Add new pass manager RUN lines to avx512f-builtins.c

2019-07-22 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

I created D65110  if we're ok with just using 
the new PM.


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

https://reviews.llvm.org/D63638



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


[PATCH] D65104: [clang-tidy] Add FixItHint for performance-noexcept-move-constructor

2019-07-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/performance/NoexceptMoveConstructorCheck.cpp:57
+  assert(Decl->getNumParams() > 0);
+  SourceLocation NoexceptLoc = Decl->getParamDecl(Decl->getNumParams() - 1)
+   ->getSourceRange()

Does `getParamDecl()->getEndLoc()` not give the correct answer?



Comment at: test/clang-tidy/performance-noexcept-move-constructor-fix.cpp:7
+ C_1(C_1&& a) :C_1(5) {}
+ // CHECK-FIXES:{{.*}}noexcept{{.*}}
+ C_1& operator=(C_1&&) { return *this; }

This style of test is a bit loose as it will pass even if the fix-it replaces 
the entire constructor with the `noexcept` token.


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

https://reviews.llvm.org/D65104



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


[PATCH] D65107: [clang-doc] Fix html entities in rendered text

2019-07-22 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clang-doc/HTMLGenerator.cpp:181
 
+std::string TextNode::getHTMLEntity(const char &C) {
+  switch (C) {

There is printHTMLEscaped() in ADT/StringExtras.h. May b it could be used or 
common code moved into other function in ADT/StringExtras.h?


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

https://reviews.llvm.org/D65107



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


[PATCH] D62648: [Sema][Typo] Fix assertion failure for expressions with multiple typos

2019-07-22 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 211184.
dgoldman added a comment.

- Bug fixes


Repository:
  rC Clang

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

https://reviews.llvm.org/D62648

Files:
  lib/Sema/SemaExprCXX.cpp
  test/Sema/typo-correction-recursive.cpp

Index: test/Sema/typo-correction-recursive.cpp
===
--- /dev/null
+++ test/Sema/typo-correction-recursive.cpp
@@ -0,0 +1,120 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Check the following typo correction behavior:
+// - multiple typos in a single member call chain are all diagnosed
+// - no typos are diagnosed for multiple typos in an expression when not all
+//   typos can be corrected
+
+class DeepClass
+{
+public:
+  void trigger() const;  // expected-note {{'trigger' declared here}}
+};
+
+class Y
+{
+public:
+  const DeepClass& getX() const { return m_deepInstance; }  // expected-note {{'getX' declared here}}
+private:
+  DeepClass m_deepInstance;
+  int m_n;
+};
+
+class Z
+{
+public:
+  const Y& getY0() const { return m_y0; }  // expected-note {{'getY0' declared here}}
+  const Y& getActiveY() const { return m_y0; }
+
+private:
+  Y m_y0;
+  Y m_y1;
+};
+
+Z z_obj;
+
+void testMultipleCorrections()
+{
+  z_obj.getY2().  // expected-error {{no member named 'getY2' in 'Z'; did you mean 'getY0'}}
+  getM(). // expected-error {{no member named 'getM' in 'Y'; did you mean 'getX'}}
+  triggee();  // expected-error {{no member named 'triggee' in 'DeepClass'; did you mean 'trigger'}}
+}
+
+void testNoCorrections()
+{
+  z_obj.getY2().  // expected-error {{no member named 'getY2' in 'Z'}}
+  getM().
+  thisDoesntSeemToMakeSense();
+}
+
+struct C {};
+struct D { int value; };
+struct A {
+  C get_me_a_C();
+};
+struct B {
+  D get_me_a_D();  // expected-note {{'get_me_a_D' declared here}}
+};
+class Scope {
+public:
+  A make_an_A();
+  B make_a_B();  // expected-note {{'make_a_B' declared here}}
+};
+
+Scope scope_obj;
+
+int testDiscardedCorrections() {
+  return scope_obj.make_an_E().  // expected-error {{no member named 'make_an_E' in 'Scope'; did you mean 'make_a_B'}}
+  get_me_a_Z().value;// expected-error {{no member named 'get_me_a_Z' in 'B'; did you mean 'get_me_a_D'}}
+}
+
+class AmbiguousHelper {
+public:
+  int helpMe();
+  int helpBe();
+};
+class Ambiguous {
+public:
+  int calculateA();
+  int calculateB();
+
+  AmbiguousHelper getHelp1();
+  AmbiguousHelper getHelp2();
+};
+
+Ambiguous ambiguous_obj;
+
+int testDirectAmbiguousCorrection() {
+  return ambiguous_obj.calculateZ();  // expected-error {{no member named 'calculateZ' in 'Ambiguous'}}
+}
+
+int testRecursiveAmbiguousCorrection() {
+  return ambiguous_obj.getHelp3().// expected-error {{no member named 'getHelp3' in 'Ambiguous'}}
+  helpCe();
+}
+
+
+class DeepAmbiguityHelper {
+public:
+  DeepAmbiguityHelper& help1();
+  DeepAmbiguityHelper& help2();
+
+  DeepAmbiguityHelper& methodA();
+  DeepAmbiguityHelper& somethingMethodB();
+  DeepAmbiguityHelper& functionC();
+  DeepAmbiguityHelper& deepMethodD();
+  DeepAmbiguityHelper& asDeepAsItGets();
+};
+
+DeepAmbiguityHelper deep_obj;
+
+int testDeepAmbiguity() {
+  deep_obj.
+  methodB(). // expected-error {{no member named 'methodB' in 'DeepAmbiguityHelper'}}
+  somethingMethodC().
+  functionD().
+  deepMethodD().
+  help3().
+  asDeepASItGet().
+  functionE();
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -7584,15 +7584,22 @@
   llvm::SmallDenseMap OverloadResolution;
 
   /// Emit diagnostics for all of the TypoExprs encountered.
+  ///
   /// If the TypoExprs were successfully corrected, then the diagnostics should
   /// suggest the corrections. Otherwise the diagnostics will not suggest
   /// anything (having been passed an empty TypoCorrection).
-  void EmitAllDiagnostics() {
+  ///
+  /// If we've failed to correct due to ambiguous corrections, we need to
+  /// be sure to pass empty corrections and replacements. Otherwise it's
+  /// possible that the Consumer has a TypoCorrection that failed to ambiguity
+  /// and we don't want to report those diagnostics.
+  void EmitAllDiagnostics(bool IsAmbiguous) {
 for (TypoExpr *TE : TypoExprs) {
   auto &State = SemaRef.getTypoExprState(TE);
   if (State.DiagHandler) {
-TypoCorrection TC = State.Consumer->getCurrentCorrection();
-ExprResult Replacement = TransformCache[TE];
+TypoCorrection TC = IsAmbiguous
+? TypoCorrection() : State.Consumer->getCurrentCorrection();
+ExprResult Replacement = IsAmbiguous ? ExprError() : TransformCache[TE];
 
 // Extract the NamedDecl from the transformed TypoExpr and add it to the
 // TypoCorrection, replacing the existing decls. This ensures the right
@@ -7654,6 +7661,115 @@
 return ExprF

[libunwind] r366734 - [runtimes] Don't depend on libpthread on Android

2019-07-22 Thread Yi Kong via cfe-commits
Author: kongyi
Date: Mon Jul 22 13:41:03 2019
New Revision: 366734

URL: http://llvm.org/viewvc/llvm-project?rev=366734&view=rev
Log:
[runtimes] Don't depend on libpthread on Android

r362048 added support for ELF dependent libraries, but broke Android
build since Android does not have libpthread. Remove the dependency on
the Android build.

Differential Revision: https://reviews.llvm.org/D65098

Modified:
libunwind/trunk/src/AddressSpace.hpp
libunwind/trunk/src/RWMutex.hpp

Modified: libunwind/trunk/src/AddressSpace.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/AddressSpace.hpp?rev=366734&r1=366733&r2=366734&view=diff
==
--- libunwind/trunk/src/AddressSpace.hpp (original)
+++ libunwind/trunk/src/AddressSpace.hpp Mon Jul 22 13:41:03 2019
@@ -27,7 +27,7 @@
 
 #if _LIBUNWIND_USE_DLADDR
 #include 
-#if defined(__unix__) &&  defined(__ELF__) && 
defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
+#if defined(__unix__) && defined(__ELF__) && 
defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
 #pragma comment(lib, "dl")
 #endif
 #endif

Modified: libunwind/trunk/src/RWMutex.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/RWMutex.hpp?rev=366734&r1=366733&r2=366734&view=diff
==
--- libunwind/trunk/src/RWMutex.hpp (original)
+++ libunwind/trunk/src/RWMutex.hpp Mon Jul 22 13:41:03 2019
@@ -17,7 +17,7 @@
 #include 
 #elif !defined(_LIBUNWIND_HAS_NO_THREADS)
 #include 
-#if defined(__unix__) &&  defined(__ELF__) && 
defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
+#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && 
defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
 #pragma comment(lib, "pthread")
 #endif
 #endif


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


  1   2   >